widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #15121
[Merge] lp:~widelands-dev/widelands/bug-1798812-replay-savegame-type into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1798812-replay-savegame-type into lp:widelands.
Commit message:
Fix bugs when loading a savegame saved from a replay
- Show replays in single player load screen
- Set win condition display name when loading a replay.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1798812 in widelands: "Saving a game from replay does not show up in load game menu"
https://bugs.launchpad.net/widelands/+bug/1798812
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1798812-replay-savegame-type/+merge/357588
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1798812-replay-savegame-type into lp:widelands.
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2018-09-08 08:19:51 +0000
+++ src/logic/game.cc 2018-10-21 09:56:53 +0000
@@ -851,6 +851,13 @@
return static_cast<LuaGameInterface&>(EditorGameBase::lua());
}
+const std::string& Game::get_win_condition_displayname() const {
+ return win_condition_displayname_;
+}
+void Game::set_win_condition_displayname(const std::string& name) {
+ win_condition_displayname_ = name;
+}
+
/**
* Sample global statistics for the game.
*/
=== modified file 'src/logic/game.h'
--- src/logic/game.h 2018-09-08 08:19:51 +0000
+++ src/logic/game.h 2018-10-21 09:56:53 +0000
@@ -244,9 +244,8 @@
void sample_statistics();
- const std::string& get_win_condition_displayname() {
- return win_condition_displayname_;
- }
+ const std::string& get_win_condition_displayname() const;
+ void set_win_condition_displayname(const std::string& name);
bool is_replay() const {
return replay_;
=== modified file 'src/logic/replay.cc'
--- src/logic/replay.cc 2018-04-07 16:59:00 +0000
+++ src/logic/replay.cc 2018-10-21 09:56:53 +0000
@@ -23,6 +23,7 @@
#include "base/md5.h"
#include "base/wexception.h"
#include "game_io/game_loader.h"
+#include "game_io/game_preload_packet.h"
#include "io/filesystem/layered_filesystem.h"
#include "io/streamread.h"
#include "io/streamwrite.h"
@@ -82,6 +83,9 @@
{
GameLoader gl(filename + kSavegameExtension, game);
+ Widelands::GamePreloadPacket gpdp;
+ gl.preload_game(gpdp);
+ game.set_win_condition_displayname(gpdp.get_win_condition());
gl.load_game();
}
=== modified file 'src/wui/load_or_save_game.cc'
--- src/wui/load_or_save_game.cc 2018-07-15 11:33:09 +0000
+++ src/wui/load_or_save_game.cc 2018-10-21 09:56:53 +0000
@@ -349,7 +349,7 @@
if (gamedata.gametype == GameController::GameType::kSingleplayer) {
continue;
}
- } else if (gamedata.gametype > GameController::GameType::kSingleplayer) {
+ } else if ((gamedata.gametype != GameController::GameType::kSingleplayer) && (gamedata.gametype != GameController::GameType::kReplay)) {
continue;
}
}
Follow ups