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

       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"

CUnit Class Reference

#include <unit.h>

List of all members.

Public Member Functions

 CUnit ()
void Init ()
bool IsIdle () const
void ClearAction ()
 Increase a unit's reference count.
void RefsIncrease ()
 Decrease a unit's reference count.
void RefsDecrease ()
 Initialize unit structure with default values.
void Init (CUnitType *type)
 Assign unit to player.
void AssignToPlayer (CPlayer *player)
 Draw a single unit.
void Draw () const
 Place a unit on map.
void Place (int x, int y)
 Move unit to tile(x, y). (Do special stuff : vision, cachelist, pathfinding).
void MoveToXY (int x, int y)
 Add a unit inside a container. Only deal with list stuff.
void AddInContainer (CUnit *host)
 Change owner of unit.
void ChangeOwner (CPlayer *newplayer)
 Remove unit from map/groups/...
void Remove (CUnit *host)
 Release a unit.
void Release ()
 Returns true, if unit is directly seen by an allied unit.
bool IsVisible (const CPlayer *player) const
 Returns true, if unit is visible as a goal.
bool IsVisibleAsGoal (const CPlayer *player) const
 Returns true, if the unit is alive and on the map.
bool IsAliveOnMap () const
 Returns true, if unit is Visible for game logic on the map.
bool IsVisibleOnMap (const CPlayer *player) const
 Returns true if unit is visible on minimap. Only for ThisPlayer.
bool IsVisibleOnMinimap () const
 Returns true if unit is visible in an viewport. Only for ThisPlayer.
bool IsVisibleInViewport (const CViewport *vp) const
 Returns true, if unit is visible on current map view (any viewport).
bool IsVisibleOnScreen () const
void GetMapArea (int *sx, int *sy, int *ex, int *ey) const
bool IsEnemy (const CPlayer *x) const
bool IsEnemy (const CUnit *x) const
bool IsAllied (const CPlayer *x) const
bool IsAllied (const CUnit *x) const
bool IsSharedVision (const CPlayer *x) const
bool IsSharedVision (const CUnit *x) const
bool IsBothSharedVision (const CPlayer *x) const
bool IsBothSharedVision (const CUnit *x) const
bool IsTeamed (const CPlayer *x) const
bool IsTeamed (const CUnit *x) const
bool IsUnusable () const

Public Attributes

unsigned long Refs
 Reference counter.
int Slot
 Assigned slot number.
CUnit ** UnitSlot
 Slot pointer of Units.
CUnit ** PlayerSlot
 Slot pointer of Player->Units.
CUnitNext
 Generic link pointer (on map).
int InsideCount
 Number of units inside.
int BoardCount
 Number of units transported inside.
CUnitUnitInside
 Pointer to one of the units inside.
CUnitContainer
 Pointer to the unit containing it (or 0).
CUnitNextContained
 Next unit in the container.
CUnitPrevContained
 Previous unit in the container.
int X
 Map position X.
int Y
 Map position Y.
CUnitTypeType
 Pointer to unit-type (peon,...).
CPlayerPlayer
 Owner of this unit.
CUnitStatsStats
 Current unit stats.
int CurrentSightRange
 Unit's Current Sight Range.
CUnitColorsColors
 Player colors.
signed char IX
 X image displacement to map position.
signed char IY
 Y image displacement to map position.
int Frame
 Image frame: <0 is mirrored.
unsigned Direction: 8
 angle (0-255) unit looking
unsigned long Attacked
 gamecycle unit was last attacked
unsigned Burning: 1
 unit is burning
unsigned Destroyed: 1
 unit is destroyed pending reference
unsigned Removed: 1
 unit is removed (not on map)
unsigned Selected: 1
 unit is selected
unsigned Constructed: 1
 Unit is in construction.
unsigned Boarded: 1
 Unit is on board a transporter.
unsigned TeamSelected
 unit is selected by a team member.
CPlayerRescuedFrom
int VisCount [PlayerMax]
 Unit visibility counts.
struct CUnit::_unit_seen_ Seen
CVariableVariable
 array of User Defined variables.
unsigned long TTL
 time to live
int GroupId
 unit belongs to this group id
int LastGroup
 unit belongs to this last group
int ResourcesHeld [MaxCosts]
 Resources held by a unit.
unsigned ProductionEfficiency: 8
 Production efficiency.
unsigned SubAction: 8
 sub-action of unit
unsigned Wait
 action counter
unsigned State: 8
 action state
unsigned Blink: 3
 Let selection rectangle blink.
unsigned Moving: 1
 The unit is moving.
unsigned ReCast: 1
 Recast again next cycle.
struct CUnit::_unit_anim_ Anim
char OrderCount
 how many orders in queue
char OrderFlush
 cancel current order, take next
std::vector< COrder * > Orders
 orders to process
COrder SavedOrder
 order to continue after current
COrder NewOrder
 order for new trained units
char * AutoCastSpell
 spells to auto cast
unsigned AutoRepair: 1
 True if unit tries to repair on still action.
union CUnit::_order_data_ Data
 Storage room for different commands.
CUnitGoal
 Generic goal pointer.

Classes

union  _order_data_
struct  _unit_anim_
struct  _unit_seen_


Detailed Description

#include "unit.h"

Everything belonging to a unit. FIXME: rearrange for less memory.

This class contains all information about a unit in game. A unit could be anything: a man, a vehicle, a ship, or a building. Currently only a tile, a unit, or a missile could be placed on the map.

The unit structure members:

CUnit::Refs

The reference counter of the unit. If the pointer to the unit is stored the counter must be incremented and if this reference is destroyed the counter must be decremented. Alternative it would be possible to implement a garbage collector for this.

CUnit::Slot

This is the unique slot number. It is not possible that two units have the same slot number at the same time. The slot numbers are reused. This field could be accessed by the macro UnitNumber(Unit *). Maximal 65535 (=MAX_UNIT_SLOTS) simultaneous units are supported.

