$treeview $search $mathjax
Stratagus  2.2.6
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
           Stratagus - A free fantasy real time strategy game engine

src/action/action_unload.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include "stratagus.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "actions.h"
#include "map.h"
#include "interface.h"
#include "pathfinder.h"

Functions

action_unload.cpp - The unload action.
static bool FindUnloadPosition (const CUnit &transporter, const CUnit &unit, const Vec2i startPos, int maxRange, Vec2i *res)
static int UnloadUnit (CUnit &transporter, CUnit &unit)
static bool IsDropZonePossible (const CUnit &transporter, const Vec2i &pos)
static bool ClosestFreeDropZone_internal (const CUnit &transporter, const Vec2i &startPos, int maxRange, Vec2i *resPos)
static int ClosestFreeDropZone (CUnit &transporter, const Vec2i &startPos, int maxRange, Vec2i *resPos)
static int MoveToDropZone (CUnit &unit)
static void LeaveTransporter (CUnit &transporter)
void HandleActionUnload (CUnit &unit)
 Handle command unload.

Function Documentation

static int ClosestFreeDropZone ( CUnit transporter,
const Vec2i startPos,
int  maxRange,
Vec2i resPos 
) [static]

Find the closest available drop zone for a transporter. Fail if transporter don't transport any unit..

Parameters:
transporter the transporter
startPos start location for the search
maxRange The maximum distance from initial position to search...
resPos drop zone position
Returns:
1 if a location was found, 0 otherwise

static bool ClosestFreeDropZone_internal ( const CUnit transporter,
const Vec2i startPos,
int  maxRange,
Vec2i resPos 
) [static]

Find the closest available drop zone for a transporter. Fail if transporter don't transport any unit..

Parameters:
transporter the transporter
startPos start location for the search
maxRange The maximum distance from initial position to search...
resPos drop zone position
Returns:
true if a location was found, false otherwise
Note:
to be called only from ClosestFreeDropZone.

static bool FindUnloadPosition ( const CUnit transporter,
const CUnit unit,
const Vec2i  startPos,
int  maxRange,
Vec2i res 
) [static]

Find a free position close to startPos

Parameters:
transporter 
unit Unit to unload.
startPos Original search position
maxrange maximal range to unload.
res Unload position.
Returns:
True if a position was found, False otherwise.
Note:
res is undefined if a position is not found.
Bug:
FIXME: Place unit only on fields reachable from the transporter

void HandleActionUnload ( CUnit unit  ) 

Handle command unload.

The transporter unloads a unit.

Parameters:
unit Pointer to unit.

static bool IsDropZonePossible ( const CUnit transporter,
const Vec2i pos 
) [static]

Return true is possition is a correct place to drop out units.

Parameters:
transporter Transporter unit.
pos position to drop out units.

static void LeaveTransporter ( CUnit transporter  )  [static]

Make one or more unit leave the transporter.

Parameters:
unit Pointer to unit.

static int MoveToDropZone ( CUnit unit  )  [static]

Move to dropzone.

Parameters:
unit Pointer to unit.
Returns:
-1 if unreachable, True if reached, False otherwise.

static int UnloadUnit ( CUnit transporter,
CUnit unit 
) [static]

Reappear unit on map.

Parameters:
unit Unit to drop out.
Returns:
True if unit can be unloaded.
Bug:
FIXME: Place unit only on fields reachable from the transporter

(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.