Advanced Strategic Command
Functions | Variables
viewcalculation.cpp File Reference

functions for calculating the view of units and buildings More...

#include "global.h"
#include "viewcalculation.h"
#include "mapalgorithms.h"
#include "vehicletype.h"
#include "buildingtype.h"
#include "errors.h"
#include "gameeventsystem.h"
#include "actions/changeview.h"
#include "actions/viewregistration.h"
Include dependency graph for viewcalculation.cpp:

Go to the source code of this file.

Functions

void clearvisibility (GameMap *gamemap)
 
VisibilityStates calcvisibilityfield (GameMap *gamemap, MapField *fld, int player, int add, int initial, int additionalEnemyJamming)
 calculates the view on a given field. More...
 
int evaluatevisibilityfield (GameMap *gamemap, MapField *fld, int player, int add, int initial)
 evaluates the view on a given field and saves it for that field. More...
 
int evaluateviewcalculation (GameMap *gamemap, int player_fieldcount_mask, bool disableShareView, const Context *context)
 evaluates the view on the whole map. More...
 
int evaluateviewcalculation (GameMap *gamemap, const MapCoordinate &pos, int distance, int player_fieldcount_mask, bool disableShareView, const Context *context)
 evaluates the view on a part of the map. More...
 
int computeview (GameMap *gamemap, int player_fieldcount_mask, bool disableShareView, const Context *context)
 completely computes the view More...
 
int getPlayersWithSharedViewMask (int player, GameMap *gamemap)
 

Variables

sigc::signal< void > buildingSeen
 

Detailed Description

functions for calculating the view of units and buildings

Definition in file viewcalculation.cpp.

Function Documentation

VisibilityStates calcvisibilityfield ( GameMap gamemap,
MapField fld,
int  player,
int  add,
int  initial,
int  additionalEnemyJamming 
)

calculates the view on a given field.

Radar and jamming values must have already been applied to the field!

Parameters
gamemapthe map that contains field
fldthe field to evaluate
playerthe player that the view is calculated for
adda bitmapped variable containing the players that share their view with player
initialthe initial visibility of the map when starting the game.
additionalEnemyJammingif > 0 run an WhatIf analysis and don't save the result

Definition at line 249 of file viewcalculation.cpp.

References MapField::building, chsatellit, chschwimmend, direct, MapField::View::direct, ContainerBase::getOwner(), GameMap::getPlayerCount(), getPlayersWithSharedViewMask(), MapField::getVehicle(), ContainerBaseType::height, Vehicle::height, MapField::View::jamming, MapField::View::mine, MapField::mineowner(), MapField::mines, GameMap::player, MapField::View::satellite, MapField::secondvehicle, MapField::View::sonar, Player::stat, Player::supervisor, Building::typ, MapField::View::view, MapField::view, MapField::visible, visible_ago, visible_all, visible_not, and visible_now.

Referenced by ReplayMapDisplay::displayMovingUnit(), and evaluatevisibilityfield().

void clearvisibility ( GameMap gamemap)
int computeview ( GameMap gamemap,
int  player_fieldcount_mask = 0,
bool  disableShareView = false,
const Context context = NULL 
)

completely computes the view

Parameters
gamemapthe map that the view is generated on
player_fieldcount_maskbitmapped variable containing the players for whom the changed fields are calculated
disableShareViewsharing the view between different players is disabled.
Returns
the number of fields that have a changed visibility for the given players. If nothing changes, the map must not be displayed again after the view calculation

Definition at line 450 of file viewcalculation.cpp.

References Vehicle::addview(), Player::buildingList, clearvisibility(), evaluateviewcalculation(), Player::exist(), GameMap::getField(), GameMap::getPlayerCount(), Vehicle::getPosition(), GameMap::player, Player::vehicleList, GameMap::xsize, and GameMap::ysize.

