← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-998544 into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-998544 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #998544 in widelands: "Replay name should contain Widelands version"
  https://bugs.launchpad.net/widelands/+bug/998544

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-998544/+merge/251947

Added Widelands version to game preload packet and load game/replay screens.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-998544 into lp:widelands.
=== modified file 'src/game_io/game_preload_packet.cc'
--- src/game_io/game_preload_packet.cc	2015-01-31 16:03:59 +0000
+++ src/game_io/game_preload_packet.cc	2015-03-05 14:22:55 +0000
@@ -24,6 +24,7 @@
 
 #include <boost/format.hpp>
 
+#include "build_info.h"
 #include "base/time_string.h"
 #include "graphic/graphic.h"
 #include "graphic/minimap_renderer.h"
@@ -42,7 +43,7 @@
 
 namespace Widelands {
 
-#define CURRENT_PACKET_VERSION 5
+#define CURRENT_PACKET_VERSION 6
 #define PLAYERS_AMOUNT_KEY_V4 "player_amount"
 #define MINIMAP_FILENAME "minimap.png"
 
@@ -64,6 +65,8 @@
 			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(PLAYERS_AMOUNT_KEY_V4);
+			m_version= s.get_safe_string("widelands_version");
+
 			if (fs.file_exists(MINIMAP_FILENAME)) {
 				m_minimap_path = MINIMAP_FILENAME;
 			}
@@ -108,6 +111,7 @@
 		}
 	}
 	s.set_int(PLAYERS_AMOUNT_KEY_V4, game.player_manager()->get_number_of_players());
+	s.set_string("widelands_version", build_id());
 
 	s.set_string("background", map.get_background());
 	s.set_string("win_condition", game.get_win_condition_displayname());

=== modified file 'src/game_io/game_preload_packet.h'
--- src/game_io/game_preload_packet.h	2014-11-07 19:41:27 +0000
+++ src/game_io/game_preload_packet.h	2015-03-05 14:22:55 +0000
@@ -44,6 +44,7 @@
 	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;}
@@ -59,6 +60,7 @@
 	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;
 };

=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc	2015-01-30 23:10:35 +0000
+++ src/ui_fsmenu/loadgame.cc	2015-03-05 14:22:55 +0000
@@ -110,8 +110,15 @@
 					 m_right_column_tab, m_label_players.get_y(),
 					 get_right_column_w(m_right_column_tab), m_label_height),
 
+	m_label_version
+		(this, m_right_column_x, get_y_from_preceding(m_ta_players),
+		 "",
+		 UI::Align_Left),
+	m_ta_version(this,
+					 m_right_column_tab, m_label_version.get_y(), "", UI::Align_Left),
+
 	m_label_win_condition
-		(this, m_right_column_x, get_y_from_preceding(m_ta_players) + 3 * m_padding,
+		(this, m_right_column_x, get_y_from_preceding(m_ta_version) + 3 * m_padding,
 		 "",
 		 UI::Align_Left),
 	m_ta_win_condition(this,
@@ -147,6 +154,7 @@
 	m_title.set_textstyle(UI::TextStyle::ui_big());
 	m_ta_gametime.set_tooltip(_("The time that elapsed inside this game"));
 	m_ta_players.set_tooltip(_("The number of players"));
+	m_ta_version.set_tooltip(_("The version of Widelands that this game was played under"));
 	m_ta_win_condition.set_tooltip(_("The win condition that was set for this game"));
 
 	if (m_is_replay) {
@@ -294,11 +302,13 @@
 		m_label_mapname .set_text(std::string());
 		m_label_gametime.set_text(std::string());
 		m_label_players.set_text(std::string());
+		m_label_version.set_text(std::string());
 		m_label_win_condition.set_text(std::string());
 
 		m_ta_mapname .set_text(std::string());
 		m_ta_gametime.set_text(std::string());
 		m_ta_players.set_text(std::string());
+		m_ta_version.set_text(std::string());
 		m_ta_win_condition.set_text(std::string());
 		m_minimap_icon.set_icon(nullptr);
 		m_minimap_icon.set_visible(false);
@@ -334,6 +344,14 @@
 				m_ta_players.set_text("");
 			}
 
+			if (gamedata.version.empty()) {
+				m_label_version.set_text("");
+				m_ta_version.set_text("");
+			} else {
+				m_label_version.set_text(_("Widelands Version:"));
+				m_ta_version.set_text(gamedata.version);
+			}
+
 			m_ta_win_condition.set_text(gamedata.wincondition);
 
 			std::string minimap_path = gamedata.minimap_path;
@@ -387,6 +405,8 @@
 			m_ta_gametime.set_text("");
 			m_label_players.set_text("");
 			m_ta_players.set_text("");
+			m_label_version.set_text("");
+			m_ta_version.set_text("");
 			m_label_win_condition.set_text("");
 			m_ta_win_condition.set_text("");
 
@@ -470,6 +490,7 @@
 				gamedata->mapname = gpdp.get_mapname();
 				gamedata->gametime = gpdp.get_gametime();
 				gamedata->nrplayers = gpdp.get_number_of_players();
+				gamedata->version = gpdp.get_version();
 
 				gamedata->savetimestamp = gpdp.get_savetimestamp();
 				time_t t;

=== modified file 'src/ui_fsmenu/loadgame.h'
--- src/ui_fsmenu/loadgame.h	2014-11-13 08:39:14 +0000
+++ src/ui_fsmenu/loadgame.h	2015-03-05 14:22:55 +0000
@@ -58,6 +58,7 @@
 
 	uint32_t gametime;
 	uint32_t nrplayers;
+	std::string version;
 	time_t savetimestamp;
 	GameController::GameType gametype;
 
@@ -100,6 +101,8 @@
 	UI::MultilineTextarea         m_ta_gametime; // Multiline because we want tooltips
 	UI::Textarea                  m_label_players;
 	UI::MultilineTextarea         m_ta_players;
+	UI::Textarea                  m_label_version;
+	UI::Textarea                  m_ta_version;
 	UI::Textarea                  m_label_win_condition;
 	UI::MultilineTextarea         m_ta_win_condition;
 


Follow ups