Advanced Strategic Command
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Building Class Reference

An actual building on the map, which references a BuildingType Buildings have an owner,. More...

#include <buildings.h>

Inheritance diagram for Building:
Inheritance graph
[legend]

Public Member Functions

const BuildingTypegetType () const
 
bool getVisible ()
 
 Building (GameMap *map, const MapCoordinate &entryPosition, const BuildingType *type, int player, bool setupImages=true, bool chainToField=true)
 
bool canRepair (const ContainerBase *item) const
 checks whether the item can be repaired provided that it is in range More...
 
void write (tnstream &stream, bool includeLoadedUnits=true) const
 
void read (tnstream &stream)
 
void execnetcontrol (void)
 executes the resource net operations, like filling the tanks with fuel. More...
 
int putResource (int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)
 scope: 0 = local 1 = resource network 2 = global in all buildings 3 = map wide pool( used only internally! ) More...
 
int getResource (int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)
 
int getAvailableResource (int amount, int resourcetype, int scope=1) const
 
Resources putResource (const Resources &res, bool queryonly, int scope=1, int player=-1)
 
Resources getResource (const Resources &res, bool queryonly, int scope=1, int player=-1)
 
int getIdentification () const
 
const SurfacegetPicture (const BuildingType::LocalCoordinate &localCoordinate) const
 returns the picture of the building. It may depend on the current weather of the fields the building is standing on More...
 
void paintSingleField (Surface &s, SPoint imgpos, BuildingType::LocalCoordinate pos) const
 
virtual Surface getImage () const
 returns an image for the Container. More...
 
bool isBuilding () const
 
void convert (int player, bool recursive=true)
 changes the building's owner. More...
 
void registerForNewOwner (int player)
 this is a low level functions that changes the registration in the map. It's called by convert(int,bool) More...
 
void addview ()
 Adds the view and jamming of the building to the player's global radar field. More...
 
void resetview ()
 resets the internal view state, so that addview() can be executed again More...
 
void removeview ()
 Removes the view and jamming of the building from the player's global radar field. More...
 
bool isViewing () const
 returns true if the buildings' view is currently added to the maps global visibility. More...
 
int getArmor () const
 returns the armor of the building. More...
 
MapFieldgetEntryField () const
 returns the field the buildings entry is standing on More...
 
MapCoordinate3D getEntry () const
 returns the position of the buildings entry More...
 
MapFieldgetField (const BuildingType::LocalCoordinate &localCoordinates) const
 returns the pointer to the field which the given part of the building is standing on More...
 
MapCoordinate getFieldCoordinates (const BuildingType::LocalCoordinate &localCoordinates) const
 returns the absolute map coordinate of the given part of the building More...
 
BuildingType::LocalCoordinate getLocalCoordinate (const MapCoordinate &field) const
 converts a global coordinate into a local coordinate. More...
 
MapCoordinate3D getPosition () const
 returns the position of the buildings entry More...
 
MapCoordinate3D getPosition3D () const
 returns the position of the buildings entry More...
 
int chainbuildingtofield (const MapCoordinate &entryPos, bool setupImages=true)
 registers the building at the given position on the map More...
 
int unchainbuildingfromfield (void)
 unregister the building from the map position More...
 
int getCompletion () const
 returns the completion of the building. More...
 
void setCompletion (int completion, bool setupImages=true)
 Sets the level of completion of the building. More...
 
void endRound (void)
 hook that is called when a turn ends More...
 
ASCString getName () const
 returns a name for the building. If the building itself has a name, it will be returned. If it doesn't, the name of the building type will be returned. More...
 
int getAmmo (int type, int num, bool queryOnly)
 
int getAmmo (int type, int num) const
 
int putAmmo (int type, int num, bool queryOnly)
 
int maxAmmo (int type) const
 
int getHeight () const
 returns the bitmapped level of height. Only one bit will be set, of course More...
 
 ~Building ()
 
virtual int repairableDamage () const
 returns the amount of damage that can still be repaired this turn More...
 
int getMemoryFootprint () const
 
- Public Member Functions inherited from ContainerBase
const ProductiongetProduction () const
 
Resources getProductionCost (const VehicleType *unit) const
 
