OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
OpenXcom::SavedGame Class Reference

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, Ruleset *rule)
 Loads a saved game from YAML. More...
 
void save (const std::string &filename) const
 Saves a saved game to YAML. More...
 
std::wstring getName () const
 Gets the game name. More...
 
void setName (const std::wstring &name)
 Sets the game name. More...
 
GameDifficulty getDifficulty () const
 Gets the game difficulty. More...
 
void setDifficulty (GameDifficulty difficulty)
 Sets the game difficulty. 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...
 
int getFunds () const
 Gets the current funds. More...
 
const std::vector< int > & getFundsList () const
 Gets the list of funds from previous months. More...
 
void setFunds (int 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...
 
GameTimegetTime () const
 Gets the current game time. More...
 
void setTime (GameTime time)
 Sets the current game time. More...
 
int getId (const std::string &name)
 Gets the current ID for an object. 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< TerrorSite * > * getTerrorSites ()
 Gets the list of terror sites. More...
 
SavedBattleGamegetSavedBattle ()
 Gets the current battle game. More...
 
void setBattleGame (SavedBattleGame *battleGame)
 Sets the current battle game. More...
 
void addFinishedResearch (const RuleResearch *r, const Ruleset *ruleset=NULL)
 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 Ruleset *ruleset, Base *base) const
 Get the list of ResearchProject which can be researched in a Base. More...
 
void getAvailableProductions (std::vector< RuleManufacture * > &productions, const Ruleset *ruleset, Base *base) const
 Get the list of Productions which can be manufactured in a Base. More...
 
void getDependableResearch (std::vector< RuleResearch * > &dependables, const RuleResearch *research, const Ruleset *ruleset, Base *base) const
 Get the list of newly available research projects once a research has been completed. More...
 
void getDependableManufacture (std::vector< RuleManufacture * > &dependables, const RuleResearch *research, const Ruleset *ruleset, Base *base) const
 Get the list of newly available manufacture projects once a research has been completed. More...
 
bool isResearchAvailable (RuleResearch *r, const std::vector< const RuleResearch * > &unlocked, const Ruleset *ruleset) const
 Check whether a ResearchProject can be researched. More...
 
bool isResearched (const std::string &research) const
 Gets if a research has been unlocked. More...
 
bool isResearched (const std::vector< std::string > &research) const
 Gets if a list of research has been unlocked. More...
 
SoldiergetSoldier (int id) const
 Gets the soldier matching this ID. More...
 
bool handlePromotions (std::vector< Soldier * > &participants)
 Handles the higher promotions. More...
 
void inspectSoldiers (Soldier **highestRanked, size_t *total, 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< int > 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< int > getIncomes ()
 gets the list of incomes. More...
 
std::vector< int > 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...
 
AlienStrategygetAlienStrategy ()
 Full access to the alien strategy data.
 
const AlienStrategygetAlienStrategy () 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.
 
AlienMissiongetAlienMission (const std::string &region, const std::string &type) const
 Gets a mission matching region and type. More...
 
RegionlocateRegion (double lon, double lat) const
 Locate a region containing a position. More...
 
RegionlocateRegion (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...
 
BasegetSelectedBase ()
 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...
 

Static Public Member Functions

static std::vector< SaveInfogetList (Language *lang, bool autoquick)
 Gets list of saves in the user directory. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

void OpenXcom::SavedGame::addFinishedResearch ( const RuleResearch r,
const Ruleset ruleset = NULL 
)

Add a finished ResearchProject.

Add a ResearchProject to the list of already discovered ResearchProject.

Parameters
rThe newly found ResearchProject
rulesetthe game Ruleset
void OpenXcom::SavedGame::addResearchScore ( int  score)

sets the research score for the month

adds to this month's research score

Parameters
scorethe amount to add.
std::vector< AlienBase * > * OpenXcom::SavedGame::getAlienBases ( )

Returns the list of alien bases.

Returns
Pointer to alien base list.
AlienMission * OpenXcom::SavedGame::getAlienMission ( const std::string &  region,
const std::string &  type 
) const

Gets a mission matching region and type.

Find a mission from the active alien missions.

Parameters
regionThe region ID.
typeThe mission type ID.
Returns
A pointer to the mission, or 0 if no mission matched.
void OpenXcom::SavedGame::getAvailableProductions ( std::vector< RuleManufacture * > &  productions,
const Ruleset ruleset,
Base base 
) const

Get the list of Productions which can be manufactured in a Base.

Get the list of RuleManufacture which can be manufacture in a Base.

Parameters
productionsthe list of Productions which are available.
rulesetthe Game Ruleset
basea pointer to a Base
void OpenXcom::SavedGame::getAvailableResearchProjects ( std::vector< RuleResearch * > &  projects,
const Ruleset ruleset,
Base base 
) 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.

Parameters
projectsthe list of ResearchProject which are available.
rulesetthe game Ruleset
basea pointer to a Base
int OpenXcom::SavedGame::getBaseMaintenance ( ) const

Gets the total base maintenance.

Adds up the monthly maintenance of all the bases.

Returns
Total maintenance.
std::vector< Base * > * OpenXcom::SavedGame::getBases ( )

Gets the list of bases.

Returns the list of player bases.

Returns
Pointer to base list.
const std::vector< Base * > * OpenXcom::SavedGame::getBases ( ) const

Gets the list of bases.

Returns an immutable list of player bases.

Returns
Pointer to base list.
std::vector< Country * > * OpenXcom::SavedGame::getCountries ( )

Gets the list of countries.

Returns the list of countries in the game world.

Returns
Pointer to country list.
int OpenXcom::SavedGame::getCountryFunding ( ) const

Gets the total country funding.

Adds up the monthly funding of all the countries.

Returns
Total funding.
std::vector< Soldier * > * OpenXcom::SavedGame::getDeadSoldiers ( )

Gets the list of dead soldiers.

Returns the list of dead soldiers.

Returns
Pointer to soldier list.
bool OpenXcom::SavedGame::getDebugMode ( ) const

Gets debug mode.

Gets the current debug mode.

Returns
Debug mode.
void OpenXcom::SavedGame::getDependableManufacture ( std::vector< RuleManufacture * > &  dependables,
const RuleResearch research,
const Ruleset ruleset,
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.

Parameters
dependablesthe list of RuleManufacture which are now available.
researchThe RuleResearch which has just been discovered
rulesetthe Game Ruleset
basea pointer to a Base
void OpenXcom::SavedGame::getDependableResearch ( std::vector< RuleResearch * > &  dependables,
const RuleResearch research,
const Ruleset ruleset,
Base base 
) 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.

This function check for fake ResearchProject.

Parameters
dependablesthe list of RuleResearch which are now available.
researchThe RuleResearch which has just been discovered
rulesetthe Game Ruleset
basea pointer to a Base
GameDifficulty OpenXcom::SavedGame::getDifficulty ( ) const

Gets the game difficulty.

Returns the game's difficulty level.

Returns
Difficulty 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.

Returns
the list of already discovered ResearchProject
std::vector< int > OpenXcom::SavedGame::getExpenditures ( )

gets the list of expenditures.

return the list of expenditures scores

Returns
list of expenditures scores.
int OpenXcom::SavedGame::getFunds ( ) const

Gets the current funds.

Returns the player's current funds.

Returns
Current funds.
const std::vector< int > & OpenXcom::SavedGame::getFundsList ( ) const

Gets the list of funds from previous months.

Returns the player's funds for the last 12 months.

Returns
funds.
double OpenXcom::SavedGame::getGlobeLatitude ( ) const

Gets the current globe latitude.

Returns the current latitude of the Geoscape globe.

Returns
Latitude.
double OpenXcom::SavedGame::getGlobeLongitude ( ) const

Gets the current globe longitude.

Returns the current longitude of the Geoscape globe.

Returns
Longitude.
int OpenXcom::SavedGame::getGlobeZoom ( ) const

Gets the current globe zoom.

Returns the current zoom level of the Geoscape globe.

Returns
Zoom level.
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.

Parameters
nameObject name.
Returns
Latest ID number.
std::vector< int > OpenXcom::SavedGame::getIncomes ( )

gets the list of incomes.

return the list of income scores

Returns
list of income scores.
std::vector< SaveInfo > OpenXcom::SavedGame::getList ( Language lang,
bool  autoquick 
)
static

Gets list of saves in the user directory.

Gets all the info of the saves found in the user folder.

Parameters
langLoaded language.
autoquickInclude autosaves and quicksaves.
Returns
List of saves info.
std::vector< int > OpenXcom::SavedGame::getMaintenances ( )

return a list of maintenance costs

return the list of monthly maintenance costs

Returns
list of maintenances.
std::wstring OpenXcom::SavedGame::getName ( ) const

Gets the game name.

Returns the game's name shown in Save screens.

Returns
Save name.
std::vector< Region * > * OpenXcom::SavedGame::getRegions ( )

Gets the list of regions.

Returns the list of world regions.

Returns
Pointer to region list.
std::vector< int > & OpenXcom::SavedGame::getResearchScores ( )

gets the list of research scores

return the list of research scores

Returns
list of research scores.
SavedBattleGame * OpenXcom::SavedGame::getSavedBattle ( )

Gets the current battle game.

Get pointer to the battleGame object.

Returns
Pointer to the battleGame object.
Base * OpenXcom::SavedGame::getSelectedBase ( )

Gets the last selected player base.

Returns the last selected player base.

Returns
Pointer to base.
Soldier * OpenXcom::SavedGame::getSoldier ( int  id) const

Gets the soldier matching this ID.

Returns pointer to the Soldier given it's unique ID.

Parameters
idA soldier's unique id.
Returns
Pointer to Soldier.
int OpenXcom::SavedGame::getSoldierScore ( Soldier soldier)

Evaluate the score of a soldier based on all of his stats, missions and kills.

Parameters
soldierthe soldier to get a score for.
Returns
this soldier's score.
std::vector< TerrorSite * > * OpenXcom::SavedGame::getTerrorSites ( )

Gets the list of terror sites.

Returns the list of terror sites.

Returns
Pointer to terror site list.
GameTime * OpenXcom::SavedGame::getTime ( ) const

Gets the current game time.

Returns the current time of the game.

Returns
Pointer to the game time.
std::vector< Ufo * > * OpenXcom::SavedGame::getUfos ( )

Gets the list of UFOs.

Returns the list of alien UFOs.

Returns
Pointer to UFO list.
bool OpenXcom::SavedGame::getWarned ( ) const

gets whether or not the player has been warned

return if the player has been warned about poor performance.

Returns
true or false.
std::vector< Waypoint * > * OpenXcom::SavedGame::getWaypoints ( )

Gets the list of waypoints.

Returns the list of craft waypoints.

Returns
Pointer to waypoint list.
bool OpenXcom::SavedGame::handlePromotions ( std::vector< Soldier * > &  participants)

Handles the higher promotions.

Handles the higher promotions (not the rookie-squaddie ones).

Parameters
participantsa list of soldiers that were actually present at the battle.
Returns
Whether or not some promotions happened - to show the promotions screen.
void OpenXcom::SavedGame::inspectSoldiers ( Soldier **  highestRanked,
size_t *  total,
int  rank 
)

Checks how many soldiers of a rank exist and which one has the highest score.

Parameters
highestRankedPointer to store the highest-scoring soldier of that rank.
totalPointer to an int to store the total in.
rankRank 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.

Returns
Tony Stark
bool OpenXcom::SavedGame::isResearchAvailable ( RuleResearch r,
const std::vector< const RuleResearch * > &  unlocked,
const Ruleset ruleset 
) const

Check whether a ResearchProject can be researched.

Parameters
rthe RuleResearch to test.
unlockedthe list of currently unlocked RuleResearch
rulesetthe current Ruleset
Returns
true if the RuleResearch can be researched
bool OpenXcom::SavedGame::isResearched ( const std::string &  research) const

Gets if a research has been unlocked.

Returns if a certain research has been completed.

Parameters
researchResearch ID.
Returns
Whether it's researched or not.
bool OpenXcom::SavedGame::isResearched ( const std::vector< std::string > &  research) const

Gets if a list of research has been unlocked.

Returns if a certain list of research has been completed.

Parameters
researchList of research IDs.
Returns
Whether it's researched or not.
void OpenXcom::SavedGame::load ( const std::string &  filename,
Ruleset rule 
)

Loads a saved game from YAML.

Loads a saved game's contents from a YAML file.

Note
Assumes the saved game is blank.
Parameters
filenameYAML filename.
ruleRuleset 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.

Parameters
lonThe longtitude.
latThe latitude.
Returns
Pointer to the region, or 0.
Region * OpenXcom::SavedGame::locateRegion ( const Target target) const

Locate a region containing a Target.

Find the region containing this target.

Parameters
targetThe target to locate.
Returns
Pointer to the region, or 0.
void OpenXcom::SavedGame::monthlyFunding ( )

Handles monthly funding.

Gives the player his monthly funds, taking in account all maintenance and profit costs.

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.

Parameters
filenameYAML filename.
void OpenXcom::SavedGame::setBattleGame ( SavedBattleGame battleGame)

Sets the current battle game.

Set battleGame object.

Parameters
battleGamePointer 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.

Parameters
difficultyNew difficulty.
void OpenXcom::SavedGame::setFunds ( int  funds)

Sets new funds.

Changes the player's funds to a new value.

Parameters
fundsNew funds.
void OpenXcom::SavedGame::setGlobeLatitude ( double  lat)

Sets the new globe latitude.

Changes the current latitude of the Geoscape globe.

Parameters
latLatitude.
void OpenXcom::SavedGame::setGlobeLongitude ( double  lon)

Sets the new globe longitude.

Changes the current longitude of the Geoscape globe.

Parameters
lonLongitude.
void OpenXcom::SavedGame::setGlobeZoom ( int  zoom)

Sets the new globe zoom.

Changes the current zoom level of the Geoscape globe.

Parameters
zoomZoom level.
void OpenXcom::SavedGame::setGraphCountryToggles ( const std::string &  value)

Sets the GraphCountryToggles.

Parameters
valueThe new value for GraphCountryToggles.
void OpenXcom::SavedGame::setGraphFinanceToggles ( const std::string &  value)

Sets the GraphFinanceToggles.

Parameters
valueThe new value for GraphFinanceToggles.
void OpenXcom::SavedGame::setGraphRegionToggles ( const std::string &  value)

Sets the GraphRegionToggles.

Parameters
valueThe 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.

Parameters
ironmanTony Stark
void OpenXcom::SavedGame::setName ( const std::wstring &  name)

Sets the game name.

Changes the game's name shown in Save screens.

Parameters
nameNew name.
void OpenXcom::SavedGame::setSelectedBase ( size_t  base)

Set the last selected player base.

Sets the last selected player base.

Parameters
basenumber of the base.
void OpenXcom::SavedGame::setTime ( GameTime  time)

Sets the current game time.

Changes the current time of the game.

Parameters
timeGame time.
void OpenXcom::SavedGame::setWarned ( bool  warned)

sets whether or not the player has been warned

sets the player's "warned" status.

Parameters
warnedset "warned" to this.

The documentation for this class was generated from the following files: