OpenXcom  1.0
Open-source clone of the original X-Com
SavedGame.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_SAVEDGAME_H
20 #define OPENXCOM_SAVEDGAME_H
21 
22 #include <map>
23 #include <vector>
24 #include <string>
25 #include <time.h>
26 
27 namespace OpenXcom
28 {
29 
30 class Ruleset;
31 class GameTime;
32 class Country;
33 class Base;
34 class Region;
35 class Ufo;
36 class Waypoint;
37 class SavedBattleGame;
38 class TextList;
39 class Language;
40 class RuleResearch;
41 class ResearchProject;
42 class Soldier;
43 class RuleManufacture;
44 class TerrorSite;
45 class AlienBase;
46 class AlienStrategy;
47 class AlienMission;
48 class Target;
49 class Soldier;
50 
54 enum GameDifficulty { DIFF_BEGINNER = 0, DIFF_EXPERIENCED, DIFF_VETERAN, DIFF_GENIUS, DIFF_SUPERHUMAN };
55 
59 enum SaveType { SAVE_DEFAULT, SAVE_QUICK, SAVE_AUTO_GEOSCAPE, SAVE_AUTO_BATTLESCAPE, SAVE_IRONMAN, SAVE_IRONMAN_END };
60 
64 struct SaveInfo
65 {
66  std::string fileName;
67  std::wstring displayName;
68  time_t timestamp;
69  std::wstring isoDate, isoTime;
70  std::wstring details;
71  std::vector<std::string> rulesets;
72  bool reserved;
73 };
74 
80 class SavedGame
81 {
82 private:
83  std::wstring _name;
84  GameDifficulty _difficulty;
85  bool _ironman;
86  GameTime *_time;
87  std::vector<int> _funds, _maintenance, _researchScores, _incomes, _expenditures;
88  double _globeLon, _globeLat;
89  int _globeZoom;
90  std::map<std::string, int> _ids;
91  std::vector<Country*> _countries;
92  std::vector<Region*> _regions;
93  std::vector<Base*> _bases;
94  std::vector<Ufo*> _ufos;
95  std::vector<Waypoint*> _waypoints;
96  std::vector<TerrorSite*> _terrorSites;
97  std::vector<AlienBase*> _alienBases;
98  AlienStrategy *_alienStrategy;
99  SavedBattleGame *_battleGame;
100  std::vector<const RuleResearch *> _discovered;
101  std::vector<AlienMission*> _activeMissions;
102  bool _debug, _warned;
103  int _monthsPassed;
104  std::string _graphRegionToggles;
105  std::string _graphCountryToggles;
106  std::string _graphFinanceToggles;
107  std::vector<const RuleResearch *> _poppedResearch;
108  std::vector<Soldier*> _deadSoldiers;
109  size_t _selectedBase;
110 
111  void getDependableResearchBasic (std::vector<RuleResearch *> & dependables, const RuleResearch *research, const Ruleset * ruleset, Base * base) const;
112  static SaveInfo getSaveInfo(const std::string &file, Language *lang);
113 public:
114  static const std::string AUTOSAVE_GEOSCAPE, AUTOSAVE_BATTLESCAPE, QUICKSAVE;
115 
117  SavedGame();
119  ~SavedGame();
121  static std::vector<SaveInfo> getList(Language *lang, bool autoquick);
123  void load(const std::string &filename, Ruleset *rule);
125  void save(const std::string &filename) const;
127  std::wstring getName() const;
129  void setName(const std::wstring &name);
131  GameDifficulty getDifficulty() const;
133  void setDifficulty(GameDifficulty difficulty);
135  bool isIronman() const;
137  void setIronman(bool ironman);
139  int getFunds() const;
141  const std::vector<int> &getFundsList() const;
143  void setFunds(int funds);
145  double getGlobeLongitude() const;
147  void setGlobeLongitude(double lon);
149  double getGlobeLatitude() const;
151  void setGlobeLatitude(double lat);
153  int getGlobeZoom() const;
155  void setGlobeZoom(int zoom);
157  void monthlyFunding();
159  GameTime *getTime() const;
161  void setTime(GameTime time);
163  int getId(const std::string &name);
165  std::vector<Country*> *getCountries();
167  int getCountryFunding() const;
169  std::vector<Region*> *getRegions();
171  std::vector<Base*> *getBases();
173  const std::vector<Base*> *getBases() const;
175  int getBaseMaintenance() const;
177  std::vector<Ufo*> *getUfos();
179  std::vector<Waypoint*> *getWaypoints();
181  std::vector<TerrorSite*> *getTerrorSites();
183  SavedBattleGame *getSavedBattle();
185  void setBattleGame(SavedBattleGame *battleGame);
187  void addFinishedResearch (const RuleResearch * r, const Ruleset * ruleset = NULL);
189  const std::vector<const RuleResearch *> & getDiscoveredResearch() const;
191  void getAvailableResearchProjects (std::vector<RuleResearch *> & projects, const Ruleset * ruleset, Base * base) const;
193  void getAvailableProductions (std::vector<RuleManufacture *> & productions, const Ruleset * ruleset, Base * base) const;
195  void getDependableResearch (std::vector<RuleResearch *> & dependables, const RuleResearch *research, const Ruleset * ruleset, Base * base) const;
197  void getDependableManufacture (std::vector<RuleManufacture *> & dependables, const RuleResearch *research, const Ruleset * ruleset, Base * base) const;
199  bool isResearchAvailable (RuleResearch * r, const std::vector<const RuleResearch *> & unlocked, const Ruleset * ruleset) const;
201  bool isResearched(const std::string &research) const;
203  bool isResearched(const std::vector<std::string> &research) const;
205  Soldier *getSoldier(int id) const;
207  bool handlePromotions(std::vector<Soldier*> &participants);
209  void inspectSoldiers(Soldier **highestRanked, size_t *total, int rank);
211  std::vector<AlienBase*> *getAlienBases();
213  void setDebugMode();
215  bool getDebugMode() const;
217  std::vector<int> getMaintenances();
219  void addResearchScore(int score);
221  std::vector<int> &getResearchScores();
223  std::vector<int> getIncomes();
225  std::vector<int> getExpenditures();
227  bool getWarned() const;
229  void setWarned(bool warned);
231  AlienStrategy &getAlienStrategy() { return *_alienStrategy; }
233  const AlienStrategy &getAlienStrategy() const { return *_alienStrategy; }
235  std::vector<AlienMission*> &getAlienMissions() { return _activeMissions; }
237  const std::vector<AlienMission*> &getAlienMissions() const { return _activeMissions; }
239  AlienMission *getAlienMission(const std::string &region, const std::string &type) const;
241  Region *locateRegion(double lon, double lat) const;
243  Region *locateRegion(const Target &target) const;
245  int getMonthsPassed() const;
247  const std::string &getGraphRegionToggles() const;
249  const std::string &getGraphCountryToggles() const;
251  const std::string &getGraphFinanceToggles() const;
253  void setGraphRegionToggles(const std::string &value);
255  void setGraphCountryToggles(const std::string &value);
257  void setGraphFinanceToggles(const std::string &value);
259  void addMonth();
261  void addPoppedResearch(const RuleResearch* research);
263  bool wasResearchPopped(const RuleResearch* research);
265  void removePoppedResearch(const RuleResearch* research);
267  std::vector<Soldier*> *getDeadSoldiers();
269  Base *getSelectedBase();
271  void setSelectedBase(size_t base);
273  int getSoldierScore(Soldier *soldier);
274 };
275 
276 }
277 
278 #endif
SaveType
Enumerator for the various save types.
Definition: SavedGame.h:59
Stores the information about alien strategy.
Definition: AlienStrategy.h:32
Represents an ongoing alien mission.
Definition: AlienMission.h:45
const std::vector< AlienMission * > & getAlienMissions() const
Read-only access to the current alien missions.
Definition: SavedGame.h:237
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:80
AlienStrategy & getAlienStrategy()
Full access to the alien strategy data.
Definition: SavedGame.h:231
const AlienStrategy & getAlienStrategy() const
Read-only access to the alien strategy data.
Definition: SavedGame.h:233
GameDifficulty
Enumerator containing all the possible game difficulties.
Definition: SavedGame.h:54
Contains strings used throughout the game for localization.
Definition: Language.h:42
Set of rules and stats for a game.
Definition: Ruleset.h:69
Stores the current ingame time/date according to GMT.
Definition: GameTime.h:40
Represents a soldier hired by the player.
Definition: Soldier.h:49
Represents a player base on the globe.
Definition: Base.h:47
Represents one research project.
Definition: RuleResearch.h:40
std::vector< AlienMission * > & getAlienMissions()
Full access to the current alien missions.
Definition: SavedGame.h:235
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:50
Represents a region of the world.
Definition: Region.h:35
Base class for targets on the globe with a set of radian coordinates.
Definition: Target.h:35
Container for savegame info displayed on listings.
Definition: SavedGame.h:64
COPYING:
Definition: BaseInfoState.cpp:40