Merge lp:~widelands-dev/widelands/bug-1798812-replay-savegame-type into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8900
Proposed branch: lp:~widelands-dev/widelands/bug-1798812-replay-savegame-type
Merge into: lp:widelands
Diff against target: 103 lines (+17/-11)
6 files modified
src/logic/game.cc (+7/-0)
src/logic/game.h (+2/-3)
src/logic/replay.cc (+4/-0)
src/wui/game_main_menu_save_game.cc (+1/-1)
src/wui/load_or_save_game.cc (+2/-6)
src/wui/load_or_save_game.h (+1/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1798812-replay-savegame-type
Reviewer Review Type Date Requested Status
Notabilis Approve
GunChleoc Needs Resubmitting
Review via email: mp+357588@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4158. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/444318487.
Appveyor build 3955. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1798812_replay_savegame_type-3955.

Revision history for this message
Notabilis (notabilis27) wrote :

Code is looking good and the game appears in the load menu.

Two issues:
- My single player replay savegame also shows up in the multiplayer load game screen (even before this change). Not that much of an issue, might even be intentional?
- The savegame isn't shown in the "save game" dialog. So I can load a game but when saving later on it isn't shown any longer (Huh? Where did it go?). Saving without seeing the game in the save dialog will trigger an "really override" message (Huh? For which game?), but after saving it once it will correctly appear in the list.

Revision history for this message
GunChleoc (gunchleoc) wrote :

1. Replays don't know if the came from a single or multiplayer game, so we can't filter for that here.
2. Good point, needs fixing

Revision history for this message
GunChleoc (gunchleoc) wrote :

Save game screen should be fixed now

review: Needs Resubmitting
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4165. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/445997183.
Appveyor build 3963. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1798812_replay_savegame_type-3963.

Revision history for this message
Notabilis (notabilis27) wrote :

Looking good now, thanks!

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/game.cc'
2--- src/logic/game.cc 2018-09-08 08:19:51 +0000
3+++ src/logic/game.cc 2018-10-25 04:01:54 +0000
4@@ -851,6 +851,13 @@
5 return static_cast<LuaGameInterface&>(EditorGameBase::lua());
6 }
7
8+const std::string& Game::get_win_condition_displayname() const {
9+ return win_condition_displayname_;
10+}
11+void Game::set_win_condition_displayname(const std::string& name) {
12+ win_condition_displayname_ = name;
13+}
14+
15 /**
16 * Sample global statistics for the game.
17 */
18
19=== modified file 'src/logic/game.h'
20--- src/logic/game.h 2018-09-08 08:19:51 +0000
21+++ src/logic/game.h 2018-10-25 04:01:54 +0000
22@@ -244,9 +244,8 @@
23
24 void sample_statistics();
25
26- const std::string& get_win_condition_displayname() {
27- return win_condition_displayname_;
28- }
29+ const std::string& get_win_condition_displayname() const;
30+ void set_win_condition_displayname(const std::string& name);
31
32 bool is_replay() const {
33 return replay_;
34
35=== modified file 'src/logic/replay.cc'
36--- src/logic/replay.cc 2018-04-07 16:59:00 +0000
37+++ src/logic/replay.cc 2018-10-25 04:01:54 +0000
38@@ -23,6 +23,7 @@
39 #include "base/md5.h"
40 #include "base/wexception.h"
41 #include "game_io/game_loader.h"
42+#include "game_io/game_preload_packet.h"
43 #include "io/filesystem/layered_filesystem.h"
44 #include "io/streamread.h"
45 #include "io/streamwrite.h"
46@@ -82,6 +83,9 @@
47
48 {
49 GameLoader gl(filename + kSavegameExtension, game);
50+ Widelands::GamePreloadPacket gpdp;
51+ gl.preload_game(gpdp);
52+ game.set_win_condition_displayname(gpdp.get_win_condition());
53 gl.load_game();
54 }
55
56
57=== modified file 'src/wui/game_main_menu_save_game.cc'
58--- src/wui/game_main_menu_save_game.cc 2018-06-01 08:50:29 +0000
59+++ src/wui/game_main_menu_save_game.cc 2018-10-25 04:01:54 +0000
60@@ -55,7 +55,7 @@
61 info_box_(&main_box_, 0, 0, UI::Box::Horizontal),
62
63 load_or_save_(
64- &info_box_, igbase().game(), LoadOrSaveGame::FileType::kGame, UI::PanelStyle::kWui, false),
65+ &info_box_, igbase().game(), LoadOrSaveGame::FileType::kShowAll, UI::PanelStyle::kWui, false),
66
67 filename_box_(load_or_save_.table_box(), 0, 0, UI::Box::Horizontal),
68 filename_label_(&filename_box_, 0, 0, 0, 0, _("Filename:"), UI::Align::kLeft),
69
70=== modified file 'src/wui/load_or_save_game.cc'
71--- src/wui/load_or_save_game.cc 2018-07-15 11:33:09 +0000
72+++ src/wui/load_or_save_game.cc 2018-10-25 04:01:54 +0000
73@@ -341,15 +341,11 @@
74 gamedata.gametype = gpdp.get_gametype();
75
76 if (filetype_ != FileType::kReplay) {
77- if (filetype_ == FileType::kGame) {
78- if (gamedata.gametype == GameController::GameType::kReplay) {
79- continue;
80- }
81- } else if (filetype_ == FileType::kGameMultiPlayer) {
82+ if (filetype_ == FileType::kGameMultiPlayer) {
83 if (gamedata.gametype == GameController::GameType::kSingleplayer) {
84 continue;
85 }
86- } else if (gamedata.gametype > GameController::GameType::kSingleplayer) {
87+ } else if ((gamedata.gametype != GameController::GameType::kSingleplayer) && (gamedata.gametype != GameController::GameType::kReplay)) {
88 continue;
89 }
90 }
91
92=== modified file 'src/wui/load_or_save_game.h'
93--- src/wui/load_or_save_game.h 2018-05-14 08:33:24 +0000
94+++ src/wui/load_or_save_game.h 2018-10-25 04:01:54 +0000
95@@ -35,7 +35,7 @@
96
97 protected:
98 /// Choose which type of files to show
99- enum class FileType { kReplay, kGame, kGameMultiPlayer, kGameSinglePlayer };
100+ enum class FileType { kShowAll, kGameMultiPlayer, kGameSinglePlayer, kReplay };
101
102 /// A table of savegame/replay files and a game details panel.
103 LoadOrSaveGame(UI::Panel* parent,

Subscribers

People subscribed via source and target branches

to status/vote changes: