← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/failed_skipped_10s into lp:widelands

 

Toni Förster has proposed merging lp:~widelands-dev/widelands/failed_skipped_10s into lp:widelands.

Commit message:
add failed programs to the skipped stack

don't show % for trend


Requested reviews:
  hessenfarmer (stephan-lutz)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/failed_skipped_10s/+merge/368014
-- 
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/failed_skipped_10s.
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc	2019-05-26 17:21:15 +0000
+++ src/logic/map_objects/tribes/productionsite.cc	2019-05-28 21:06:25 +0000
@@ -428,7 +428,7 @@
 		}
 
 		const std::string trend_str =
-		   g_gr->styles().color_tag((boost::format(_("%i%%")) % trend).str(), color);
+		   g_gr->styles().color_tag((boost::format(_("%i")) % trend).str(), color);
 
 		// TODO(GunChleoc): We might need to reverse the order here for RTL languages
 		statistics_string_on_changed_statistics_ =
@@ -924,8 +924,8 @@
 
 	program_timer_ = true;
 	uint32_t tdelta = 10;
-	SkippedPrograms::const_iterator i = skipped_programs_.find(program_name);
-	if (i != skipped_programs_.end()) {
+	FailedSkippedPrograms::const_iterator i = failed_skipped_programs_.find(program_name);
+	if (i != failed_skipped_programs_.end()) {
 		uint32_t const gametime = game.get_gametime();
 		uint32_t const earliest_allowed_start_time = i->second + 10000;
 		if (gametime + tdelta < earliest_allowed_start_time)
@@ -956,13 +956,14 @@
 
 	switch (result) {
 	case ProgramResult::kFailed:
+		failed_skipped_programs_[program_name] = game.get_gametime();
 		statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
 		statistics_.push_back(false);
 		calc_statistics();
 		update_crude_statistics(current_duration, false);
 		break;
 	case ProgramResult::kCompleted:
-		skipped_programs_.erase(program_name);
+		failed_skipped_programs_.erase(program_name);
 		statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
 		statistics_.push_back(true);
 		train_workers(game);
@@ -970,11 +971,11 @@
 		calc_statistics();
 		break;
 	case ProgramResult::kSkipped:
-		skipped_programs_[program_name] = game.get_gametime();
+		failed_skipped_programs_[program_name] = game.get_gametime();
 		update_crude_statistics(current_duration, false);
 		break;
 	case ProgramResult::kNone:
-		skipped_programs_.erase(program_name);
+		failed_skipped_programs_.erase(program_name);
 		break;
 	}
 

=== modified file 'src/logic/map_objects/tribes/productionsite.h'
--- src/logic/map_objects/tribes/productionsite.h	2019-05-22 15:46:08 +0000
+++ src/logic/map_objects/tribes/productionsite.h	2019-05-28 21:06:25 +0000
@@ -307,13 +307,13 @@
 
 	int32_t fetchfromflag_;  ///< Number of wares to fetch from flag
 
-	/// If a program has ended with the result Skipped, that program may not
+	/// If a program has ended with the result Failed or Skipped, that program may not
 	/// start again until a certain time has passed. This is a map from program
-	/// name to game time. When a program ends with the result Skipped, its name
+	/// name to game time. When a program ends with the result Failed or Skipped, its name
 	/// is added to this map, with the current game time. (When the program ends
 	/// with any other result, its name is removed from the map.)
-	using SkippedPrograms = std::map<std::string, Time>;
-	SkippedPrograms skipped_programs_;
+	using FailedSkippedPrograms = std::map<std::string, Time>;
+	FailedSkippedPrograms failed_skipped_programs_;
 
 	using Stack = std::vector<State>;
 	Stack stack_;           ///<  program stack

=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc	2019-05-18 11:58:43 +0000
+++ src/map_io/map_buildingdata_packet.cc	2019-05-28 21:06:25 +0000
@@ -646,13 +646,13 @@
 				if (pr_descr.programs().count(program_name)) {
 					uint32_t const skip_time = fr.unsigned_32();
 					if (gametime < skip_time)
-						throw GameDataError("program %s was skipped at time %u, but time is only "
+						throw GameDataError("program %s failed/was skipped at time %u, but time is only "
 						                    "%u",
 						                    program_name, skip_time, gametime);
-					productionsite.skipped_programs_[program_name] = skip_time;
+					productionsite.failed_skipped_programs_[program_name] = skip_time;
 				} else {
 					fr.unsigned_32();  // eat skip time
-					log("WARNING: productionsite has skipped program \"%s\", which "
+					log("WARNING: productionsite has failed/skipped program \"%s\", which "
 					    "does not exist\n",
 					    program_name);
 				}
@@ -1129,10 +1129,10 @@
 	fw.signed_32(productionsite.fetchfromflag_);
 
 	//  skipped programs
-	assert(productionsite.skipped_programs_.size() <= std::numeric_limits<uint8_t>::max());
-	fw.unsigned_8(productionsite.skipped_programs_.size());
+	assert(productionsite.failed_skipped_programs_.size() <= std::numeric_limits<uint8_t>::max());
+	fw.unsigned_8(productionsite.failed_skipped_programs_.size());
 
-	for (const auto& temp_program : productionsite.skipped_programs_) {
+	for (const auto& temp_program : productionsite.failed_skipped_programs_) {
 		fw.string(temp_program.first);
 		fw.unsigned_32(temp_program.second);
 	}


Follow ups