Advanced Strategic Command
Functions | Variables
spfst.h File Reference

map accessing and usage routines used by ASC and the mapeditor More...

#include <sigc++/sigc++.h>
#include "typen.h"
#include "gamemap.h"
Include dependency graph for spfst.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void putbuilding (GameMap *gamemap, const MapCoordinate &entryPosition, int color, const BuildingType *buildingtyp, int completion, int ignoreunits=0)
 puts a building onto the map. To be used by the map editor! For ingame usage, see ConstructBuildingCommand or SpawnBuilding More...
 
void calculateallobjects (GameMap *m)
 recalculates the connection (like road interconnections) of all objects on the map More...
 
void calculateobject (int x, int y, bool mof, const ObjectType *obj, GameMap *gamemap)
 recalculates the connection (like road interconnections) of an object More...
 
void calculateobject (const MapCoordinate &pos, bool mof, const ObjectType *obj, GameMap *gamemap)
 
int fieldAccessible (const MapField *field, const Vehicle *vehicle, int uheight=-2, const bool *attacked=NULL, bool ignoreVisibility=false)
 
void checkunitsforremoval (GameMap *gamemap)
 removes all units that cannot exist any more, either due to invalid terrin (like tanks on melting ice) or too much wind (eg. More...
 
void checkobjectsforremoval (GameMap *gamemap)
 removes all objects that cannot exist where they currently are (terrainaccess) More...
 
int getmaxwindspeedforunit (const Vehicle *eht)
 returns the maximum wind speed that the unit can endure More...
 
int getwindheightforunit (const Vehicle *eht, int uheight=-1)
 Wind may be different at different heights. More...
 
int terrainaccessible (const MapField *field, const Vehicle *vehicle, int uheight=-1)
 Checks if the unit can drive on the field. More...
 
int terrainaccessible2 (const MapField *field, const Vehicle *vehicle, int uheight=-1)
 Checks if the unit can drive on the field. More...
 
int terrainaccessible2 (const MapField *field, const TerrainAccess &terrainAccess, int uheight)
 Checks if the field can be accessed. More...
 
int getheightdelta (const ContainerBase *c1, const ContainerBase *c2)
 calculate the height difference between two levels of height. More...
 
bool fieldvisiblenow (const MapField *pe, Vehicle *veh, int player)
 {@ More...
 
bool fieldvisiblenow (const MapField *pe, int player)
 
bool fieldvisiblenow (const MapField *pe, Vehicle *veh)
 
bool fieldvisiblenow (const MapField *pe)
 
VisibilityStates fieldVisibility (const MapField *pe)
 }@ More...
 
VisibilityStates fieldVisibility (const MapField *pe, int player)
 
void displaymap ()
 

Variables

sigc::signal< void > repaintMap
 }@ More...
 
sigc::signal< void > repaintDisplay
 
sigc::signal< void > updateFieldInfo
 
sigc::signal< void > cursorMoved
 
sigc::signal< void > viewChanged
 the view of the player onto the map changed, for example because he scrolled the map More...
 
sigc::signal< void, GameMap * > mapChanged
 
sigc::signal< void,
ContainerBase * > 
showContainerInfo
 
sigc::signal< void, VehicleType * > showVehicleTypeInfo
 
sigc::signal< bool > idleEvent
 
sigc::signal< void, const
Context & > 
fieldCrossed
 

Detailed Description

map accessing and usage routines used by ASC and the mapeditor

spfst comes from german "Spielfeldsteuerung" :-)

Definition in file spfst.h.

Function Documentation

void calculateallobjects ( GameMap m)
void calculateobject ( int  x,
int  y,
bool  mof,
const ObjectType obj,
GameMap gamemap 
)
void calculateobject ( const MapCoordinate pos,
bool  mof,
const ObjectType obj,
GameMap gamemap 
)
void checkobjectsforremoval ( GameMap gamemap)

removes all objects that cannot exist where they currently are (terrainaccess)

Definition at line 247 of file spfst.cpp.

References MapField::bdt, getfield(), MapField::getWeather(), MapField::objects, MapField::removeObject(), GameMap::xsize, and GameMap::ysize.

Referenced by MapChangeCompleted::execute().

void checkunitsforremoval ( GameMap gamemap)
void displaymap ( )
int fieldAccessible ( const MapField field,
const Vehicle vehicle,
int  uheight = -2,
const bool *  attacked = NULL,
bool  ignoreVisibility = false 
)
VisibilityStates fieldVisibility ( const MapField pe)
VisibilityStates fieldVisibility ( const MapField pe,
int  player 
)
bool fieldvisiblenow ( const MapField pe,
Vehicle veh,
int  player 
)

