Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1399621 into lp:widelands

2015-06-08 Thread TiborB
Review: Approve

I understand that the discussion on forum is over and there are no further 
objections.

I myself tested it and it looks good to me as well.

I went over the code, and as far as I can understand it it looks really good.

So here is my approve
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1399621/+merge/258843
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/bug-1399621.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


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

2015-06-08 Thread GunChleoc
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 +
+++ src/logic/productionsite.cc	2015-06-08 12:51:06 +
@@ -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 +
+++ src/logic/productionsite.h	2015-06-08 12:51:06 +
@@ -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_tm_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};
+	Trendtrend_;
 	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 +
+++ tribes/atlanteans/blackroot_farm/conf	2015-06-08 12:51:06 +
@@ -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 +
+++ tribes/atlanteans/farm/conf	2015-06-08 12:51:06 +
@@ -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 +
+++ tribes/atlanteans/hunters_house/

Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1399621 into lp:widelands

2015-06-08 Thread GunChleoc
Yay! Will merge :)
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1399621/+merge/258843
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/bug-1399621.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp


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

2015-06-08 Thread noreply
The proposal to merge lp:~widelands-dev/widelands/bug-1399621 into lp:widelands 
has been updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1399621/+merge/258843
-- 
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/bug-1399621.

___
Mailing list: https://launchpad.net/~widelands-dev
Post to : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp