Merge lp:~shevonar/widelands/feature-random-tribe-and-AI into lp:widelands

Proposed by Shevonar
Status: Merged
Merged at revision: 5991
Proposed branch: lp:~shevonar/widelands/feature-random-tribe-and-AI
Merge into: lp:widelands
Diff against target: 33 lines (+8/-4)
2 files modified
src/network/nethost.cc (+4/-2)
src/wlapplication.cc (+4/-2)
To merge this branch: bzr merge lp:~shevonar/widelands/feature-random-tribe-and-AI
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+76897@code.launchpad.net

Description of the change

AI: random will not result in AI: None

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/network/nethost.cc'
2--- src/network/nethost.cc 2011-09-19 17:48:27 +0000
3+++ src/network/nethost.cc 2011-09-25 10:36:26 +0000
4@@ -174,8 +174,10 @@
5 newstate = PlayerSettings::stateClosed;
6 }
7 } else if (it == impls.end()) {
8- uint8_t random = (std::rand() % impls.size()); // Choose a random AI
9- it = impls.begin() + random;
10+ do {
11+ uint8_t random = (std::rand() % impls.size()); // Choose a random AI
12+ it = impls.begin() + random;
13+ } while ((*it)->name == "None");
14 setPlayerAI(number, (*it)->name, true);
15 newstate = PlayerSettings::stateComputer;
16 break;
17
18=== modified file 'src/wlapplication.cc'
19--- src/wlapplication.cc 2011-09-19 17:48:27 +0000
20+++ src/wlapplication.cc 2011-09-25 10:36:26 +0000
21@@ -1902,8 +1902,10 @@
22 it = impls.begin();
23 } else if (it == impls.end()) {
24 s.players[number].random_ai = true;
25- uint8_t random = (std::rand() % impls.size()); // Choose a random AI
26- it = impls.begin() + random;
27+ do {
28+ uint8_t random = (std::rand() % impls.size()); // Choose a random AI
29+ it = impls.begin() + random;
30+ } while ((*it)->name == "None");
31 }
32 s.players[number].ai = (*it)->name;
33 }

Subscribers

People subscribed via source and target branches

to status/vote changes: