From 5eaf6cc1f9ab772139a2dbe6d325a7ab9879e01b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 Nov 2013 19:20:06 +0000 Subject: Prevent player reputation for the 'default' faction from getting loaded from savegame. --- src/game/base/faction.h | 20 +++++++++++++++++++- src/game/base/savegame.cc | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/base/faction.h b/src/game/base/faction.h index 3f6a1e5..551ce7b 100644 --- a/src/game/base/faction.h +++ b/src/game/base/faction.h @@ -84,6 +84,9 @@ public: */ static bool init(); + /** + * @brief cleanup routines + */ static void done(); /** @@ -91,6 +94,9 @@ public: */ static void list(); + /** + * @brief returns a pointer to the faction with the given label, returns 0 if not found. + * */ static Faction *find(const std::string & label); /** @@ -98,11 +104,23 @@ public: * */ static void apply_default(core::Reputation & reputation); - + /** + * @brief faction info type + * */ static inline const core::InfoType *infotype() { return faction_infotype; } + /** + * @brief default faction + * This faction represents the default player reputation. + * No ships should be a member of this faction, not even player ships. + * */ + static inline const Faction *default_faction() + { + return faction_default; + } + private: /* --- attributes ------------------------------------------------- */ diff --git a/src/game/base/savegame.cc b/src/game/base/savegame.cc index 90b7956..28f0ddb 100644 --- a/src/game/base/savegame.cc +++ b/src/game/base/savegame.cc @@ -99,6 +99,8 @@ void SaveGame::load_game(core::Player *player, filesystem::IniFile & inifile) } else if (inifile.got_key_float("reputation", reputation)) { if (!faction) { inifile.unknown_error("reputation without faction"); + } else if (faction == Faction::default_faction()) { + inifile.unknown_error("ignoring reputation for default faction"); } else { player->reputation().set_reputation(faction, reputation); } -- cgit v1.2.3