CUnit::UnitSlot

This is the pointer into Units[], where the unit pointer is stored. Units[] is a table of all units currently active in game. This pointer is only needed to speed up, the remove of the unit pointer from Units[], it didn't must be searched in the table.

CUnit::PlayerSlot

A pointer into Player::Units[], where the unit pointer is stored. Player::Units[] is a table of all units currently belonging to a player. This pointer is only needed to speed up, the remove of the unit pointer from Player::Units[].

CUnit::Next

A generic link pointer. This member is currently used, if an unit is on the map, to link all units on the same map field together. This also links corpses and stuff. Also, this is used in memory management to link unused units.

CUnit::Container

Pointer to the unit containing it, or NoUnitP if the unit is free. This points to the transporter for units on board, or to the building for peasants inside(when they are mining).

CUnit::UnitInside

Pointer to the last unit added inside. Order doesn't really matter. All units inside are kept in a circular linked list. This is NoUnitP if there are no units inside. Multiple levels of inclusion are allowed, though not very usefull right now

CUnit::NextContained, CUnit::PrevContained

The next and previous element in the curent container. Bogus values allowed for units not contained.

CUnit::InsideCount

The number of units inside the container.

CUnit::BoardCount

The number of units transported inside the container. This does not include for instance stuff like harvesters returning cargo.

CUnit::X CUnit::Y

The tile map coordinates of the unit. 0,0 is the upper left on the map. To convert the map coordinates into pixels, they must be multiplicated with the TileSizeX and TileSizeY. To get the pixel coordinates of a unit, calculate CUnit::X*TileSizeX+CUnitIX , CUnit::Y*TileSizeY+CUnitIY.

CUnit::Type

Pointer to the unit-type (UnitType). The unit-type contains all informations that all units of the same type shares. (Animations, Name, Stats, ...)

CUnit::SeenType Pointer to the unit-type that this unit was, when last seen. Currently only used by buildings.

CUnit::Player

Pointer to the owner of this unit (Player). An unit could only be owned by one player.

CUnit::Stats

Pointer to the current status (UnitStats) of a unit. The units of the same player and the same type could share the same stats. The status contains all values which could be different for each player. This f.e. the upgradeable abilities of an unit. (CUnit::Stats::SightRange, CUnit::Stats::Armor, CUnit::Stats::HitPoints, ...)

CUnit::CurrentSightRange

Current sight range of a unit, this changes when a unit enters a transporter or building or exits one of these.

CUnit::Colors

