widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02342
[Merge] lp:~f-thiessen/widelands/bug-965633 into lp:widelands
Ferdinand T. has proposed merging lp:~f-thiessen/widelands/bug-965633 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #965633 in widelands: "Set default AI to random tribe"
https://bugs.launchpad.net/widelands/+bug/965633
For more details, see:
https://code.launchpad.net/~f-thiessen/widelands/bug-965633/+merge/227095
Fixed bug 965633: Set default AI in single player games to random tribe.
Added some standard cleanup in the changed file (container_iterate replaced with std::for).
Tested and works!
--
https://code.launchpad.net/~f-thiessen/widelands/bug-965633/+merge/227095
Your team Widelands Developers is requested to review the proposed merge of lp:~f-thiessen/widelands/bug-965633 into lp:widelands.
=== modified file 'src/logic/single_player_game_settings_provider.cc'
--- src/logic/single_player_game_settings_provider.cc 2014-07-05 12:48:58 +0000
+++ src/logic/single_player_game_settings_provider.cc 2014-07-16 19:31:47 +0000
@@ -94,6 +94,9 @@
player.ai = impls.at(0)->name;
player.random_ai = false;
}
+ //If AI player then set tribe to random
+ if (!s.scenario)
+ setPlayerTribe(oldplayers, "", true);
}
++oldplayers;
}
@@ -162,25 +165,29 @@
actual_tribe = s.tribes.at(random).name;
}
- container_iterate_const(std::vector<TribeBasicInfo>, s.tribes, i)
- if (i.current->name == player.tribe) {
+ for (const TribeBasicInfo tmp_tribe : s.tribes)
+ {
+ if (tmp_tribe.name == player.tribe) {
s.players[number].tribe = actual_tribe;
- if (i.current->initializations.size() <= player.initialization_index) {
+ if (tmp_tribe.initializations.size() <= player.initialization_index) {
player.initialization_index = 0;
}
}
+ }
}
void SinglePlayerGameSettingsProvider::setPlayerInit(uint8_t const number, uint8_t const index) {
if (number >= s.players.size())
return;
- container_iterate_const(std::vector<TribeBasicInfo>, s.tribes, i)
- if (i.current->name == s.players[number].tribe) {
- if (index < i.current->initializations.size())
+ for (const TribeBasicInfo tmp_tribe : s.tribes)
+ {
+ if (tmp_tribe.name == s.players[number].tribe) {
+ if (index < tmp_tribe.initializations.size())
s.players[number].initialization_index = index;
return;
}
+ }
assert(false);
}