widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #07467
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands.
Commit message:
Persist PlayerEndStatus. This fixes missing result screen after saveloading.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1302593 in widelands: "Result screen not shown in loaded game when a player was already defeated in saved game."
https://bugs.launchpad.net/widelands/+bug/1302593
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1302593-result-screen/+merge/293521
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands.
=== modified file 'src/game_io/game_player_info_packet.cc'
--- src/game_io/game_player_info_packet.cc 2016-02-16 10:27:23 +0000
+++ src/game_io/game_player_info_packet.cc 2016-05-02 11:10:41 +0000
@@ -26,11 +26,12 @@
#include "logic/game_data_error.h"
#include "logic/map_objects/tribes/tribe_descr.h"
#include "logic/player.h"
+#include "logic/playersmanager.h"
#include "wui/interactive_player.h"
namespace Widelands {
-constexpr uint16_t kCurrentPacketVersion = 19;
+constexpr uint16_t kCurrentPacketVersion = 20;
void GamePlayerInfoPacket::read
(FileSystem & fs, Game & game, MapObjectLoader *) {
@@ -38,7 +39,7 @@
FileRead fr;
fr.open(fs, "binary/player_info");
uint16_t const packet_version = fr.unsigned_16();
- if (packet_version == kCurrentPacketVersion) {
+ if (packet_version >= 19 && packet_version <= kCurrentPacketVersion) {
uint32_t const max_players = fr.unsigned_16();
for (uint32_t i = 1; i < max_players + 1; ++i) {
game.remove_player(i);
@@ -72,6 +73,19 @@
player.civil_blds_defeated_ = fr.unsigned_32();
}
}
+
+ // Result screen
+ PlayersManager* manager = game.player_manager();
+ const uint8_t no_endstatus = fr.unsigned_8();
+ for (uint8_t i = 0; i < no_endstatus; ++i) {
+ PlayerEndStatus status;
+ status.player = fr.unsigned_8();
+ status.result = static_cast<PlayerEndResult>(fr.unsigned_8());
+ status.time = fr.unsigned_32();
+ status.info = fr.c_string();
+ manager->set_player_end_status(status);
+ }
+
game.read_statistics(fr);
} else {
throw UnhandledVersionError("GamePlayerInfoPacket", packet_version, kCurrentPacketVersion);
@@ -118,8 +132,20 @@
fw.unsigned_32(plr->msites_defeated ());
fw.unsigned_32(plr->civil_blds_lost ());
fw.unsigned_32(plr->civil_blds_defeated());
- } else
+
+ } else {
fw.unsigned_8(0); // Player is NOT in game.
+ }
+
+ // Result screen
+ const std::vector<PlayerEndStatus>& end_status_list = game.player_manager()->get_players_end_status();
+ fw.unsigned_8(end_status_list.size());
+ for (const PlayerEndStatus& status : end_status_list) {
+ fw.unsigned_8(status.player);
+ fw.unsigned_8(static_cast<uint8_t>(status.result));
+ fw.unsigned_32(status.time);
+ fw.c_string(status.info.c_str());
+ }
game.write_statistics(fw);
=== modified file 'src/logic/playersmanager.cc'
--- src/logic/playersmanager.cc 2016-02-16 10:27:23 +0000
+++ src/logic/playersmanager.cc 2016-05-02 11:10:41 +0000
@@ -120,5 +120,22 @@
}
}
+void PlayersManager::set_player_end_status(const PlayerEndStatus& status)
+{
+ std::vector<PlayerEndStatus>::iterator it;
+ bool found = false;
+ for (it = players_end_status_.begin(); it != players_end_status_.end(); ++it) {
+ PlayerEndStatus pes = *it;
+ if (pes.player == status.player) {
+ pes = status;
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ players_end_status_.push_back(status);
+ }
+}
+
} // namespace Widelands
=== modified file 'src/logic/playersmanager.h'
--- src/logic/playersmanager.h 2016-02-16 10:27:23 +0000
+++ src/logic/playersmanager.h 2016-05-02 11:10:41 +0000
@@ -94,6 +94,11 @@
*/
void add_player_end_status(const PlayerEndStatus & status);
+ /**
+ * Changes an already existing player end status
+ */
+ void set_player_end_status(const PlayerEndStatus & status);
+
private:
Player* players_[MAX_PLAYERS];
EditorGameBase& egbase_;
Follow ups
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: noreply, 2016-05-11
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-11
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: GunChleoc, 2016-05-11
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: Miroslav Remák, 2016-05-11
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: Miroslav Remák, 2016-05-11
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: GunChleoc, 2016-05-11
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: Miroslav Remák, 2016-05-11
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-11
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-11
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-11
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: GunChleoc, 2016-05-11
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-11
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-11
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: Miroslav Remák, 2016-05-10
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: GunChleoc, 2016-05-10
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: Miroslav Remák, 2016-05-10
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: Miroslav Remák, 2016-05-10
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: GunChleoc, 2016-05-10
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: GunChleoc, 2016-05-08
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: Klaus Halfmann, 2016-05-07
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: Miroslav Remák, 2016-05-05
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-04
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-04
-
[Merge] lp:~widelands-dev/widelands/bug-1302593-result-screen into lp:widelands
From: bunnybot, 2016-05-02