void deleteProductionLine (const VehicleType *type)
 
void deleteAllProductionLines ()
 
void addProductionLine (const VehicleType *type)
 
bool hasProductionLine (const VehicleType *type)
 
void setProductionLines (const Production &production)
 
int getOwner () const
 returns the number of the player this vehicle/building belongs to More...
 
PlayergetOwningPlayer () const
 returns the player this vehicle/building belongs to More...
 
GameMapgetMap () const
 
ASCString getPrivateName () const
 
virtual void setName (const ASCString &name)
 
virtual void endOwnTurn (void)
 hook that is called when a player ends his turn More...
 
virtual void endAnyTurn (void)
 hook that is called when any player (including owner) ends turn More...
 
WorkspawnWorkClasses (bool justQuery)
 
virtual ~ContainerBase ()
 
int getMaxRepair (const ContainerBase *item) const
 returns the maximum amount of damage that the given item can be repaired More...
 
int getMaxRepair (const ContainerBase *item, int newDamage, Resources &cost, bool ignoreCost=false) const
 
int repairItem (ContainerBase *item, int newDamage=0, bool autoRepair=false)
 
const CargogetCargo () const
 
int getCargoCount () const
 
VehiclegetCargo (int i)
 returns the cargo slot with index i Warning: the cargo may contain NULL items. More...
 
void clearCargo ()
 removes ALL units from cargo More...
 
void addToCargo (Vehicle *veh, int position=-1)
 adds the unit to the cargo More...
 
void moveToCargo (Vehicle *veh)
 adds the unit to the cargo, and removes its from its current position More...
 
bool removeUnitFromCargo (Vehicle *veh, bool recursive=false)
 removes the given unit from the container. More...
 
bool removeUnitFromCargo (int nwid, bool recursive=false)
 
int vehiclesLoaded (void) const
 returns the number of loaded units More...
 
ContainerBasegetCarrier () const
 if this is a unit and it is inside a building or transport, returns the transport. NULL otherwise. More...
 
VehiclefindUnit (int nwid, bool recursive=true) const
 searches for a the unit in carrier and optionally all inner carriers More...
 
bool vehicleLoadable (const Vehicle *vehicle, int uheight=-1, const bool *attacked=NULL) const
 can the vehicle be loaded. More...
 
int vehicleUnloadable (const VehicleType *vehicleType, int carrierHeight=-1) const
 checks the unloading of a unit type More...
 
const
ContainerBaseType::TransportationIO
vehicleUnloadSystem (const VehicleType *vehicle, int height)
 returns the unloading system More...
 
int vehicleDocking (const Vehicle *vehicle, bool out) const
 returns the levels of height on which this unit can be transfered by docking; or 0 if no unloading is possible More...
 
bool doesVehicleFit (const Vehicle *vehicle) const
 Does the vehicle fit into the container? This does not include checking if it can reach the entry. More...
 
int cargoWeight () const
 weight of all loaded units More...
 
int cargoNestingDepth ()
 returns the nesting depth of the cargo. The unit standing on the field is 0, its cargo is 1, the cargo's cargo 2 ... More...
 
Resources putResource (const Resources &res, bool queryonly, int scope=1, int player=-1)
 
Resources getResource (const Resources &res, bool queryonly, int scope=1, int player=-1)
 
Resources getResource (const Resources &res) const
 
Resources getResourceUsage ()
 returns the resource that the building consumes for its operation. More...
 
Resources getResourcePlus ()
 
Resources getStorageCapacity () const
 returns the local storage capacity for the given resource, which depends on the resource mode of the map. More...
 
Resources netResourcePlus () const
 returns the amount of resources that the net which the building is connected to produces each turn More...
 
void setInternalResourcePlus (const Resources &res)
 The ResourcePlus is used for different purposes by different building or vehicle functions, or not at all. More...
 
void setInternalResourceMaxPlus (const Resources &res)
 The ResourceMaxPlus is used for different purposes by different building or vehicle functions, or not at all. More...
 
Resources getInternalResourcePlus () const
 The ResourcePlus is used for different purposes by different building or vehicle functions, or not at all. More...
 
