← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~gunchleoc/widelands/bug-1454371 into lp:widelands

 

GunChleoc has proposed merging lp:~gunchleoc/widelands/bug-1454371 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1454371 in widelands: ""Out of resources" messages should be triggered by productivity"
  https://bugs.launchpad.net/widelands/+bug/1454371

For more details, see:
https://code.launchpad.net/~gunchleoc/widelands/bug-1454371/+merge/261375

For "Out of resources" notifications, replaced delay counter in production sites with a productivity threshold + falling trend.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~gunchleoc/widelands/bug-1454371 into lp:widelands.
=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc	2015-05-04 19:06:37 +0000
+++ src/logic/productionsite.cc	2015-06-08 12:51:06 +0000
@@ -65,13 +65,13 @@
 	{
 		m_out_of_resource_title = section->get_string("title", "");
 		m_out_of_resource_message = section->get_string("message", "");
-		m_out_of_resource_delay_attempts = section->get_natural("delay_attempts", 0);
+		out_of_resource_productivity_threshold_ = section->get_natural("productivity_threshold", 0);
 	}
 	else
 	{
 		m_out_of_resource_title = "";
 		m_out_of_resource_message = "";
-		m_out_of_resource_delay_attempts = 0;
+		out_of_resource_productivity_threshold_ = 100;
 	}
 	while
 		(Section::Value const * const op = global_s.get_next_val("output"))
@@ -202,8 +202,7 @@
 	m_crude_percent     (0),
 	m_is_stopped        (false),
 	m_default_anim      ("idle"),
-	m_production_result (""),
-	m_out_of_resource_delay_counter(0)
+	m_production_result ("")
 {
 	calc_statistics();
 }
@@ -322,12 +321,15 @@
 
 	std::string trend;
 	if (lastPercOk > percOk) {
+		trend_ = Trend::kRising;
 		color = UI_FONT_CLR_GOOD_HEX;
 		trend = "+";
 	} else if (lastPercOk < percOk) {
+		trend_ = Trend::kFalling;
 		color = UI_FONT_CLR_BAD_HEX;
 		trend = "-";
 	} else {
+		trend_ = Trend::kUnchanged;
 		color = UI_FONT_CLR_BRIGHT_HEX;
 		trend = "=";
 	}