{@

evaluates the visibility of a field

Parameters
pethe field to be evaluated
playerthe player who is 'looking'

Definition at line 399 of file spfst.cpp.

References MapField::building, chhochfliegend, chschwimmend, ContainerBase::color, GameMap::getInitialMapVisibility(), MapField::getMap(), ContainerBaseType::height, Vehicle::height, Building::typ, MapField::vehicle, MapField::visible, visible_ago, and visible_all.

Referenced by tsearchreactionfireingunits::attack(), attackpossible(), GuiFunctions::UnitInfo::available(), GuiFunctions::OpenContainer::available(), GuiFunctions::SelfDestructIcon::available(), tsearchreactionfireingunits::checkfield(), ReplayMapDisplay::displayActionCursor(), ReplayMapDisplay::displayMovingUnit(), ReplayMapDisplay::displayPosition(), DashboardPanel::eval(), trunreplay::execnextreplaymove(), executeUserAction(), JumpDriveCommand::fieldReachable(), fieldvisiblenow(), tsearchreactionfireingunits::finalCheck(), PutMineCommand::go(), NewGuiHost::mapIconProcessing(), DashboardPanel::painter(), ReplayMapDisplay::playPositionalSound(), WholeMapRenderer::renderVisibility(), WeaponRange::run(), VehicleAttackAction::runAction(), MoveUnit::runAction(), AttackCommand::searchTargets(), tunitattacksunit::setup(), AI::showFieldInformation(), showUnitAiProperties(), DashboardPanel::showUnitData(), testAttack2(), testAttack3(), testDiplomacy1(), testTransferControl(), testView1(), testView2(), OverviewMapHolder::updateField(), viewUnitSetinfo(), and trunreplay::wait().

bool fieldvisiblenow ( const MapField pe,
int  player 
)
inline

Definition at line 151 of file spfst.h.

References fieldvisiblenow().

bool fieldvisiblenow ( const MapField pe,
Vehicle veh 
)
inline

Definition at line 152 of file spfst.h.

References GameMap::actplayer, fieldvisiblenow(), and MapField::getMap().

bool fieldvisiblenow ( const MapField pe)
inline

Definition at line 153 of file spfst.h.

References GameMap::actplayer, fieldvisiblenow(), and MapField::getMap().

int getheightdelta ( const ContainerBase c1,
const ContainerBase c2 
)

calculate the height difference between two levels of height.

Since floating and ground based are assumed to be the same effective height, a simple subtraction isn't sufficient. Height is a numeric (and not bitmapped) value

Definition at line 393 of file spfst.cpp.

References getFirstBit(), ContainerBase::getHeight(), and getheightdelta().

Referenced by attackpossible(), attackpossible28(), attackpossible2n(), attackpossible2u(), ConstructBuildingCommand::buildingProductionPrerequisites(), fieldAccessible(), DestructBuildingCommand::getFields(), getheightdelta(), WeapDist::getWeaponStrength(), WeaponInfoPanel::showWeapon(), ContainerBase::vehicleLoadable(), and ContainerBaseType::vehicleUnloadable().

int getmaxwindspeedforunit ( const Vehicle eht)
int getwindheightforunit ( const Vehicle eht,
int  uheight = -1 
)

Wind may be different at different heights.

This function returns the index for the wind array. If uheight != -1 it is assumed the unit was uheight instead the actual level of height

Definition at line 318 of file spfst.cpp.

References chfliegend, chhochfliegend, and Vehicle::height.

void putbuilding ( GameMap gamemap,
const MapCoordinate entryPosition,
int  color,
const BuildingType buildingtyp,
int  completion,
int  ignoreunits = 0 
)
int terrainaccessible ( const MapField field,
const Vehicle vehicle,
int  uheight = -1 
)

Checks if the unit can drive on the field.

Parameters
fieldthe field that the unit is checked again
vehiclethe unit who accessabilit to field is tested
uheightif != -1, the unit is assumed to be on this height instead of the actual one.
Returns
0=unit cannot access this field; 1=unit can move across this field but cannot keep standing there 2=unit can move and stand there

Definition at line 70 of file spfst.cpp.

References terrainaccessible2().

Referenced by Vehicle::canMove(), fieldAccessible(), AStar3D::findPath(), movebuilding(), VehicleItem::place(), and tmapgenerator::setmap().

int terrainaccessible2 ( const MapField field,
const Vehicle vehicle,
int  uheight = -1 
)

Checks if the unit can drive on the field.

Parameters
fieldthe field that the unit is checked again
vehiclethe unit who accessabilit to field is tested
uheightif != -1, the unit is assumed to be on this height instead of the actual one.
Returns
0=unit cannot access this field; 1=unit can move across this field but cannot keep standing there; 2=unit can move and stand there; < 0 unit cannot access this field, because of: -1 very deep water required to submerge deep -2 deep water required to submerge -3 unit cannot drive onto terrain

Definition at line 79 of file spfst.cpp.

References ContainerBaseType::height, Vehicle::height, VehicleType::terrainaccess, terrainaccessible2(), and Vehicle::typ.

Referenced by terrainaccessible(), terrainaccessible2(), and Vehicle::vehicleconstructable().

int terrainaccessible2 ( const MapField field,
const TerrainAccess terrainAccess,
int  uheight 
)

Checks if the field can be accessed.

Returns
0=unit cannot access this field; 1=unit can move across this field but cannot keep standing there; 2=unit can move and stand there; < 0 unit cannot access this field, because of: -1 very deep water required to submerge deep -2 deep water required to submerge -3 unit cannot drive onto terrain

Definition at line 91 of file spfst.cpp.

References TerrainAccess::accessible(), MapField::bdt, cbwater, cbwater2, cbwater3, chgetaucht, chschwimmend, chtieffliegend, chtiefgetaucht, and getTerrainBitType().

Variable Documentation

sigc::signal<void> cursorMoved
sigc::signal<void, const Context&> fieldCrossed
sigc::signal<bool> idleEvent

Definition at line 53 of file spfst.cpp.

Referenced by ASC_PG_App::ASC_PG_App(), and OverviewMapHolder::connect().

sigc::signal<void,GameMap*> mapChanged
sigc::signal<void> repaintDisplay
sigc::signal<void> repaintMap
sigc::signal<void,ContainerBase*> showContainerInfo

Definition at line 49 of file spfst.cpp.

sigc::signal<void,VehicleType*> showVehicleTypeInfo

Definition at line 50 of file spfst.cpp.

sigc::signal<void> updateFieldInfo

Definition at line 47 of file spfst.cpp.

Referenced by tsearchreactionfireingunits::attack(), DashboardPanel::DashboardPanel(), MapDisplayPG::eventMouseButtonDown(), ExchangeGraphics::ExchangeGraphics(), execaction(), trunreplay::execnextreplaymove(), GuiFunctions::MovementBase::execute(), GuiFunctions::Cancel::execute(), GuiFunctions::AttackGui::execute(), ReplayGuiFunctions::ReplayPlay::execute(), ReplayGuiFunctions::ReplayPause::execute(), ReplayGuiFunctions::ReplayFaster::execute(), ReplayGuiFunctions::ReplaySlower::execute(), ReplayGuiFunctions::ReplayRewind::execute(), ReplayGuiFunctions::ReplayExit::execute(), ReplayGuiFunctions::ReplayRecord::execute(), ReplayGuiFunctions::ReplayRecordExit::execute(), GuiFunctions::PowerSwitch::execute(), GuiFunctions::DestructBuilding::execute(), GuiFunctions::OpenContainer::execute(), GuiFunctions::EnableReactionfire::execute(), GuiFunctions::DisableReactionfire::execute(), GuiFunctions::JumpDriveIcon::execute(), GuiFunctions::RepairUnit::execute(), GuiFunctions::RefuelUnitCommand::execute(), GuiFunctions::RefuelUnitDialogCommand::execute(), GuiFunctions::PutMine::execute(), GuiFunctions::PutMineStage2::execute(), GuiFunctions::RemoveMine::execute(), GuiFunctions::ObjectBuildingGui::execute(), GuiFunctions::BuildObject::execute(), GuiFunctions::BuildVehicleCommand::execute(), GuiFunctions::ConstructBuilding::execute(), GuiFunctions::InternalAmmoTransferDialog::execute(), GuiFunctions::SelfDestructIcon::execute(), executeUserAction(), gamethread(), hookGuiToMap(), loadGame(), main(), NewGuiHost::NewGuiHost(), LuaBrush::place(), NewGuiHost::popIconHandler(), NewGuiHost::pushIconHandler(), redo(), trunreplay::run(), MoveUnit::runAction(), runai(), selectAndRunLuaScript(), Maped_MainScreenWidget::setupStatusBar(), StartMultiplayerGame::start(), undo(), and PG_MapDisplay::updateDashboard().

sigc::signal<void> viewChanged

the view of the player onto the map changed, for example because he scrolled the map

Definition at line 51 of file spfst.cpp.

Referenced by MapDisplayPG::centerOnField(), MapDisplayPG::eventMouseButtonDown(), execaction_pg(), executeUserAction(), OverviewMapPanel::OverviewMapPanel(), MapDisplayPG::scrollMap(), MapSwitcher::toggle(), and Weathercast::Weathercast().