widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #14268
[Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
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:
introduced the return value no_stats for work programs.
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/353514
When the program returns=no_stats it enters the None case. No stats are calculated but in case it has been return=skipped before it gets removed from the skipped_programs-stack.
--
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/mines-worldsavior.
=== modified file 'src/logic/map_objects/tribes/production_program.cc'
--- src/logic/map_objects/tribes/production_program.cc 2018-07-12 16:53:21 +0000
+++ src/logic/map_objects/tribes/production_program.cc 2018-08-21 16:05:14 +0000
@@ -467,9 +467,11 @@
result_ = Completed;
else if (match(parameters, "skipped"))
result_ = Skipped;
+ else if (match(parameters, "no_stats"))
+ result_ = None;
else
throw GameDataError(
- "expected %s but found \"%s\"", "{\"failed\"|\"completed\"|\"skipped\"}", parameters);
+ "expected %s but found \"%s\"", "{\"failed\"|\"completed\"|\"skipped\"|\"no_stats\"}", parameters);
if (skip(parameters)) {
if (match_force_skip(parameters, "when")) {
=== modified file 'src/logic/map_objects/tribes/production_program.h'
--- src/logic/map_objects/tribes/production_program.h 2018-07-12 16:53:21 +0000
+++ src/logic/map_objects/tribes/production_program.h 2018-08-21 16:05:14 +0000
@@ -107,10 +107,11 @@
///
/// Parameter syntax:
/// parameters ::= return_value [condition_part]
- /// return_value ::= Failed | Completed | Skipped
+ /// return_value ::= Failed | Completed | Skipped | None
/// Failed ::= "failed"
/// Completed ::= "completed"
/// Skipped ::= "skipped"
+ /// None ::= "no_stats"
/// condition_part ::= when_condition | unless_conition
/// when_condition ::= "when" condition {"and" condition}
/// unless_condition ::= "unless" condition {"or" condition}
@@ -126,8 +127,9 @@
/// Parameter semantics:
/// return_value:
/// If return_value is Failed or Completed, the productionsite's
- /// statistics is updated accordingly. If return_value is Skipped, the
- /// statistics are not affected.
+ /// statistics is updated accordingly. If return_value is Skipped or
+ /// None, the statistics are not affected. But Skipped adds a 10s delay
+ /// before the program is executed again.
/// condition:
/// A boolean condition that can be evaluated to true or false.
/// condition_part:
@@ -235,11 +237,12 @@
/// Parameter syntax:
/// parameters ::= program {handling_directive}
/// handling_directive ::= "on" Result handling_method
- /// Result ::= "failure" | "completion" | "skip"
+ /// Result ::= "failure" | "completion" | "skip" | "no_stats"
/// handling_method ::= Fail | Complete | Skip | Repeat
/// Fail ::= "fail"
/// Ignore ::= "ignore"
/// Repeat ::= "repeat"
+ /// None ::= "no_stats"
/// Parameter semantics:
/// program:
/// The name of a program defined in the productionsite.
@@ -260,6 +263,9 @@
/// * If handling_method is Skip, the command skips the calling
/// program (with the same effect as executing "return=skipped").
/// * If handling_method is "repeat", the command is repeated.
+ /// * If handling_method is None the called program continues normal,
+ /// but no statistics are calculated (with the same effect as
+ /// executing "return=no_stats")
struct ActCall : public Action {
ActCall(char* parameters, const ProductionSiteDescr&);
void execute(Game&, ProductionSite&) const override;
=== 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-21 16:05:14 +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);
@@ -941,6 +941,7 @@
crude_percent_ = crude_percent_ * 98 / 100;
break;
case None:
+ skipped_programs_.erase(program_name);
break;
}
Follow ups
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: Toni Förster, 2018-09-06
-
[Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: Toni Förster, 2018-09-06
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: Toni Förster, 2018-09-06
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: GunChleoc, 2018-09-06
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: GunChleoc, 2018-08-28
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: hessenfarmer, 2018-08-28
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: GunChleoc, 2018-08-28
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: Toni Förster, 2018-08-21
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: Toni Förster, 2018-08-21
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: hessenfarmer, 2018-08-21
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1786613-10s-return-skipped into lp:widelands
From: Toni Förster, 2018-08-21