@@ -918,9 +920,8 @@
 
 void ProductionSite::notify_player(Game & game, uint8_t minutes)
 {
-
-	if (m_out_of_resource_delay_counter >=
-		 descr().out_of_resource_delay_attempts()) {
+	if ((m_last_stat_percent <= descr().out_of_resource_productivity_threshold()
+		  && trend_ == Trend::kFalling)) {
 		if (descr().out_of_resource_title().empty())
 		{
 			set_production_result(_("Can’t find any more resources!"));
@@ -942,10 +943,6 @@
 		if (descr().get_ismine())
 			Notifications::publish(NoteProductionSiteOutOfResources(this, get_owner()));
 	}
-	if (m_out_of_resource_delay_counter++ >=
-		 descr().out_of_resource_delay_attempts()) {
-		m_out_of_resource_delay_counter = 0;
-	}
 }
 
 void ProductionSite::unnotify_player() {

=== modified file 'src/logic/productionsite.h'
--- src/logic/productionsite.h	2015-01-28 07:35:51 +0000
+++ src/logic/productionsite.h	2015-06-08 12:51:06 +0000
@@ -94,8 +94,8 @@
 	const std::string& out_of_resource_message() const {
 		return m_out_of_resource_message;
 	}
-	uint32_t out_of_resource_delay_attempts() const {
-		return m_out_of_resource_delay_attempts;
+	uint32_t out_of_resource_productivity_threshold() const {
+		return out_of_resource_productivity_threshold_;
 	}
 
 private:
@@ -106,7 +106,7 @@
 	Programs m_programs;
 	std::string m_out_of_resource_title;
 	std::string m_out_of_resource_message;
-	uint32_t    m_out_of_resource_delay_attempts;
+	int         out_of_resource_productivity_threshold_;
 
 	DISALLOW_COPY_AND_ASSIGN(ProductionSiteDescr);
 };
@@ -281,9 +281,10 @@
 	std::string              m_default_anim; // normally "idle", "empty", if empty mine.
 
 private:
+	enum class Trend {kUnchanged, kRising, kFalling};
+	Trend                    trend_;
 	std::string              m_statistics_string_on_changed_statistics;
 	std::string              m_production_result; // hover tooltip text
-	uint32_t                 m_out_of_resource_delay_counter;
 
 	DISALLOW_COPY_AND_ASSIGN(ProductionSite);
 };

=== modified file 'tribes/atlanteans/blackroot_farm/conf'
--- tribes/atlanteans/blackroot_farm/conf	2014-08-02 19:55:23 +0000
+++ tribes/atlanteans/blackroot_farm/conf	2015-06-08 12:51:06 +0000
@@ -42,7 +42,7 @@
 [out_of_resource_notification]
 title=_Out of Fields
 message=_The farmer working at this blackroot farm has no cleared soil to plant his seeds.
-delay_attempts=10
+productivity_threshold=33
 
 [idle]
 pics=blackroot_farm_i_??.png  # ???

=== modified file 'tribes/atlanteans/farm/conf'
--- tribes/atlanteans/farm/conf	2014-08-02 19:55:23 +0000
+++ tribes/atlanteans/farm/conf	2015-06-08 12:51:06 +0000
@@ -46,7 +46,7 @@
 [out_of_resource_notification]
 title=_Out of Fields
 message=_The farmer working at this farm has no cleared soil to plant his seeds.
-delay_attempts=10
+productivity_threshold=33
 
 [idle]
 pics=farm_i_??.png  # ???

=== modified file 'tribes/atlanteans/hunters_house/conf'
--- tribes/atlanteans/hunters_house/conf	2014-08-02 19:55:23 +0000
+++ tribes/atlanteans/hunters_house/conf	2015-06-08 12:51:06 +0000
@@ -27,7 +27,7 @@
 # TRANSLATORS: "Game" means animals that you can hunt
 title=_Out of Game
 message=_The hunter working out of this hunter’s house can’t find any game in his working radius.
-delay_attempts=10
+productivity_threshold=33
 
 [idle]
 pics=hunters_house_i_??.png

=== modified file 'tribes/atlanteans/well/conf'
--- tribes/atlanteans/well/conf	2014-08-02 19:55:23 +0000
+++ tribes/atlanteans/well/conf	2015-06-08 12:51:06 +0000
@@ -31,7 +31,7 @@
 [out_of_resource_notification]
 title=_Out of Water
 message=_The carrier working at this well can’t find any water in his working radius.
-delay_attempts=50
+productivity_threshold=33
 
 [idle]
 pics=well_i_??.png  # ???

=== modified file 'tribes/atlanteans/woodcutters_house/conf'
--- tribes/atlanteans/woodcutters_house/conf	2014-08-02 19:55:23 +0000
+++ tribes/atlanteans/woodcutters_house/conf	2015-06-08 12:51:06 +0000
@@ -27,7 +27,7 @@
 [out_of_resource_notification]
 title=_Out of Trees
 message=_The woodcutter working at this woodcutter’s house can’t find any trees in his working radius. You should consider dismantling or destroying the building or building a forester’s house.
-delay_attempts=60
+productivity_threshold=33
 
 [idle]
 pics=woodcutters_house_i_??.png

=== modified file 'tribes/barbarians/farm/conf'
--- tribes/barbarians/farm/conf	2015-02-07 01:51:19 +0000
+++ tribes/barbarians/farm/conf	2015-06-08 12:51:06 +0000
@@ -28,7 +28,7 @@
 [plant_wheat]
 sleep=14000  #orig 20000
 worker=plant
-# animate=working  10000 
+# animate=working  10000
 
 [harvest_wheat]
 sleep=4000  #orig 5000
@@ -44,7 +44,7 @@
 [out_of_resource_notification]
 title=_Out of Fields
 message=_The farmer working at this farm has no cleared soil to plant his seeds.
-delay_attempts=10
+productivity_threshold=33
 
 [build]
 pics=build_??.png  # ???
@@ -60,4 +60,4 @@
 
 [working]
 pics=working_??.png  # ???
-hotspot=69 76
\ No newline at end of file
+hotspot=69 76

=== modified file 'tribes/barbarians/hunters_hut/conf'
--- tribes/barbarians/hunters_hut/conf	2015-02-11 18:12:14 +0000
+++ tribes/barbarians/hunters_hut/conf	2015-06-08 12:51:06 +0000
@@ -27,7 +27,7 @@
 # TRANSLATORS: "Game" means animals that you can hunt
 title=_Out of Game
 message=_The hunter working out of this hunter’s hut can’t find any game in his working radius. Remember that you can build a gamekeeper’s hut to release more game into the wild.
-delay_attempts=10
+productivity_threshold=33
 
 [build]
 pics=build_??.png

=== modified file 'tribes/barbarians/lumberjacks_hut/conf'
--- tribes/barbarians/lumberjacks_hut/conf	2015-02-12 03:27:56 +0000
+++ tribes/barbarians/lumberjacks_hut/conf	2015-06-08 12:51:06 +0000
@@ -25,7 +25,7 @@
 [out_of_resource_notification]
 title=_Out of Trees
 message=_The lumberjack working at this lumberjack’s hut can’t find any trees in his working radius. You should consider dismantling or destroying the building or building a rangers’s hut.
-delay_attempts=60
+productivity_threshold=33
 
 [idle]
 pics=idle_??.png

=== modified file 'tribes/barbarians/reed_yard/conf'
--- tribes/barbarians/reed_yard/conf	2014-08-02 19:55:23 +0000
+++ tribes/barbarians/reed_yard/conf	2015-06-08 12:51:06 +0000
@@ -40,7 +40,7 @@
 [out_of_resource_notification]
 title=_Out of Fields
 message=_The gardener working at this reed yard has no cleared soil to plant his seeds.
-delay_attempts=10
+productivity_threshold=33
 
 [idle]
 pics=reed_yard_i_??.png  # ???

=== modified file 'tribes/barbarians/well/conf'
--- tribes/barbarians/well/conf	2014-08-02 19:55:23 +0000
+++ tribes/barbarians/well/conf	2015-06-08 12:51:06 +0000
@@ -27,7 +27,7 @@
 [out_of_resource_notification]
 title=_Out of Water
 message=_The carrier working at this well can’t find any water in his working radius.
-delay_attempts=50
+productivity_threshold=33
 
 [idle]
 pics=well_i_??.png

=== modified file 'tribes/empire/farm/conf'
--- tribes/empire/farm/conf	2014-08-02 19:55:23 +0000
+++ tribes/empire/farm/conf	2015-06-08 12:51:06 +0000
@@ -45,7 +45,7 @@
 [out_of_resource_notification]
 title=_Out of Fields
 message=_The farmer working at this farm has no cleared soil to plant his seeds.
-delay_attempts=10
+productivity_threshold=33
 
 [idle]
 pics=farm_i_??.png  # ???

=== modified file 'tribes/empire/hunters_house/conf'
--- tribes/empire/hunters_house/conf	2014-08-02 19:55:23 +0000
+++ tribes/empire/hunters_house/conf	2015-06-08 12:51:06 +0000
@@ -26,7 +26,7 @@
 # TRANSLATORS: "Game" means animals that you can hunt
 title=_Out of Game
 message=_The hunter working out of this hunter’s house can’t find any game in his working radius.
-delay_attempts=10
+productivity_threshold=33
 
 [idle]
 pics=hunters_house_i_??.png

=== modified file 'tribes/empire/lumberjacks_house/conf'
--- tribes/empire/lumberjacks_house/conf	2014-08-02 19:55:23 +0000
+++ tribes/empire/lumberjacks_house/conf	2015-06-08 12:51:06 +0000
@@ -27,7 +27,7 @@
 [out_of_resource_notification]
 title=_Out of Trees
 message=_The lumberjack working at this lumberjack’s house can’t find any trees in his working radius. You should consider dismantling or destroying the building or building a forester’s house.
-delay_attempts=60
+productivity_threshold=33
 
 [idle]
 pics=lumberjacks_house_i_??.png

=== modified file 'tribes/empire/vineyard/conf'
--- tribes/empire/vineyard/conf	2014-08-02 19:55:23 +0000
+++ tribes/empire/vineyard/conf	2015-06-08 12:51:06 +0000
@@ -42,7 +42,7 @@
 [out_of_resource_notification]
 title=_Out of Fields
 message=_The farmer working at this vineyard has no cleared soil to plant his seeds.
-delay_attempts=10
+productivity_threshold=33
 
 [idle]
 pics=vineyard_i_??.png  # ???

=== modified file 'tribes/empire/well/conf'
--- tribes/empire/well/conf	2014-08-02 19:55:23 +0000
+++ tribes/empire/well/conf	2015-06-08 12:51:06 +0000
@@ -30,7 +30,7 @@
 [out_of_resource_notification]
 title=_Out of Water
 message=_The carrier working at this well can’t find any water in his working radius.
-delay_attempts=50
+productivity_threshold=33
 
 [idle]
 pics=well_i_??.png  # ???


Follow ups