widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #06447
[Merge] lp:~widelands-dev/widelands/bug-1395278-game_io into lp:widelands
Klaus Halfmann has proposed merging lp:~widelands-dev/widelands/bug-1395278-game_io into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1395278 in widelands: "Consolidate naming of member variables"
https://bugs.launchpad.net/widelands/+bug/1395278
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1395278-game_io/+merge/288172
Checked the code and played a game (with some stores and loads)
LGTM
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1395278-game_io into lp:widelands.
=== modified file 'src/game_io/game_loader.cc'
--- src/game_io/game_loader.cc 2016-03-02 16:30:42 +0000
+++ src/game_io/game_loader.cc 2016-03-04 20:31:45 +0000
@@ -40,12 +40,16 @@
namespace Widelands {
GameLoader::GameLoader(const std::string & path, Game & game) :
+<<<<<<< TREE
m_fs(*g_fs->make_sub_file_system(path)), game_(game)
+=======
+ fs_(*g_fs->make_sub_file_system(path)), game_(game)
+>>>>>>> MERGE-SOURCE
{}
GameLoader::~GameLoader() {
- delete &m_fs;
+ delete &fs_;
}
/*
@@ -53,7 +57,11 @@
*/
int32_t GameLoader::preload_game(GamePreloadPacket & mp) {
// Load elemental data block
+<<<<<<< TREE
mp.read(m_fs, game_, nullptr);
+=======
+ mp.read(fs_, game_, nullptr);
+>>>>>>> MERGE-SOURCE
return 0;
}
@@ -65,19 +73,35 @@
ScopedTimer timer("GameLoader::load() took %ums");
log("Game: Reading Preload Data ... ");
+<<<<<<< TREE
{GamePreloadPacket p; p.read(m_fs, game_);}
+=======
+ {GamePreloadPacket p; p.read(fs_, game_);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Reading Game Class Data ... ");
+<<<<<<< TREE
{GameClassPacket p; p.read(m_fs, game_);}
+=======
+ {GameClassPacket p; p.read(fs_, game_);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Reading Map Data ... ");
+<<<<<<< TREE
GameMapPacket M; M.read(m_fs, game_);
+=======
+ GameMapPacket M; M.read(fs_, game_);
+>>>>>>> MERGE-SOURCE
log("Game: Reading Map Data took %ums\n", timer.ms_since_last_query());
log("Game: Reading Player Info ... ");
+<<<<<<< TREE
{GamePlayerInfoPacket p; p.read(m_fs, game_);}
+=======
+ {GamePlayerInfoPacket p; p.read(fs_, game_);}
+>>>>>>> MERGE-SOURCE
log("Game: Reading Player Info took %ums\n", timer.ms_since_last_query());
log("Game: Calling read_complete()\n");
@@ -87,15 +111,27 @@
MapObjectLoader * const mol = M.get_map_object_loader();
log("Game: Reading Player Economies Info ... ");
+<<<<<<< TREE
{GamePlayerEconomiesPacket p; p.read(m_fs, game_, mol);}
+=======
+ {GamePlayerEconomiesPacket p; p.read(fs_, game_, mol);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Reading ai persistent data ... ");
+<<<<<<< TREE
{GamePlayerAiPersistentPacket p; p.read(m_fs, game_, mol);}
+=======
+ {GamePlayerAiPersistentPacket p; p.read(fs_, game_, mol);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Reading Command Queue Data ... ");
+<<<<<<< TREE
{GameCmdQueuePacket p; p.read(m_fs, game_, mol);}
+=======
+ {GameCmdQueuePacket p; p.read(fs_, game_, mol);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
// This must be after the command queue has been read.
@@ -104,14 +140,19 @@
iterate_players_existing_const(p, nr_players, game_, player) {
const MessageQueue & messages = player->messages();
for (std::pair<MessageId, Message *> temp_message : messages) {
- Message* m = temp_message.second;
- MessageId m_id = temp_message.first;
+ Message* message = temp_message.second;
+ MessageId message_id = temp_message.first;
// Renew MapObject connections
+<<<<<<< TREE
if (m->serial() > 0) {
MapObject* mo = game_.objects().get_object(m->serial());
+=======
+ if (message->serial() > 0) {
+ MapObject* mo = game_.objects().get_object(message->serial());
+>>>>>>> MERGE-SOURCE
mo->removed.connect
- (boost::bind(&Player::message_object_removed, player, m_id));
+ (boost::bind(&Player::message_object_removed, player, message_id));
}
}
}
@@ -125,7 +166,11 @@
// player.
if (!multiplayer) {
log("Game: Reading Interactive Player Data ... ");
+<<<<<<< TREE
{GameInteractivePlayerPacket p; p.read(m_fs, game_, mol);}
+=======
+ {GameInteractivePlayerPacket p; p.read(fs_, game_, mol);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
}
=== modified file 'src/game_io/game_loader.h'
--- src/game_io/game_loader.h 2016-03-02 16:30:42 +0000
+++ src/game_io/game_loader.h 2016-03-04 20:31:45 +0000
@@ -43,8 +43,13 @@
int32_t load_game(bool multiplayer = false);
private:
+<<<<<<< TREE
FileSystem & m_fs;
Game & game_;
+=======
+ FileSystem & fs_;
+ Game & game_;
+>>>>>>> MERGE-SOURCE
};
}
=== modified file 'src/game_io/game_map_packet.cc'
--- src/game_io/game_map_packet.cc 2016-01-29 13:43:56 +0000
+++ src/game_io/game_map_packet.cc 2016-03-04 20:31:45 +0000
@@ -30,8 +30,8 @@
namespace Widelands {
GameMapPacket::~GameMapPacket() {
- delete m_wms;
- delete m_wml;
+ delete wms_;
+ delete wml_;
}
void GameMapPacket::read
@@ -41,11 +41,11 @@
throw GameDataError("no map");
// Now Load the map as it would be a normal map saving.
- delete m_wml;
-
- m_wml = new WidelandsMapLoader(fs.make_sub_file_system("map"), &game.map());
-
- m_wml->preload_map(true);
+ delete wml_;
+
+ wml_ = new WidelandsMapLoader(fs.make_sub_file_system("map"), &game.map());
+
+ wml_->preload_map(true);
// DONE, mapfs gets deleted by WidelandsMapLoader.
@@ -54,8 +54,8 @@
void GameMapPacket::read_complete(Game & game) {
- m_wml->load_map_complete(game, MapLoader::LoadType::kScenario);
- m_mol = m_wml->get_map_object_loader();
+ wml_->load_map_complete(game, MapLoader::LoadType::kScenario);
+ mol_ = wml_->get_map_object_loader();
}
@@ -67,10 +67,10 @@
(fs.create_sub_file_system("map", FileSystem::DIR));
// Now Write the map as it would be a normal map saving.
- delete m_wms;
- m_wms = new MapSaver(*mapfs, game);
- m_wms->save();
- m_mos = m_wms->get_map_object_saver();
+ delete wms_;
+ wms_ = new MapSaver(*mapfs, game);
+ wms_->save();
+ mos_ = wms_->get_map_object_saver();
}
}
=== modified file 'src/game_io/game_map_packet.h'
--- src/game_io/game_map_packet.h 2014-09-19 12:54:54 +0000
+++ src/game_io/game_map_packet.h 2016-03-04 20:31:45 +0000
@@ -31,7 +31,7 @@
* This is just a wrapper around MapSaver and MapLoader
*/
struct GameMapPacket : public GameDataPacket {
- GameMapPacket() : m_mos(nullptr), m_mol(nullptr), m_wms(nullptr), m_wml(nullptr) {}
+ GameMapPacket() : mos_(nullptr), mol_(nullptr), wms_(nullptr), wml_(nullptr) {}
virtual ~GameMapPacket();
@@ -42,14 +42,14 @@
void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
- MapObjectSaver * get_map_object_saver () {return m_mos;}
- MapObjectLoader * get_map_object_loader() {return m_mol;}
+ MapObjectSaver * get_map_object_saver () {return mos_;}
+ MapObjectLoader * get_map_object_loader() {return mol_;}
private:
- MapObjectSaver * m_mos;
- MapObjectLoader * m_mol;
- MapSaver * m_wms;
- WidelandsMapLoader * m_wml;
+ MapObjectSaver * mos_;
+ MapObjectLoader * mol_;
+ MapSaver * wms_;
+ WidelandsMapLoader * wml_;
};
}
=== modified file 'src/game_io/game_preload_packet.cc'
--- src/game_io/game_preload_packet.cc 2015-10-24 15:42:37 +0000
+++ src/game_io/game_preload_packet.cc 2016-03-04 20:31:45 +0000
@@ -56,19 +56,19 @@
int32_t const packet_version = s.get_int("packet_version");
if (packet_version == kCurrentPacketVersion) {
- m_gametime = s.get_safe_int("gametime");
- m_mapname = s.get_safe_string("mapname");
+ gametime_ = s.get_safe_int("gametime");
+ mapname_ = s.get_safe_string("mapname");
- m_background = s.get_safe_string("background");
- m_player_nr = s.get_safe_int("player_nr");
- m_win_condition = s.get_safe_string("win_condition");
- m_number_of_players = s.get_safe_int("player_amount");
- m_version = s.get_safe_string("widelands_version");
+ background_ = s.get_safe_string("background");
+ player_nr_ = s.get_safe_int("player_nr");
+ win_condition_ = s.get_safe_string("win_condition");
+ number_of_players_ = s.get_safe_int("player_amount");
+ version_ = s.get_safe_string("widelands_version");
if (fs.file_exists(kMinimapFilename)) {
- m_minimap_path = kMinimapFilename;
+ minimap_path_ = kMinimapFilename;
}
- m_savetimestamp = static_cast<time_t>(s.get_natural("savetimestamp"));
- m_gametype = static_cast<GameController::GameType>(s.get_natural("gametype"));
+ savetimestamp_ = static_cast<time_t>(s.get_natural("savetimestamp"));
+ gametype_ = static_cast<GameController::GameType>(s.get_natural("gametype"));
} else {
throw UnhandledVersionError("GamePreloadPacket", packet_version, kCurrentPacketVersion);
}
=== modified file 'src/game_io/game_preload_packet.h'
--- src/game_io/game_preload_packet.h 2015-03-05 13:38:10 +0000
+++ src/game_io/game_preload_packet.h 2016-03-04 20:31:45 +0000
@@ -39,30 +39,30 @@
void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
- char const * get_mapname() {return m_mapname.c_str();}
- std::string get_background() {return m_background;}
- std::string get_win_condition() {return m_win_condition;}
- uint32_t get_gametime() {return m_gametime;}
- uint8_t get_player_nr() {return m_player_nr;}
- std::string get_version() {return m_version;}
-
- uint8_t get_number_of_players() {return m_number_of_players;}
- std::string get_minimap_path() {return m_minimap_path;}
-
- time_t get_savetimestamp() {return m_savetimestamp;}
- GameController::GameType get_gametype() {return m_gametype;}
+ char const * get_mapname() {return mapname_.c_str();}
+ std::string get_background() {return background_;}
+ std::string get_win_condition() {return win_condition_;}
+ uint32_t get_gametime() {return gametime_;}
+ uint8_t get_player_nr() {return player_nr_;}
+ std::string get_version() {return version_;}
+
+ uint8_t get_number_of_players() {return number_of_players_;}
+ std::string get_minimap_path() {return minimap_path_;}
+
+ time_t get_savetimestamp() {return savetimestamp_;}
+ GameController::GameType get_gametype() {return gametype_;}
private:
- std::string m_minimap_path;
- std::string m_mapname;
- std::string m_background;
- std::string m_win_condition;
- uint32_t m_gametime;
- uint8_t m_player_nr; // The local player idx
- uint8_t m_number_of_players;
- std::string m_version;
- time_t m_savetimestamp;
- GameController::GameType m_gametype;
+ std::string minimap_path_;
+ std::string mapname_;
+ std::string background_;
+ std::string win_condition_;
+ uint32_t gametime_;
+ uint8_t player_nr_; // The local player idx
+ uint8_t number_of_players_;
+ std::string version_;
+ time_t savetimestamp_;
+ GameController::GameType gametype_;
};
}
=== modified file 'src/game_io/game_saver.cc'
--- src/game_io/game_saver.cc 2016-03-02 16:30:42 +0000
+++ src/game_io/game_saver.cc 2016-03-04 20:31:45 +0000
@@ -34,7 +34,11 @@
namespace Widelands {
+<<<<<<< TREE
GameSaver::GameSaver(FileSystem & fs, Game & game) : m_fs(fs), game_(game) {
+=======
+GameSaver::GameSaver(FileSystem & fs, Game & game) : fs_(fs), game_(game) {
+>>>>>>> MERGE-SOURCE
}
@@ -44,40 +48,72 @@
void GameSaver::save() {
ScopedTimer timer("GameSaver::save() took %ums");
- m_fs.ensure_directory_exists("binary");
+ fs_.ensure_directory_exists("binary");
log("Game: Writing Preload Data ... ");
+<<<<<<< TREE
{GamePreloadPacket p; p.write(m_fs, game_, nullptr);}
+=======
+ {GamePreloadPacket p; p.write(fs_, game_, nullptr);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Writing Game Class Data ... ");
+<<<<<<< TREE
{GameClassPacket p; p.write(m_fs, game_, nullptr);}
+=======
+ {GameClassPacket p; p.write(fs_, game_, nullptr);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Writing Player Info ... ");
+<<<<<<< TREE
{GamePlayerInfoPacket p; p.write(m_fs, game_, nullptr);}
+=======
+ {GamePlayerInfoPacket p; p.write(fs_, game_, nullptr);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Writing Map Data!\n");
+<<<<<<< TREE
GameMapPacket M; M.write(m_fs, game_, nullptr);
+=======
+ GameMapPacket M; M.write(fs_, game_, nullptr);
+>>>>>>> MERGE-SOURCE
log("Game: Writing Map Data took %ums\n", timer.ms_since_last_query());
MapObjectSaver * const mos = M.get_map_object_saver();
log("Game: Writing Player Economies Info ... ");
+<<<<<<< TREE
{GamePlayerEconomiesPacket p; p.write(m_fs, game_, mos);}
+=======
+ {GamePlayerEconomiesPacket p; p.write(fs_, game_, mos);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Writing ai persistent data ... ");
+<<<<<<< TREE
{GamePlayerAiPersistentPacket p; p.write(m_fs, game_, mos);}
+=======
+ {GamePlayerAiPersistentPacket p; p.write(fs_, game_, mos);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Writing Command Queue Data ... ");
+<<<<<<< TREE
{GameCmdQueuePacket p; p.write(m_fs, game_, mos);}
+=======
+ {GameCmdQueuePacket p; p.write(fs_, game_, mos);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
log("Game: Writing Interactive Player Data ... ");
+<<<<<<< TREE
{GameInteractivePlayerPacket p; p.write(m_fs, game_, mos);}
+=======
+ {GameInteractivePlayerPacket p; p.write(fs_, game_, mos);}
+>>>>>>> MERGE-SOURCE
log("took %ums\n", timer.ms_since_last_query());
}
=== modified file 'src/game_io/game_saver.h'
--- src/game_io/game_saver.h 2016-03-02 16:30:42 +0000
+++ src/game_io/game_saver.h 2016-03-04 20:31:45 +0000
@@ -43,8 +43,13 @@
void save();
private:
+<<<<<<< TREE
FileSystem & m_fs;
Game & game_;
+=======
+ FileSystem & fs_;
+ Game & game_;
+>>>>>>> MERGE-SOURCE
};
}
Follow ups