Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Building Class Reference

An actual building on the map, which references a BuildingType. More...

#include <buildings.h>

Inheritance diagram for Building:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Building (GameMap *map, const MapCoordinate &entryPosition, const BuildingType *type, int player, bool setupImages=true, bool chainToField=true)
bool canRepair (const ContainerBase *item) const
void write (tnstream &stream, bool includeLoadedUnits=true)
void read (tnstream &stream)
void execnetcontrol (void)
 executes the resource net operations, like filling the tanks with fuel.
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! )
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 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
void paintSingleField (Surface &s, SPoint imgpos, BuildingType::LocalCoordinate pos) const
virtual Surface getImage () const
bool isBuilding () const
void convert (int player)
 changes the building's owner.
void addview ()
 Adds the view and jamming of the building to the player's global radar field.
void removeview ()
 Removes the view and jamming of the building from the player's global radar field.
int getArmor () const
 returns the armor of the building.
tfieldgetEntryField () const
 returns the field the buildings entry is standing on
MapCoordinate3D getEntry () const
 returns the position of the buildings entry
tfieldgetField (const BuildingType::LocalCoordinate &localCoordinates) const
 returns the pointer to the field which the given part of the building is standing on
MapCoordinate getFieldCoordinates (const BuildingType::LocalCoordinate &localCoordinates) const
 returns the absolute map coordinate of the given part of the building
BuildingType::LocalCoordinate getLocalCoordinate (const MapCoordinate &field) const
 converts a global coordinate into a local coordinate.
MapCoordinate3D getPosition () const
 returns the position of the buildings entry
MapCoordinate3D getPosition3D () const
 returns the position of the buildings entry
int chainbuildingtofield (const MapCoordinate &entryPos, bool setupImages=true)
 registers the building at the given position on the map
int unchainbuildingfromfield (void)
 unregister the building from the map position
int getCompletion () const
 returns the completion of the building.
void setCompletion (int completion, bool setupImages=true)
 Sets the level of completion of the building.
void endRound (void)
 hook that is called when a turn ends
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.
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
 ~Building ()
virtual int repairableDamage ()
 returns the amount of damate that can still be repaired this turn
int getMemoryFootprint () const

Static Public Member Functions

static BuildingnewFromStream (GameMap *gamemap, tnstream &stream, bool chainToField=true)

Public Attributes

const BuildingTypetyp
int ammo [waffenanzahl]
 the ammo that is stored in the building
ASCString name
 the building's name
int netcontrol
 a bitmapped variable containing the status of the resource-net connection.
int connection
 bitmapped: are there events that are triggered by actions affecting this building
bool visible
 is the building visible? Building can be made invisible, but this feature should be used only in some very special cases
AiValueaiparam [8]
int lastmineddist
Resources actstorage
 the current storage of Resources

Protected Member Functions

const ResourceMatrixgetRepairEfficiency (void)
virtual void postRepair (int oldDamage)
 is called after a repair is perfored. Vehicles use this to reduce their experience.
vector< MapCoordinategetCoveredFields ()

Protected Attributes

int repairedThisTurn
 the percantage that this build has already been repaired this turn. The maximum percentage may be limited by a gameparameter
ResourceMatrix repairEfficiency

Friends

class tprocessminingfields

Detailed Description

An actual building on the map, which references a BuildingType.

Definition at line 34 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
 

Definition at line 45 of file buildings.cpp.

References aiparam, ammo, Player::buildingList, chainbuildingtofield(), connection, ContainerBase::damage, ContainerBaseType::defaultProduction, ContainerBase::gamemap, lastmineddist, netcontrol, GameMap::player, ContainerBase::plus, repairedThisTurn, typ, visible, and waffenanzahl.

Referenced by newFromStream().

Building::~Building  ) 
 

Definition at line 416 of file buildings.cpp.

References Player::buildingList, ContainerBase::color, ContainerBase::gamemap, GameMap::player, and unchainbuildingfromfield().


Member Function Documentation

void Building::addview  )  [virtual]
 

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

Implements ContainerBase.

Definition at line 332 of file buildings.cpp.

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

Referenced by convert(), and Reinforcements::execute().

bool Building::canRepair const ContainerBase item  )  const [virtual]
 

Implements ContainerBase.

Definition at line 91 of file buildings.cpp.

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

Referenced by VehicleService::FieldSearch::checkBuilding2Vehicle().

int Building::chainbuildingtofield const MapCoordinate entryPos,
bool  setupImages = true
 

registers the building at the given position on the map

Definition at line 238 of file buildings.cpp.

