mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 20:10:38 +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() {
|
||||
const std::set<std::string>& options = current_team().recruits();
|
||||
const int choice = (rand()%options.size());
|
||||
std::set<std::string>::const_iterator i = options.begin();
|
||||
std::advance(i,choice);
|
||||
if (!options.empty()) {
|
||||
const int choice = (rand()%options.size());
|
||||
std::set<std::string>::const_iterator i = options.begin();
|
||||
std::advance(i,choice);
|
||||
|
||||
const bool res = recruit(*i);
|
||||
if(res) {
|
||||
do_recruitment();
|
||||
const bool res = recruit(*i);
|
||||
if(res) {
|
||||
do_recruitment();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user