← Back to team overview

widelands-dev team mailing list archive

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

 

cghislai has proposed merging lp:~widelands-dev/widelands/bug1212191_bug1212192 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1212191 in widelands: "100% training site production without any soldier"
  https://bugs.launchpad.net/widelands/+bug/1212191
  Bug #1212192 in widelands: "Evict worker doesn't work for the second worker"
  https://bugs.launchpad.net/widelands/+bug/1212192

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug1212191_bug1212192/+merge/180098

These are small fixes for the attached bugs.
As the worker evict logic changed a bit, i put it for review.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug1212191_bug1212192/+merge/180098
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug1212191_bug1212192 into lp:widelands.
=== modified file 'src/logic/production_program.cc'
--- src/logic/production_program.cc	2013-08-08 19:55:12 +0000
+++ src/logic/production_program.cc	2013-08-14 11:24:04 +0000
@@ -1276,10 +1276,15 @@
 {
 	SoldierControl & ctrl = dynamic_cast<SoldierControl &>(ps);
 	const std::vector<Soldier *> soldiers = ctrl.presentSoldiers();
+	if (soldiers.empty()) {
+			snprintf
+				(ps.m_result_buffer, sizeof(ps.m_result_buffer),
+				 _("No soldier to train!"));
+		return ps.program_end(game, Skipped);
+	}
+	ps.molog("  Checking soldier (%u) level %d)\n", attribute, level);
+
 	const std::vector<Soldier *>::const_iterator soldiers_end = soldiers.end();
-
-	ps.molog("  Checking soldier (%u) level %d)\n", attribute, level);
-
 	for (std::vector<Soldier *>::const_iterator it = soldiers.begin();; ++it) {
 		if (it == soldiers_end) {
 			snprintf

=== modified file 'src/logic/worker.cc'
--- src/logic/worker.cc	2013-08-08 19:55:12 +0000
+++ src/logic/worker.cc	2013-08-14 11:24:04 +0000
@@ -1699,7 +1699,6 @@
 	push_task(game, taskBuildingwork);
 	State & state = top_state();
 	state.ivar1 = 0;
-	state.ivar2 = 0;
 }
 
 
@@ -1708,13 +1707,13 @@
 	// Reset any signals that are not related to location
 	std::string signal = get_signal();
 	signal_handled();
+	if (signal == "evict") {
+		return pop_task(game);
+	}
 
 	if (state.ivar1 == 1)
 		state.ivar1 = (signal == "fail") * 2;
 
-	if (state.ivar2 == 1)
-		return pop_task(game); // evict worker
-
 	// Return to building, if necessary
 	upcast(Building, building, get_location(game));
 	if (!building)
@@ -1753,11 +1752,8 @@
  */
 void Worker::evict(Game & game)
 {
-	if (State * state = get_state(taskBuildingwork)) {
-		if (is_evict_allowed()) {
-			state->ivar2 = 1;
-			send_signal(game, "evict");
-		}
+	if (is_evict_allowed()) {
+		send_signal(game, "evict");
 	}
 }
 


Follow ups