Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-11-07 20:08:05 +0000
committerStijn Buys <ingar@osirion.org>2013-11-07 20:08:05 +0000
commit87d5637c09dca61a650fe81d83ef328943176503 (patch)
tree60b97aa68a593d71b9a5566242da8d7f0676c3ef /src/game/base/savegame.cc
parentcd9ad2786e0e4b0f0448363252d4b010dfe6515c (diff)
Save/load player reputation,
count player NPC and PVP kills.
Diffstat (limited to 'src/game/base/savegame.cc')
-rw-r--r--src/game/base/savegame.cc48
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