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:
Benoît Timbert 2006-07-27 13:15:34 +00:00
parent 0afb158715
commit e32933a6c5

View File

@ -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();
}
}
}
};