![]() |
OpenXcom
1.0
Open-source clone of the original X-Com
|
The game data that gets written to disk when the game is saved. More...
#include <SavedGame.h>
Public Member Functions | |
SavedGame () | |
Creates a new saved game. More... | |
~SavedGame () | |
Cleans up the saved game. More... | |
void | load (const std::string &filename, Mod *mod) |
Loads a saved game from YAML. More... | |
void | save (const std::string &filename) const |
Saves a saved game to YAML. More... | |
std::string | getName () const |
Gets the game name. More... | |
void | setName (const std::string &name) |
Sets the game name. More... | |
GameDifficulty | getDifficulty () const |
Gets the game difficulty. More... | |
void | setDifficulty (GameDifficulty difficulty) |
Sets the game difficulty. More... | |
int | getDifficultyCoefficient () const |
Gets the game difficulty coefficient. More... | |
GameEnding | getEnding () const |
Gets the game ending. More... | |
void | setEnding (GameEnding end) |
Sets the game ending. More... | |
bool | isIronman () const |
Gets if the game is in ironman mode. More... | |
void | setIronman (bool ironman) |
Sets if the game is in ironman mode. More... | |
int64_t | getFunds () const |
Gets the current funds. More... | |
std::vector< int64_t > & | getFundsList () |
Gets the list of funds from previous months. More... | |
void | setFunds (int64_t funds) |
Sets new funds. More... | |
double | getGlobeLongitude () const |
Gets the current globe longitude. More... | |
void | setGlobeLongitude (double lon) |
Sets the new globe longitude. More... | |
double | getGlobeLatitude () const |
Gets the current globe latitude. More... | |
void | setGlobeLatitude (double lat) |
Sets the new globe latitude. More... | |
int | getGlobeZoom () const |
Gets the current globe zoom. More... | |
void | setGlobeZoom (int zoom) |
Sets the new globe zoom. More... | |
void | monthlyFunding () |
Handles monthly funding. More... | |
GameTime * | getTime () const |
Gets the current game time. More... | |
void | setTime (const GameTime &time) |
Sets the current game time. More... | |
int | getId (const std::string &name) |
Gets the current ID for an object. More... | |
const std::map< std::string, int > & | getAllIds () const |
Resets the list of object IDs. More... | |
void | setAllIds (const std::map< std::string, int > &ids) |
Resets the list of object IDs. More... | |
std::vector< Country * > * | getCountries () |
Gets the list of countries. More... | |
int | getCountryFunding () const |
Gets the total country funding. More... | |
std::vector< Region * > * | getRegions () |
Gets the list of regions. More... | |
std::vector< Base * > * | getBases () |
Gets the list of bases. More... | |
const std::vector< Base * > * | getBases () const |
Gets the list of bases. More... | |
int | getBaseMaintenance () const |
Gets the total base maintenance. More... | |
std::vector< Ufo * > * | getUfos () |
Gets the list of UFOs. More... | |
std::vector< Waypoint * > * | getWaypoints () |
Gets the list of waypoints. More... | |
std::vector< MissionSite * > * | getMissionSites () |
Gets the list of mission sites. More... | |
SavedBattleGame * | getSavedBattle () |
Gets the current battle game. More... | |
void | setBattleGame (SavedBattleGame *battleGame) |
Sets the current battle game. More... | |
void | addFinishedResearchSimple (const RuleResearch *research) |
Add a finished ResearchProject. More... | |
void | addFinishedResearch (const RuleResearch *research, const Mod *mod, Base *base, bool score=true) |
Add a finished ResearchProject. More... | |
const std::vector< const RuleResearch * > & | getDiscoveredResearch () const |
Get the list of already discovered research projects. More... | |
void | getAvailableResearchProjects (std::vector< RuleResearch *> &projects, const Mod *mod, Base *base, bool considerDebugMode=false) const |
Get the list of ResearchProject which can be researched in a Base. More... | |
void | getNewlyAvailableResearchProjects (std::vector< RuleResearch *> &before, std::vector< RuleResearch *> &after, std::vector< RuleResearch *> &diff) const |
Get the list of newly available research projects once a research has been completed. More... | |
void | getAvailableProductions (std::vector< RuleManufacture *> &productions, const Mod *mod, Base *base) const |
Get the list of Productions which can be manufactured in a Base. More... | |
void | getDependableManufacture (std::vector< RuleManufacture *> &dependables, const RuleResearch *research, const Mod *mod, Base *base) const |
Get the list of newly available manufacture projects once a research has been completed. More... | |
bool | hasUndiscoveredProtectedUnlock (const RuleResearch *r, const Mod *mod) const |
Gets if a research still has undiscovered "protected unlocks". More... | |
bool | isResearched (const std::string &research, bool considerDebugMode=true) const |
Gets if a certain research has been completed. More... | |
bool | isResearched (const std::vector< std::string > &research, bool considerDebugMode=true) const |
Gets if a certain list of research topics has been completed. More... | |
Soldier * | getSoldier (int id) const |
Gets the soldier matching this ID. More... | |
bool | handlePromotions (std::vector< Soldier *> &participants) |
Handles the higher promotions. More... | |
void | processSoldier (Soldier *soldier, PromotionInfo &soldierData) |
Processes a soldier's promotion. More... | |
Soldier * | inspectSoldiers (std::vector< Soldier *> &soldiers, std::vector< Soldier *> &participants, int rank) |
Checks how many soldiers of a rank exist and which one has the highest score. More... | |
std::vector< AlienBase * > * | getAlienBases () |
Returns the list of alien bases. More... | |
void | setDebugMode () |
Sets debug mode. More... | |
bool | getDebugMode () const |
Gets debug mode. More... | |
std::vector< int64_t > & | getMaintenances () |
return a list of maintenance costs More... | |
void | addResearchScore (int score) |
sets the research score for the month More... | |
std::vector< int > & | getResearchScores () |
gets the list of research scores More... | |
std::vector< int64_t > & | getIncomes () |
gets the list of incomes. More... | |
std::vector< int64_t > & | getExpenditures () |
gets the list of expenditures. More... | |
bool | getWarned () const |
gets whether or not the player has been warned More... | |
void | setWarned (bool warned) |
sets whether or not the player has been warned More... | |
AlienStrategy & | getAlienStrategy () |
Full access to the alien strategy data. | |
const AlienStrategy & | getAlienStrategy () const |
Read-only access to the alien strategy data. | |
std::vector< AlienMission * > & | getAlienMissions () |
Full access to the current alien missions. | |
const std::vector< AlienMission * > & | getAlienMissions () const |
Read-only access to the current alien missions. | |
AlienMission * | findAlienMission (const std::string ®ion, MissionObjective objective) const |
Finds a mission by region and objective. More... | |
Region * | locateRegion (double lon, double lat) const |
Locate a region containing a position. More... | |
Region * | locateRegion (const Target &target) const |
Locate a region containing a Target. More... | |
int | getMonthsPassed () const |
Return the month counter. | |
const std::string & | getGraphRegionToggles () const |
Return the GraphRegionToggles. | |
const std::string & | getGraphCountryToggles () const |
Return the GraphCountryToggles. | |
const std::string & | getGraphFinanceToggles () const |
Return the GraphFinanceToggles. | |
void | setGraphRegionToggles (const std::string &value) |
Sets the GraphRegionToggles. More... | |
void | setGraphCountryToggles (const std::string &value) |
Sets the GraphCountryToggles. More... | |
void | setGraphFinanceToggles (const std::string &value) |
Sets the GraphFinanceToggles. More... | |
void | addMonth () |
Increment the month counter. | |
void | addPoppedResearch (const RuleResearch *research) |
add a research to the "popped up" array | |
bool | wasResearchPopped (const RuleResearch *research) |
check if a research is on the "popped up" array | |
void | removePoppedResearch (const RuleResearch *research) |
remove a research from the "popped up" array | |
std::vector< Soldier * > * | getDeadSoldiers () |
Gets the list of dead soldiers. More... | |
Base * | getSelectedBase () |
Gets the last selected player base. More... | |
void | setSelectedBase (size_t base) |
Set the last selected player base. More... | |
int | getSoldierScore (Soldier *soldier) |
Evaluate the score of a soldier based on all of his stats, missions and kills. More... | |
void | setLastSelectedArmor (const std::string &value) |
Sets the last selected armour. More... | |
std::string | getLastSelectedArmor () const |
Gets the last selected armour. More... | |
Craft * | findCraftByUniqueId (const CraftId &craftId) const |
Returns the craft corresponding to the specified unique id. More... | |
std::vector< MissionStatistics * > * | getMissionStatistics () |
Gets the list of missions statistics. More... | |
std::vector< Soldier * >::iterator | killSoldier (Soldier *soldier, BattleUnitKills *cause=0) |
Handles a soldier's death. More... | |
Static Public Member Functions | |
static std::string | sanitizeModName (const std::string &name) |
Sanitizies a mod name in a save. More... | |
static std::vector< SaveInfo > | getList (Language *lang, bool autoquick) |
Gets list of saves in the user directory. More... | |
The game data that gets written to disk when the game is saved.
A saved game holds all the variable info in a game like funds, game time, current bases and contents, world activities, score, etc.
OpenXcom::SavedGame::SavedGame | ( | ) |
Creates a new saved game.
Initializes a brand new saved game according to the specified difficulty.
OpenXcom::SavedGame::~SavedGame | ( | ) |
Cleans up the saved game.
Deletes the game content from memory.
void OpenXcom::SavedGame::addFinishedResearch | ( | const RuleResearch * | research, |
const Mod * | mod, | ||
Base * | base, | ||
bool | score = true |
||
) |
Add a finished ResearchProject.
Add a ResearchProject to the list of already discovered ResearchProject.
research | The newly found ResearchProject |
mod | the game Mod |
base | the base, in which the project was finished |
score | should the score be awarded or not? |
void OpenXcom::SavedGame::addFinishedResearchSimple | ( | const RuleResearch * | research | ) |
Add a finished ResearchProject.
Add a ResearchProject to the list of already discovered ResearchProject.
research | The newly found ResearchProject |
void OpenXcom::SavedGame::addResearchScore | ( | int | score | ) |
sets the research score for the month
adds to this month's research score
score | the amount to add. |
AlienMission * OpenXcom::SavedGame::findAlienMission | ( | const std::string & | region, |
MissionObjective | objective | ||
) | const |
Finds a mission by region and objective.
Find a mission type in the active alien missions.
region | The region string ID. |
objective | The active mission objective. |
Craft * OpenXcom::SavedGame::findCraftByUniqueId | ( | const CraftId & | craftId | ) | const |
Returns the craft corresponding to the specified unique id.
craftId | The unique craft id to look up. |
std::vector< AlienBase * > * OpenXcom::SavedGame::getAlienBases | ( | ) |
Returns the list of alien bases.
const std::map< std::string, int > & OpenXcom::SavedGame::getAllIds | ( | ) | const |
Resets the list of object IDs.
Resets the list of unique object IDs.
ids | New ID list. |
void OpenXcom::SavedGame::getAvailableProductions | ( | std::vector< RuleManufacture *> & | productions, |
const Mod * | mod, | ||
Base * | base | ||
) | const |
void OpenXcom::SavedGame::getAvailableResearchProjects | ( | std::vector< RuleResearch *> & | projects, |
const Mod * | mod, | ||
Base * | base, | ||
bool | considerDebugMode = false |
||
) | const |
Get the list of ResearchProject which can be researched in a Base.
Get the list of RuleResearch which can be researched in a Base.
projects | the list of ResearchProject which are available. |
mod | the game Mod |
base | a pointer to a Base |
considerDebugMode | Should debug mode be considered or not. |
int OpenXcom::SavedGame::getBaseMaintenance | ( | ) | const |
Gets the total base maintenance.
Adds up the monthly maintenance of all the bases.
std::vector< Base * > * OpenXcom::SavedGame::getBases | ( | ) |
Gets the list of bases.
Returns the list of player bases.
const std::vector< Base * > * OpenXcom::SavedGame::getBases | ( | ) | const |
Gets the list of bases.
Returns an immutable list of player bases.
std::vector< Country * > * OpenXcom::SavedGame::getCountries | ( | ) |
Gets the list of countries.
Returns the list of countries in the game world.
int OpenXcom::SavedGame::getCountryFunding | ( | ) | const |
Gets the total country funding.
Adds up the monthly funding of all the countries.
std::vector< Soldier * > * OpenXcom::SavedGame::getDeadSoldiers | ( | ) |
Gets the list of dead soldiers.
Returns the list of dead soldiers.
bool OpenXcom::SavedGame::getDebugMode | ( | ) | const |
Gets debug mode.
Gets the current debug mode.
void OpenXcom::SavedGame::getDependableManufacture | ( | std::vector< RuleManufacture *> & | dependables, |
const RuleResearch * | research, | ||
const Mod * | mod, | ||
Base * | base | ||
) | const |
Get the list of newly available manufacture projects once a research has been completed.
Get the list of newly available manufacture projects once a ResearchProject has been completed.
This function check for fake ResearchProject.
dependables | the list of RuleManufacture which are now available. |
research | The RuleResearch which has just been discovered |
mod | the Game Mod |
base | a pointer to a Base |
GameDifficulty OpenXcom::SavedGame::getDifficulty | ( | ) | const |
Gets the game difficulty.
Returns the game's difficulty level.
int OpenXcom::SavedGame::getDifficultyCoefficient | ( | ) | const |
Gets the game difficulty coefficient.
Returns the game's difficulty coefficient based on the current level.
const std::vector< const RuleResearch * > & OpenXcom::SavedGame::getDiscoveredResearch | ( | ) | const |
Get the list of already discovered research projects.
Returns the list of already discovered ResearchProject.
GameEnding OpenXcom::SavedGame::getEnding | ( | ) | const |
Gets the game ending.
Returns the game's current ending.
std::vector< int64_t > & OpenXcom::SavedGame::getExpenditures | ( | ) |
gets the list of expenditures.
return the list of expenditures scores
int64_t OpenXcom::SavedGame::getFunds | ( | ) | const |
Gets the current funds.
Returns the player's current funds.
std::vector< int64_t > & OpenXcom::SavedGame::getFundsList | ( | ) |
Gets the list of funds from previous months.
Returns the player's funds for the last 12 months.
double OpenXcom::SavedGame::getGlobeLatitude | ( | ) | const |
Gets the current globe latitude.
Returns the current latitude of the Geoscape globe.
double OpenXcom::SavedGame::getGlobeLongitude | ( | ) | const |
Gets the current globe longitude.
Returns the current longitude of the Geoscape globe.
int OpenXcom::SavedGame::getGlobeZoom | ( | ) | const |
Gets the current globe zoom.
Returns the current zoom level of the Geoscape globe.
int OpenXcom::SavedGame::getId | ( | const std::string & | name | ) |
Gets the current ID for an object.
Returns the latest ID for the specified object and increases it.
name | Object name. |
std::vector< int64_t > & OpenXcom::SavedGame::getIncomes | ( | ) |
gets the list of incomes.
return the list of income scores
std::string OpenXcom::SavedGame::getLastSelectedArmor | ( | ) | const |
Gets the last selected armour.
Gets list of saves in the user directory.
Gets all the info of the saves found in the user folder.
lang | Loaded language. |
autoquick | Include autosaves and quicksaves. |
std::vector< int64_t > & OpenXcom::SavedGame::getMaintenances | ( | ) |
return a list of maintenance costs
return the list of monthly maintenance costs
std::vector< MissionSite * > * OpenXcom::SavedGame::getMissionSites | ( | ) |
Gets the list of mission sites.
Returns the list of mission sites.
std::vector< MissionStatistics * > * OpenXcom::SavedGame::getMissionStatistics | ( | ) |
Gets the list of missions statistics.
Returns the list of mission statistics.
std::string OpenXcom::SavedGame::getName | ( | ) | const |
Gets the game name.
Returns the game's name shown in Save screens.
void OpenXcom::SavedGame::getNewlyAvailableResearchProjects | ( | std::vector< RuleResearch *> & | before, |
std::vector< RuleResearch *> & | after, | ||
std::vector< RuleResearch *> & | diff | ||
) | const |
Get the list of newly available research projects once a research has been completed.
Get the list of newly available research projects once a ResearchProject has been completed.
before | the list of available RuleResearch before completing new research. |
after | the list of available RuleResearch after completing new research. |
diff | the list of newly available RuleResearch after completing new research (after - before). |
std::vector< Region * > * OpenXcom::SavedGame::getRegions | ( | ) |
Gets the list of regions.
Returns the list of world regions.
std::vector< int > & OpenXcom::SavedGame::getResearchScores | ( | ) |
gets the list of research scores
return the list of research scores
SavedBattleGame * OpenXcom::SavedGame::getSavedBattle | ( | ) |
Gets the current battle game.
Get pointer to the battleGame object.
Base * OpenXcom::SavedGame::getSelectedBase | ( | ) |
Gets the last selected player base.
Returns the last selected player base.
Soldier * OpenXcom::SavedGame::getSoldier | ( | int | id | ) | const |
int OpenXcom::SavedGame::getSoldierScore | ( | Soldier * | soldier | ) |
Evaluate the score of a soldier based on all of his stats, missions and kills.
soldier | the soldier to get a score for. |
GameTime * OpenXcom::SavedGame::getTime | ( | ) | const |
Gets the current game time.
Returns the current time of the game.
std::vector< Ufo * > * OpenXcom::SavedGame::getUfos | ( | ) |
Gets the list of UFOs.
Returns the list of alien UFOs.
bool OpenXcom::SavedGame::getWarned | ( | ) | const |
gets whether or not the player has been warned
return if the player has been warned about poor performance.
std::vector< Waypoint * > * OpenXcom::SavedGame::getWaypoints | ( | ) |
Gets the list of waypoints.
Returns the list of craft waypoints.
bool OpenXcom::SavedGame::handlePromotions | ( | std::vector< Soldier *> & | participants | ) |
Handles the higher promotions.
Handles the higher promotions (not the rookie-squaddie ones).
participants | a list of soldiers that were actually present at the battle. |
bool OpenXcom::SavedGame::hasUndiscoveredProtectedUnlock | ( | const RuleResearch * | r, |
const Mod * | mod | ||
) | const |
Soldier * OpenXcom::SavedGame::inspectSoldiers | ( | std::vector< Soldier *> & | soldiers, |
std::vector< Soldier *> & | participants, | ||
int | rank | ||
) |
Checks how many soldiers of a rank exist and which one has the highest score.
soldiers | full list of live soldiers. |
participants | list of participants on this mission. |
rank | Rank to inspect. |
bool OpenXcom::SavedGame::isIronman | ( | ) | const |
Gets if the game is in ironman mode.
Returns if the game is set to ironman mode.
Ironman games cannot be manually saved.
bool OpenXcom::SavedGame::isResearched | ( | const std::string & | research, |
bool | considerDebugMode = true |
||
) | const |
Gets if a certain research has been completed.
Returns if a certain research topic has been completed.
research | Research ID. |
considerDebugMode | Should debug mode be considered or not. |
bool OpenXcom::SavedGame::isResearched | ( | const std::vector< std::string > & | research, |
bool | considerDebugMode = true |
||
) | const |
Gets if a certain list of research topics has been completed.
Returns if a certain list of research topics has been completed.
research | List of research IDs. |
considerDebugMode | Should debug mode be considered or not. |
std::vector< Soldier * >::iterator OpenXcom::SavedGame::killSoldier | ( | Soldier * | soldier, |
BattleUnitKills * | cause = 0 |
||
) |
Handles a soldier's death.
Registers a soldier's death in the memorial.
soldier | Pointer to dead soldier. |
cause | Pointer to cause of death, NULL if missing in action. |
void OpenXcom::SavedGame::load | ( | const std::string & | filename, |
Mod * | mod | ||
) |
Loads a saved game from YAML.
Loads a saved game's contents from a YAML file.
filename | YAML filename. |
mod | Mod for the saved game. |
Region * OpenXcom::SavedGame::locateRegion | ( | double | lon, |
double | lat | ||
) | const |
Locate a region containing a position.
Find the region containing this location.
lon | The longtitude. |
lat | The latitude. |
Locate a region containing a Target.
Find the region containing this target.
target | The target to locate. |
void OpenXcom::SavedGame::monthlyFunding | ( | ) |
Handles monthly funding.
Gives the player his monthly funds, taking in account all maintenance and profit costs.
void OpenXcom::SavedGame::processSoldier | ( | Soldier * | soldier, |
PromotionInfo & | soldierData | ||
) |
Processes a soldier's promotion.
Processes a soldier, and adds their rank to the promotions data array.
soldier | the soldier to process. |
soldierData | the data array to put their info into. |
|
static |
Sanitizies a mod name in a save.
Removes version number from a mod name, if any.
name | Mod id from a savegame. |
void OpenXcom::SavedGame::save | ( | const std::string & | filename | ) | const |
Saves a saved game to YAML.
Saves a saved game's contents to a YAML file.
filename | YAML filename. |
void OpenXcom::SavedGame::setAllIds | ( | const std::map< std::string, int > & | ids | ) |
Resets the list of object IDs.
Resets the list of unique object IDs.
ids | New ID list. |
void OpenXcom::SavedGame::setBattleGame | ( | SavedBattleGame * | battleGame | ) |
Sets the current battle game.
Set battleGame object.
battleGame | Pointer to the battleGame object. |
void OpenXcom::SavedGame::setDebugMode | ( | ) |
Sets debug mode.
Toggles debug mode.
void OpenXcom::SavedGame::setDifficulty | ( | GameDifficulty | difficulty | ) |
Sets the game difficulty.
Changes the game's difficulty to a new level.
difficulty | New difficulty. |
void OpenXcom::SavedGame::setEnding | ( | GameEnding | end | ) |
Sets the game ending.
Changes the game's current ending.
end | New ending. |
void OpenXcom::SavedGame::setFunds | ( | int64_t | funds | ) |
Sets new funds.
Changes the player's funds to a new value.
funds | New funds. |
void OpenXcom::SavedGame::setGlobeLatitude | ( | double | lat | ) |
Sets the new globe latitude.
Changes the current latitude of the Geoscape globe.
lat | Latitude. |
void OpenXcom::SavedGame::setGlobeLongitude | ( | double | lon | ) |
Sets the new globe longitude.
Changes the current longitude of the Geoscape globe.
lon | Longitude. |
void OpenXcom::SavedGame::setGlobeZoom | ( | int | zoom | ) |
Sets the new globe zoom.
Changes the current zoom level of the Geoscape globe.
zoom | Zoom level. |
void OpenXcom::SavedGame::setGraphCountryToggles | ( | const std::string & | value | ) |
Sets the GraphCountryToggles.
value | The new value for GraphCountryToggles. |
void OpenXcom::SavedGame::setGraphFinanceToggles | ( | const std::string & | value | ) |
Sets the GraphFinanceToggles.
value | The new value for GraphFinanceToggles. |
void OpenXcom::SavedGame::setGraphRegionToggles | ( | const std::string & | value | ) |
Sets the GraphRegionToggles.
value | The new value for GraphRegionToggles. |
void OpenXcom::SavedGame::setIronman | ( | bool | ironman | ) |
Sets if the game is in ironman mode.
Changes if the game is set to ironman mode.
Ironman games cannot be manually saved.
ironman | Tony Stark |
void OpenXcom::SavedGame::setLastSelectedArmor | ( | const std::string & | value | ) |
Sets the last selected armour.
value | The new value for last selected armor - Armor type string. |
void OpenXcom::SavedGame::setName | ( | const std::string & | name | ) |
Sets the game name.
Changes the game's name shown in Save screens.
name | New name. |
void OpenXcom::SavedGame::setSelectedBase | ( | size_t | base | ) |
Set the last selected player base.
Sets the last selected player base.
base | number of the base. |
void OpenXcom::SavedGame::setTime | ( | const GameTime & | time | ) |
void OpenXcom::SavedGame::setWarned | ( | bool | warned | ) |
sets whether or not the player has been warned
sets the player's "warned" status.
warned | set "warned" to this. |