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

       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"

unit.h File Reference

The unit headerfile. More...

#include <vector>
#include "SDL.h"
#include "upgrade_structs.h"

Go to the source code of this file.

Classes

class  COrder
class  CUnit
struct  CUnit::_unit_seen_
struct  CUnit::_unit_anim_
union  CUnit::_order_data_
struct  CUnit::_order_data_::_order_move_
struct  CUnit::_order_data_::_order_built_
struct  CUnit::_order_data_::_order_harvest_
struct  CUnit::_order_data_::_order_train_
struct  CUnit::_order_data_::_order_repair_
class  CPreference

Defines

#define NextDirection   32
 Next direction N->NE->E...
#define UnitNotSeen   0x7fffffff
 Unit not seen, used by CUnit::SeenFrame.
#define MAX_PATH_LENGTH   28
 max length of precalculated path
#define NoUnitP   (CUnit *)0
 return value: for no unit found
#define InfiniteDistance   INT_MAX
 the distance is unreachable
#define FlushCommands   1
 Flush commands in queue.
#define MAX_UNIT_SLOTS   65535
 Maximal number of used slots.
#define UnitNumber(unit)   ((unit)->Slot)
#define NUM_GROUPS   10
#define IsOnlySelected(unit)   (NumSelected == 1 && Selected[0] == (unit))
 < Check if unit is the currently only selected

Typedefs

typedef unsigned short UnitRef
typedef enum _unit_action_ UnitAction

Enumerations

enum  _unit_action_ {
  UnitActionNone, UnitActionStill, UnitActionStandGround, UnitActionFollow,
  UnitActionMove, UnitActionAttack, UnitActionAttackGround, UnitActionDie,
  UnitActionSpellCast, UnitActionTrain, UnitActionBuilt, UnitActionBoard,
  UnitActionUnload, UnitActionPatrol, UnitActionBuild, UnitActionRepair,
  UnitActionResource
}
enum  UnitVoiceGroup {
  VoiceSelected, VoiceAcknowledging, VoiceReady, VoiceHelpMe,
  VoiceDying, VoiceWorkCompleted, VoiceBuilding, VoiceDocking,
  VoiceRepairing, VoiceHarvesting
}
enum  _directions_ {
  LookingN = 0 * 32, LookingNE = 1 * 32, LookingE = 2 * 32, LookingSE = 3 * 32,
  LookingS = 4 * 32, LookingSW = 5 * 32, LookingW = 6 * 32, LookingNW = 7 * 32
}

Functions

void SelectedUnitChanged (void)
 Called whenever the selected unit was updated.
void DrawUnitSelection (const CUnit *)
void DrawSelection (Uint32 color, int x1, int y1, int x2, int y2)
void MarkUnitFieldFlags (const CUnit *unit)
 < Mark the field with the FieldFlags.
void UnmarkUnitFieldFlags (const CUnit *unit)
 Update unit->CurrentSightRange.
void UpdateUnitSightRange (CUnit *unit)
 Create a new unit.
CUnitMakeUnit (CUnitType *type, CPlayer *player)
 Create a new unit and place on map.
CUnitMakeUnitAndPlace (int x, int y, CUnitType *type, CPlayer *player)
 Handle the loss of a unit (food,...).
void UnitLost (CUnit *unit)
 Remove the Orders of a Unit.
void UnitClearOrders (CUnit *unit)
void UpdateForNewUnit (const CUnit *unit, int upgrade)
void NearestOfUnit (const CUnit *unit, int tx, int ty, int *dx, int *dy)
 Call when an Unit goes under fog.
void UnitGoesUnderFog (CUnit *unit, const CPlayer *player)
 Call when an Unit goes out of fog.
void UnitGoesOutOfFog (CUnit *unit, const CPlayer *player)
 Marks a unit as seen.
void UnitsOnTileMarkSeen (const CPlayer *player, int x, int y)
 Unmarks a unit as seen.
void UnitsOnTileUnmarkSeen (const CPlayer *player, int x, int y)
 Does a recount for VisCount.
void UnitCountSeen (CUnit *unit)
 Check for rescue each second.
void RescueUnits (void)
 Convert direction (dx,dy) to heading (0-255).
int DirectionToHeading (int, int)
 Update frame from heading.
void UnitUpdateHeading (CUnit *unit)
 Heading and frame from delta direction x,y.
void UnitHeadingFromDeltaXY (CUnit *unit, int x, int y)
void DropOutOnSide (CUnit *unit, int heading, int addx, int addy)
void DropOutNearest (CUnit *unit, int x, int y, int addx, int addy)
 Drop out all units in the unit.
void DropOutAll (const CUnit *unit)
 Return the rule used to build this building.
CBuildRestrictionOnTopOnTopDetails (const CUnit *unit, const CUnitType *parent)
CUnitCanBuildHere (const CUnit *unit, const CUnitType *type, int x, int y)
bool CanBuildOn (int x, int y, int mask)
 FIXME: more docu.
CUnitCanBuildUnitType (const CUnit *unit, const CUnitType *type, int x, int y, int real)
 Holds resources.
bool UnitHoldsResources (const CUnit *unit)
 Find resource.
CUnitUnitFindResource (const CUnit *unit, int x, int y, int range, int resource=-1)
 Find the next idle worker.
CUnitFindIdleWorker (const CPlayer *player)
CUnitUnitOnScreen (int x, int y)
 Check if a unit should be removed from UnitsConsumingResources.
void UnitRemoveConsumingResources (CUnit *unit)
 Let a unit die.
void LetUnitDie (CUnit *unit)
 Destory all units inside another unit.
void DestroyAllInside (CUnit *source)
 Hit unit with damage, if destroyed give attacker the points.
void HitUnit (CUnit *attacker, CUnit *target, int damage)
 Returns the map distance between two points.
int MapDistance (int x1, int y1, int x2, int y2)
 Returns the map distance between two points with unit-type.
int MapDistanceToType (int x1, int y1, const CUnitType *type, int x2, int y2)
 Returns the map distance to unit.
int MapDistanceToUnit (int x, int y, const CUnit *dest)
 Returns the map diestance between to unittype as locations.
int MapDistanceBetweenTypes (const CUnitType *src, int x1, int y1, const CUnitType *dst, int x2, int y2)
 Returns the map distance between two units.
int MapDistanceBetweenUnits (const CUnit *src, const CUnit *dst)
 Calculate the distance from current view point to coordinate.
int ViewPointDistance (int x, int y)
 Calculate the distance from current view point to unit.
int ViewPointDistanceToUnit (const CUnit *dest)
 Can this unit-type attack the other (destination).
int CanTarget (const CUnitType *type, const CUnitType *dest)
 Can transporter transport the other unit.
int CanTransport (const CUnit *transporter, const CUnit *unit)
 Check if unit can move.
bool CanMove (const CUnit *unit)
 Generate a unit reference, a printable unique string for unit.
std::string UnitReference (const CUnit *unit)
 Save an order.
void SaveOrder (const COrder *order, CFile *file)
 save unit-structure
void SaveUnit (const CUnit *unit, CFile *file)
 save all units
void SaveUnits (CFile *file)
 Initialize unit module.
void InitUnits (void)
 Clean unit module.
void CleanUnits (void)
void DecorationCclRegister (void)
 < Register CCL decorations features
void LoadDecorations (void)
 Clean the decorations (health,mana) of units.
void CleanDecorations (void)
 Draw unit's shadow.
void DrawShadow (const CUnit *unit, const CUnitType *type, int frame, int x, int y)
 Draw all units visible on map in viewport.
int FindAndSortUnits (const CViewport *vp, CUnit **table, int tablesize)
 Show a unit's orders.
void ShowOrder (const CUnit *unit)
int FindUnitsByType (const CUnitType *type, CUnit **table, int tablesize)
 < Find all units of this type
int FindPlayerUnitsByType (const CPlayer *, const CUnitType *, CUnit **, int)
 Return any unit on that map tile.
CUnitUnitOnMapTile (int tx, int ty, unsigned type=(unsigned)-1)
 Return possible attack target on that map area.
CUnitTargetOnMap (const CUnit *unit, int x1, int y1, int x2, int y2)
 Return resource, if on map tile.
CUnitResourceOnMap (int tx, int ty, int resource=-1)
 Find best enemy in numeric range to attack.
CUnitAttackUnitsInDistance (const CUnit *unit, int range)
 Find best enemy in attack range to attack.
CUnitAttackUnitsInRange (const CUnit *unit)
 Find best enemy in reaction range to attack.
CUnitAttackUnitsInReactRange (const CUnit *unit)
void InitGroups (void)
 < Initialize data structures for groups
void SaveGroups (CFile *file)
 Cleanup groups.
void CleanGroups (void)
int GetNumberUnitsOfGroup (int num)
 < Get the number of units in a particular group
CUnit ** GetUnitsOfGroup (int num)
 Remove all units from a group.
void ClearGroup (int num)
 Add the array of units to the group.
void AddToGroup (CUnit **units, int nunits, int num)
 Set the contents of a particular group with an array of units.
void SetGroup (CUnit **units, int nunits, int num)
 Remove a unit from a group.
void RemoveUnitFromGroups (CUnit *unit)
 Register CCL group features.
void GroupCclRegister (void)
void SaveSelection (void)
 Restore selection.
void RestoreSelection (void)
 Clear current selection.
void UnSelectAll (void)
 Select group as selection.
void ChangeSelectedUnits (CUnit **units, int num_units)
 Changed TeamUnit Selection.
void ChangeTeamSelectedUnits (CPlayer *player, CUnit **units, int adjust, int count)
 Add a unit to selection.
