diff options
Diffstat (limited to 'src/game/base/savegame.cc')
-rw-r--r-- | src/game/base/savegame.cc | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/src/game/base/savegame.cc b/src/game/base/savegame.cc index 5100064..b498717 100644 --- a/src/game/base/savegame.cc +++ b/src/game/base/savegame.cc @@ -29,6 +29,8 @@ void SaveGame::load_game(core::Player *player, filesystem::IniFile & inifile) std::string itemtype; std::string itemlabel; float armor; + float reputation; + Faction *faction = 0; while (inifile.getline()) { @@ -39,6 +41,9 @@ void SaveGame::load_game(core::Player *player, filesystem::IniFile & inifile) continue; } else if (inifile.got_section("player")) { continue; + } else if (inifile.got_section("reputation")) { + faction = 0; + continue; } else if (inifile.got_section("ship")) { continue; } else if (inifile.got_section("item")) { @@ -67,9 +72,32 @@ void SaveGame::load_game(core::Player *player, filesystem::IniFile & inifile) } else if (inifile.got_key_string("name", str)) { continue; + } else if (inifile.got_key_long("npckills", l)) { + player->set_npckills(l); + + } else if (inifile.got_key_long("pvpkills", l)) { + player->set_pvpkills(l); + } + } else { inifile.unknown_key(); } + + } else if (inifile.in_section("reputation")) { + + if (inifile.got_key_label("faction", str)) { + faction = Faction::find (str); + if (!faction) { + inifile.unknown_error("unknown faction '" + str + "'"); + } + continue; + + } else if (inifile.got_key_float("reputation", reputation)) { + if (!faction) { + inifile.unknown_error("reputation without faction"); + } else { + player->reputation().set_reputation(faction, reputation); + } } else if (inifile.in_section("ship")) { @@ -269,12 +297,9 @@ void SaveGame::load_game(core::Player *player, filesystem::IniFile & inifile) player->set_control(ship); } } - - // FIXME load reputation from savegame - Faction *faction_default = Faction::find("default"); - if (faction_default) { - player->reputation().assign(faction_default->reputation()); - } + + // apply default reputation + Faction::apply_default(player->reputation()); } void SaveGame::player_to_stream(core::Player *player, std::ostream & os) @@ -286,9 +311,18 @@ void SaveGame::player_to_stream(core::Player *player, std::ostream & os) // player name os << "name=" << player->name() << std::endl; // credit - os << "credits=" << player->credits() << std::endl; + os << "credits=" << player->credits() << std::endl; + os << "npckills=" << player->npckills() << std::endl; + os << "pvpkills=" << player->pvpkills() << std::endl; os << std::endl; + // player reputation + for (core::Reputation::FactionReps::const_iterator it = player->reputation().factionreps().begin(); it != player->reputation().factionreps().end(); ++it) { + os << "[reputation]" << std::endl; + os << "faction=" << (*it)->faction()->label() << std::endl; + os << "reputation=" << (*it)->reputation() << std::endl; + os << std::endl; + } // save ship // TODO iterate assets and save all ships |