References tfield::bdt, tfield::building, GameMap::calculateAllObjects(), ContainerBase::cargo, cbbuildingentry, BuildingType::entry, BuildingType::fieldExists(), ContainerBase::gamemap, getField(), getFieldCoordinates(), getLocalCoordinate(), getTerrainBitType(), tfield::objects, typ, tfield::vehicle, warning(), BuildingType::LocalCoordinate::x, MapCoordinate::x, BuildingType::LocalCoordinate::y, and MapCoordinate::y.

Referenced by Building(), Reinforcements::execute(), movebuilding(), ClipBoardBase::place(), and transformMap().

void Building::convert int  player  )  [virtual]
 

changes the building's owner.

Parameters:
player range: 0 .. 8

Implements ContainerBase.

Definition at line 103 of file buildings.cpp.

References actstorage, addview(), ContainerBase::anyContainerConquered, GameMap::bi_resource, Player::buildingList, ContainerBase::cargo, cnet_stopenergyinput, ContainerBase::color, ContainerBase::conquered, fatalError(), ContainerBase::gamemap, ContainerBase::getOwner(), ContainerBaseType::hasFunction(), GameMap::isResourceGlobal(), netcontrol, GameMap::player, putResource(), removeview(), Resources::resource(), ContainerBaseType::SelfDestructOnConquer, and typ.

Referenced by trunreplay::execnextreplaymove(), ChangeBuildingOwner::execute(), BaseVehicleMovement::moveunitxy(), and tgiveunitawaydlg::run().

void Building::endRound void   )  [virtual]
 

hook that is called when a turn ends

Reimplemented from ContainerBase.

Definition at line 736 of file buildings.cpp.

References ContainerBase::endRound(), and repairedThisTurn.

void Building::execnetcontrol void   ) 
 

executes the resource net operations, like filling the tanks with fuel.

See also:
netcontrol

Definition at line 541 of file controls.cpp.

References actmap, actstorage, cnet_moveenergyout, cnet_stopenergyinput, cnet_stopenergyoutput, cnet_storeenergy, getResource(), ContainerBase::getStorageCapacity(), GameMap::isResourceGlobal(), netcontrol, npop, npush, putResource(), and Resources::resource().

int Building::getAmmo int  type,
int  num
const [virtual]
 

Implements ContainerBase.

Definition at line 716 of file buildings.cpp.

References ammo, assert, min(), and waffenanzahl.

int Building::getAmmo int  type,
int  num,
bool  queryOnly
[virtual]
 

Implements ContainerBase.

Definition at line 705 of file buildings.cpp.

References ammo, assert, min(), and waffenanzahl.

int Building::getArmor  )  const [virtual]
 

returns the armor of the building.

See also:
BuildingType::_armor

Implements ContainerBase.

Definition at line 356 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]
 

Implements ContainerBase.

Definition at line 607 of file controls.cpp.

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

Referenced by DashboardPanel::showUnitData().

int Building::getCompletion  )  const [inline]
 

returns the completion of the building.

See also:
setCompletion(int,bool)

Definition at line 148 of file buildings.h.

Referenced by destructbuildinglevel2(), trunreplay::execnextreplaymove(), tcomputebuildingview::init(), putbuilding2(), and write().

vector< MapCoordinate > Building::getCoveredFields  )  [protected, virtual]
 

Implements ContainerBase.

Definition at line 743 of file buildings.cpp.

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

MapCoordinate3D Building::getEntry  )  const
 

returns the position of the buildings entry

Definition at line 373 of file buildings.cpp.

References BuildingType::buildingheight, and typ.

Referenced by PutResource::checkbuilding(), VehicleService::FieldSearch::checkBuilding2Vehicle(), VehicleService::execute(), getPosition(), getPosition3D(), tcomputebuildingview::init(), VehicleService::FieldSearch::init(), movebuilding(), PutTribute::puttribute(), transformMap(), and write().

tfield * Building::getEntryField  )  const
 

returns the field the buildings entry is standing on

Definition at line 368 of file buildings.cpp.

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

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

tfield * Building::getField const BuildingType::LocalCoordinate localCoordinates  )  const
 

returns the pointer to the field which the given part of the building is standing on

Definition at line 362 of file buildings.cpp.

References ContainerBase::gamemap, GameMap::getField(), and getFieldCoordinates().

Referenced by chainbuildingtofield(), getEntryField(), getPicture(), BuildingSeen::getState(), tcomputebuildingview::init(), tfield::setparams(), and unchainbuildingfromfield().

MapCoordinate Building::getFieldCoordinates const BuildingType::LocalCoordinate localCoordinates  )  const
 

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

Definition at line 380 of file buildings.cpp.

References BuildingType::getFieldCoordinate(), and typ.

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

int Building::getHeight  )  const [inline, virtual]
 

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

Implements ContainerBase.

Definition at line 170 of file buildings.h.

References BuildingType::buildingheight, and typ.

Referenced by paintSingleField().

