Toni Förster has proposed merging 
lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands 
with lp:~widelands-dev/widelands/mines-worldsavior as a prerequisite.

Commit message:
check for whether the program name is work or not.

Requested reviews:
  hessenfarmer (stephan-lutz)
Related bugs:
  Bug #1786613 in widelands: "production times are 10s longer when 
return=skipped"
  https://bugs.launchpad.net/widelands/+bug/1786613

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1786613-10s-return-skipped/+merge/353449

I went a different route now. I did some logging and I figured out that the 
program is only labeled "work" when it calls other programs. Checking for the 
program name would solve this. there is one catch though. The main work program 
in the lua files should call a sub program to make this work. this is the case 
for e.g. Farms, Shipyard, Metalworkshop, etc. There only the unconditioned 
"return=skipped" needs to be removed.

Productionssites that only have work as a program need to be modified. E.g. the 
barbarians bakery currently looks like this:

   programs = {
      work = {
         -- TRANSLATORS: Completed/Skipped/Did not start baking bread because 
...
         descname = pgettext("barbarians_building", "baking pitta bread"),
         actions = {
            "sleep=20000",
            "return=skipped unless economy needs barbarians_bread",
            "consume=water:3 wheat:3",
            "animate=working 20000",
            "produce=barbarians_bread",
            "animate=working 20000",
            "produce=barbarians_bread"
         }
      },
   },

Should then look like this:

   programs = {
      work = {
         -- TRANSLATORS: Completed/Skipped/Did not start baking bread because 
...
         descname = _"working",
         actions = {
            "call=bake_bread",
         }
      },
      bake_bread = {
         descname = pgettext("barbarians_building", "baking pitta bread"),
         actions = {
            "sleep=20000",
            "return=skipped unless economy needs barbarians_bread",
            "consume=water:3 wheat:3",
            "animate=working 20000",
            "produce=barbarians_bread",
            "animate=working 20000",
            "produce=barbarians_bread"
         }
      },
   },

This of course needs to be done for all other buildings as well. It would also 
unify the way production programs are called. Work then would always call the 
"sub-programs" for all buildings. Not only the ones that produce only one ware 
or have the working routine split for other reasons.
-- 
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/mines-worldsavior.
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc	2018-06-19 08:52:49 +0000
+++ src/logic/map_objects/tribes/productionsite.cc	2018-08-20 20:27:08 +0000
@@ -920,7 +920,7 @@
 	stack_.pop_back();
 	if (!stack_.empty())
 		top_state().phase = result;
-
+	
 	switch (result) {
 	case Failed:
 		statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
@@ -929,12 +929,14 @@
 		crude_percent_ = crude_percent_ * 8 / 10;
 		break;
 	case Completed:
-		skipped_programs_.erase(program_name);
-		statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
-		statistics_.push_back(true);
-		train_workers(game);
-		crude_percent_ = crude_percent_ * 8 / 10 + 1000000 * 2 / 10;
-		calc_statistics();
+		if (program_name.compare("work") != 0) {
+			skipped_programs_.erase(program_name);
+			statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
+			statistics_.push_back(true);
+			train_workers(game);
+			crude_percent_ = crude_percent_ * 8 / 10 + 1000000 * 2 / 10;
+			calc_statistics();
+		}
 		break;
 	case Skipped:
 		skipped_programs_[program_name] = game.get_gametime();

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to