← Back to team overview

widelands-dev team mailing list archive

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

 

TiborB has proposed merging lp:~widelands-dev/widelands/bug-1656671 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1656671 in widelands: "Wares are not always transported to construction site"
  https://bugs.launchpad.net/widelands/+bug/1656671

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

I propose my take about this issue. It seems that the problem is that request time for some building material for a constructionsite is in future, but algorithm does not plan a "pairing session" for this. And if there is no other trigger for pairing - it never takes place and previosly delayed request is never addressed. I added a 30 seconds delay to not forget about such outstanding requests.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1656671 into lp:widelands.
=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc	2016-12-01 16:59:34 +0000
+++ src/economy/economy.cc	2017-01-18 21:16:27 +0000
@@ -701,6 +701,9 @@
  * Walk all Requests and find potential transfer candidates.
 */
 void Economy::process_requests(Game& game, RSPairStruct& s) {
+	// Algorithm can decide that wares are not to be delivered to productionsite
+	// right now, therefore we need to shcedule next pairing
+	bool postponed_pairing_needed = false;
 	for (Request* temp_req : requests_) {
 		Request& req = *temp_req;
 
@@ -734,6 +737,9 @@
 
 		int32_t const priority = req.get_priority(cost);
 		if (priority < 0) {
+			// We dont "pair" the req with supply now, and dont set s.nexttimer right now
+			// but should not forget about this productionsite waiting for the building material
+			postponed_pairing_needed = true;
 			continue;
 		}
 
@@ -746,6 +752,10 @@
 
 		s.queue.push(rsp);
 	}
+	if (postponed_pairing_needed && s.nexttimer < 0) {
+		// so no other pair set the timer, so we set them now for after 30 seconds
+		s.nexttimer = 30 * 1000;
+	}
 }
 
 /**


Follow ups