Player colors of the unit. Contains the hardware dependent pixel values for the player colors (palette index #208-#211). Setup from the global palette. This is a pointer.

Note:
Index #208-#211 are various SHADES of the team color (#208 is brightest shade, #211 is darkest shade) .... these numbers are NOT red=#208, blue=#209, etc
CUnit::IX CUnit::IY

Coordinate displacement in pixels or coordinates inside a tile. Currently only !=0, if the unit is moving from one tile to another (0-32 and for ships/flyers 0-64).

CUnit::Frame

Current graphic image of the animation sequence. The high bit (128) is used to flip this image horizontal (x direction). This also limits the number of different frames/image to 126.

CUnit::SeenFrame

Graphic image (see CUnit::Frame) what the player on this computer has last seen. If UnitNotSeen the player haven't seen this unit yet.

CUnit::Direction

Contains the binary angle (0-255) in which the direction the unit looks. 0, 32, 64, 128, 160, 192, 224, 256 corresponds to 0, 45, 90, 135, 180, 225, 270, 315, 360 or north, north-east, east, south-east, south, south-west, west, north-west, north. Currently only 8 directions are used, this is more for the future.

CUnit::Attacked

Last cycle the unit was attacked. 0 means never.

CUnit::Burning

If Burning is non-zero, the unit is burning.

CUnit::VisCount[PlayerMax]

Used to keep track of visible units on the map, it counts the Number of seen tiles for each player. This is only modified in UnitsMarkSeen and UnitsUnmarkSeen, from fow. We keep track of visilibty for each player, and combine with Shared vision ONLY when querying and such.

CUnit::SeenByPlayer

This is a bitmask of 1 and 0 values. SeenByPlayer & (1<<p) is 0 If p never saw the unit and 1 if it did. This is important for keeping track of dead units under fog. We only keep track of units that are visible under fog with this.

CUnit::Destroyed

Unit is destroyed. pending reference.

CUnit::Removed

This flag means the unit is not active on map. This flag have workers set if they are inside a building, units that are on board of a transporter.

CUnit::Selected

Unit is selected. (So you can give it orders)

CUnit::Constructed Set when a building is under construction, and still using the generic building animation.

CUnit::SeenConstructed Last seen state of construction. Used to draw correct building frame. See CUnit::Constructed for more information.

CUnit::SeenState The Seen State of the building. 01 The building in being built when last seen. 10 The building was been upgraded when last seen.

CUnit::Boarded

This is 1 if the unit is on board a transporter.

CUnit::Kills

How many units have been killed by the unit.

CUnit::GroupId

Number of the group to that the unit belongs. This is the main group showed on map, a unit can belong to many groups.

CUnit::LastGroup

Automatic group number, to reselect the same units. When the user selects more than one unit all units is given the next same number. (Used for ALT-CLICK)

CUnit::Value

This values hold the amount of resources in a resource or in in a harvester.

CUnit::SubAction

This is an action private variable, it is zero on the first entry of an action. Must be set to zero, if an action finishes. It should only be used inside of actions.

CUnit::Wait

The unit is forced too wait for that many cycles. Be carefull, setting this to 0 will lock the unit.

CUnit::State

Animation state, currently position in the animation script. 0 if an animation has just started, it should only be changed inside of actions.

CUnit::Reset

CUnit::Blink

CUnit::Moving

CUnit::RescuedFrom

Pointer to the original owner of a unit. It will be NULL if the unit was not rescued.

CUnit::OrderCount

The number of the orders unit to process. An unit has atleast one order. CUnit::OrderCount should be a number at least 1. The orders are in CUnit::Orders[].

CUnit::OrderFlush

A flag, which tells the unit to stop with the current order and immediately start with the next order.

CUnit::TotalOrders

The number of Orders allocated for this unit to use. Default is 4, but is dynamically updated if more orders are given.

CUnit::Orders

Contains all orders of the unit. Slot 0 is always used.

CUnit::SavedOrder

This order is executed, if the current order is finished. This is used for attacking units, to return to the old place or for patrolling units to return to patrol after killing some enemies. Any new order given to the unit, clears this saved order.

CUnit::NewOrder

This field is only used by buildings and this order is assigned to any by this building new trained unit. This is can be used to set the exit or gathering point of a building.

CUnit::Data

Todo:
continue documentation
CUnit::Goal

Generic goal pointer. Used by teleporters to point to circle of power.

Definition at line 489 of file unit.h.


Constructor & Destructor Documentation

CUnit::CUnit (  )  [inline]

Definition at line 491 of file unit.h.


Member Function Documentation

void CUnit::Init ( void   )  [inline]

Definition at line 493 of file unit.h.

References AutoCastSpell(), AutoRepair(), GroupId, Selected, and TeamSelected.

Referenced by CUnitManager::AllocUnit(), CclUnit(), and MakeUnit().

bool CUnit::IsIdle (  )  const [inline]

Definition at line 669 of file unit.h.

References UnitActionStill.

Referenced by AiForceAttacks(), AiMoveUnitInTheWay(), AiPlanAttack(), and AiTrainUnit().

void CUnit::ClearAction (  )  [inline]

void CUnit::RefsIncrease (  ) 

void CUnit::RefsDecrease (  ) 

void CUnit::Init ( CUnitType type  ) 

void CUnit::AssignToPlayer ( CPlayer player  ) 

void CUnit::Draw ( void   )  const

void CUnit::Place ( int  x,
int  y 
)

Move unit to tile(x, y). (Do special stuff : vision, cachelist, pathfinding).

Place unit on map.

Parameters:
x X map tile position.
y Y map tile position.

Definition at line 603 of file unit.cpp.

References Assert, Container, CUnitCache::Insert(), MapMarkUnitSight(), MapUnmarkUnitSight(), MarkUnitFieldFlags(), Removed, RemoveUnitFromContainer(), SaveGameLoading, UnitCache, UnitCountSeen(), UnitInXY(), and UpdateUnitSightRange().

Referenced by Polymorph::Cast(), CclCreateUnit(), CclMoveUnit(), DropOutNearest(), DropOutOnSide(), LoadGame(), MakeUnitAndPlace(), StartBuilding(), and UnloadUnit().

void CUnit::MoveToXY ( int  x,
int  y 
)

Add a unit inside a container. Only deal with list stuff.

Move a unit (with units inside) to tile (x, y). (Do stuff with vision, cachelist and pathfinding).

Parameters:
x X map tile position.
y Y map tile position.

Definition at line 580 of file unit.cpp.

References Assert, CUnitCache::Insert(), MapMarkUnitSight(), MapUnmarkUnitSight(), MarkUnitFieldFlags(), CUnitCache::Remove(), UnitCache, UnitCanBeAt(), UnitCountSeen(), UnitInXY(), and UnmarkUnitFieldFlags().

Referenced by SpawnPortal::Cast(), and DoActionMove().

void CUnit::AddInContainer ( CUnit host  ) 

Change owner of unit.

Add unit to a container. It only updates linked list stuff.

Parameters:
host Pointer to container.

Definition at line 507 of file unit.cpp.

References Assert, Container, InsideCount, NextContained, NoUnitP, PrevContained, and UnitInside.

Referenced by CclUnit(), and Remove().

void CUnit::ChangeOwner ( CPlayer newplayer  ) 

void CUnit::Remove ( CUnit host  ) 

void CUnit::Release (  ) 

Returns true, if unit is directly seen by an allied unit.

Release a unit.

The unit is only released, if all references are dropped.

Definition at line 121 of file unit.cpp.

References _C_, Assert, AutoCastSpell, Container, DebugPrint, Destroyed, Goal, MapUnmarkUnitSight(), NumUnits, OrderCount, Orders, Refs, CUnitManager::ReleaseUnit(), Removed, RemoveUnitFromContainer(), Slot, Type, UnitManager, UnitSlot, and Variable.

Referenced by Summon::Cast(), Polymorph::Cast(), DestroyAllInside(), EditorActionPlaceUnit(), EditorActionRemoveUnit(), HandleActionDie(), LetUnitDie(), RefsDecrease(), and StartBuilding().

bool CUnit::IsVisible ( const CPlayer player  )  const

Returns true, if unit is visible as a goal.

Returns true, if the unit is visible. It check the Viscount of the player and everyone who shares vision with him.

Note:
This understands shared vision, and should be used all around.
Parameters:
player The player to check.

Definition at line 1081 of file unit.cpp.

References CPlayer::Index, CPlayer::IsBothSharedVision(), PlayerMax, Players, and VisCount.

Referenced by Draw(), DrawInfoPanelNoneSelected(), DrawInformations(), DrawUnitOn(), IsVisibleAsGoal(), IsVisibleInViewport(), IsVisibleOnMap(), IsVisibleOnMinimap(), UIHandleMouseMove(), UnitCountSeen(), UnitShowAnimationScaled(), UnitsOnTileMarkSeen(), and UnitsOnTileUnmarkSeen().

bool CUnit::IsVisibleAsGoal ( const CPlayer player  )  const

Returns true, if the unit is alive and on the map.

Returns true, if unit is visible as an action goal for a player on the map.

Parameters:
player Player to check for.
Returns:
True if visible, false otherwise.

Definition at line 1104 of file unit.cpp.

References CUnit::_unit_seen_::ByPlayer, CUnit::_unit_seen_::Destroyed, Destroyed, CPlayer::Index, IsVisible(), Orders, PlayerComputer, Removed, Seen, Type, CPlayer::Type, UnitActionDie, UnitVisibleOnRadar(), and CUnitType::VisibleUnderFog.

Referenced by AttackUnitsInDistance(), CheckForDeadGoal(), EnterTransporter(), FindRangeAttack(), HandleActionFollow(), MoveToLocation(), RepairUnit(), StartGathering(), TargetOnMap(), UIHandleMouseMove(), UnitOnScreen(), UnitToRepairInRange(), and WaitForTransporter().

bool CUnit::IsAliveOnMap (  )  const

Returns true, if unit is Visible for game logic on the map.

Returns true if unit is alive and on the map. Another unit can interact only with alive map units.

Returns:
True if alive, false otherwise.

Definition at line 1122 of file unit.cpp.

References Destroyed, Orders, Removed, and UnitActionDie.

Referenced by GatherResource().

bool CUnit::IsVisibleOnMap ( const CPlayer player  )  const

Returns true if unit is visible on minimap. Only for ThisPlayer.

Returns true, if unit is visible for this player on the map. The unit has to be out of fog of war and alive

Parameters:
player Player to check for.
Returns:
True if visible, false otherwise.

Definition at line 1135 of file unit.cpp.

References Destroyed, IsVisible(), Orders, Removed, and UnitActionDie.

Referenced by HitUnit(), and SelectUnitsInRectangle().

bool CUnit::IsVisibleOnMinimap (  )  const

Returns true if unit is visible in an viewport. Only for ThisPlayer.

Returns true, if unit is shown on minimap.

Warning:
This is for ThisPlayer only.
Todo:
radar support
Returns:
True if visible, false otherwise.

Definition at line 1149 of file unit.cpp.

References CUnit::_unit_seen_::ByPlayer, CUnit::_unit_seen_::Destroyed, Destroyed, CPlayer::Index, IsVisible(), Orders, Removed, ReplayRevealMap, Seen, CUnit::_unit_seen_::State, ThisPlayer, Type, UnitActionDie, UnitVisibleOnRadar(), and CUnitType::VisibleUnderFog.

bool CUnit::IsVisibleInViewport ( const CViewport vp  )  const

Returns true, if unit is visible on current map view (any viewport).

Returns true, if unit is visible in viewport.

Warning:
This is only true for ThisPlayer
Parameters:
vp Viewport pointer.
Returns:
True if visible, false otherwise.

Definition at line 1172 of file unit.cpp.

References Assert, CUnit::_unit_seen_::ByPlayer, CUnit::_unit_seen_::Destroyed, Destroyed, CViewport::EndX, CViewport::EndY, CUnitType::Height, CPlayer::Index, IsVisible(), IX, IY, CViewport::MapX, CViewport::MapY, CViewport::OffsetX, CUnitType::OffsetX, CViewport::OffsetY, CUnitType::OffsetY, ReplayRevealMap, Seen, ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, Type, CUnitType::VisibleUnderFog, CUnitType::Width, CViewport::X, X, CViewport::Y, Y, and y.

Referenced by FindAndSortUnits(), IsVisibleOnScreen(), and SelectUnitsInRectangle().

bool CUnit::IsVisibleOnScreen (  )  const

Todo:
more docu
Returns true, if unit is visible on current map view (any viewport).

Returns:
True if visible, false otherwise.

Definition at line 1211 of file unit.cpp.

References IsVisibleInViewport(), CUserInterface::NumViewports, UI, and CUserInterface::Viewports.

void CUnit::GetMapArea ( int *  sx,
int *  sy,
int *  ex,
int *  ey 
) const

Get area of map tiles covered by unit, including its displacement.

Parameters:
sx Out: Top left X tile map postion.
sy Out: Top left Y tile map postion.
ex Out: Bottom right X tile map postion.
ey Out: Bottom right Y tile map postion.
Returns:
sx,sy,ex,ey defining area in Map

Definition at line 1231 of file unit.cpp.

References IX, IY, CUnitType::TileHeight, CUnitType::TileWidth, Type, X, and Y.

bool CUnit::IsEnemy ( const CPlayer x  )  const

Check if the player is an enemy

Parameters:
x Player to check

Definition at line 2486 of file unit.cpp.

References CPlayer::Enemy, CPlayer::Index, and Player.

Referenced by Capture::Cast(), Polymorph::Cast(), DoRightButton(), DrawUnitInfo(), HitUnit(), IsEnemy(), PassCondition(), and SelectTargetUnitsOfAutoCast().

bool CUnit::IsEnemy ( const CUnit x  )  const

Check if the unit is an enemy

Parameters:
x Unit to check

Definition at line 2496 of file unit.cpp.

References IsEnemy(), and Player.

bool CUnit::IsAllied ( const CPlayer x  )  const

Check if the player is an ally

Parameters:
x Player to check

Definition at line 2506 of file unit.cpp.

References CPlayer::IsAllied(), and Player.

Referenced by CheckAlreadyBuilding(), DoRightButton(), IsAllied(), PassCondition(), and RescueUnits().

bool CUnit::IsAllied ( const CUnit x  )  const

Check if the unit is an ally

Parameters:
x Unit to check

Definition at line 2516 of file unit.cpp.

References IsAllied(), and Player.

bool CUnit::IsSharedVision ( const CPlayer x  )  const

Check if unit shares vision with the player

Parameters:
x Player to check

Definition at line 2526 of file unit.cpp.

References CPlayer::Index, Player, and CPlayer::SharedVision.

Referenced by IsSharedVision().

bool CUnit::IsSharedVision ( const CUnit x  )  const

Check if the unit shares vision with the unit

Parameters:
x Unit to check

Definition at line 2536 of file unit.cpp.

References IsSharedVision(), and Player.

bool CUnit::IsBothSharedVision ( const CPlayer x  )  const

Check if both players share vision

Parameters:
x Player to check

Definition at line 2546 of file unit.cpp.

References CPlayer::Index, Player, and CPlayer::SharedVision.

Referenced by IsBothSharedVision().

bool CUnit::IsBothSharedVision ( const CUnit x  )  const

Check if both units share vision

Parameters:
x Unit to check

Definition at line 2557 of file unit.cpp.

References IsBothSharedVision(), and Player.

bool CUnit::IsTeamed ( const CPlayer x  )  const

Check if the player is on the same team

Parameters:
x Player to check

Definition at line 2567 of file unit.cpp.

References Player, and CPlayer::Team.

Referenced by CanTransport(), DoRightButton(), and IsTeamed().

bool CUnit::IsTeamed ( const CUnit x  )  const

Check if the unit is on the same team

Parameters:
x Unit to check

Definition at line 2577 of file unit.cpp.

References IsTeamed(), and Player.

bool CUnit::IsUnusable (  )  const


Member Data Documentation

unsigned long CUnit::Refs

Slot pointer of Units.

Definition at line 554 of file unit.h.

Referenced by Init(), and Release().

Slot pointer of Player->Units.

Definition at line 555 of file unit.h.

Referenced by AssignToPlayer(), ChangeOwner(), and UnitLost().

Generic link pointer (on map).

Definition at line 557 of file unit.h.

Referenced by CclUnit(), and SaveUnit().

Number of units transported inside.

Definition at line 560 of file unit.h.

Referenced by CanTransport(), CclUnit(), DrawUnitInfo(), EnterTransporter(), HandleMouseOn(), IsButtonAllowed(), LeaveTransporter(), SaveUnit(), and UpdateUnitVariables().

Previous unit in the container.

Definition at line 564 of file unit.h.

Referenced by AddInContainer(), RemoveUnitFromContainer(), and SaveUnit().

int CUnit::X

Map position X.

Definition at line 566 of file unit.h.

Referenced by AiAssignHarvester(), AiAttackWithForce(), AiCanNotBuild(), AiCheckSurrounding(), AiEnemyUnitsInDistance(), AiFindBuildingPlace(), AiFindTarget(), AiForceAttacks(), AiHelpMe(), AiMarkWaterTransporter(), AiMoveUnitInTheWay(), AiRepairBuilding(), AiTrainingComplete(), AiWorkComplete(), AttackTarget(), AttackUnitsInDistance(), AutoAttack(), CalculateStereo(), Summon::Cast(), Polymorph::Cast(), CclCreateUnit(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclMoveUnit(), CclUnit(), CheckCanBuild(), CheckForDeadGoal(), CheckForTargetInRange(), CommandAttack(), CommandFollow(), CommandPatrolUnit(), CommandRepair(), CommandSpellCast(), CostMoveTo(), DoActionMove(), CButtonPanel::DoClicked(), Draw(), DrawLevelCompare(), DrawUnitOn(), DrawUnitSelection(), DropOutNearest(), DropOutOnSide(), EditorRemoveUnit(), EnemyOnMapTile(), EvaluateMissileLocation(), FindNewResource(), FindRangeAttack(), FireMissile(), GetMapArea(), GetOrderPosition(), HandleActionAttack(), HandleActionBuilt(), HandleActionFollow(), HandleActionMove(), HandleActionPatrol(), HandleActionSpellCast(), HandleActionTrain(), HitUnit(), CUnitCache::Insert(), IsVisibleInViewport(), LeaveTransporter(), LetUnitDie(), LoadGame(), MapDistanceBetweenUnits(), MapDistanceToUnit(), MapMarkUnitSight(), MapUnmarkUnitSight(), MarkUnitFieldFlags(), MoveToLocation(), MoveToTarget(), MoveToTransporter(), NearestOfUnit(), NewPath(), NextPathElement(), PlaceReachable(), CUnitCache::Remove(), Remove(), RepairUnit(), RescueUnits(), SaveUnit(), SelectSpritesInsideRectangle(), SelectTargetUnitsOfAutoCast(), ShowOrder(), SpellCast(), SpellMoveToTarget(), StartBuilding(), StartGathering(), TargetOnMap(), UiCenterOnGroup(), UiCenterOnSelected(), UiFindIdleWorker(), UnitActions(), UnitCountSeen(), UnitFillSeenValues(), UnitFindResource(), UnitInXY(), UnitLost(), UnitOnScreen(), UnitReachable(), UnitsOnTileUnmarkSeen(), UnitToRepairInRange(), UnitVisibleOnRadar(), UnloadUnit(), UnmarkUnitFieldFlags(), and UpdateUnitVariables().

int CUnit::Y

Map position Y.

Definition at line 567 of file unit.h.

Referenced by AiAssignHarvester(), AiAttackWithForce(), AiCanNotBuild(), AiCheckSurrounding(), AiEnemyUnitsInDistance(), AiFindBuildingPlace(), AiFindTarget(), AiForceAttacks(), AiHelpMe(), AiMarkWaterTransporter(), AiMoveUnitInTheWay(), AiRepairBuilding(), AiTrainingComplete(), AiWorkComplete(), AttackTarget(), AttackUnitsInDistance(), AutoAttack(), Summon::Cast(), Polymorph::Cast(), CclCreateUnit(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclMoveUnit(), CclUnit(), CheckCanBuild(), CheckForDeadGoal(), CheckForTargetInRange(), CommandAttack(), CommandFollow(), CommandPatrolUnit(), CommandRepair(), CommandSpellCast(), CostMoveTo(), DoActionMove(), CButtonPanel::DoClicked(), Draw(), DrawLevelCompare(), DrawUnitOn(), DrawUnitSelection(), DropOutNearest(), DropOutOnSide(), EditorRemoveUnit(), EnemyOnMapTile(), EvaluateMissileLocation(), FindNewResource(), FindRangeAttack(), FireMissile(), GetMapArea(), GetOrderPosition(), HandleActionAttack(), HandleActionBuilt(), HandleActionFollow(), HandleActionMove(), HandleActionPatrol(), HandleActionSpellCast(), HandleActionTrain(), HitUnit(), CUnitCache::Insert(), IsVisibleInViewport(), LeaveTransporter(), LetUnitDie(), LoadGame(), MapDistanceBetweenUnits(), MapDistanceToUnit(), MapMarkUnitSight(), MapUnmarkUnitSight(), MarkUnitFieldFlags(), MoveToLocation(), MoveToTarget(), MoveToTransporter(), NearestOfUnit(), NewPath(), NextPathElement(), PlaceReachable(), CUnitCache::Remove(), Remove(), RepairUnit(), RescueUnits(), SaveUnit(), SelectSpritesInsideRectangle(), SelectTargetUnitsOfAutoCast(), ShowOrder(), SpellCast(), SpellMoveToTarget(), StartBuilding(), StartGathering(), TargetOnMap(), UiCenterOnGroup(), UiCenterOnSelected(), UiFindIdleWorker(), UnitActions(), UnitCountSeen(), UnitFillSeenValues(), UnitFindResource(), UnitInXY(), UnitLost(), UnitOnScreen(), UnitReachable(), UnitsOnTileUnmarkSeen(), UnitToRepairInRange(), UnitVisibleOnRadar(), UnloadUnit(), UnmarkUnitFieldFlags(), and UpdateUnitVariables().

Pointer to unit-type (peon,...).

Definition at line 569 of file unit.h.

Referenced by ActionStillGeneric(), AddSelectedAirUnitsInRectangle(), AddSelectedGroundUnitsInRectangle(), AddToGroup(), AiAssignToForce(), AiAttackWithForce(), AiAttackWithForceAt(), AiCanNotBuild(), AiCanNotMove(), AiCheckBelongsToForce(), AiCheckMagic(), AiCheckRepair(), AiCleanForce(), AiCollectResources(), AiEnemyUnitsInDistance(), AiFindBuildingPlace2(), AiFindTarget(), AiForceAttacks(), AiForceManager(), AiHelpMe(), AiMarkWaterTransporter(), AiMoveUnitInTheWay(), AiPlanAttack(), AiRepairBuilding(), AiRepairUnit(), AiSendExplorers(), AiTrainingComplete(), AiUnitKilled(), AiWorkComplete(), AnimateActionAttack(), AnimateActionHarvest(), AnimateActionRepair(), AssignToPlayer(), AttackTarget(), AttackUnitsInDistance(), AttackUnitsInRange(), AttackUnitsInReactRange(), AutoAttack(), AutoRepair(), ButtonCheckAttack(), CalculateStereo(), CanHandleOrder(), CanMove(), CanTransport(), Summon::Cast(), Capture::Cast(), Polymorph::Cast(), AreaAdjustVitals::Cast(), CclCreateUnit(), CclGetNumUnitsAt(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclKillUnit(), CclKillUnitAt(), CclOrderUnit(), CclParseBuilt(), CclUnit(), ChangeOwner(), CheckCanBuild(), CheckForTargetInRange(), ChooseUnitVoiceSound(), ClosestFreeDropZone(), CommandAttack(), CommandAttackGround(), CommandBoard(), CommandBuildBuilding(), CommandFollow(), CommandLog(), CommandRepair(), CommandResource(), CommandSpellCast(), CommandStandGround(), CostMoveTo(), DoActionMove(), DoNextReplay(), DoRepair(), DoRightButton(), Draw(), DrawConstructionShadow(), DrawDecoration(), DrawInfoPanelMultipleSelected(), DrawLevelCompare(), DrawShadow(), DrawUnitInfo(), DrawUnitOn(), DrawUnitSelection(), DrawUnitStats(), DropOutAll(), EditorRemoveUnit(), EnemyOnMapTile(), EnterTransporter(), FindIdleWorker(), FindPlayerUnitsByType(), FindRangeAttack(), FindUnitsByType(), FireMissile(), GatherResource(), GetMapArea(), GetOrderPosition(), HandleActionAttack(), HandleActionBoard(), HandleActionBuilt(), HandleActionDie(), HandleActionFollow(), HandleActionMove(), HandleActionNone(), HandleActionPatrol(), HandleActionSpellCast(), HandleActionTrain(), HandleRegenerations(), HitUnit(), Init(), InitPlayers(), CUnitCache::Insert(), IsButtonAllowed(), IsVisibleAsGoal(), IsVisibleInViewport(), IsVisibleOnMinimap(), LetUnitDie(), MapDistanceBetweenUnits(), MapDistanceToUnit(), MapFogFilterFlags(), MapMarkUnitSight(), MapUnmarkUnitSight(), MarkUnitFieldFlags(), MissileHit(), MoveToLocation(), MoveToTarget(), NearestOfUnit(), NewPath(), OnTopDetails(), ParseCommand(), PassCondition(), PlaceReachable(), CPlayer::RebuildUnitsConsumingResourcesList(), Release(), CUnitCache::Remove(), Remove(), RepairUnit(), RescueUnits(), CMap::Reveal(), SaveAiPlayer(), SaveUnit(), CUnitCache::Select(), SelectAirUnitsInRectangle(), SelectGroundUnitsInRectangle(), SelectOrganicUnitsInTable(), SelectSpritesInsideRectangle(), SelectTargetUnitsOfAutoCast(), SelectUnit(), SelectUnitsByType(), SelectUnitsInRectangle(), SendAttack(), SendAttackGround(), SendMove(), SendRepair(), SendResource(), SendSpellCast(), ShowOrder(), ShowUnitInfo(), SpellCast(), SpellMoveToTarget(), StartBuilding(), StartGathering(), TargetOnMap(), ToggleUnitsByType(), UiDrawLifeBar(), UiDrawManaBar(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UnitActions(), UnitCanBeAt(), UnitCountSeen(), UnitFillSeenValues(), UnitFindResource(), UnitGoesOutOfFog(), UnitGoesUnderFog(), UnitLost(), UnitOnScreen(), UnitReachable(), UnitRemoveConsumingResources(), UnitRotate(), UnitsOnTileUnmarkSeen(), UnitToRepairInRange(), UnitUpdateHeading(), UnitVisibleOnRadar(), UnloadUnit(), UnmarkUnitFieldFlags(), CButtonPanel::Update(), UpdateButtonPanelSingleUnit(), UpdateConstructionFrame(), UpdateForNewUnit(), and UpdateUnitVariables().

Owner of this unit.

Definition at line 570 of file unit.h.

Referenced by AddSelectedAirUnitsInRectangle(), AddSelectedGroundUnitsInRectangle(), AiAssignHarvester(), AiCanNotBuild(), AiCanNotMove(), AiCanNotReach(), AiEnemyUnitsInDistance(), AiFindBuildingPlace2(), AiHelpMe(), AiMoveUnitInTheWay(), AiNeedMoreSupply(), AiTrainingComplete(), AiUnitKilled(), AiWorkComplete(), AssignToPlayer(), AttackUnitsInDistance(), AttackUnitsInReactRange(), AutoCastSpell(), ButtonCheckUnitsAnd(), ButtonCheckUnitsOr(), CalculateCosts(), CanBuildUnitType(), Summon::Cast(), Capture::Cast(), Polymorph::Cast(), CclGetNumUnitsAt(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclKillUnitAt(), CclOrderUnit(), CclUnit(), ChangeOwner(), CheckAlreadyBuilding(), CheckCanBuild(), CheckForDeadGoal(), CommandCancelTraining(), CommandTrainUnit(), CostMoveTo(), CreateGame(), DoActionMove(), DoRepair(), DoRightButton(), CButtonPanel::Draw(), DrawConstruction(), DrawDecoration(), DrawInformations(), DrawPieMenu(), DrawTrainingUnits(), DrawTransportingUnits(), DrawUnitInfo(), DrawUnitOn(), DrawUnitSelection(), EditorRemoveUnit(), EnemyOnMapTile(), EnterTransporter(), FindRangeAttack(), GatherResource(), HandleActionBuilt(), HandleActionDie(), HandleActionFollow(), HandleActionSpellCast(), HandleActionTrain(), HitUnit(), IsAllied(), CPlayer::IsAllied(), IsBothSharedVision(), CPlayer::IsBothSharedVision(), IsButtonAllowed(), IsEnemy(), CPlayer::IsEnemy(), IsSharedVision(), CPlayer::IsSharedVision(), IsTeamed(), CPlayer::IsTeamed(), LetUnitDie(), MapMarkUnitSight(), MapMarkUnitSightRec(), MapUnmarkUnitSight(), MaxRate(), MoveToLocation(), MoveToResource(), PassCondition(), CPlayer::RebuildUnitsConsumingResourcesList(), RepairUnit(), RescueUnits(), SaveUnit(), SelectAirUnitsInRectangle(), SelectGroundUnitsInRectangle(), SelectOrganicUnitsInTable(), SelectTargetUnitsOfAutoCast(), SelectUnitsByType(), SelectUnitsInRectangle(), SendRepair(), ShowUnitInfo(), StartBuilding(), StartGathering(), TargetOnMap(), ToggleUnitsByType(), UIHandleButtonUp(), UIHandleMouseMove(), UnitActions(), UnitFindResource(), UnitLost(), UnitRemoveConsumingResources(), UnitShowAnimationScaled(), UnitToRepairInRange(), UnitVisibleOnRadar(), CButtonPanel::Update(), UpdateForNewUnit(), and WaitForTransporter().

Unit's Current Sight Range.

Definition at line 572 of file unit.h.

Referenced by CclUnit(), HandleActionBuilt(), HandleActionDie(), LetUnitDie(), MapMarkUnitSightRec(), SaveUnit(), StartBuilding(), and UpdateUnitSightRange().

Player colors.

Definition at line 575 of file unit.h.

Referenced by AssignToPlayer(), CclUnit(), and CreateGame().

signed char CUnit::IX

signed char CUnit::IY

unsigned CUnit::Direction

angle (0-255) unit looking

Definition at line 580 of file unit.h.

Referenced by CclUnit(), DoActionMove(), HandleActionBuilt(), Init(), SaveUnit(), StartBuilding(), UnitHeadingFromDeltaXY(), UnitRotate(), and UnitUpdateHeading().

unsigned long CUnit::Attacked

gamecycle unit was last attacked

Definition at line 582 of file unit.h.

Referenced by AiCheckRepair(), CclUnit(), DrawUnitOn(), HitUnit(), and SaveUnit().

unsigned CUnit::Burning

unit is burning

Definition at line 584 of file unit.h.

Referenced by MissileFire::Action(), CclUnit(), HitUnit(), and SaveUnit().

unsigned CUnit::Destroyed

unsigned CUnit::Removed

unsigned CUnit::Selected

Unit is in construction.

Definition at line 589 of file unit.h.

Referenced by CclGetNumUnitsAt(), CclUnit(), Draw(), HandleActionBuilt(), SaveUnit(), StartBuilding(), UnitFillSeenValues(), and UpdateUnitSightRange().

unsigned CUnit::Boarded

Unit is on board a transporter.

Definition at line 590 of file unit.h.

Referenced by CclUnit(), EnterTransporter(), LeaveTransporter(), SaveUnit(), UIHandleButtonDown(), and UnloadUnit().

The original owner of a rescued unit. NULL if the unit was not rescued.

Definition at line 592 of file unit.h.

Referenced by CclIfRescuedNearUnit(), CclUnit(), CreateGame(), DrawConstruction(), RescueUnits(), and SaveUnit().

int CUnit::VisCount[PlayerMax]

Unit visibility counts.

Definition at line 595 of file unit.h.

Referenced by DrawInformations(), IsVisible(), UnitCountSeen(), UnitsOnTileMarkSeen(), and UnitsOnTileUnmarkSeen().

unsigned long CUnit::TTL

time to live

Definition at line 612 of file unit.h.

Referenced by CclUnit(), HandleActionTrain(), HandleBuffs(), LetUnitDie(), and SaveUnit().

unit belongs to this group id

Definition at line 614 of file unit.h.

Referenced by AddToGroup(), CclUnit(), ClearGroup(), DrawDecoration(), RemoveUnitFromGroups(), SaveUnit(), and UnitLost().

int CUnit::ResourcesHeld[MaxCosts]

Production efficiency.

Definition at line 618 of file unit.h.

Referenced by CclUnit(), LetUnitDie(), SaveUnit(), StartBuilding(), and UpdateForNewUnit().

unsigned CUnit::SubAction

unsigned CUnit::Wait

unsigned CUnit::State

unsigned CUnit::Blink

Let selection rectangle blink.

Definition at line 623 of file unit.h.

Referenced by CclUnit(), DoRightButton(), DrawUnitSelection(), RescueUnits(), SaveUnit(), SendAttack(), SendMove(), SendResource(), UIHandleButtonDown(), and UnitActions().

unsigned CUnit::Moving

The unit is moving.

Definition at line 624 of file unit.h.

Referenced by CclUnit(), CostMoveTo(), DoActionMove(), LetUnitDie(), and SaveUnit().

unsigned CUnit::ReCast

Recast again next cycle.

Definition at line 625 of file unit.h.

Referenced by CclUnit(), HandleActionSpellCast(), SaveUnit(), and UnitShowAnimationScaled().

cancel current order, take next

Definition at line 635 of file unit.h.

Referenced by CclUnit(), HandleActionTrain(), HandleUnitAction(), ReleaseOrders(), SaveUnit(), and ShowOrder().

std::vector<COrder *> CUnit::Orders

orders to process

Definition at line 636 of file unit.h.

Referenced by MissileFire::Action(), AiBuildBuilding(), AiCanNotMove(), AiCheckRepair(), AiCleanForce(), AiEnemyUnitsInDistance(), AiForceAttacks(), AiRepairBuilding(), AiUnitKilled(), AssignToPlayer(), AttackTarget(), AutoAttack(), AutoRepair(), ButtonCheckNoWork(), CanTransport(), Summon::Cast(), Demolish::Cast(), CclParseOrders(), CclUnit(), CheckCanBuild(), CheckForDeadGoal(), CheckForTargetInRange(), CommandAttack(), CommandAttackGround(), CommandAutoRepair(), CommandAutoSpellCast(), CommandBoard(), CommandBuildBuilding(), CommandCancelTraining(), CommandDismiss(), CommandFollow(), CommandMove(), CommandMoveOrder(), CommandPatrolUnit(), CommandRepair(), CommandResource(), CommandSpellCast(), CommandTrainUnit(), CommandUnload(), DoRepair(), DoRightButton(), Draw(), DrawInformations(), DrawLevelCompare(), DrawShadow(), DrawTrainingUnits(), DrawUnitInfo(), DrawUnitSelection(), DropOutAll(), EnemyOnMapTile(), EnterTransporter(), FindIdleWorker(), FindNewResource(), FireMissile(), GatherResource(), GetNextOrder(), HandleActionAttack(), HandleActionBoard(), HandleActionDie(), HandleActionFollow(), HandleActionMove(), HandleActionPatrol(), HandleActionResource(), HandleActionSpellCast(), HandleActionTrain(), HandleActionUnload(), HandleRegenerations(), HandleUnitAction(), HitUnit(), Init(), IsAliveOnMap(), IsButtonAllowed(), IsUnusable(), IsVisibleAsGoal(), IsVisibleOnMap(), IsVisibleOnMinimap(), LeaveTransporter(), LetUnitDie(), MissileHitsGoal(), MoveToDropZone(), MoveToLocation(), MoveToResource(), MoveToTarget(), MoveToTransporter(), NewPath(), NextPathElement(), PassCondition(), CPlayer::RebuildUnitsConsumingResourcesList(), Release(), ReleaseOrders(), RemoveOrder(), RepairUnit(), ResourceGiveUp(), RestoreSavedOrder(), SaveUnit(), SelectUnitsByType(), SelectUnitsInRectangle(), ShowOrder(), SpellMoveToTarget(), StartBuilding(), StartGathering(), SwapPatrolPoints(), ToggleUnitsByType(), UnitActions(), UnitClearOrders(), UnitFillSeenValues(), UnitLost(), UnitRemoveConsumingResources(), UnitShowAnimationScaled(), UnmarkUnitFieldFlags(), UpdateButtonPanelSingleUnit(), UpdateUnitVariables(), and WaitForTransporter().

spells to auto cast

Definition at line 639 of file unit.h.

Referenced by AutoCast(), CclUnit(), CommandAutoSpellCast(), Init(), Release(), and SaveUnit().

True if unit tries to repair on still action.

Definition at line 640 of file unit.h.

Referenced by AutoRepair(), CclUnit(), CommandAutoRepair(), and SaveUnit().

Generic goal pointer.

Definition at line 666 of file unit.h.

Referenced by SpawnPortal::Cast(), CclUnit(), Init(), NextPathElement(), Release(), and SaveUnit().


The documentation for this class was generated from the following files:

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