mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-09 18:08:34 +00:00
merge 2006-07-27T13:11:54Z!benoit.timbert@free.fr:
sample_ai should no longer crash the game if the recruitment list of the faction is empty.
This commit is contained in:
parent
0afb158715
commit
e32933a6c5
14
src/ai.cpp
14
src/ai.cpp
@ -148,13 +148,15 @@ protected:
|
|||||||
|
|
||||||
void do_recruitment() {
|
void do_recruitment() {
|
||||||
const std::set<std::string>& options = current_team().recruits();
|
const std::set<std::string>& options = current_team().recruits();
|
||||||
const int choice = (rand()%options.size());
|
if (!options.empty()) {
|
||||||
std::set<std::string>::const_iterator i = options.begin();
|
const int choice = (rand()%options.size());
|
||||||
std::advance(i,choice);
|
std::set<std::string>::const_iterator i = options.begin();
|
||||||
|
std::advance(i,choice);
|
||||||
|
|
||||||
const bool res = recruit(*i);
|
const bool res = recruit(*i);
|
||||||
if(res) {
|
if(res) {
|
||||||
do_recruitment();
|
do_recruitment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user