int SelectUnit (CUnit *unit)
 Select one unit as selection.
void SelectSingleUnit (CUnit *unit)
 Remove a unit from selection.
void UnSelectUnit (CUnit *unit)
 Add a unit to selected if not already selected, remove it otherwise.
int ToggleSelectUnit (CUnit *unit)
 Select units from the same type (if selectable by rectangle).
int SelectUnitsByType (CUnit *base)
 Toggle units from the same type (if selectable by rectangle).
int ToggleUnitsByType (CUnit *base)
 Select the units belonging to a particular group.
int SelectGroup (int group_number)
 Add the units from the same group as the one in parameter.
int AddGroupFromUnitToSelection (CUnit *unit)
 Select the units from the same group as the one in parameter.
int SelectGroupFromUnit (CUnit *unit)
 Select the units in the selection rectangle.
int SelectUnitsInRectangle (int tx, int ty, int w, int h)
 Select ground units in the selection rectangle.
int SelectGroundUnitsInRectangle (int tx, int ty, int w, int h)
 Select flying units in the selection rectangle.
int SelectAirUnitsInRectangle (int tx, int ty, int w, int h)
 Add the units in the selection rectangle to the current selection.
int AddSelectedUnitsInRectangle (int tx, int ty, int w, int h)
 Add ground units in the selection rectangle to the current selection.
int AddSelectedGroundUnitsInRectangle (int tx, int ty, int w, int h)
 Add flying units in the selection rectangle to the current selection.
int AddSelectedAirUnitsInRectangle (int tx, int ty, int w, int h)
 Init selections.
void InitSelections (void)
 Save current selection state.
void SaveSelections (CFile *file)
 Clean up selections.
void CleanSelections (void)
 Register CCL selection features.
void SelectionCclRegister (void)
void CclParseOrder (lua_State *l, COrder *order)
 < Parse order
void UnitCclRegister (void)

Variables

CPreference Preference
CUnitUnits [MAX_UNIT_SLOTS]
 Units used.
int NumUnits
 Number of units used.
unsigned long ShowOrdersCount
 Show orders for some time.
bool EnableBuildingCapture
 Config: building capture enabled.
const CViewportCurrentViewport
 CurrentViewport.
int MaxSelectable
 How many units could be selected.
CUnit ** Selected
 currently selected units
CUnit ** TeamSelected [PlayerMax]
 teams currently selected units
int NumSelected
 how many units selected
int TeamNumSelected [PlayerMax]
 Number of Units a team member has selected.


Detailed Description

The unit headerfile.

Definition in file unit.h.


Define Documentation

#define FlushCommands   1

#define InfiniteDistance   INT_MAX

the distance is unreachable

Definition at line 741 of file unit.h.

#define IsOnlySelected ( unit   )     (NumSelected == 1 && Selected[0] == (unit))

< Check if unit is the currently only selected

Save selection to restore after.

Definition at line 974 of file unit.h.

Referenced by EnterTransporter(), FindIdleWorker(), HandleActionBuilt(), HandleActionTrain(), HandleUnitAction(), and LeaveTransporter().

#define MAX_PATH_LENGTH   28

max length of precalculated path

Definition at line 646 of file unit.h.

Referenced by NewPath().

#define MAX_UNIT_SLOTS   65535

Maximal number of used slots.

Definition at line 745 of file unit.h.

Referenced by CUnitManager::Init().

#define NextDirection   32

Next direction N->NE->E...

Definition at line 485 of file unit.h.

Referenced by DoActionMove().

#define NoUnitP   (CUnit *)0

return value: for no unit found

Definition at line 740 of file unit.h.

Referenced by CUnit::AddInContainer(), AiForceAttacks(), AiRepairBuilding(), CUnitManager::AllocUnit(), AttackTarget(), AttackUnitsInDistance(), AutoAttack(), AutoRepair(), Summon::Cast(), CclCreateUnit(), ChangeTeamSelectedUnits(), CheckForDeadGoal(), CheckForTargetInRange(), CleanCursors(), CreateGame(), CButtonPanel::DoClicked(), DoNextReplay(), DoRightButton(), DrawBuildingCursor(), DrawMapArea(), EditorActionPlaceUnit(), EnemyOnMapTile(), EnterTransporter(), FindIdleWorker(), FindNewResource(), FindRangeAttack(), GatherResource(), HandleActionAttack(), HandleActionBoard(), HandleActionBuilt(), HandleActionFollow(), HandleActionMove(), HandleActionPatrol(), HandleActionSpellCast(), HandleActionTrain(), HandleRegenerations(), HitUnit(), InputKey(), LeaveTransporter(), MakeUnit(), MakeUnitAndPlace(), MissileHit(), MoveToLocation(), MoveToTarget(), ParseCommand(), ParseExtendedCommand(), ParseNetworkCommand(), ReleaseOrder(), RemoveUnitFromContainer(), RepairUnit(), ResourceOnMap(), RestoreSavedOrder(), SendCommandAttackGround(), SendCommandAutoRepair(), SendCommandAutoSpellCast(), SendCommandBuildBuilding(), SendCommandCancelTraining(), SendCommandDiplomacy(), SendCommandMove(), SendCommandPatrol(), SendCommandSharedVision(), SendCommandStandGround(), SendCommandStopUnit(), SendCommandTrainUnit(), SendUnload(), SpellMoveToTarget(), StartBuilding(), StartGathering(), TargetOnMap(), UiFindIdleWorker(), UnitClearOrders(), UnitFindResource(), UnitLost(), UnitOnMapTile(), UnitToRepairInRange(), UnSelectAll(), UnSelectUnit(), and WaitForTransporter().

#define NUM_GROUPS   10

How many groups supported

Definition at line 755 of file unit.h.

Referenced by AddToGroup(), CleanGroups(), InitGroups(), SaveGroups(), SelectGroup(), and SetGroup().

#define UnitNotSeen   0x7fffffff

Unit not seen, used by CUnit::SeenFrame.

The big unit structure

Definition at line 486 of file unit.h.

Referenced by CclUnit(), CUnit::Draw(), CUnit::Init(), and SaveUnit().

#define UnitNumber ( unit   )     ((unit)->Slot)


Typedef Documentation

typedef enum _unit_action_ UnitAction

All possible unit actions.

Note:
Always change the table HandleActionTable
See also:
HandleActionTable

typedef unsigned short UnitRef

Unit references over network, or for memory saving.

Definition at line 372 of file unit.h.


Enumeration Type Documentation

Unit/Missile headings. N NW NE W E SW SE S

Enumerator:
LookingN  Unit looking north.
LookingNE  Unit looking north east.
LookingE  Unit looking east.
LookingSE  Unit looking south east.
LookingS  Unit looking south.
LookingSW  Unit looking south west.
LookingW  Unit looking west.
LookingNW  Unit looking north west.

Definition at line 474 of file unit.h.

All possible unit actions.

Note:
Always change the table HandleActionTable
See also:
HandleActionTable
Enumerator:
UnitActionNone  No valid action.
UnitActionStill  unit stand still, does nothing
UnitActionStandGround  unit stands ground
UnitActionFollow  unit follows units
UnitActionMove  unit moves to position/unit
UnitActionAttack  unit attacks position/unit
UnitActionAttackGround  unit attacks ground
UnitActionDie  unit dies
UnitActionSpellCast  unit casts spell
UnitActionTrain  building is training
UnitActionBuilt  building is under construction
UnitActionBoard  unit entering transporter
UnitActionUnload  unit leaving transporter
UnitActionPatrol  unit paroling area
UnitActionBuild  unit builds building
UnitActionRepair  unit repairing
UnitActionResource  unit harvesting resources

Definition at line 381 of file unit.h.

Voice groups for a unit

Enumerator:
VoiceSelected  If selected.
VoiceAcknowledging  Acknowledge command.
VoiceReady  Command completed.
VoiceHelpMe  If attacked.
VoiceDying  If killed.
VoiceWorkCompleted  only worker, work completed
VoiceBuilding  only for building under construction
VoiceDocking  only for transport reaching coast
VoiceRepairing  repairing
VoiceHarvesting  harvesting

Definition at line 453 of file unit.h.


Function Documentation

int AddGroupFromUnitToSelection ( CUnit unit  ) 

Select the units from the same group as the one in parameter.

Add units from group of a particular unit to selection.

Parameters:
unit unit belonging to the group to be selected.
Returns:
0 if the unit doesn't belong to a group, or the number of units in the group.

Definition at line 531 of file selection.cpp.

References CUnit::LastGroup, MaxSelectable, NumSelected, NumUnits, SelectUnit(), and Units.

Referenced by DoSelectionButtons(), SelectGroupFromUnit(), and UIHandleButtonUp().

int AddSelectedAirUnitsInRectangle ( int  sx0,
int  sy0,
int  sx1,
int  sy1 
)

Init selections.

Add the air units in the rectangle to the current selection

Parameters:
sx0 X start of selection rectangle in tile coordinates
sy0 Y start of selection rectangle in tile coordinates
sx1 X start of selection rectangle in tile coordinates
sy1 Y start of selection rectangle in tile coordinates
Returns:
the number of units found.

Definition at line 1007 of file selection.cpp.

References CanSelectMultipleUnits, CUnit::IsUnusable(), MaxSelectable, NumSelected, CUnit::Player, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectAirUnitsInRectangle(), SelectSpritesInsideRectangle(), SelectUnit(), CUnit::TeamSelected, TileSizeX, TileSizeY, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, and UnitTypeFly.

Referenced by UIHandleButtonUp().