int Building::getIdentification  )  [virtual]
 

Implements ContainerBase.

Definition at line 98 of file buildings.cpp.

References getPosition().

Referenced by compareMapResources().

Surface Building::getImage  )  const [virtual]
 

Implements ContainerBase.

Definition at line 199 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 386 of file buildings.cpp.

References BuildingType::getLocalCoordinate(), and typ.

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

int Building::getMemoryFootprint  )  const
 

Definition at line 754 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 697 of file buildings.cpp.

References ContainerBaseType::name, name, and typ.

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 158 of file buildings.cpp.

References getField(), BuildingType::getPicture(), tfield::getweather(), and typ.

Referenced by paintSingleField().

MapCoordinate3D Building::getPosition void   )  const [inline, virtual]
 

returns the position of the buildings entry

Implements ContainerBase.

Definition at line 136 of file buildings.h.

References getEntry().

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

MapCoordinate3D Building::getPosition3D  )  const
 

returns the position of the buildings entry

Definition at line 348 of file buildings.cpp.

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

const ResourceMatrix& Building::getRepairEfficiency void   )  [inline, protected, virtual]
 

Implements ContainerBase.

Definition at line 181 of file buildings.h.

References repairEfficiency.

Resources Building::getResource const Resources res,
bool  queryonly,
int  scope = 1,
int  player = -1
[inline]
 

Reimplemented from ContainerBase.

Definition at line 87 of file buildings.h.

References ContainerBase::getResource().

int Building::getResource int  amount,
int  resourcetype,
bool  queryonly,
int  scope = 1,
int  player = -1
[virtual]
 

Implements ContainerBase.

Definition at line 590 of file controls.cpp.

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

Referenced by compareMapResources(), doresearch(), execnetcontrol(), trunreplay::execnextreplaymove(), VehicleService::execute(), putResource(), VehicleService::FieldSearch::run(), and PutTribute::start().

bool Building::isBuilding  )  const [inline, virtual]
 

Implements ContainerBase.

Definition at line 104 of file buildings.h.

int Building::maxAmmo int  type  )  const [inline, virtual]
 

Implements ContainerBase.

Definition at line 166 of file buildings.h.

References maxint.

Building * Building::newFromStream GameMap gamemap,
tnstream stream,
bool  chainToField = true
[static]
 

Definition at line 519 of file buildings.cpp.

References ContainerBase::bi_resourceplus, Building(), ContainerBase::color, GameMap::getbuildingtype_byid(), tnstream::getDeviceName(), tnstream::readChar(), readData(), tnstream::readInt(), tnstream::readWord(), Resources::resource(), and typ.

Referenced by Reinforcements::execute(), ClipBoardBase::place(), and tspfldloaders::readfields().

void Building::paintSingleField Surface s,
SPoint  imgpos,
BuildingType::LocalCoordinate  pos
const
 

Definition at line 168 of file buildings.cpp.

References chfahrend, getHeight(), getPicture(), and ContainerBase::paintField().

Referenced by MapRenderer::paintSingleField().

void Building::postRepair int  oldDamage  )  [protected, virtual]
 

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

Implements ContainerBase.

Definition at line 86 of file buildings.cpp.

References ContainerBase::damage, and repairedThisTurn.

int Building::putAmmo int  type,
int  num,
bool  queryOnly
[virtual]
 

Implements ContainerBase.

Definition at line 723 of file buildings.cpp.

References ammo, assert, and waffenanzahl.

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

Reimplemented from ContainerBase.

Definition at line 86 of file buildings.h.

References ContainerBase::putResource().

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 573 of file controls.cpp.

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

Referenced by convert(), destructbuildinglevel2(), execnetcontrol(), trunreplay::execnextreplaymove(), AddResources::execute(), getResource(), and VehicleService::FieldSearch::run().

void Building::read tnstream stream  )  [virtual]
 

Implements ContainerBase.

Definition at line 563 of file buildings.cpp.

References ContainerBase::bi_resourceplus, and Resources::resource().

void Building::removeview  )  [virtual]
 

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

Implements ContainerBase.

Definition at line 339 of file buildings.cpp.

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

Referenced by convert().

int Building::repairableDamage  )  [virtual]
 

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

Implements ContainerBase.

Definition at line 76 of file buildings.cpp.

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

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

Sets the level of completion of the building.

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

Definition at line 229 of file buildings.cpp.

Referenced by destructbuildinglevel2(), trunreplay::execnextreplaymove(), putbuilding(), and putbuilding2().

int Building::unchainbuildingfromfield void   ) 
 

unregister the building from the map position

Definition at line 300 of file buildings.cpp.