Resources getInternalResourceMaxPlus () const
 The ResourceMaxPlus is used for different purposes by different building or vehicle functions, or not at all. More...
 

Static Public Member Functions

static BuildingnewFromStream (GameMap *gamemap, tnstream &stream, bool chainToField=true)
 
- Static Public Member Functions inherited from ContainerBase
static int calcShadowDist (int binaryHeight)
 
static bool registerWorkClassFactory (WorkClassFactory *wcf, bool ASCmode=true)
 

Public Attributes

const BuildingTypetyp
 
int ammo [waffenanzahl]
 the ammo that is stored in the building More...
 
int netcontrol
 a bitmapped variable containing the status of the resource-net connection. More...
 
int connection
 bitmapped: are there events that are triggered by actions affecting this building More...
 
bool visible
 is the building visible? Building can be made invisible, but this feature should be used only in some very special cases More...
 
AiValueaiparam [8]
 
int lastmineddist
 
Resources actstorage
 the current storage of Resources More...
 
- Public Attributes inherited from ContainerBase
const ContainerBaseTypebaseType
 the type descriping all non-instance specific properties of the container More...
 
int damage
 Damage. 0 is no damage, when damage reaches 100 the container is destroyed. More...
 
int color
 The owner of the container. More...
 
sigc::signal< void > conquered
 
sigc::signal< void > destroyed
 
int researchpoints
 the current amount of research that the building conducts every turn More...
 
int maxresearchpoints
 
int view
 
sigc::signal< void > cargoChanged
 
ASCString name
 a name given by the user or the map creator More...
 
ASCString privateName
 a name given by the user which is only visible to him and his allies. More...
 
Resources plus
 the Resources that are produced each turn More...
 
Resources maxplus
 the maximum amount of Resources that the building can produce each turn in the ASC resource mode ; see also bi_resourceplus More...
 
Resources bi_resourceplus
 the maximum amount of Resources that the building can produce each turn in the BI resource mode ; see also maxplus More...
 

Protected Member Functions

const ResourceMatrixgetRepairEfficiency () const
 when a ContainerBase is repair by this ContainerBase, the default cost can be customized with this matrix. More...
 
virtual void postRepair (int oldDamage, bool autoRepair)
 is called after a repair is performed. Vehicles use this to reduce their experience. More...
 
vector< MapCoordinategetCoveredFields ()
 
- Protected Member Functions inherited from ContainerBase
void paintField (const Surface &src, Surface &dest, SPoint pos, int dir, bool shaded, int shadowDist=-1) const
 displays an image of this container on the surface. More...
 
 ContainerBase (const ContainerBaseType *bt, GameMap *map, int player)
 

Protected Attributes

ResourceMatrix repairEfficiency
 
- Protected Attributes inherited from ContainerBase
int repairedThisTurn
 the percantage that this container has already been repaired this turn. More...
 
GameMapgamemap
 the map that this container is placed on More...
 
ContainerBasecargoParent
 if this container is transported inside a carrier, this is carrier More...
 
Production internalUnitProduction
 
Cargo cargo
 

Friends

class tprocessminingfields
 

Additional Inherited Members

- Public Types inherited from ContainerBase
typedef vector< const
VehicleType * > 
Production
 
typedef vector< Vehicle * > Cargo
 
- Static Public Attributes inherited from ContainerBase
static sigc::signal< void,
ContainerBase * > 
anyContainerDestroyed
 
static sigc::signal< void,
ContainerBase * > 
anyContainerConquered
 

Detailed Description

An actual building on the map, which references a BuildingType Buildings have an owner,.

Unlike a Vehicle, a Building can not move, can not shoot and may cover several fields on the map

Definition at line 38 of file buildings.h.

Constructor & Destructor Documentation

Building::Building ( GameMap map,
const MapCoordinate entryPosition,
const BuildingType type,
int  player,
bool  setupImages = true,
bool  chainToField = true 
)
Building::~Building ( )

Member Function Documentation

void Building::addview ( void  )
virtual

Adds the view and jamming of the building to the player's global radar field.

Implements ContainerBase.

Definition at line 353 of file buildings.cpp.

References fatalError(), ContainerBase::gamemap, tcomputebuildingview::init(), and SearchFields::startsearch().

