← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/economy-target-profiles into lp:widelands

 

Benedikt Straub has proposed merging lp:~widelands-dev/widelands/economy-target-profiles into lp:widelands.

Commit message:
Fix economy targets profile application when no items are selected

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1827696 in widelands: "Allow users to define their own economy default settings"
  https://bugs.launchpad.net/widelands/+bug/1827696
  Bug #1831196 in widelands: "Economy profile selection doesn't work"
  https://bugs.launchpad.net/widelands/+bug/1831196

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/economy-target-profiles/+merge/368181
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/economy-target-profiles into lp:widelands.
=== modified file 'src/wui/economy_options_window.cc'
--- src/wui/economy_options_window.cc	2019-05-29 16:59:16 +0000
+++ src/wui/economy_options_window.cc	2019-05-31 09:22:25 +0000
@@ -307,29 +307,25 @@
 	const PredefinedTargets settings = economy_options_window_->get_selected_target();
 
 	bool anything_selected = false;
-	bool second_phase = false;
-
-	do {
-		for (const Widelands::DescriptionIndex& index : items) {
-			if (display_.ware_selected(index) || (second_phase && !display_.is_ware_hidden(index))) {
-				anything_selected = true;
-				if (is_wares) {
-					game.send_player_command(new Widelands::CmdSetWareTargetQuantity(
-					   game.get_gametime(), player_->player_number(), serial_, index,
-					   settings.wares.at(index)));
-				} else {
-					game.send_player_command(new Widelands::CmdSetWorkerTargetQuantity(
-					   game.get_gametime(), player_->player_number(), serial_, index,
-					   settings.workers.at(index)));
-				}
+	for (const Widelands::DescriptionIndex& index : items) {
+		if (display_.ware_selected(index)) {
+			anything_selected = true;
+			break;
+		}
+	}
+	for (const Widelands::DescriptionIndex& index : items) {
+		if (display_.ware_selected(index) || (!anything_selected && !display_.is_ware_hidden(index))) {
+			if (is_wares) {
+				game.send_player_command(new Widelands::CmdSetWareTargetQuantity(
+				   game.get_gametime(), player_->player_number(), serial_, index,
+				   settings.wares.at(index)));
+			} else {
+				game.send_player_command(new Widelands::CmdSetWorkerTargetQuantity(
+				   game.get_gametime(), player_->player_number(), serial_, index,
+				   settings.workers.at(index)));
 			}
 		}
-		if (anything_selected) {
-			return;
-		}
-		// Nothing was selected, now go through the loop again and change everything
-		second_phase = true;
-	} while (!second_phase);
+	}
 }
 
 constexpr unsigned kThinkInterval = 200;


Follow ups