Advanced Strategic Command
Functions | Variables
spfst.cpp File Reference

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

#include <stdio.h>
#include <cstring>
#include <utility>
#include <map>
#include "vehicletype.h"
#include "buildingtype.h"
#include "typen.h"
#include "spfst.h"
#include "attack.h"
#include "mapalgorithms.h"
#include "vehicle.h"
#include "buildings.h"
#include "mapfield.h"
#include "spfst-legacy.h"
Include dependency graph for spfst.cpp:

Go to the source code of this file.

Functions

void displaymap ()
 
int terrainaccessible (const MapField *field, const Vehicle *vehicle, int uheight)
 Checks if the unit can drive on the field. More...
 
int terrainaccessible2 (const MapField *field, const Vehicle *vehicle, int uheight)
 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 fieldAccessible (const MapField *field, const Vehicle *vehicle, int uheight, const bool *attacked, bool ignoreVisibility)
 
MapFieldgetfield (int x, int y)
 returns the field at the given coordinates More...
 
void putbuilding (GameMap *actmap, const MapCoordinate &entryPosition, int color, const BuildingType *buildingtyp, int completion, int ignoreunits)
 puts a building onto the map. To be used by the map editor! For ingame usage, see ConstructBuildingCommand or SpawnBuilding More...
 
void checkobjectsforremoval (GameMap *gamemap)
 removes all objects that cannot exist where they currently are (terrainaccess) More...
 
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...
 
int getwindheightforunit (const Vehicle *eht, int uheight)
 Wind may be different at different heights. More...
 
int getmaxwindspeedforunit (const Vehicle *eht)
 returns the maximum wind speed that the unit can endure 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...
 
VisibilityStates fieldVisibility (const MapField *pe)
 }@ More...
 
VisibilityStates fieldVisibility (const MapField *pe, int player)
 
void calculateobject (const MapCoordinate &pos, bool mof, const ObjectType *obj, GameMap *gamemap)
 
void calculateobject (int x, int y, bool mof, const ObjectType *obj, GameMap *actmap)
 recalculates the connection (like road interconnections) of an object More...
 
void calculateallobjects (GameMap *actmap)
 recalculates the connection (like road interconnections) of all objects on the map More...
 

Variables

sigc::signal< void > repaintMap
 }@ More...
 
sigc::signal< void > repaintDisplay
 
sigc::signal< void > updateFieldInfo
 
sigc::signal< void > cursorMoved
 
sigc::signal< void,
ContainerBase * > 
showContainerInfo
 
sigc::signal< void, VehicleType * > showVehicleTypeInfo
 
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< bool > idleEvent
 
sigc::signal< void, const
Context & > 
fieldCrossed
 
GameMapactmap = NULL
 
Schriften schriften
 

Detailed Description

map accessing and usage routines used by ASC and the mapeditor

Definition in file spfst.cpp.

Function Documentation

void calculateallobjects ( GameMap actmap)
void calculateobject ( const MapCoordinate pos,
bool  mof,
const ObjectType obj,
GameMap gamemap 
)
void calculateobject ( int  x,
int  y,
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().

MapField* getfield ( int  x,
int  y 
)
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 actmap,
const MapCoordinate entryPosition,
int  color,
const BuildingType buildingtyp,
int  completion,
int  ignoreunits 
)
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

GameMap* actmap = NULL

Definition at line 64 of file spfst.cpp.