Referenced by convert(), Reinforcements::execute(), registerForNewOwner(), and DestructContainer::undoAction().

bool Building::canRepair ( const ContainerBase item) const
virtual

checks whether the item can be repaired provided that it is in range

Implements ContainerBase.

Definition at line 93 of file buildings.cpp.

References ContainerBaseType::ExternalRepair, ContainerBaseType::hasFunction(), ContainerBaseType::InternalUnitRepair, and typ.

int Building::chainbuildingtofield ( const MapCoordinate entryPos,
bool  setupImages = true 
)
void Building::convert ( int  player,
bool  recursive = true 
)
void Building::endRound ( void  )
virtual

hook that is called when a turn ends

Reimplemented from ContainerBase.

Definition at line 750 of file buildings.cpp.

References ContainerBase::endRound(), and ContainerBase::repairedThisTurn.

void Building::execnetcontrol ( void  )
int Building::getAmmo ( int  type,
int  num,
bool  queryOnly 
)
virtual

Implements ContainerBase.

Definition at line 719 of file buildings.cpp.

References ammo, and min().

int Building::getAmmo ( int  type,
int  num 
) const
virtual

Implements ContainerBase.

Definition at line 730 of file buildings.cpp.

References ammo, and min().

int Building::getArmor ( ) const
virtual

returns the armor of the building.

See Also
BuildingType::_armor

Implements ContainerBase.

Definition at line 393 of file buildings.cpp.

References BuildingType::_armor, cgp_buildingarmor, ContainerBase::gamemap, GameMap::getgameparameter(), and typ.

Referenced by tunitattacksbuilding::setup(), and DashboardPanel::showUnitData().

int Building::getAvailableResource ( int  amount,
int  resourcetype,
int  scope = 1 
) const
virtual
int Building::getCompletion ( ) const
inline
vector< MapCoordinate > Building::getCoveredFields ( )
protectedvirtual

Implements ContainerBase.

Definition at line 757 of file buildings.cpp.

References BuildingType::fieldExists(), getFieldCoordinates(), and typ.

MapCoordinate3D Building::getEntry ( ) const
MapField * Building::getEntryField ( ) const

returns the field the buildings entry is standing on

Definition at line 405 of file buildings.cpp.

References BuildingType::entry, getField(), and typ.

Referenced by SearchReconquerBuilding::canUnitCapture(), copyFieldStep2(), and MapNetwork::searchbuilding().

MapField * Building::getField ( const BuildingType::LocalCoordinate localCoordinates) const
MapCoordinate Building::getFieldCoordinates ( const BuildingType::LocalCoordinate localCoordinates) const

returns the absolute map coordinate of the given part of the building

Definition at line 417 of file buildings.cpp.

References BuildingType::getFieldCoordinate(), and typ.

Referenced by chainbuildingtofield(), getCoveredFields(), getField(), DestructContainer::runAction(), and MapNetwork::searchbuilding().

int Building::getHeight ( ) const
inlinevirtual

returns the bitmapped level of height. Only one bit will be set, of course

Implements ContainerBase.

Definition at line 187 of file buildings.h.

References ContainerBaseType::height, and typ.

Referenced by paintSingleField().

int Building::getIdentification ( ) const
virtual

Implements ContainerBase.

Definition at line 100 of file buildings.cpp.

References getPosition(), MapCoordinate::x, and MapCoordinate::y.

Referenced by compareMapResources().

Surface Building::getImage ( ) const
virtual

returns an image for the Container.

Note
Buildings have a size of several fields. The image returned here is therefore not suited to be painted on the map, as map-painting is done on a per-field basis

Implements ContainerBase.

Definition at line 229 of file buildings.cpp.

References ASC_max(), ASC_min(), Surface::createSurface(), fielddisthalfx, fielddistx, fielddisty, BuildingType::fieldExists(), fieldsizex, fieldsizey, ContainerBase::getOwningPlayer(), maxint, BuildingType::paint(), Surface::transparent, and typ.

BuildingType::LocalCoordinate Building::getLocalCoordinate ( const MapCoordinate field) const

converts a global coordinate into a local coordinate.