int AddSelectedGroundUnitsInRectangle ( int  sx0,
int  sy0,
int  sx1,
int  sy1 
)

Add flying units in the selection rectangle to the current selection.

Add the ground units in the rectangle to the current selection

Parameters:
sx0 X start of selection rectangle in tile coordinates
sy0 Y start of selection rectangle in tile coordinates
sx1 X start of selection rectangle in tile coordinates
sy1 Y start of selection rectangle in tile coordinates
Returns:
the number of units found.

Definition at line 933 of file selection.cpp.

References CanSelectMultipleUnits, CUnit::IsUnusable(), MaxSelectable, NumSelected, CUnit::Player, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectGroundUnitsInRectangle(), SelectSpritesInsideRectangle(), SelectUnit(), CUnit::TeamSelected, TileSizeX, TileSizeY, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, and UnitTypeFly.

Referenced by UIHandleButtonUp().

int AddSelectedUnitsInRectangle ( int  x0,
int  y0,
int  x1,
int  y1 
)

Add ground units in the selection rectangle to the current selection.

Add the units in the rectangle to the current selection

Parameters:
x0 X start of selection rectangle in tile coordinates
y0 Y start of selection rectangle in tile coordinates
x1 X start of selection rectangle in tile coordinates
y1 Y start of selection rectangle in tile coordinates
Returns:
the _total_ number of units selected.

Definition at line 668 of file selection.cpp.

References CanSelectMultipleUnits, MaxSelectable, NumSelected, CUnitCache::Select(), SelectOrganicUnitsInTable(), SelectSpritesInsideRectangle(), SelectUnit(), SelectUnitsInRectangle(), TileSizeX, TileSizeY, UnitCache, and UnitMax.

Referenced by UIHandleButtonUp().

void AddToGroup ( CUnit **  units,
int  nunits,
int  num 
)

Set the contents of a particular group with an array of units.

Add units to group num contents from unit array "units"

Parameters:
units Array of units to place into group.
nunits Number of units in array.
num Group number for storage.

Definition at line 160 of file groups.cpp.

References Assert, CUnit::GroupId, CPlayer::IsTeamed(), MaxSelectable, NUM_GROUPS, CUnitGroup::NumUnits, CUnitType::SelectableByRectangle, ThisPlayer, CUnit::Type, and CUnitGroup::Units.

Referenced by SetGroup(), and UiAddToGroup().

CUnit* AttackUnitsInDistance ( const CUnit unit,
int  range 
)

CUnit* AttackUnitsInRange ( const CUnit unit  ) 

Find best enemy in reaction range to attack.

Attack units in attack range.

Parameters:
unit Find unit in attack range for this unit.
Returns:
Pointer to unit which should be attacked.

Definition at line 677 of file unit_find.cpp.

References Assert, ATTACKRANGE_INDEX, AttackUnitsInDistance(), CUnitType::CanAttack, CVariable::Max, CUnit::Stats, CUnit::Type, and CUnitStats::Variables.

Referenced by AutoAttack().

CUnit* AttackUnitsInReactRange ( const CUnit unit  ) 

Attack units in reaction range.

Parameters:
unit Find unit in reaction range for this unit.
Returns:
Pointer to unit which should be attacked.

Definition at line 690 of file unit_find.cpp.

References Assert, AttackUnitsInDistance(), CUnitType::CanAttack, CUnit::Player, PlayerPerson, CUnitType::ReactRangeComputer, CUnitType::ReactRangePerson, CPlayer::Type, and CUnit::Type.

Referenced by AiForceManager(), AttackTarget(), AutoAttack(), CheckForTargetInRange(), HandleActionFollow(), HandleActionPatrol(), and HitUnit().

CUnit* CanBuildHere ( const CUnit unit,
const CUnitType type,
int  x,
int  y 
)

Todo:
more docu
Can build unit here.

Parameters:
unit Unit doing the building
type unit-type to be checked.
x Map X position.
y Map Y position.
Returns:
OnTop, parent unit, builder on true or 1 if unit==NULL, NULL false.

Definition at line 239 of file build.cpp.

References CUnitType::BuildingRules, CMap::Field(), CMapField::Flags, CMap::Info, Map, MapFieldCoastAllowed, CMapInfo::MapHeight, CMapInfo::MapWidth, CUnitType::ShoreBuilding, CUnitType::TileHeight, and CUnitType::TileWidth.

Referenced by CanBuildUnitType(), and DrawBuildingCursor().

bool CanBuildOn ( int  x,
int  y,
int  mask 
)

FIXME: more docu.

Can build on this point.

Parameters:
x X tile map position.
y Y tile map position.
mask terrain mask
Returns:
if we can build on this point.

Definition at line 301 of file build.cpp.

References CMap::Field(), CMapField::Flags, CMap::Info, Map, CMapInfo::MapHeight, and CMapInfo::MapWidth.

Referenced by CanBuildUnitType(), and DrawBuildingCursor().

CUnit* CanBuildUnitType ( const CUnit unit,
const CUnitType type,
int  x,
int  y,
int  real 
)

Holds resources.

Can build unit-type at this point.

Parameters:
unit Worker that want to build the building or NULL.
type Building unit-type.
x X tile map position.
y Y tile map position.
real Really build, or just placement
Returns:
OnTop, parent unit, builder on true, NULL false.

Definition at line 320 of file build.cpp.

References CanBuildHere(), CanBuildOn(), CMap::IsFieldExplored(), Map, MapFogFilterFlags(), MarkUnitFieldFlags(), CUnitType::MovementMask, CUnit::Player, PlayerPerson, CUnitType::TileHeight, CUnitType::TileWidth, CPlayer::Type, and UnmarkUnitFieldFlags().

Referenced by AiFindBuildingPlace2(), CclCreateUnit(), CheckCanBuild(), EditorCallbackButtonDown(), EditorCallbackMouse(), and UIHandleButtonDown().

bool CanMove ( const CUnit unit  ) 

Generate a unit reference, a printable unique string for unit.

Test if unit can move. For the moment only check for move animation.

Parameters:
unit unit to test if it can move.
Returns:
0 if unit cannot move.

Definition at line 68 of file action_move.cpp.

References CUnitType::Animations, Assert, CAnimations::Move, and CUnit::Type.

Referenced by AiMoveUnitInTheWay(), AiSendExplorers(), AutoAttack(), CommandFollow(), CommandMove(), CommandPatrolUnit(), DoActionMove(), CButtonPanel::DoClicked(), DoRightButton(), HandleActionAttack(), HandleActionMove(), HandleActionUnload(), HitUnit(), IsButtonAllowed(), MoveToTarget(), SendAttack(), SendResource(), ShowOrder(), and SpellMoveToTarget().

int CanTarget ( const CUnitType source,
const CUnitType dest 
)

Can transporter transport the other unit.

Can the source unit attack the destination unit.

Parameters:
source Unit type pointer of the attacker.
dest Unit type pointer of the target.
Returns:
0 if attacker can't target the unit, else a positive number.

Definition at line 2425 of file unit.cpp.

References CUnitType::CanTarget, CanTargetAir, CanTargetLand, CanTargetSea, CUnitType::ShoreBuilding, CUnitType::UnitType, UnitTypeFly, UnitTypeLand, and UnitTypeNaval.

Referenced by AiEnemyUnitsInDistance(), AttackUnitsInDistance(), DoRightButton(), EnemyOnMapTile(), FindRangeAttack(), HitUnit(), MissileHit(), SendAttack(), and TargetOnMap().

int CanTransport ( const CUnit transporter,
const CUnit unit 
)

Check if unit can move.

Can the transporter transport the other unit.

Parameters:
transporter Unit which is the transporter.
unit Unit which wants to go in the transporter.
Returns:
1 if transporter can transport unit, 0 else.

Definition at line 2450 of file unit.cpp.

References CUnit::BoardCount, CUnitType::CanTransport, CUnit::IsTeamed(), CUnitType::MaxOnBoard, CUnit::Orders, CUnitType::Organic, CUnit::Type, UnitActionBuilt, CUnitType::UnitType, and UnitTypeLand.

Referenced by DoRightButton(), SendMove(), and WaitForTransporter().

void CclParseOrder ( lua_State *  l,
COrder order 
)

void ChangeSelectedUnits ( CUnit **  units,
int  count 
)

Changed TeamUnit Selection.

Replace a group of selected units by an other group of units.

Parameters:
units Array of units to be selected.
count Number of units in array to be selected.

Definition at line 143 of file selection.cpp.

References Assert, GroupId, CUnit::LastGroup, MaxSelectable, NetworkSendSelection(), NumSelected, CUnit::Selected, and UnSelectAll().

Referenced by SelectAirUnitsInRectangle(), SelectGroundUnitsInRectangle(), SelectGroup(), SelectSingleUnit(), and SelectUnitsInRectangle().

void ChangeTeamSelectedUnits ( CPlayer player,
CUnit **  units,
int  adjust,
int  count 
)

Add a unit to selection.

Change A Unit Selection from my Team

Parameters:
player The Player who is selecting the units
units The Units to add/remove
adjust 0 = reset, 1 = remove units, 2 = add units
count the number of units to be adjusted

Definition at line 173 of file selection.cpp.

References Assert, CPlayer::Index, MaxSelectable, NoUnitP, TeamNumSelected, and CUnit::TeamSelected.

Referenced by CommandQuit(), and NetworkProcessSelection().

void CleanDecorations ( void   ) 

Draw unit's shadow.

Clean decorations.

Definition at line 300 of file unit_draw.cpp.