References actmap, tfield::addobject(), tfield::bdt, tfield::building, cbbuildingentry, GameMap::Destruction, BuildingType::destructionObjects, BuildingType::fieldExists(), ContainerBase::gamemap, getField(), GameMap::getobjecttype_byid(), getTerrainBitType(), GameMap::state, and typ.

Referenced by movebuilding(), transformMap(), and ~Building().

void Building::write tnstream stream,
bool  includeLoadedUnits = true
[virtual]
 

Implements ContainerBase.

Definition at line 449 of file buildings.cpp.

References actstorage, ammo, assert, ContainerBase::bi_resourceplus, BUILDINGVERSIONLIMIT, ContainerBase::cargo, ContainerBase::color, ContainerBase::damage, getCompletion(), getEntry(), ContainerBaseType::id, ContainerBase::internalUnitProduction, max(), ContainerBase::maxplus, ContainerBase::maxresearchpoints, name, netcontrol, ContainerBase::plus, repairedThisTurn, ContainerBase::researchpoints, Resources::resource(), typ, visible, waffenanzahl, tnstream::writeChar(), tnstream::writeInt(), tnstream::writeString(), and tnstream::writeWord().

Referenced by ReinforcementSelector::mark(), and tspfldloaders::writefields().


Friends And Related Function Documentation

friend class tprocessminingfields [friend]
 

Definition at line 39 of file buildings.h.


Member Data Documentation

Resources Building::actstorage
 

the current storage of Resources

Definition at line 87 of file buildings.h.

Referenced by PutTribute::checkbuilding(), PutResource::checkbuilding(), convert(), copyBuildingData(), destructbuildinglevel2(), execnetcontrol(), trunreplay::execnextreplaymove(), BuildingValues::init(), putbuilding2(), and write().

AiValue* Building::aiparam[8]
 

Definition at line 64 of file buildings.h.

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

int Building::ammo[waffenanzahl]
 

the ammo that is stored in the building

Definition at line 49 of file buildings.h.

Referenced by Building(), VehicleService::FieldSearch::checkBuilding2Vehicle(), copyBuildingData(), VehicleService::execute(), getAmmo(), BuildingValues::init(), putAmmo(), and write().

int Building::connection
 

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

Definition at line 58 of file buildings.h.

Referenced by Building(), evaluatevisibilityfield(), and putbuilding2().

int Building::lastmineddist
 

Definition at line 68 of file buildings.h.

Referenced by Building(), and copyBuildingData().

ASCString Building::name
 

the building's name

Definition at line 52 of file buildings.h.

Referenced by copyBuildingData(), getName(), BuildingValues::init(), DashboardPanel::showUnitData(), and write().

int Building::netcontrol
 

a bitmapped variable containing the status of the resource-net connection.

See also:
execnetcontrol()
Deprecated:

Definition at line 55 of file buildings.h.

Referenced by Building(), GetResourceCapacity::checkbuilding(), PutTribute::checkbuilding(), PutResource::checkbuilding(), convert(), copyBuildingData(), destructbuildinglevel2(), execnetcontrol(), trunreplay::execnextreplaymove(), putbuilding2(), and write().

int Building::repairedThisTurn [protected]
 

the percantage that this build has already been repaired this turn. The maximum percentage may be limited by a gameparameter

Definition at line 43 of file buildings.h.

Referenced by Building(), endRound(), postRepair(), repairableDamage(), and write().

ResourceMatrix Building::repairEfficiency [protected]
 

Definition at line 180 of file buildings.h.

Referenced by getRepairEfficiency().

const BuildingType* Building::typ
 

Definition at line 46 of file buildings.h.

Referenced by attackpossible(), Building(), calcvisibilityfield(), canRepair(), chainbuildingtofield(), VehicleService::FieldSearch::checkBuilding2Vehicle(), convert(), doresearch(), Reinforcements::execute(), getArmor(), getCoveredFields(), getEntry(), getEntryField(), getFieldCoordinates(), getHeight(), getImage(), getLocalCoordinate(), getName(), getPicture(), BuildingSeen::getState(), tcomputebuildingview::init(), BuildingValues::init(), VehicleService::FieldSearch::initrefuelling(), newFromStream(), MapRenderer::paintSingleField(), SelectionHolder::pickup(), ClipBoardBase::place(), putbuilding2(), tfield::setparams(), tunitattacksbuilding::setup(), DashboardPanel::showUnitData(), tsearchdestructbuildingfields::testfield(), transformMap(), unchainbuildingfromfield(), viewterraininfo(), and write().

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 61 of file buildings.h.

Referenced by Building(), copyBuildingData(), BuildingValues::init(), MapRenderer::paintSingleField(), putbuilding2(), and write().


The documentation for this class was generated from the following files:
Generated on Wed May 14 01:47:48 2008 for Advanced Strategic Command by  doxygen 1.4.2