Definition at line 423 of file buildings.cpp.

References BuildingType::getLocalCoordinate(), and typ.

Referenced by chainbuildingtofield(), and MapRenderer::paintSingleField().

int Building::getMemoryFootprint ( ) const

Definition at line 768 of file buildings.cpp.

ASCString Building::getName ( ) const
virtual

returns a name for the building. If the building itself has a name, it will be returned. If it doesn't, the name of the building type will be returned.

Implements ContainerBase.

Definition at line 711 of file buildings.cpp.

References ContainerBaseType::name, ContainerBase::name, and typ.

Referenced by getBuildingReference(), and BuildingPositionTrigger::getName().

const Surface & Building::getPicture ( const BuildingType::LocalCoordinate localCoordinate) const

returns the picture of the building. It may depend on the current weather of the fields the building is standing on

Definition at line 188 of file buildings.cpp.

References getField(), BuildingType::getPicture(), MapField::getWeather(), and typ.

Referenced by paintSingleField().

MapCoordinate3D Building::getPosition ( void  ) const
inlinevirtual

returns the position of the buildings entry

Implements ContainerBase.

Definition at line 152 of file buildings.h.

References getEntry().

Referenced by compareMapResources(), Reinforcements::execute(), getBuildingReference(), getIdentification(), and SpawnBuilding::runAction().

MapCoordinate3D Building::getPosition3D ( ) const

returns the position of the buildings entry

Definition at line 385 of file buildings.cpp.

References getEntry(), MapCoordinate3D::setnum(), MapCoordinate::x, and MapCoordinate::y.

const ResourceMatrix& Building::getRepairEfficiency ( ) const
inlineprotectedvirtual

when a ContainerBase is repair by this ContainerBase, the default cost can be customized with this matrix.

Note
This effects both reparing another ContainerBase as well as self-repsir

Implements ContainerBase.

Definition at line 198 of file buildings.h.

References repairEfficiency.

int Building::getResource ( int  amount,
int  resourcetype,
bool  queryonly,
int  scope = 1,
int  player = -1 
)
virtual
Resources Building::getResource ( const Resources res,
bool  queryonly,
int  scope = 1,
int  player = -1 
)
inline

Definition at line 91 of file buildings.h.

References ContainerBase::getResource().

const BuildingType* Building::getType ( ) const
inline

Definition at line 50 of file buildings.h.

References typ.

bool Building::getVisible ( )
inline

Definition at line 65 of file buildings.h.

References visible.

bool Building::isBuilding ( ) const
inlinevirtual

Implements ContainerBase.

Definition at line 108 of file buildings.h.

bool Building::isViewing ( ) const
inline

returns true if the buildings' view is currently added to the maps global visibility.

See Also
viewcalculation.cpp

Definition at line 129 of file buildings.h.

Referenced by DestructContainer::runAction().

int Building::maxAmmo ( int  type) const
inlinevirtual

Implements ContainerBase.

Definition at line 183 of file buildings.h.

References maxint.

Building * Building::newFromStream ( GameMap gamemap,
tnstream stream,
bool  chainToField = true 
)
static
void Building::paintSingleField ( Surface s,
SPoint  imgpos,
BuildingType::LocalCoordinate  pos 
) const
void Building::postRepair ( int  oldDamage,
bool  autoRepair 
)
protectedvirtual

is called after a repair is performed. Vehicles use this to reduce their experience.

Implements ContainerBase.

Definition at line 88 of file buildings.cpp.

References ContainerBase::damage, and ContainerBase::repairedThisTurn.

int Building::putAmmo ( int  type,
int  num,
bool  queryOnly 
)
virtual

Implements ContainerBase.

Definition at line 737 of file buildings.cpp.

References ammo.

Referenced by trunreplay::execnextreplaymove().

int Building::putResource ( int  amount,
int  resourcetype,
bool  queryonly,
int  scope = 1,
int  player = -1 
)
virtual

scope: 0 = local 1 = resource network 2 = global in all buildings 3 = map wide pool( used only internally! )

Implements ContainerBase.

Definition at line 226 of file controls.cpp.

References ContainerBase::getMap(), getResource(), StaticResourceNet::getresource(), MapCoordinate::x, and MapCoordinate::y.