References CGraphic::Free(), DecoSpriteType::Name, and DecoSpriteType::SpriteArray.

Referenced by CleanModules().

void CleanGroups ( void   ) 

Clean up group part.

Definition at line 102 of file groups.cpp.

References NUM_GROUPS, CUnitGroup::NumUnits, and CUnitGroup::Units.

Referenced by CleanGame(), and CleanModules().

void CleanSelections ( void   ) 

Register CCL selection features.

Clean up the selection module.

Definition at line 1110 of file selection.cpp.

References _TeamNumSelected, GroupId, NumSelected, PlayerMax, and TeamNumSelected.

Referenced by CleanGame(), and CleanModules().

void CleanUnits ( void   ) 

Clean up unit module.

Definition at line 2611 of file unit.cpp.

References HelpMeLastCycle, CUnitManager::Init(), NumUnits, and UnitManager.

Referenced by CleanGame(), and CleanModules().

void ClearGroup ( int  num  ) 

Add the array of units to the group.

Clear contents of group num

Parameters:
num Group number.

Definition at line 140 of file groups.cpp.

References Assert, CUnit::Destroyed, CUnit::GroupId, CUnitGroup::NumUnits, and CUnitGroup::Units.

Referenced by SetGroup().

void DecorationCclRegister ( void   ) 

< Register CCL decorations features

Load the decorations (health,mana) of units

Register CCL features for decorations.

Definition at line 279 of file unit_draw.cpp.

References CclDefineSprites(), and Lua.

Referenced by InitCcl().

void DestroyAllInside ( CUnit source  ) 

Hit unit with damage, if destroyed give attacker the points.

Destroy all units inside unit.

Parameters:
source container.

Definition at line 2027 of file unit.cpp.

References DestroyAllInside(), CUnit::InsideCount, CUnit::NextContained, CUnit::Release(), UnitClearOrders(), CUnit::UnitInside, and UnitLost().

Referenced by DestroyAllInside(), and LetUnitDie().

int DirectionToHeading ( int  delta_x,
int  delta_y 
)

Update frame from heading.

Convert direction to heading.

Parameters:
delta_x Delta X.
delta_y Delta Y.
Returns:
Angle (0..255)

Definition at line 1424 of file unit.cpp.

References myatan().

Referenced by MissileNewHeadingFromXY(), StartBuilding(), and UnitHeadingFromDeltaXY().

