← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/message_expired into lp:widelands

 

cghislai has proposed merging lp:~widelands-dev/widelands/message_expired into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1207477 in widelands: "Assertion `it != end()' failed in message queue"
  https://bugs.launchpad.net/widelands/+bug/1207477
  Bug #1208440 in widelands: "Some messages directly expired and still play sound"
  https://bugs.launchpad.net/widelands/+bug/1208440

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/message_expired/+merge/178836

This branch introduces a new parameter in the Building::send_message method to prevent linking the message to the immovable, so the message will not expire once the building is destroyed. This is used by the "military site lost" message.
Also thanks to the tests the lua method has been updated as well, which was previously forgotten.
-- 
https://code.launchpad.net/~widelands-dev/widelands/message_expired/+merge/178836
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/message_expired into lp:widelands.
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc	2013-08-02 18:36:03 +0000
+++ src/logic/building.cc	2013-08-06 20:05:35 +0000
@@ -914,6 +914,8 @@
  * \param title user-visible title of the message
  * \param description user-visible message body, will be placed in an
  *   appropriate rich-text paragraph
+ * \param keep_when_removed if true, the message will not expire when this
+ *   building will be removed from the game. Default to false
  * \param throttle_time if non-zero, the minimum time delay in milliseconds
  *   between messages of this type (see \p msgsender) within the
  *   given \p throttle_radius
@@ -923,6 +925,7 @@
 	 const std::string & msgsender,
 	 const std::string & title,
 	 const std::string & description,
+	 bool keep_when_removed,
 	 uint32_t throttle_time,
 	 uint32_t throttle_radius)
 {
@@ -949,7 +952,7 @@
 
 	Message * msg = new Message
 		(msgsender, game.get_gametime(), 60 * 60 * 1000,
-		 title, rt_description, get_position(), m_serial);
+		 title, rt_description, get_position(), (keep_when_removed ? 0 : m_serial));
 
 	if (throttle_time)
 		owner().add_message_with_timeout

=== modified file 'src/logic/building.h'
--- src/logic/building.h	2013-08-02 18:36:03 +0000
+++ src/logic/building.h	2013-08-06 20:05:35 +0000
@@ -268,6 +268,7 @@
 		 const std::string & msgsender,
 		 const std::string & title,
 		 const std::string & description,
+		 bool keep_when_removed = false,
 		 uint32_t throttle_time = 0,
 		 uint32_t throttle_radius = 0);
 protected:

=== modified file 'src/logic/militarysite.cc'
--- src/logic/militarysite.cc	2013-07-31 17:00:28 +0000
+++ src/logic/militarysite.cc	2013-08-06 20:05:35 +0000
@@ -842,7 +842,7 @@
 				(game,
 				 "site_lost",
 				 _("Militarysite lost!"),
-				 message);
+				 message, true);
 		}
 
 		// Now let's see whether the enemy conquers our militarysite, or whether
@@ -953,7 +953,7 @@
 		(game,
 		 "under_attack",
 		 _("You are under attack"),
-		 message,
+		 message, true,
 		 60 * 1000, 5);
 }
 

=== modified file 'src/logic/production_program.cc'
--- src/logic/production_program.cc	2013-07-26 20:19:36 +0000
+++ src/logic/production_program.cc	2013-08-06 20:05:35 +0000
@@ -1230,6 +1230,7 @@
 		 _
 		 ("This mines' main vein exhausted. Expect strongly diminished returns on investment. "
 		  "You should consider to expand, dismantle or destruct it."),
+		 false,
 		 60 * 60 * 1000,
 		 0);
 }

=== modified file 'src/logic/worker.cc'
--- src/logic/worker.cc	2013-08-01 08:33:15 +0000
+++ src/logic/worker.cc	2013-08-06 20:05:35 +0000
@@ -609,6 +609,7 @@
 		 	 "of the following type: "))
 		 +
 		 res_type,
+		 false,
 		 1800000, 0);
 }
 

=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc	2013-07-26 20:19:36 +0000
+++ src/scripting/lua_game.cc	2013-08-06 20:05:35 +0000
@@ -386,6 +386,7 @@
 			 	 title,
 			 	 body,
 				 c,
+				 0,
 				 st),
 			popup);
 


Follow ups