From 9a3362033391657bd86a45952bf3a8ef6ec7b349 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 14 Oct 2012 11:26:57 +0000 Subject: Corrected a bug that prevented savegame loading in multiplayer games. --- src/game/base/game.cc | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'src/game/base') diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 56719b9..738edca 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -1841,13 +1841,14 @@ void Game::game_load(core::Player *player, filesystem::IniFile & inifile) if (player->control()) return; - if (!core::server()->mode() == core::GameServer::SinglePlayer) { + if (core::server()->mode() != core::GameServer::SinglePlayer) { return; } SaveGame::load_game(player, inifile); } +// load multiplayer savegame player data void Game::player_load(core::Player *player) { if (!player->guid().is_valid()) { @@ -1857,30 +1858,31 @@ void Game::player_load(core::Player *player) if (player->control()) return; - if (!core::server()->mode() == core::GameServer::MultiPlayer) { - - std::string guid(player->guid().str()); - std::string directory(guid.substr(0,4)); + if (core::server()->mode() != core::GameServer::MultiPlayer) { + return; + } - std::string filename; - filename.append("players"); - filename += '/'; - filename.append(directory); - filename += '/'; - filename.append(guid); + std::string guid(player->guid().str()); + std::string directory(guid.substr(0,4)); + + std::string filename; + filename.append("players"); + filename += '/'; + filename.append(directory); + filename += '/'; + filename.append(guid); - filesystem::IniFile inifile; - inifile.open(filename); - if (!inifile.is_open()) { - return; - } - - con_debug << "player " << player->id() << ": " << "loading data" << std::endl; - - SaveGame::load_game(player, inifile); - - inifile.close(); + filesystem::IniFile inifile; + inifile.open(filename); + if (!inifile.is_open()) { + return; } + + con_debug << "player " << player->id() << ": " << "loading data" << std::endl; + + SaveGame::load_game(player, inifile); + + inifile.close(); } void Game::game_save(core::Player *player, std::ostream & os) -- cgit v1.2.3