Referenced by convert(), execnetcontrol(), AddResources::execute(), and getResource().

Resources Building::putResource ( const Resources res,
bool  queryonly,
int  scope = 1,
int  player = -1 
)
inline

Definition at line 90 of file buildings.h.

References ContainerBase::putResource().

void Building::read ( tnstream stream)
virtual
void Building::registerForNewOwner ( int  player)
virtual

this is a low level functions that changes the registration in the map. It's called by convert(int,bool)

Implements ContainerBase.

Definition at line 162 of file buildings.cpp.

References addview(), ContainerBase::anyContainerConquered, Player::buildingList, ContainerBase::color, ContainerBase::conquered, ContainerBase::gamemap, ContainerBase::getOwner(), GameMap::player, and removeview().

void Building::removeview ( void  )
virtual

Removes the view and jamming of the building from the player's global radar field.

Implements ContainerBase.

Definition at line 371 of file buildings.cpp.

References ContainerBase::color, fatalError(), ContainerBase::gamemap, tcomputebuildingview::init(), and SearchFields::startsearch().

Referenced by convert(), registerForNewOwner(), and DestructContainer::runAction().

int Building::repairableDamage ( ) const
virtual

returns the amount of damage that can still be repaired this turn

Implements ContainerBase.

Definition at line 78 of file buildings.cpp.

References cgp_maxbuildingrepair, ContainerBase::damage, GameMap::getgameparameter(), ContainerBase::getMap(), and ContainerBase::repairedThisTurn.

Referenced by RepairBuildingCommand::avail().

void Building::resetview ( )

resets the internal view state, so that addview() can be executed again

Definition at line 365 of file buildings.cpp.

void Building::setCompletion ( int  completion,
bool  setupImages = true 
)

Sets the level of completion of the building.

Parameters
completionrange: 0 .. typ->construction_steps-1 . If completion == typ->construction_steps-1 the building is completed and working.
setupImagesAre the building image pointer of the fields the building is standing on updated?
See Also
Buildingtype::construction_steps

Definition at line 259 of file buildings.cpp.

Referenced by putbuilding(), SpawnBuilding::runAction(), and SpawnBuilding::undoAction().

int Building::unchainbuildingfromfield ( void  )

unregister the building from the map position

Definition at line 332 of file buildings.cpp.

References MapField::bdt, MapField::building, cbbuildingentry, BuildingType::fieldExists(), getField(), getTerrainBitType(), and typ.

Referenced by movebuilding(), DestructContainer::runAction(), transformMap(), and ~Building().

void Building::write ( tnstream stream,
bool  includeLoadedUnits = true 
) const
virtual

Friends And Related Function Documentation

friend class tprocessminingfields
friend

Definition at line 43 of file buildings.h.

Member Data Documentation

Resources Building::actstorage
AiValue* Building::aiparam[8]

Definition at line 65 of file buildings.h.

Referenced by Building(), SearchReconquerBuilding::unitfound(), and ~Building().

int Building::ammo[waffenanzahl]

the ammo that is stored in the building

Definition at line 50 of file buildings.h.

Referenced by Building(), copyBuildingData(), trunreplay::execnextreplaymove(), getAmmo(), BuildingValues::init(), putAmmo(), and write().

int Building::connection

bitmapped: are there events that are triggered by actions affecting this building

Definition at line 60 of file buildings.h.

Referenced by BuildingSeen::arm(), Building(), evaluatevisibilityfield(), and SpawnBuilding::runAction().

int Building::lastmineddist

Definition at line 72 of file buildings.h.

Referenced by Building(), and copyBuildingData().

int Building::netcontrol
ResourceMatrix Building::repairEfficiency
protected

Definition at line 197 of file buildings.h.

Referenced by getRepairEfficiency().

const BuildingType* Building::typ
bool Building::visible

is the building visible? Building can be made invisible, but this feature should be used only in some very special cases

Definition at line 63 of file buildings.h.

Referenced by Building(), chainbuildingtofield(), copyBuildingData(), getVisible(), BuildingValues::init(), MapRenderer::paintSingleField(), SpawnBuilding::runAction(), and write().


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