____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

action_unload.cpp File Reference

The unload action. More...

#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"

Go to the source code of this file.

Defines

#define LandUnitMask
#define NavalUnitMask

Functions

static int FindUnloadPosition (int x, int y, int *resx, int *resy, int mask)
int UnloadUnit (CUnit *unit)
static int ClosestFreeCoast (int x, int y, int *resx, int *resy)
static int ClosestFreeDropZone (CUnit *transporter, int x, int y, int *resx, int *resy)
static int MoveToDropZone (CUnit *unit)
static void LeaveTransporter (CUnit *unit)
void HandleActionUnload (CUnit *unit)
 Handle command resource.


Detailed Description

The unload action.

Definition in file action_unload.cpp.


Define Documentation

#define LandUnitMask

#define NavalUnitMask


Function Documentation

static int ClosestFreeCoast ( int  x,
int  y,
int *  resx,
int *  resy 
) [static]

Find the closest piece of coast you can unload units on

Parameters:
x start location for the search
y start location for the search
resx coast x position
resy coast y position
Returns:
1 if a location was found, 0 otherwise

Definition at line 164 of file action_unload.cpp.

References CMap::CoastOnMap(), DebugPrint, FindUnloadPosition(), CMap::Info, LandUnitMask, Map, CMapInfo::MapHeight, CMapInfo::MapWidth, and UnitOnMapTile().

Referenced by ClosestFreeDropZone().

static int ClosestFreeDropZone ( CUnit transporter,
int  x,
int  y,
int *  resx,
int *  resy 
) [static]

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

Parameters:
transporter the transporter
x start location for the search
y start location for the search
resx coast x position
resy coast y position
Returns:
1 if a location was found, 0 otherwise

Definition at line 242 of file action_unload.cpp.

References ClosestFreeCoast(), FindUnloadPosition(), LandUnitMask, NavalUnitMask, CUnit::Type, CUnit::UnitInside, CUnitType::UnitType, UnitTypeFly, UnitTypeLand, and UnitTypeNaval.

Referenced by HandleActionUnload().

static int FindUnloadPosition ( int  x,
int  y,
int *  resx,
int *  resy,
int  mask 
) [static]

Find a free position close to x, y

Parameters:
x Original x search position
y Original y search position
resx Unload x position.
resy Unload y position.
mask Movement mask for the unit to be droped.
Returns:
True if a position was found, False otherwise.
Note:
resx and resy are undefined if a position is not found.
Bug:
FIXME: Place unit only on fields reachable from the transporter
Bug:
FIXME: This function fails for units larger than 1x1.

Definition at line 83 of file action_unload.cpp.

References CheckedCanMoveToMask().

Referenced by ClosestFreeCoast(), ClosestFreeDropZone(), and UnloadUnit().

void HandleActionUnload ( CUnit unit  ) 

Handle command resource.

The transporter unloads a unit.

Parameters:
unit Pointer to unit.

Definition at line 375 of file action_unload.cpp.

References CanMove(), CUnit::ClearAction(), ClosestFreeDropZone(), HandleActionUnload(), LeaveTransporter(), MoveToDropZone(), NewResetPath, CUnit::Orders, PF_REACHED, CUnit::SubAction, UnitActionStill, and y.

Referenced by HandleActionUnload().

static void LeaveTransporter ( CUnit unit  )  [static]

static int MoveToDropZone ( CUnit unit  )  [static]

Move to dropzone.

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

Definition at line 291 of file action_unload.cpp.

References Assert, DoActionMove(), CUnit::Orders, PF_REACHED, PF_UNREACHABLE, and UnitActionUnload.

Referenced by HandleActionUnload().

int UnloadUnit ( CUnit unit  ) 

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

Definition at line 140 of file action_unload.cpp.

References Assert, CUnit::Boarded, FindUnloadPosition(), CUnitType::MovementMask, CUnit::Place(), CUnit::Removed, CUnit::Type, CUnit::X, CUnit::Y, and y.

Referenced by LeaveTransporter().


Generated on Sat Feb 21 00:28:15 2009 for Bos Wars by  doxygen 1.5.6