void DrawSelection ( Uint32  color,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draw selected corners around the unit.

Parameters:
color Color to draw corners.
x1,y1 Coordinates of the top left corner.
x2,y2 Coordinates of the bottom right corner.

Definition at line 172 of file unit_draw.cpp.

References CVideo::DrawHLineClip(), CVideo::DrawVLineClip(), and Video.

Referenced by DrawUnitSelection(), and ShowSingleOrder().

void DrawShadow ( const CUnit unit,
const CUnitType type,
int  frame,
int  x,
int  y 
)

Draw all units visible on map in viewport.

Draw unit's shadow.

Parameters:
unit Pointer to the unit.
type Pointer to the unit type.
frame Frame number
x Screen X position of the unit.
y Screen Y position of the unit.
Todo:
FIXME: combine new shadow code with old shadow code.

Definition at line 410 of file unit_draw.cpp.

References Assert, CGraphic::DrawFrameClip(), CGraphic::DrawFrameClipX(), CUnitType::Flip, CUnitType::NumDirections, CUnitType::OffsetX, CUnitType::OffsetY, CUnit::Orders, CUnitType::ShadowHeight, CUnitType::ShadowOffsetX, CUnitType::ShadowOffsetY, CUnitType::ShadowSprite, CUnitType::ShadowWidth, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, and UnitActionDie.

Referenced by CUnit::Draw(), and DrawBuildingCursor().

void DrawUnitSelection ( const CUnit unit  ) 

void DropOutAll ( const CUnit source  ) 

Return the rule used to build this building.

Drop out all units inside unit.

Parameters:
source All units inside source are dropped out.

Definition at line 1663 of file unit.cpp.

References Assert, DropOutOnSide(), CUnit::InsideCount, LookingW, CUnit::NextContained, CUnit::Orders, CUnit::SubAction, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitActionStill, and CUnit::UnitInside.

void DropOutNearest ( CUnit unit,
int  gx,
int  gy,
int  addx,
int  addy 
)

Drop out all units in the unit.

Place a unit on the map nearest to x, y.

Parameters:
unit Unit to drop out.
gx Goal X map tile position.
gy Goal Y map tile position.
addx Tile width of unit it's dropping out of.
addy Tile height of unit it's dropping out of.

Definition at line 1578 of file unit.cpp.

References Assert, CUnit::Container, MapDistance(), CUnit::Place(), CUnit::Removed, UnitCanBeAt(), CUnit::X, CUnit::Y, and y.

void DropOutOnSide ( CUnit unit,
int  heading,
int  addx,
int  addy 
)

Todo:
more docu
Place a unit on the map to the side of a unit.

Parameters:
unit Unit to drop out.
heading Direction in which the unit should appear.
addx Tile width of unit it's dropping out of.
addy Tile height of unit it's dropping out of.

Definition at line 1502 of file unit.cpp.

References CUnit::Container, LookingNW, LookingSE, LookingSW, CUnit::Place(), UnitCanBeAt(), CUnit::X, CUnit::Y, and y.

Referenced by Summon::Cast(), CclCreateUnit(), CclMoveUnit(), DropOutAll(), HandleActionBuilt(), and HandleActionTrain().

int FindAndSortUnits ( const CViewport vp,
CUnit **  table,
int  tablesize 
)

Show a unit's orders.

Find all units to draw in viewport.

Parameters:
vp Viewport to be drawn.
table Table of units to return in sorted order
tablesize Size of table array

Definition at line 930 of file unit_draw.cpp.

References DrawLevelCompare(), CUnit::IsVisibleInViewport(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUnitCache::Select(), and UnitCache.

Referenced by CViewport::Draw().

CUnit* FindIdleWorker ( const CPlayer player  ) 

Todo:
more docu
Find the next idle worker

Parameters:
player Player's units to search through
Returns:
NoUnitP or next idle worker

Definition at line 1816 of file unit.cpp.

References CUnitType::Harvester, IsOnlySelected, NoUnitP, CUnit::Orders, CUnit::Removed, CPlayer::TotalNumUnits, CUnit::Type, UnitActionStill, and CPlayer::Units.

Referenced by UiFindIdleWorker().

int FindPlayerUnitsByType ( const CPlayer player,
const CUnitType type,
CUnit **  table,
int  tablesize 
)

Return any unit on that map tile.

Find all units of type.

Parameters:
player we're looking for the units of this player
type type of unit requested
table table in which we have to store the units
tablesize size of table array
Returns:
Returns the number of units found.

Definition at line 108 of file unit_find.cpp.

References CUnit::IsUnusable(), CUnitType::Slot, CPlayer::TotalNumUnits, CUnit::Type, CPlayer::Units, and CPlayer::UnitTypesCount.

Referenced by AiBuildBuilding(), AiRepairBuilding(), and AiTrainUnit().

int FindUnitsByType ( const CUnitType type,
CUnit **  table,
int  tablesize 
)

< Find all units of this type

Find all units of this type of the player

Find all units of type.

Parameters:
type type of unit requested
table table in which we have to store the units
tablesize size of table array
Returns:
Returns the number of units found.

Definition at line 85 of file unit_find.cpp.

References CUnit::IsUnusable(), NumUnits, CUnit::Type, and Units.

Referenced by CclIfNearUnit(), and CclIfRescuedNearUnit().

int GetNumberUnitsOfGroup ( int  num  ) 

< Get the number of units in a particular group

Get the array of units of a particular group

Return the number of units of group num

Parameters:
num Group number.
Returns:
Returns the number of units in the group.

Definition at line 118 of file groups.cpp.

References CUnitGroup::NumUnits.

Referenced by SelectGroup(), UiAddGroupToSelection(), and UiCenterOnGroup().

CUnit** GetUnitsOfGroup ( int  num  ) 

Remove all units from a group.

Return the units of group num

Parameters:
num Group number.
Returns:
Returns an array of all units in the group.

Definition at line 130 of file groups.cpp.

References CUnitGroup::Units.

Referenced by SelectGroup(), UiAddGroupToSelection(), and UiCenterOnGroup().

void GroupCclRegister ( void   ) 

Register CCL features for groups.

Definition at line 271 of file groups.cpp.

References CclGroup(), and Lua.

Referenced by InitCcl().

void HitUnit ( CUnit attacker,
CUnit target,
int  damage 
)

Returns the map distance between two points.

Unit is hit by missile or other damage.

Parameters:
attacker Unit that attacks.
target Unit that is hit.
damage How many damage to take.

Definition at line 2056 of file unit.cpp.

References _, COrder::Action, CPlayer::AiEnabled, AiHelpMe(), Assert, CUnit::Attacked, AttackUnitsInReactRange(), CUnitType::Building, CUnit::Burning, CUnitType::CanAttack, CanMove(), CanTarget(), CUnit::ChangeOwner(), CommandAttack(), CommandMove(), CommandStopUnit(), CUnitType::Coward, CYCLES_PER_SECOND, Missile::Damage, DamageMissile, DebugPrint, CVariable::Enable, EnableBuildingCapture, FlushCommands, GameCycle, GodMode, HelpMeLastCycle, HelpMeLastX, HelpMeLastY, HP_INDEX, CUnitType::Indestructible, CMap::Info, CUnit::IsEnemy(), isqrt(), CUnit::IsVisibleOnMap(), KILL_INDEX, LetUnitDie(), MakeLocalMissile(), MakeMissile(), Map, CMapInfo::MapHeight, CMapInfo::MapWidth, CVariable::Max, MissileBurningBuilding(), MissileTypeByIdent(), CUnitType::Name, CPlayer::Notify(), NotifyRed, NoUnitP, CUnit::Orders, CUnitType::Organic, CUnit::Player, PlayUnitSound(), CUnitType::Points, CUnit::RefsIncrease(), CUnit::Removed, CUnitType::RepairRange, ReplayRevealMap, CUnit::SavedOrder, CPlayer::Score, Missile::SourceUnit, SyncRand(), ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CPlayer::TotalKills, CPlayer::TotalRazings, CUnit::Type, UnitActionDie, UnitActionStill, CVariable::Value, CUnitType::Vanishes, CUnit::Variable, VoiceHelpMe, CUnit::X, y, and CUnit::Y.

Referenced by Capture::Cast(), AdjustVitals::Cast(), AreaAdjustVitals::Cast(), Demolish::Cast(), FireMissile(), HandleRegenerations(), and MissileHitsGoal().

void InitGroups ( void   ) 

< Initialize data structures for groups

Save groups

Initialize group part.

Todo:
Not needed with the new unit code!

Definition at line 71 of file groups.cpp.

References MaxSelectable, NUM_GROUPS, CUnitGroup::Units, and Units.

Referenced by CclGroup(), CreateGame(), and InitModules().

void InitSelections ( void   ) 

Save current selection state.

Initialize the selection module.

Definition at line 1074 of file selection.cpp.

References MaxSelectable, and PlayerMax.

Referenced by CclSelection(), CreateGame(), and InitModules().

void InitUnits ( void   ) 

Clean unit module.

Initialize unit module.

Definition at line 2600 of file unit.cpp.

References CUnitManager::Init(), NumUnits, SaveGameLoading, and UnitManager.

Referenced by InitModules().

void LetUnitDie ( CUnit unit  ) 

Destory all units inside another unit.

Let a unit die.

Parameters:
unit Unit to be destroyed.

Definition at line 1927 of file unit.cpp.

References CUnit::Anim, CUnitType::Animations, CUnit::_order_data_::Built, CUnitType::CanHarvestFrom, CUnitType::CorpseType, CUnit::CurrentSightRange, CUnit::Data, CAnimations::Death, CUnitType::DeathExplosion, DebugPrint, DestroyAllInside(), CUnitType::ExplodeWhenKilled, CUnitType::Explosion, CGraphic::Height, CUnitType::Height, CPlayer::Index, CUnitCache::Insert(), CUnit::IX, CUnit::IY, MakeMissile(), MapMarkUnitSight(), CVariable::Max, MaxCosts, MissileConfig::Missile, CUnit::Moving, CUnit::Orders, CUnit::Player, PlayUnitSound(), CUnit::ProductionEfficiency, CUnitType::ProductionRate, CPlayer::ProductionRate, LuaCallback::pushInteger(), LuaCallback::pushPreamble(), CUnit::Release(), CUnit::Remove(), CUnit::Removed, CUnit::ResourcesHeld, LuaCallback::run(), SIGHTRANGE_INDEX, CUnitType::Sprite, CUnit::State, CUnitType::Stats, CUnitType::StorageCapacity, CPlayer::StorageCapacity, CPlayer::StoredResources, CUnit::SubAction, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::TTL, CUnit::Type, CUnit::_unit_anim_::Unbreakable, UnitActionBuilt, UnitActionDie, UnitCache, UnitClearOrders(), CUnit::UnitInside, UnitLost(), UnitRemoveConsumingResources(), CUnitStats::Variables, VoiceDying, CGraphic::Width, CUnitType::Width, CUnit::_order_data_::_order_built_::Worker, CUnit::X, and CUnit::Y.

Referenced by CclKillUnit(), CclKillUnitAt(), CommandDismiss(), GatherResource(), HandleActionBuilt(), HandleBuffs(), and HitUnit().

void LoadDecorations ( void   ) 

Clean the decorations (health,mana) of units.

Load decoration.

Definition at line 287 of file unit_draw.cpp.

References CGraphic::New(), ShowLoadProgress(), and DecoSpriteType::SpriteArray.

Referenced by CreateGame(), and LoadModules().

CUnit* MakeUnit ( CUnitType type,
CPlayer player 
)

Create a new unit and place on map.

Create a new unit.

Parameters:
type Pointer to unit-type.
player Pointer to owning player.
Returns:
Pointer to created unit.

Definition at line 302 of file unit.cpp.

References _C_, CUnitManager::AllocUnit(), CUnit::AssignToPlayer(), DebugPrint, CUnit::Init(), NoUnitP, NumUnits, UnitManager, and UnitMax.

Referenced by Summon::Cast(), CclCreateUnit(), HandleActionTrain(), MakeUnitAndPlace(), and StartBuilding().

CUnit* MakeUnitAndPlace ( int  x,
int  y,
CUnitType type,
CPlayer player 
)

Handle the loss of a unit (food,...).

Create new unit and place on map.

Parameters:
x X map tile position.
y Y map tile position.
type Pointer to unit-type.
player Pointer to owning player.
Returns:
Pointer to created unit.

Definition at line 636 of file unit.cpp.

References MakeUnit(), NoUnitP, and CUnit::Place().

Referenced by Polymorph::Cast(), SpawnPortal::Cast(), EditorActionPlaceUnit(), and UnitLost().

int MapDistance ( int  x1,
int  y1,
int  x2,
int  y2 
)

Returns the map distance between two points with unit-type.

Returns the map distance between two points.

Parameters:
x1 X map tile position.
y1 Y map tile position.
x2 X map tile position.
y2 Y map tile position.
Returns:
The distance between in tiles.

Definition at line 2272 of file unit.cpp.

References isqrt().

Referenced by DropOutNearest(), MissileInitMove(), NextMissileFrame(), and ViewPointDistance().

int MapDistanceBetweenTypes ( const CUnitType src,
int  x1,
int  y1,
const CUnitType dst,
int  x2,
int  y2 
)

Returns the map distance between two units.

Returns the map distance between two points with unit type.

Parameters:
src src unittype
x1 X map tile position of src (upperleft).
y1 Y map tile position of src.
dst Unit type to take into account.
x2 X map tile position of dst.
y2 Y map tile position of dst.
Returns:
The distance between the types.

Definition at line 2354 of file unit.cpp.

References isqrt(), CUnitType::TileHeight, and CUnitType::TileWidth.

Referenced by CBuildRestrictionDistance::Check(), and MapDistanceBetweenUnits().

int MapDistanceBetweenUnits ( const CUnit src,
const CUnit dst 
)

Calculate the distance from current view point to coordinate.

Returns the map distance between two units.

Parameters:
src Distance from this unit.
dst Distance to this unit.
Returns:
The distance between in tiles.

Definition at line 2336 of file unit.cpp.

References MapDistanceBetweenTypes(), CUnit::Type, CUnit::X, and CUnit::Y.

Referenced by AttackTarget(), AttackUnitsInDistance(), CompareUnitDistance(), FindRangeAttack(), FireMissile(), HandleActionAttack(), MoveToLocation(), MoveToTarget(), RepairUnit(), SpellMoveToTarget(), StartGathering(), and WaitForTransporter().

int MapDistanceToType ( int  x1,
int  y1,
const CUnitType type,
int  x2,
int  y2 
)

Returns the map distance to unit.

Returns the map distance between two points with unit type.

Parameters:
x1 X map tile position.
y1 Y map tile position.
type Unit type to take into account.
x2 X map tile position.
y2 Y map tile position.
Returns:
The distance between in tiles.

Definition at line 2288 of file unit.cpp.

References isqrt(), CUnitType::TileHeight, and CUnitType::TileWidth.

Referenced by MapDistanceToUnit().

int MapDistanceToUnit ( int  x,
int  y,
const CUnit dest 
)

Returns the map diestance between to unittype as locations.

Returns the map distance to unit.

Parameters:
x X map tile position.
y Y map tile position.
dest Distance to this unit.
Returns:
The distance between in tiles.

Definition at line 2323 of file unit.cpp.

References MapDistanceToType(), CUnit::Type, CUnit::X, and CUnit::Y.

Referenced by Demolish::Cast(), MissileHit(), MoveToTarget(), SpellMoveToTarget(), and ViewPointDistanceToUnit().

void MarkUnitFieldFlags ( const CUnit unit  ) 

< Mark the field with the FieldFlags.

Unmark the field with the FieldFlags.

Mark the field with the FieldFlags.

Parameters:
unit unit to mark.

Definition at line 467 of file unit.cpp.

References CMap::Field(), CUnitType::FieldFlags, CMapField::Flags, Map, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, CUnit::X, and CUnit::Y.

Referenced by CanBuildUnitType(), DoActionMove(), CUnit::MoveToXY(), and CUnit::Place().

void NearestOfUnit ( const CUnit unit,
int  tx,
int  ty,
int *  dx,
int *  dy 
)

Call when an Unit goes under fog.

Find nearest point of unit.

Parameters:
unit Pointer to unit.
tx X tile map postion.
ty Y tile map postion.
dx Out: nearest point X tile map postion to (tx,ty).
dy Out: nearest point Y tile map postion to (tx,ty).

Definition at line 828 of file unit.cpp.

References CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, CUnit::X, CUnit::Y, and y.

Referenced by FireMissile().

CBuildRestrictionOnTop* OnTopDetails ( const CUnit unit,
const CUnitType parent 
)

Todo:
more docu
Find the building restriction that gives me this unit built on top Allows you to define how the restriction is effecting the build

Parameters:
unit the unit that is "OnTop"
parent the parent unit if known. (guess otherwise)
Returns:
the BuildingRestrictionDetails

Definition at line 55 of file build.cpp.

References CBuildRestrictionAnd::_or_list, CUnitType::BuildingRules, CBuildRestrictionOnTop::Parent, and CUnit::Type.

Referenced by EditorActionPlaceUnit(), StartBuilding(), and UnitLost().

void RemoveUnitFromGroups ( CUnit unit  ) 

Register CCL group features.

Remove unit from its groups

Parameters:
unit Unit to remove from group.

Definition at line 207 of file groups.cpp.

References Assert, CUnit::GroupId, CUnitGroup::NumUnits, NumUnits, and CUnitGroup::Units.

Referenced by UnitLost().

void RescueUnits ( void   ) 

CUnit* ResourceOnMap ( int  tx,
int  ty,
int  resource 
)

Find best enemy in numeric range to attack.

Resource on map tile

Parameters:
tx X position on map, tile-based.
ty Y position on map, tile-based.
resource Resource number or -1 for any.
Returns:
Returns the resource if found, or NoUnitP.

Definition at line 211 of file unit_find.cpp.

References NoUnitP, CUnitCache::Select(), UnitCache, UnitHoldsResources(), and UnitMax.

Referenced by UnitFindResource().

void RestoreSelection ( void   ) 

Clear current selection.

Restore selection.

Definition at line 99 of file selection.cpp.

References _NumSelected, _TeamNumSelected, NumSelected, PlayerMax, CUnit::Selected, TeamNumSelected, CUnit::TeamSelected, and UnSelectAll().

void SaveGroups ( CFile file  ) 

Cleanup groups.

Save groups.

Parameters:
file Output file.

Definition at line 85 of file groups.cpp.

References NUM_GROUPS, CUnitGroup::NumUnits, NumUnits, CFile::printf(), UnitReference(), and Units.

Referenced by SaveGame().

void SaveOrder ( const COrder order,
CFile file 
)

void SaveSelection ( void   ) 

Restore selection.

Save selection to restore after.

Definition at line 79 of file selection.cpp.

References _NumSelected, _TeamNumSelected, NumSelected, PlayerMax, and TeamNumSelected.

void SaveSelections ( CFile file  ) 

Clean up selections.

Save current selection state.

Parameters:
file Output file.

Definition at line 1094 of file selection.cpp.

References GroupId, NumSelected, CFile::printf(), and UnitReference().

Referenced by SaveGame().

void SaveUnit ( const CUnit unit,
CFile file 
)

save all units

Save the state of a unit to file.

Parameters:
unit Unit pointer to be saved.
file Output file.

Definition at line 174 of file unit_save.cpp.

References CUnit::_unit_anim_::Anim, CUnit::Anim, AnimationsArray, Assert, CUnit::Attacked, CUnit::AutoCastSpell, CUnit::AutoRepair, CUnit::Blink, CUnit::BoardCount, CUnit::Boarded, CUnit::_order_data_::Built, CUnit::Burning, CUnit::_unit_seen_::ByPlayer, CUnit::_order_data_::_order_built_::Cancel, CUnit::_unit_seen_::CFrame, CUnit::_unit_seen_::Constructed, CUnit::Constructed, CUnitType::Construction, CUnit::Container, CUnit::_unit_anim_::CurrAnim, CUnit::_order_data_::_order_harvest_::CurrentProduction, CUnit::CurrentSightRange, CUnit::Data, CUnit::_unit_seen_::Destroyed, CUnit::Destroyed, CUnit::Direction, CVariable::Enable, CUnit::_order_data_::_order_move_::Fast, CUnit::_order_data_::_order_built_::Frame, CUnit::_unit_seen_::Frame, CUnit::Frame, CConstruction::Frames, CUnit::Goal, CUnit::GroupId, CUnit::_order_data_::Harvest, CUnitType::Ident, CVariable::Increase, CPlayer::Index, CUnit::InsideCount, CUnit::_unit_seen_::IX, CUnit::IX, CUnit::_unit_seen_::IY, CUnit::IY, CUnit::LastGroup, CUnit::_order_data_::_order_move_::Length, CVariable::Max, MaxCosts, CUnit::_order_data_::Move, CUnit::Moving, CUnit::NewOrder, CConstructionFrame::Next, CUnit::Next, NumAnimations, CUnitTypeVar::NumberVariable, CUnit::OrderCount, CUnit::OrderFlush, CUnit::Orders, CUnit::_order_data_::_order_move_::Path, CUnit::Player, PlayerMax, CUnit::PrevContained, CFile::printf(), CUnit::ProductionEfficiency, CUnit::_order_data_::_order_built_::Progress, CUnit::ReCast, CUnit::Refs, CUnit::Removed, CUnit::RescuedFrom, CUnit::ResourcesHeld, CUnit::SavedOrder, SaveOrder(), CUnit::Seen, CUnit::Selected, SpellTypeTable, CUnit::State, CUnit::_unit_seen_::State, CUnit::Stats, CUnitType::Stats, CUnit::SubAction, CUnit::_order_data_::_order_train_::Ticks, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::_order_data_::Train, CUnit::TTL, CUnit::_unit_seen_::Type, CUnit::Type, CUnit::_unit_anim_::Unbreakable, UnitActionBuilt, UnitActionResource, UnitActionStill, UnitActionTrain, CUnit::UnitInside, UnitNotSeen, UnitNumber, UnitReference(), UnitTypeVar, CVariable::Value, CUnit::Variable, CUnitTypeVar::VariableName, CUnit::_unit_anim_::Wait, CUnit::Wait, CUnit::_order_data_::_order_built_::Worker, CUnit::_unit_seen_::X, CUnit::X, CUnit::_unit_seen_::Y, and CUnit::Y.

Referenced by SaveUnits().

void SaveUnits ( CFile file  ) 

Initialize unit module.

Save state of units to file.

Parameters:
file Output file.

Definition at line 429 of file unit_save.cpp.

References NumUnits, CUnitManager::Save(), SaveUnit(), UnitManager, and Units.

Referenced by SaveGame().

int SelectAirUnitsInRectangle ( int  sx0,
int  sy0,
int  sx1,
int  sy1 
)

Add the units in the selection rectangle to the current selection.

Select own air units in a rectangle.

Parameters:
sx0 X start of selection rectangle in tile coordinates
sy0 Y start of selection rectangle in tile coordinates
sx1 X start of selection rectangle in tile coordinates
sy1 Y start of selection rectangle in tile coordinates
Returns:
the number of units found.

Definition at line 878 of file selection.cpp.

References CanSelectMultipleUnits, ChangeSelectedUnits(), CUnit::IsUnusable(), MaxSelectable, CUnit::Player, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectSpritesInsideRectangle(), CUnit::TeamSelected, TileSizeX, TileSizeY, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, and UnitTypeFly.

Referenced by AddSelectedAirUnitsInRectangle(), and UIHandleButtonUp().

void SelectedUnitChanged ( void   ) 

Called whenever the selected unit was updated.

The selected unit has been altered.

Definition at line 897 of file script_ui.cpp.

References CUserInterface::ButtonPanel, UI, and CButtonPanel::Update().

int SelectGroundUnitsInRectangle ( int  sx0,
int  sy0,
int  sx1,
int  sy1 
)

Select flying units in the selection rectangle.

Select own ground units in a rectangle.

Parameters:
sx0 X start of selection rectangle in tile coordinates
sy0 Y start of selection rectangle in tile coordinates
sx1 X start of selection rectangle in tile coordinates
sy1 Y start of selection rectangle in tile coordinates
Returns:
the number of units found.

Definition at line 823 of file selection.cpp.

References CanSelectMultipleUnits, ChangeSelectedUnits(), CUnit::IsUnusable(), MaxSelectable, CUnit::Player, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectSpritesInsideRectangle(), CUnit::TeamSelected, TileSizeX, TileSizeY, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, and UnitTypeFly.

Referenced by AddSelectedGroundUnitsInRectangle(), and UIHandleButtonUp().

int SelectGroup ( int  group_number  ) 

Add the units from the same group as the one in parameter.

Change selected units to units from group group_number Doesn't change the selection if the group has no unit.

Parameters:
group_number number of the group to be selected.
Returns:
number of units in the group.

Definition at line 509 of file selection.cpp.

References Assert, ChangeSelectedUnits(), GetNumberUnitsOfGroup(), GetUnitsOfGroup(), NUM_GROUPS, and NumSelected.

Referenced by UiSelectGroup().

int SelectGroupFromUnit ( CUnit unit  ) 

Select the units in the selection rectangle.

Select units from group of a particular unit. Doesn't change the selection if the group has no unit, or the unit doesn't belong to any group.

Parameters:
unit unit belonging to the group to be selected.
Returns:
0 if the unit doesn't belong to a group, or the number of units in the group.

Definition at line 561 of file selection.cpp.

References AddGroupFromUnitToSelection(), CUnit::LastGroup, and UnSelectAll().

Referenced by DoSelectionButtons(), and UIHandleButtonUp().

void SelectionCclRegister ( void   ) 

Register CCL features for selections.

Definition at line 1182 of file selection.cpp.

References CclSelection(), CclSetGroupId(), and Lua.

Referenced by InitCcl().

void SelectSingleUnit ( CUnit unit  ) 

Remove a unit from selection.

Select a single unit, unselecting the previous ones

Parameters:
unit Pointer to unit to be selected.

Definition at line 260 of file selection.cpp.

References ChangeSelectedUnits().

Referenced by DoSelectionButtons(), SelectUnitsInRectangle(), UiFindIdleWorker(), and UIHandleButtonUp().

int SelectUnit ( CUnit unit  ) 

Select one unit as selection.

Add a unit to the other selected units.

Parameters:
unit Pointer to unit to add.
Returns:
true if added to selection, false otherwise (if NumSelected == MaxSelectable or unit is already selected or unselectable)

Definition at line 223 of file selection.cpp.

References DebugPrint, GameRunning, GroupId, CUnitType::IsNotSelectable, CUnit::LastGroup, MaxSelectable, NumSelected, CUnit::Removed, CUnitType::Revealer, CUnit::Selected, and CUnit::Type.

Referenced by AddGroupFromUnitToSelection(), AddSelectedAirUnitsInRectangle(), AddSelectedGroundUnitsInRectangle(), AddSelectedUnitsInRectangle(), ToggleSelectUnit(), ToggleUnitsByType(), and UiAddGroupToSelection().

int SelectUnitsByType ( CUnit base  ) 

Toggle units from the same type (if selectable by rectangle).

Select units from a particular type and belonging to the local player.

The base is included in the selection and defines the type of the other units to be selected.

Parameters:
base Select all units of same type.
Returns:
Number of units found, 0 means selection unchanged
FIXME: 0 can't happen. Maybe when scripting will use it?

FIXME: should always select the nearest 9 units to the base!

Definition at line 346 of file selection.cpp.

References Assert, CanSelectMultipleUnits, GameRunning, GroupId, CUnitType::IsNotSelectable, CUnit::IsUnusable(), CUnit::LastGroup, CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, MaxSelectable, CUserInterface::MouseViewport, NetworkSendSelection(), NumSelected, CUnit::Orders, CUnit::Player, CUnit::Removed, CUnitCache::Select(), CUnitType::SelectableByRectangle, CUnit::Selected, CUnit::TeamSelected, CUnit::Type, UI, UnitActionDie, UnitCache, UnitMax, and UnSelectAll().

Referenced by DoSelectionButtons(), and UIHandleButtonUp().

int SelectUnitsInRectangle ( int  sx0,
int  sy0,
int  sx1,
int  sy1 
)

Select ground units in the selection rectangle.

Select units in a rectangle. Proceed in order in none found:

  • select local player mobile units
  • select one local player static unit (random)
  • select one neutral unit (critter, mine...)
  • select one enemy unit (random)
Parameters:
sx0 X start of selection rectangle in tile coordinates
sy0 Y start of selection rectangle in tile coordinates
sx1 X start of selection rectangle in tile coordinates
sy1 Y start of selection rectangle in tile coordinates
Returns:
the number of units found.

Definition at line 727 of file selection.cpp.

References CUnitType::Building, CUnitType::CanHarvestFrom, CanSelectMultipleUnits, ChangeSelectedUnits(), CUnit::IsVisibleInViewport(), CUnit::IsVisibleOnMap(), CUnit::Orders, CUnit::Player, CUnit::Removed, CUnitCache::Select(), CUserInterface::SelectedViewport, SelectOrganicUnitsInTable(), SelectSingleUnit(), SelectSpritesInsideRectangle(), ThisPlayer, TileSizeX, TileSizeY, CUnit::Type, UI, UnitActionDie, UnitCache, and UnitMax.

Referenced by AddSelectedUnitsInRectangle(), and UIHandleButtonUp().

void SetGroup ( CUnit **  units,
int  nunits,
int  num 
)

Remove a unit from a group.

Set group num contents to unit array "units"

Parameters:
units Array of units to place into group.
nunits Number of units in array.
num Group number for storage.

Definition at line 194 of file groups.cpp.

References AddToGroup(), Assert, ClearGroup(), MaxSelectable, and NUM_GROUPS.

Referenced by UiDefineGroup().

void ShowOrder ( const CUnit unit  ) 

CUnit* TargetOnMap ( const CUnit source,
int  x1,
int  y1,
int  x2,
int  y2 
)

Return resource, if on map tile.

Choose target on map area.

Parameters:
source Unit which want to attack.
x1 X position on map, tile-based.
y1 Y position on map, tile-based.
x2 X position on map, tile-based.
y2 Y position on map, tile-based.
Returns:
Returns ideal target on map tile.

Definition at line 168 of file unit_find.cpp.

References CanTarget(), CUnit::IsVisibleAsGoal(), NoUnitP, CUnit::Player, CUnitType::Priority, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitCache, UnitMax, CUnit::X, and CUnit::Y.

Referenced by CclOrderUnit().

int ToggleSelectUnit ( CUnit unit  ) 

Select units from the same type (if selectable by rectangle).

Toggle the selection of a unit in a group of selected units

Parameters:
unit Pointer to unit to be toggled.
Returns:
0 if unselected, 1 otherwise

Definition at line 322 of file selection.cpp.

References CUnit::Selected, SelectUnit(), and UnSelectUnit().

Referenced by DoSelectionButtons(), and UIHandleButtonUp().

int ToggleUnitsByType ( CUnit base  ) 

Select the units belonging to a particular group.

Toggle units from a particular type and belonging to the local player.

The base is included in the selection and defines the type of the other units to be selected.

Parameters:
base Toggle all units of same type.
Returns:
Number of units found, 0 means selection unchanged
FIXME: toggle not written FIXME: should always select the nearest 9 units to the base!

Definition at line 440 of file selection.cpp.

References CanSelectMultipleUnits, CUnit::IsUnusable(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUserInterface::MouseViewport, NetworkSendSelection(), NumSelected, CUnit::Orders, CUnit::Player, CUnit::Removed, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectUnit(), CUnit::TeamSelected, CUnit::Type, UI, UnitActionDie, UnitCache, and UnitMax.

Referenced by DoSelectionButtons(), and UIHandleButtonUp().

void UnitCclRegister ( void   ) 

void UnitClearOrders ( CUnit unit  ) 

Todo:
more docu
Removes all orders from a unit.

Parameters:
unit The unit that will have all its orders cleared

Definition at line 770 of file unit.cpp.

References COrder::Goal, CUnit::NewOrder, NoUnitP, CUnit::OrderCount, CUnit::Orders, CUnit::RefsDecrease(), CUnit::SavedOrder, CUnit::State, CUnit::SubAction, and UnitActionStill.

Referenced by Capture::Cast(), Polymorph::Cast(), DestroyAllInside(), EditorActionPlaceUnit(), EditorActionRemoveUnit(), LetUnitDie(), and StartBuilding().

void UnitCountSeen ( CUnit unit  ) 

Check for rescue each second.

Recalculates a units visiblity count. This happens really often, Like every time a unit moves. It's really fast though, since we have per-tile counts.

Parameters:
unit pointer to the unit to check if seen

Definition at line 1013 of file unit.cpp.

References CMap::Field(), CUnit::IsVisible(), Map, CMap::NoFogOfWar, PlayerMax, PlayerNobody, Players, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitGoesOutOfFog(), UnitGoesUnderFog(), CUnit::VisCount, CMapField::Visible, CUnit::X, CUnit::Y, and y.

Referenced by CUnit::MoveToXY(), CUnit::Place(), CMap::Reveal(), and UpdateFogOfWarChange().

CUnit* UnitFindResource ( const CUnit unit,
int  x,
int  y,
int  range,
int  resource 
)

Find the next idle worker.

Find Resource.

Parameters:
unit The unit that wants to find a resource.
x Closest to x
y Closest to y
range Maximum distance to the resource.
resource The resource id.
Note:
This will return an usable resource building that doesn't belong to the player or one of his allies.
Returns:
NoUnitP or resource unit

Definition at line 1696 of file unit.cpp.

References CUnitType::CanHarvestFrom, CanMoveToMask(), CreateMatrix(), CMap::Info, CMap::IsFieldExplored(), Map, MapFieldAirUnit, MapFieldLandUnit, MapFieldSeaUnit, CMapInfo::MapHeight, CMapInfo::MapWidth, CUnitType::MovementMask, NoUnitP, CUnit::Player, PlayerNeutral, ResourceOnMap(), CPlayer::Type, CUnit::Type, CUnit::X, and CUnit::Y.

Referenced by AiAssignHarvester(), FindNewResource(), and StartGathering().

void UnitGoesOutOfFog ( CUnit unit,
const CPlayer player 
)

Marks a unit as seen.

This function should get called when a unit goes out of fog of war.

Parameters:
unit The unit that goes out of fog.
player The player the unit goes out of fog for.
Note:
For units that are visible under fog (mostly buildings) we use reference counts, from the players that know about the building. When an building goes under fog it gets a refs increase, and when it shows up it gets a decrease. It must not get an decrease the first time it's seen, so we have to keep track of what player saw what units, with SeenByPlayer.

Definition at line 923 of file unit.cpp.

References CUnit::_unit_seen_::ByPlayer, CUnit::_unit_seen_::Destroyed, CPlayer::Index, PlayerPerson, CUnit::RefsDecrease(), CUnit::Seen, CPlayer::Type, CUnit::Type, and CUnitType::VisibleUnderFog.

Referenced by CMap::Reveal(), UnitCountSeen(), and UnitsOnTileMarkSeen().

void UnitGoesUnderFog ( CUnit unit,
const CPlayer player 
)

Call when an Unit goes out of fog.

This function should get called when a unit goes under fog of war.

Parameters:
unit The unit that goes under fog.
player The player the unit goes out of fog for.

Definition at line 882 of file unit.cpp.

References CUnit::_unit_seen_::Destroyed, CUnit::Destroyed, CPlayer::Index, PlayerPerson, CUnit::RefsIncrease(), CUnit::Seen, ThisPlayer, CPlayer::Type, CUnit::Type, UnitFillSeenValues(), and CUnitType::VisibleUnderFog.

Referenced by CMap::Reveal(), UnitCountSeen(), and UnitsOnTileUnmarkSeen().

void UnitHeadingFromDeltaXY ( CUnit unit,
int  dx,
int  dy 
)

Todo:
more docu
Change unit heading/frame from delta direction x, y.

Parameters:
unit Unit for new direction looking.
dx X map tile delta direction.
dy Y map tile delta direction.

Definition at line 1484 of file unit.cpp.

References CUnit::Direction, DirectionToHeading(), and UnitUpdateHeading().

Referenced by AttackTarget(), AutoAttack(), DoActionMove(), HandleActionAttack(), MoveToLocation(), MoveToTarget(), SpellMoveToTarget(), and StartGathering().

bool UnitHoldsResources ( const CUnit unit  ) 

Find resource.

Check if a unit holds any resources

Parameters:
unit Unit to check
Returns:
True if the unit holds resources, false if it doesn't

Definition at line 1377 of file unit.cpp.

References MaxCosts, and CUnit::ResourcesHeld.

Referenced by GatherResource(), ResourceOnMap(), and UnitLost().

void UnitLost ( CUnit unit  ) 

CUnit* UnitOnMapTile ( int  tx,
int  ty,
unsigned  type 
)

Return possible attack target on that map area.

Unit on map tile.

Parameters:
tx X position on map, tile-based.
ty Y position on map, tile-based.
type UnitTypeType, (unsigned)-1 for any type.
Returns:
Returns first found unit on tile.

Definition at line 136 of file unit_find.cpp.

References NoUnitP, CUnitCache::Select(), UnitCache, and UnitMax.

Referenced by ClosestFreeCoast(), CostMoveTo(), EditorRedoAction(), EditorUndoAction(), UIHandleButtonDown(), and UIHandleMouseMove().

CUnit* UnitOnScreen ( int  x,
int  y 
)

Check if a unit should be removed from UnitsConsumingResources.

Select unit on screen. (x, y are in pixels relative to map 0,0).

Parameters:
x X pixel position.
y Y pixel position.
Returns:
Unit on x, y position.

Definition at line 1865 of file unit.cpp.

References CUnitType::BoxHeight, CUnitType::BoxWidth, CUnitType::DrawLevel, CUnit::IsVisibleAsGoal(), CUnit::IX, CUnit::IY, NumUnits, ReplayRevealMap, ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, CUnit::X, and CUnit::Y.

Referenced by EditorCallbackMouse(), UIHandleButtonUp(), and UIHandleMouseMove().

std::string UnitReference ( const CUnit unit  ) 

Save an order.

Generate a unit reference, a printable unique string for unit.

Definition at line 55 of file unit_save.cpp.

References UnitNumber.

Referenced by SaveGroups(), Missile::SaveMissile(), SaveOrder(), SaveSelections(), and SaveUnit().

void UnitRemoveConsumingResources ( CUnit unit  ) 

void UnitsOnTileMarkSeen ( const CPlayer player,
int  x,
int  y 
)

Unmarks a unit as seen.

Mark all units on a tile as now visible.

Parameters:
player The player this is for.
x x location to check
y y location to check

Definition at line 944 of file unit.cpp.

References CPlayer::Index, CPlayer::IsBothSharedVision(), CUnit::IsVisible(), PlayerMax, Players, CUnitCache::Select(), UnitCache, UnitGoesOutOfFog(), UnitMax, and CUnit::VisCount.

Referenced by MapMarkTileSight().

void UnitsOnTileUnmarkSeen ( const CPlayer player,
int  x,
int  y 
)

Does a recount for VisCount.

This function unmarks units on x, y as seen. It uses a reference count.

Parameters:
player The player to mark for.
x x location to check if building is on, and mark as seen
y y location to check if building is on, and mark as seen

Definition at line 975 of file unit.cpp.

References Assert, CPlayer::Index, CPlayer::IsBothSharedVision(), CUnit::IsVisible(), PlayerMax, Players, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitCache, UnitGoesUnderFog(), UnitMax, CUnit::VisCount, CUnit::X, and CUnit::Y.

Referenced by MapUnmarkTileSight().

void UnitUpdateHeading ( CUnit unit  ) 

Heading and frame from delta direction x,y.

Update sprite frame for new heading.

Definition at line 1448 of file unit.cpp.

References CUnitType::Building, CUnit::Direction, CUnit::Frame, LookingS, CUnitType::NumDirections, and CUnit::Type.

Referenced by DoActionMove(), HandleActionBuilt(), HandleActionDie(), HandleActionFollow(), CUnit::Init(), StartBuilding(), UnitHeadingFromDeltaXY(), UnitRotate(), and UnitShowAnimationScaled().

void UnmarkUnitFieldFlags ( const CUnit unit  ) 

Update unit->CurrentSightRange.

Mark the field with the FieldFlags.

Parameters:
unit unit to mark.

Definition at line 483 of file unit.cpp.

References CMap::Field(), CUnitType::FieldFlags, CMapField::Flags, Map, CUnit::Orders, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitActionDie, UnitCache, UnitMax, CUnit::X, and CUnit::Y.

Referenced by CanBuildUnitType(), DoActionMove(), CUnit::MoveToXY(), and CUnit::Remove().

void UnSelectAll ( void   ) 

Select group as selection.

Unselect all the units in the current selection

Definition at line 122 of file selection.cpp.

References GroupId, NoUnitP, NumSelected, and CUnit::Selected.

Referenced by ChangeSelectedUnits(), RestoreSelection(), SelectGroupFromUnit(), SelectUnitsByType(), and UiUnselectAll().

void UnSelectUnit ( CUnit unit  ) 

Add a unit to selected if not already selected, remove it otherwise.

Unselect unit

Parameters:
unit Pointer to unit to be unselected.

Definition at line 270 of file selection.cpp.

References Assert, GroupId, CUnit::LastGroup, NoUnitP, NumSelected, PlayerMax, CUnit::Selected, TeamNumSelected, and CUnit::TeamSelected.

Referenced by DoActionMove(), CUnit::Remove(), and ToggleSelectUnit().

void UpdateForNewUnit ( const CUnit unit,
int  upgrade 
)

Todo:
more docu
Update for new unit. Food and income ...

Parameters:
unit New unit pointer.
upgrade True unit was upgraded.

Definition at line 805 of file unit.cpp.

References MaxCosts, CUnit::Player, CUnit::ProductionEfficiency, CUnitType::ProductionRate, CPlayer::ProductionRate, CUnitType::StorageCapacity, CPlayer::StorageCapacity, and CUnit::Type.

Referenced by CclCreateUnit(), CclUnit(), CUnit::ChangeOwner(), HandleActionBuilt(), and HandleActionTrain().

void UpdateUnitSightRange ( CUnit unit  ) 

Create a new unit.

Update the Unit Current sight range to good value and transported units inside.

Parameters:
unit unit to update SightRange

Definition at line 435 of file unit.cpp.

References Assert, CUnit::Constructed, CUnit::Container, CUnit::CurrentSightRange, CUnit::InsideCount, CVariable::Max, CUnit::NextContained, SaveGameLoading, SIGHTRANGE_INDEX, CUnit::Stats, CUnit::UnitInside, UpdateUnitSightRange(), and CUnitStats::Variables.

Referenced by CUnit::ChangeOwner(), CUnit::Place(), CUnit::Remove(), and UpdateUnitSightRange().

int ViewPointDistance ( int  x,
int  y 
)

Calculate the distance from current view point to unit.

Compute the distance from the view point to a given point.

Parameters:
x X map tile position.
y Y map tile position.
Todo:
FIXME: is it the correct place to put this function in?

Definition at line 2391 of file unit.cpp.

References MapDistance(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUserInterface::SelectedViewport, and UI.

Referenced by ViewPointDistanceToMissile().

int ViewPointDistanceToUnit ( const CUnit dest  ) 

Can this unit-type attack the other (destination).

Compute the distance from the view point to a given unit.

Parameters:
dest Distance to this unit.
Todo:
FIXME: is it the correct place to put this function in?

Definition at line 2410 of file unit.cpp.

References MapDistanceToUnit(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUserInterface::SelectedViewport, and UI.

Referenced by PlayUnitSound().


Variable Documentation

CurrentViewport.

Definition at line 104 of file unit_draw.cpp.

Referenced by CViewport::Draw(), and Missile::DrawMissile().

Config: building capture enabled.

Definition at line 73 of file unit.cpp.

Referenced by CclSetBuildingCapture(), and HitUnit().

int NumUnits

unsigned long ShowOrdersCount

Show orders for some time.

Todo:
could be moved into the user interface ?
Show orders for some time

Definition at line 90 of file unit_draw.cpp.

Referenced by DoRightButton(), CViewport::Draw(), and SendCommand().

int TeamNumSelected[PlayerMax]

Number of Units a team member has selected.

Definition at line 60 of file selection.cpp.

Referenced by ChangeTeamSelectedUnits(), CleanSelections(), RestoreSelection(), SaveSelection(), and UnSelectUnit().

CUnit** TeamSelected[PlayerMax]

teams currently selected units

Definition at line 63 of file selection.cpp.

Referenced by CUnit::Init().

CUnit* Units[MAX_UNIT_SLOTS]


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