Referenced by tmapgenerator::addcoast(), EventAreasDialog::addNewWeatherAreaInformation(), EventWindChangesDialog::addNewWindInformation(), tplayerchange::anzeige(), authenticateUser(), GuiFunctions::MovementBase::available(), ContextMenu::ContainerProperties::available(), ContextMenu::ContainerCargo::available(), ContextMenu::DeleteVehicle::available(), ContextMenu::DeleteBuilding::available(), ContextMenu::ContainerProduction::available(), ContextMenu::DeleteMine::available(), ContextMenu::ChangeMineStrength::available(), ContextMenu::DeleteTopObject::available(), ContextMenu::DeleteAllObjects::available(), GuiFunctions::Ascend::available(), GuiFunctions::Descend::available(), GuiFunctions::EndTurn::available(), GuiFunctions::Attack::available(), GuiFunctions::PowerSwitch::available(), GuiFunctions::UnitInfo::available(), GuiFunctions::DestructBuilding::available(), GuiFunctions::OpenContainer::available(), GuiFunctions::EnableReactionfire::available(), GuiFunctions::DisableReactionfire::available(), GuiFunctions::JumpDriveIcon::available(), GuiFunctions::RepairUnit::available(), GuiFunctions::RefuelUnitCommand::available(), GuiFunctions::RefuelUnitDialogCommand::available(), GuiFunctions::PutMine::available(), GuiFunctions::BuildObject::available(), GuiFunctions::BuildVehicleCommand::available(), GuiFunctions::ConstructBuilding::available(), GuiFunctions::SelfDestructIcon::available(), benchgame(), buildemptymap(), ResourcePlacementDialog::buttonEvent(), tplayerchange::buttonpressed(), MapDisplayPG::centerOnField(), GuiIconHandler::checkForKey(), checkforreplay(), checkJournal(), ResizeMap::checkvalue(), MapDisplayPG::checkViewPosition(), continueAndStartMultiplayerGame(), trunreplay::createReplayContext(), MapSwitcher::deleteMaps(), VehicleItem::display(), BuildingItem::display(), ReplayMapDisplay::displayActionCursor(), ReplayMapDisplay::displayMovingUnit(), PG_MapDisplay::displayMovingUnit(), ReplayMapDisplay::displayPosition(), MapDisplayPG::displayUnitMovement(), displaywindspeed(), editAlliances(), editArchivalInformation(), editjournal(), editpolygon(), editResearch(), editResearchPoints(), editTechAdapter(), endTurn(), DashboardPanel::eval(), NewGuiHost::evalCursor(), EventAreasDialog::EventAreasDialog(), ASC_MainScreenWidget::eventKeyDown(), Maped_MainScreenWidget::eventKeyDown(), TargetCoordinateLocator::eventMouseButtonDown(), MapDisplayPG::eventMouseButtonDown(), MapDisplayPG::eventMouseMotion(), EventWindChangesDialog::EventWindChangesDialog(), execaction(), execaction_pg(), trunreplay::execnextreplaymove(), GuiFunctions::MovementBase::execute(), GuiFunctions::Cancel::execute(), GuiFunctions::AttackGui::execute(), GuiFunctions::EndTurn::execute(), GuiFunctions::Attack::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::SelfDestructIcon::execute(), executeUserAction(), CopyMap::fieldOperator(), MapDisplayPG::fillSurface(), gamethread(), generatemap(), getactfield(), getActiveMap(), GuiFunctions::AttackGui::getName(), MapSwitcher::getName(), GuiFunctions::RepairUnit::getName(), getplayercolor(), getSelectedField(), ContextMenu::ContainerProperties::getText(), ContextMenu::ContainerCargo::getText(), getxy_building(), importbattleislemap(), IngameMessageViewer::IngameMessageViewer(), tmapgenerator::init(), ttributepayments::init(), tdialogbox::init(), tresearchinfo::init(), tchoice_dlg::init(), ResizeMap::init(), insertbattleislemap(), CargoItemFactory::isFiltered(), CargoItemFactory::itemSelected(), iterateToNextPlayer(), k_loadmap(), k_savemap(), MapDisplayPG::keyboardHandler(), tloadBImap::LoadFromFile(), loadGame(), loadGameFromFile(), loadGameLua(), loadmap(), loadStartupMap(), mainloopidle(), maintainencecheck(), mapeditorMainThread(), NewGuiHost::mapIconProcessing(), MessageSelectionWindow::messageSelected(), mirrorMap(), MirrorMap::mirrorX(), MirrorMap::mirrorY(), OverviewMapPanel::mouseClick(), Weathercast::mouseClick(), newmap(), newmessage(), newreminder(), UnitInfoPanel::onClick(), UnitWeaponRangeLayer::operateField(), UnitMovementRangeLayer::operateField(), OverviewMapPanel::painter(), DashboardPanel::painter(), Weathercast::painter(), ShowPolygonUsingTemps::paintPolygon(), CopyMap::paste(), pasteArea(), ClipBoardBase::pasteUnit(), ClipBoardBase::place(), VehicleItem::place(), BuildingItem::place(), ObjectItem::place(), TerrainItem::place(), MineItem::place(), placeCurrentItem(), playerchange(), PlayerColorPanel::PlayerColorPanel(), ReplayMapDisplay::playPositionalSound(), MapDisplayPG::Cursor::pos(), ImportBiMap::preparemap(), InsertBiMap::preparemap(), process_ASC_map(), process_BI_map(), readtextmessage(), redo(), tdialogbox::redraw(), ObjectItem::remove(), removeCurrentItem(), researchinfo(), resetActmap(), resourceAnalysis(), resourceComparison(), trunreplay::run(), tputresourcesdlg::run(), ttributepayments::run(), tchoosetechlevel::run(), ResizeMap::run(), UnitTypeTransformation::run(), runOpenTasks(), runSpecificReplay(), saveGame(), MapDisplayPG::scrollMap(), selectFields(), selectgraphicset(), selectPosition(), selectunit(), tmapgenerator::setmap(), IngameMessageViewer::SetMessage(), tmessagedlg::setup(), setweatherall(), PG_MapDisplay::showBattle(), showbdtbits(), showCargoSummary(), showGameParameters(), showMemoryFootprint(), showPlayerTime(), showUsedPackages(), UnitListFactory::spawnNextItem(), AvailableProductionItemFactory::spawnNextItem(), ASC_MainScreenWidget::spawnPanel(), StartMultiplayerGame::start(), startnextcampaignmap(), testDebugFunction(), testMaps(), MapSwitcher::toggle(), transfer_all_outstanding_tribute(), transformMap(), tshowhistoryinit(), undo(), unitInfoDialog(), MapDisplayPG::updateMap(), Maped_MainScreenWidget::updateStatusBar(), viewjournal(), viewmessages(), viewMiningPower(), viewUnitSetinfo(), trunreplay::wait(), Weathercast::Weathercast(), weathercast(), WeatherDialog::WeatherDialog(), WeatherPanel::WeatherPanel(), and writeLuaCommands().

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
Schriften schriften
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().