Referenced by benchgame(), continueNetworkGame(), editAlliances(), execaction_pg(), trunreplay::execnextreplaymove(), MapModificationEvent::execute(), SetViewSharing::execute(), executeUserAction(), getVisibilityStatistics(), DiplomacyCommand::go(), JumpDriveCommand::go(), TransferControlCommand::go(), PutMineCommand::go(), loadGameFromFile(), loadmap(), loadStartupMap(), WholeMapRenderer::renderVisibility(), trunreplay::run(), runai(), StartMultiplayerGame::start(), startMap(), startnextcampaignmap(), and viewcomp().

int evaluateviewcalculation ( GameMap gamemap,
int  player_fieldcount_mask = 0,
bool  disableShareView = false,
const Context context = NULL 
)

evaluates the view on the whole map.

Radar and jamming values must have already been applied to the field!

Parameters
gamemapthe map that the view is calculated of
player_fieldcount_maskdetermines, which players should be counted when the view has changed
disableShareViewsharing the view between different players is disabled.
Returns
the number of fields which have a changed visibility status

Definition at line 332 of file viewcalculation.cpp.

References cgp_initialMapVisibility, ActionRegistry::ChangeView, evaluatevisibilityfield(), Player::exist(), GameMap::getField(), GameMap::getgameparameter(), GameMap::getPlayerCount(), getPlayersWithSharedViewMask(), MapField::getTemp3(), GameMap::player, MapField::setTemp3(), MapField::visible, GameMap::xsize, and GameMap::ysize.

Referenced by RecalculateAreaView::addView(), computeview(), ChangeBuildingOwner::execute(), Reinforcements::execute(), DestructUnitCommand::go(), DestructBuildingCommand::go(), SpawnBuilding::runAction(), MoveUnit::runAction(), SpawnUnit::runAction(), DestructContainer::runAction(), and VehicleAttackAction::undoAction().

int evaluateviewcalculation ( GameMap gamemap,
const MapCoordinate pos,
int  distance,
int  player_fieldcount_mask = 0,
bool  disableShareView = false,
const Context context = NULL 
)

evaluates the view on a part of the map.

Radar and jamming values must have already been applied to the field!

Parameters
gamemapthe map that the view is calculated of
posthe central position around which the view is calculated
distancethe radius of the circle around pos in which the view is evaluated. The view is calculated in AT LEAST this circle, in reality it is a rectangle containing this circle. This is not the number of fields, but the distance in points (with 10 points = 1 field)
player_fieldcount_maskdetermines, which players should be counted when the view has changed
disableShareViewsharing the view between different players is disabled.
Returns
the number of fields which have a changed visibility status

Definition at line 380 of file viewcalculation.cpp.

References cgp_initialMapVisibility, ActionRegistry::ChangeView, Player::diplomacy, evaluatevisibilityfield(), Player::exist(), GameMap::getField(), GameMap::getgameparameter(), GameMap::getPlayerCount(), maxmalq, GameMap::player, playerNum, DiplomaticStateVector::sharesView(), MapField::visible, MapCoordinate::x, GameMap::xsize, MapCoordinate::y, and GameMap::ysize.

int evaluatevisibilityfield ( GameMap gamemap,
MapField fld,
int  player,
int  add,
int  initial 
)

evaluates the view on a given field and saves it for that field.

Calls calcvisibilityfield for the calculation Radar and jamming values must have already been applied to the field!

Parameters
gamemapthe map that contains field
fldthe field to evaluate
playerthe player that the view is calculated for
adda bitmapped variable containing the players that share their view with player
initialthe initial visibility of the map when starting the game.

Definition at line 308 of file viewcalculation.cpp.

References MapField::building, buildingSeen, calcvisibilityfield(), cconnection_seen, Building::connection, MapField::setVisibility(), MapField::visible, visible_ago, visible_all, and visible_now.

Referenced by evaluateviewcalculation(), and MoveUnit::runAction().

int getPlayersWithSharedViewMask ( int  player,
GameMap gamemap 
)

Variable Documentation

sigc::signal<void> buildingSeen

Definition at line 34 of file viewcalculation.cpp.

Referenced by BuildingSeen::arm(), and evaluatevisibilityfield().