OpenXcom
1.0
Open-source clone of the original X-Com
|
The battlescape data that gets written to disk when the game is saved. More...
#include <SavedBattleGame.h>
Public Member Functions | |
SavedBattleGame () | |
Creates a new battle save, based on the current generic save. More... | |
~SavedBattleGame () | |
Cleans up the saved game. More... | |
void | load (const YAML::Node &node, Ruleset *rule, SavedGame *savedGame) |
Loads a saved battle game from YAML. More... | |
YAML::Node | save () const |
Saves a saved battle game to YAML. More... | |
void | initMap (int mapsize_x, int mapsize_y, int mapsize_z) |
Sets the dimensions of the map and initializes it. More... | |
void | initUtilities (ResourcePack *res) |
Initialises the pathfinding and tileengine. More... | |
std::vector< MapDataSet * > * | getMapDataSets () |
Gets the game's mapdatafiles. More... | |
void | setMissionType (const std::string &missionType) |
Sets the mission type. More... | |
std::string | getMissionType () const |
Gets the mission type. More... | |
void | setGlobalShade (int shade) |
Sets the global shade. More... | |
int | getGlobalShade () const |
Gets the global shade. More... | |
Tile ** | getTiles () const |
Gets a pointer to the tiles, a tile is the smallest component of battlescape. More... | |
std::vector< Node * > * | getNodes () |
Gets a pointer to the list of nodes. More... | |
std::vector< BattleItem * > * | getItems () |
Gets a pointer to the list of items. More... | |
std::vector< BattleUnit * > * | getUnits () |
Gets a pointer to the list of units. More... | |
int | getMapSizeX () const |
Gets terrain size x. More... | |
int | getMapSizeY () const |
Gets terrain size y. More... | |
int | getMapSizeZ () const |
Gets terrain size z. More... | |
int | getMapSizeXYZ () const |
Gets terrain x*y*z. More... | |
int | getTileIndex (const Position &pos) const |
Converts coordinates into a unique index. More... | |
void | getTileCoords (int index, int *x, int *y, int *z) const |
Converts a tile index to its coordinates. More... | |
Tile * | getTile (const Position &pos) const |
Gets the Tile at a given position on the map. More... | |
BattleUnit * | getSelectedUnit () const |
Gets the currently selected unit. More... | |
void | setSelectedUnit (BattleUnit *unit) |
Sets the currently selected unit. More... | |
BattleUnit * | selectPreviousPlayerUnit (bool checkReselect=false, bool setReselect=false, bool checkInventory=false) |
Selects the previous soldier. More... | |
BattleUnit * | selectNextPlayerUnit (bool checkReselect=false, bool setReselect=false, bool checkInventory=false) |
Selects the next soldier. More... | |
BattleUnit * | selectUnit (const Position &pos) |
Selects the unit with position on map. More... | |
Pathfinding * | getPathfinding () const |
Gets the pathfinding object. More... | |
TileEngine * | getTileEngine () const |
Gets a pointer to the tileengine. More... | |
UnitFaction | getSide () const |
Gets the playing side. More... | |
int | getTurn () const |
Gets the turn number. More... | |
void | endTurn () |
Ends the turn. More... | |
void | setDebugMode () |
Sets debug mode. More... | |
bool | getDebugMode () const |
Gets debug mode. More... | |
void | loadMapResources (Game *game) |
Load map resources. More... | |
void | resetUnitTiles () |
Resets tiles units are standing on. More... | |
void | removeItem (BattleItem *item) |
Removes an item from the game. More... | |
void | setAborted (bool flag) |
Sets whether the mission was aborted. More... | |
bool | isAborted () const |
Checks if the mission was aborted. More... | |
void | setObjectiveDestroyed (bool flag) |
Sets whether the objective is destroyed. More... | |
bool | isObjectiveDestroyed () |
Checks if the objective is detroyed. More... | |
int * | getCurrentItemId () |
Gets the current item ID. More... | |
Node * | getSpawnNode (int nodeRank, BattleUnit *unit) |
Gets a spawn node. More... | |
Node * | getPatrolNode (bool scout, BattleUnit *unit, Node *fromNode) |
Gets a patrol node. More... | |
void | prepareNewTurn () |
Carries out new turn preparations. More... | |
void | reviveUnconsciousUnits () |
Revives unconscious units (healthcheck). More... | |
void | removeUnconsciousBodyItem (BattleUnit *bu) |
Removes the body item that corresponds to the unit. | |
bool | setUnitPosition (BattleUnit *bu, const Position &position, bool testOnly=false) |
Sets or tries to set a unit of a certain size on a certain position of the map. More... | |
bool | addFallingUnit (BattleUnit *unit) |
Adds this unit to the vector of falling units. More... | |
std::list< BattleUnit * > * | getFallingUnits () |
Gets the vector of falling units. More... | |
void | setUnitsFalling (bool fall) |
Toggles the switch that says "there are units falling, start the fall state". More... | |
bool | getUnitsFalling () const |
Checks the status of the switch that says "there are units falling". More... | |
BattlescapeState * | getBattleState () |
Gets a pointer to the BattlescapeState. More... | |
BattlescapeGame * | getBattleGame () |
Gets a pointer to the BattlescapeGame. More... | |
void | setBattleState (BattlescapeState *bs) |
Sets the pointer to the BattlescapeState. More... | |
BattleUnit * | getHighestRankedXCom () |
Gets the highest ranked, living XCom unit. More... | |
int | getMoraleModifier (BattleUnit *unit=0) |
Gets the morale modifier for XCom based on the highest ranked, living XCom unit, or the modifier for the unit passed to this function. More... | |
bool | eyesOnTarget (UnitFaction faction, BattleUnit *unit) |
Checks whether a particular faction has eyes on *unit (whether any unit on that faction sees *unit). More... | |
bool | placeUnitNearPosition (BattleUnit *unit, Position entryPoint) |
Attempts to place a unit on or near entryPoint. More... | |
void | resetTurnCounter () |
Resets the turn counter. | |
void | resetTiles () |
Resets the visibility of all tiles on the map. More... | |
const std::vector< Position > | getTileSearch () |
get an 11x11 grid of positions (-10 to +10) to check. More... | |
bool | isCheating () |
check if the AI has engaged cheat mode. More... | |
BattleActionType | getTUReserved () const |
get the reserved fire mode. More... | |
void | setTUReserved (BattleActionType reserved) |
set the reserved fire mode. More... | |
bool | getKneelReserved () const |
get whether we are reserving TUs to kneel. More... | |
void | setKneelReserved (bool reserved) |
set whether we are reserving TUs to kneel. More... | |
std::vector< Position > & | getStorageSpace () |
give me access to the storage tiles vector. More... | |
void | randomizeItemLocations (Tile *t) |
move all the leftover items to random locations in the storage tiles vector. More... | |
std::vector< std::vector < std::pair< int, int > > > & | getModuleMap () |
get a reference to the baseModules map. More... | |
void | calculateModuleMap () |
calculate the number of map modules remaining More... | |
SavedGame * | getGeoscapeSave () |
a shortcut to the geoscape save. More... | |
The battlescape data that gets written to disk when the game is saved.
A saved game holds all the variable info in a game like mapdata, soldiers, items, etc.
OpenXcom::SavedBattleGame::SavedBattleGame | ( | ) |
Creates a new battle save, based on the current generic save.
Initializes a brand new battlescape saved game.
OpenXcom::SavedBattleGame::~SavedBattleGame | ( | ) |
Cleans up the saved game.
Deletes the game content from memory.
bool OpenXcom::SavedBattleGame::addFallingUnit | ( | BattleUnit * | unit | ) |
Adds this unit to the vector of falling units.
Adds this unit to the vector of falling units, if it doesn't already exist.
unit | The unit. |
void OpenXcom::SavedBattleGame::calculateModuleMap | ( | ) |
calculate the number of map modules remaining
calculate the number of map modules remaining by counting the map objects on the top floor who have the baseModule flag set.
we store this data in the grid as outlined in the comments above, in pairs representing intial and current values.
void OpenXcom::SavedBattleGame::endTurn | ( | ) |
Ends the turn.
Ends the current turn and progresses to the next one.
bool OpenXcom::SavedBattleGame::eyesOnTarget | ( | UnitFaction | faction, |
BattleUnit * | unit | ||
) |
Checks whether a particular faction has eyes on *unit (whether any unit on that faction sees *unit).
Checks whether anyone on a particular faction is looking at the unit.
Similar to getSpottingUnits() but returns a bool and stops searching if one positive hit is found.
faction | Faction to check through. |
unit | Whom to spot. |
BattlescapeGame * OpenXcom::SavedBattleGame::getBattleGame | ( | ) |
Gets a pointer to the BattlescapeGame.
Gets the BattlescapeState.
BattlescapeState * OpenXcom::SavedBattleGame::getBattleState | ( | ) |
Gets a pointer to the BattlescapeState.
Gets the BattlescapeState.
int * OpenXcom::SavedBattleGame::getCurrentItemId | ( | ) |
Gets the current item ID.
bool OpenXcom::SavedBattleGame::getDebugMode | ( | ) | const |
Gets debug mode.
Gets the current debug mode.
std::list< BattleUnit * > * OpenXcom::SavedBattleGame::getFallingUnits | ( | ) |
Gets the vector of falling units.
Gets all units in the battlescape that are falling.
SavedGame * OpenXcom::SavedBattleGame::getGeoscapeSave | ( | ) |
a shortcut to the geoscape save.
get a pointer to the geoscape save
int OpenXcom::SavedBattleGame::getGlobalShade | ( | ) | const |
Gets the global shade.
BattleUnit * OpenXcom::SavedBattleGame::getHighestRankedXCom | ( | ) |
Gets the highest ranked, living XCom unit.
std::vector< BattleItem * > * OpenXcom::SavedBattleGame::getItems | ( | ) |
Gets a pointer to the list of items.
Gets the list of items.
bool OpenXcom::SavedBattleGame::getKneelReserved | ( | ) | const |
get whether we are reserving TUs to kneel.
Gets the kneel reservation setting.
std::vector< MapDataSet * > * OpenXcom::SavedBattleGame::getMapDataSets | ( | ) |
Gets the game's mapdatafiles.
Gets the array of mapblocks.
int OpenXcom::SavedBattleGame::getMapSizeX | ( | ) | const |
Gets terrain size x.
Gets the map width.
int OpenXcom::SavedBattleGame::getMapSizeXYZ | ( | ) | const |
Gets terrain x*y*z.
Gets the map size in tiles.
int OpenXcom::SavedBattleGame::getMapSizeY | ( | ) | const |
Gets terrain size y.
Gets the map length.
int OpenXcom::SavedBattleGame::getMapSizeZ | ( | ) | const |
Gets terrain size z.
Gets the map height.
std::string OpenXcom::SavedBattleGame::getMissionType | ( | ) | const |
Gets the mission type.
std::vector< std::vector< std::pair< int, int > > > & OpenXcom::SavedBattleGame::getModuleMap | ( | ) |
get a reference to the baseModules map.
Return a reference to the base module destruction map this map contains information on how many destructible base modules remain at any given grid reference in the basescape, using [x][y] format.
-1 for "no items" 0 for "destroyed" and any actual number represents how many left.
int OpenXcom::SavedBattleGame::getMoraleModifier | ( | BattleUnit * | unit = 0 | ) |
Gets the morale modifier for XCom based on the highest ranked, living XCom unit, or the modifier for the unit passed to this function.
Gets the morale modifier for.
unit | Unit. |
std::vector< Node * > * OpenXcom::SavedBattleGame::getNodes | ( | ) |
Gets a pointer to the list of nodes.
Gets the list of nodes.
Pathfinding * OpenXcom::SavedBattleGame::getPathfinding | ( | ) | const |
Gets the pathfinding object.
Node * OpenXcom::SavedBattleGame::getPatrolNode | ( | bool | scout, |
BattleUnit * | unit, | ||
Node * | fromNode | ||
) |
Gets a patrol node.
Finds a fitting node where a unit can patrol to.
scout | Is the unit scouting? |
unit | Pointer to the unit (to get its position). |
fromNode | Pointer to the node the unit is at. |
BattleUnit * OpenXcom::SavedBattleGame::getSelectedUnit | ( | ) | const |
Gets the currently selected unit.
UnitFaction OpenXcom::SavedBattleGame::getSide | ( | ) | const |
Gets the playing side.
Gets the side currently playing.
Node * OpenXcom::SavedBattleGame::getSpawnNode | ( | int | nodeRank, |
BattleUnit * | unit | ||
) |
Gets a spawn node.
Finds a fitting node where a unit can spawn.
nodeRank | Rank of the node (this is not the rank of the alien!). |
unit | Pointer to the unit (to get its position). |
std::vector< Position > & OpenXcom::SavedBattleGame::getStorageSpace | ( | ) |
give me access to the storage tiles vector.
Gives access to the "storage space" vector, for distribution of items in base defense missions.
void OpenXcom::SavedBattleGame::getTileCoords | ( | int | index, |
int * | x, | ||
int * | y, | ||
int * | z | ||
) | const |
Converts a tile index to its coordinates.
Converts a tile index to coordinates.
index | The (unique) tileindex. |
x | Pointer to the X coordinate. |
y | Pointer to the Y coordinate. |
z | Pointer to the Z coordinate. |
TileEngine * OpenXcom::SavedBattleGame::getTileEngine | ( | ) | const |
Gets a pointer to the tileengine.
Gets the terrain modifier object.
|
inline |
Converts coordinates into a unique index.
getTile() calls this every time, so should be inlined along with it.
pos | The position to convert. |
Tile ** OpenXcom::SavedBattleGame::getTiles | ( | ) | const |
Gets a pointer to the tiles, a tile is the smallest component of battlescape.
Gets the array of tiles.
const std::vector< Position > OpenXcom::SavedBattleGame::getTileSearch | ( | ) |
get an 11x11 grid of positions (-10 to +10) to check.
BattleActionType OpenXcom::SavedBattleGame::getTUReserved | ( | ) | const |
get the reserved fire mode.
Gets the TU reserved type.
int OpenXcom::SavedBattleGame::getTurn | ( | ) | const |
Gets the turn number.
Gets the current turn number.
std::vector< BattleUnit * > * OpenXcom::SavedBattleGame::getUnits | ( | ) |
Gets a pointer to the list of units.
Gets the list of units.
bool OpenXcom::SavedBattleGame::getUnitsFalling | ( | ) | const |
Checks the status of the switch that says "there are units falling".
Returns whether there are any units falling in the battlescape.
void OpenXcom::SavedBattleGame::initMap | ( | int | mapsize_x, |
int | mapsize_y, | ||
int | mapsize_z | ||
) |
Sets the dimensions of the map and initializes it.
Initializes the array of tiles and creates a pathfinding object.
mapsize_x | |
mapsize_y | |
mapsize_z |
void OpenXcom::SavedBattleGame::initUtilities | ( | ResourcePack * | res | ) |
Initialises the pathfinding and tileengine.
Initializes the map utilities.
res | Pointer to resource pack. |
bool OpenXcom::SavedBattleGame::isAborted | ( | ) | const |
Checks if the mission was aborted.
Returns whether the mission was aborted or successful.
bool OpenXcom::SavedBattleGame::isCheating | ( | ) |
check if the AI has engaged cheat mode.
is the AI allowed to cheat?
bool OpenXcom::SavedBattleGame::isObjectiveDestroyed | ( | ) |
Checks if the objective is detroyed.
Returns whether the objective is detroyed.
void OpenXcom::SavedBattleGame::load | ( | const YAML::Node & | node, |
Ruleset * | rule, | ||
SavedGame * | savedGame | ||
) |
Loads a saved battle game from YAML.
Loads the saved battle game from a YAML file.
node | YAML node. |
rule | for the saved game. |
savedGame | Pointer to saved game. |
void OpenXcom::SavedBattleGame::loadMapResources | ( | Game * | game | ) |
Load map resources.
Loads the resources required by the map in the battle save.
game | Pointer to the game. |
bool OpenXcom::SavedBattleGame::placeUnitNearPosition | ( | BattleUnit * | unit, |
Position | entryPoint | ||
) |
Attempts to place a unit on or near entryPoint.
Places a unit on or near a position.
unit | The unit to place. |
entryPoint | The position around which to attempt to place the unit. |
void OpenXcom::SavedBattleGame::prepareNewTurn | ( | ) |
Carries out new turn preparations.
Carries out new turn preparations such as fire and smoke spreading.
void OpenXcom::SavedBattleGame::randomizeItemLocations | ( | Tile * | t | ) |
move all the leftover items to random locations in the storage tiles vector.
Move all the leftover items in base defense missions to random locations in the storage facilities.
t | the tile where all our goodies are initially stored. |
void OpenXcom::SavedBattleGame::removeItem | ( | BattleItem * | item | ) |
Removes an item from the game.
Eg. when ammo item is depleted.
item | The Item to remove. |
void OpenXcom::SavedBattleGame::resetTiles | ( | ) |
Resets the visibility of all tiles on the map.
Resets visibility of all the tiles on the map.
void OpenXcom::SavedBattleGame::resetUnitTiles | ( | ) |
Resets tiles units are standing on.
Resets all the units to their current standing tile(s).
void OpenXcom::SavedBattleGame::reviveUnconsciousUnits | ( | ) |
Revives unconscious units (healthcheck).
Checks for units that are unconcious and revives them if they shouldn't be.
Revived units need a tile to stand on. If the unit's current position is occupied, then all directions around the tile are searched for a free tile to place the unit in. If no free tile is found the unit stays unconscious.
YAML::Node OpenXcom::SavedBattleGame::save | ( | ) | const |
Saves a saved battle game to YAML.
Saves the saved battle game to a YAML file.
BattleUnit * OpenXcom::SavedBattleGame::selectNextPlayerUnit | ( | bool | checkReselect = false , |
bool | setReselect = false , |
||
bool | checkInventory = false |
||
) |
Selects the next soldier.
Selects the next player unit.
checkReselect | Whether to check if we should reselect a unit. |
setReselect | Don't reselect a unit. |
checkInventory | Whether to check if the unit has an inventory. |
BattleUnit * OpenXcom::SavedBattleGame::selectPreviousPlayerUnit | ( | bool | checkReselect = false , |
bool | setReselect = false , |
||
bool | checkInventory = false |
||
) |
Selects the previous soldier.
Selects the previous player unit.
checkReselect | Whether to check if we should reselect a unit. |
setReselect | Don't reselect a unit. |
checkInventory | Whether to check if the unit has an inventory. |
BattleUnit * OpenXcom::SavedBattleGame::selectUnit | ( | const Position & | pos | ) |
Selects the unit with position on map.
Selects the unit at the given position on the map.
pos | Position. |
void OpenXcom::SavedBattleGame::setAborted | ( | bool | flag | ) |
Sets whether the mission was aborted.
Sets whether the mission was aborted or successful.
flag | True, if the mission was aborted, or false, if the mission was successful. |
void OpenXcom::SavedBattleGame::setBattleState | ( | BattlescapeState * | bs | ) |
Sets the pointer to the BattlescapeState.
Sets the BattlescapeState.
bs | A Pointer to a BattlescapeState. |
void OpenXcom::SavedBattleGame::setDebugMode | ( | ) |
Sets debug mode.
Turns on debug mode.
void OpenXcom::SavedBattleGame::setGlobalShade | ( | int | shade | ) |
Sets the global shade.
shade | The global shade. |
void OpenXcom::SavedBattleGame::setKneelReserved | ( | bool | reserved | ) |
set whether we are reserving TUs to kneel.
Sets the kneel reservation setting.
reserved | Should we reserve an extra 4 TUs to kneel? |
void OpenXcom::SavedBattleGame::setMissionType | ( | const std::string & | missionType | ) |
Sets the mission type.
missionType | The mission type. |
void OpenXcom::SavedBattleGame::setObjectiveDestroyed | ( | bool | flag | ) |
Sets whether the objective is destroyed.
flag | True if the objective is destroyed. |
void OpenXcom::SavedBattleGame::setSelectedUnit | ( | BattleUnit * | unit | ) |
Sets the currently selected unit.
unit | Pointer to BattleUnit. |
void OpenXcom::SavedBattleGame::setTUReserved | ( | BattleActionType | reserved | ) |
set the reserved fire mode.
Sets the TU reserved type.
reserved | A battleactiontype. |
bool OpenXcom::SavedBattleGame::setUnitPosition | ( | BattleUnit * | bu, |
const Position & | position, | ||
bool | testOnly = false |
||
) |
Sets or tries to set a unit of a certain size on a certain position of the map.
Places units on the map.
Handles large units that are placed on multiple tiles.
bu | The unit to be placed. |
position | The position to place the unit. |
testOnly | If true then just checks if the unit can be placed at the position. |
void OpenXcom::SavedBattleGame::setUnitsFalling | ( | bool | fall | ) |
Toggles the switch that says "there are units falling, start the fall state".
fall | True if there are any units falling in the battlescape. |