added check before execution of ai_default...
...recruit action to prevent trying to recruit when it's impossible to recruit
This commit is contained in:
parent
15f007377f
commit
d0c80ffc20
2 changed files with 10 additions and 2 deletions
|
@ -121,7 +121,11 @@ bool action_result::is_ok()
|
|||
|
||||
void action_result::set_error(int error_code){
|
||||
status_ = error_code;
|
||||
ERR_AI_ACTIONS << "Error #"<<error_code<<" in "<< do_describe();
|
||||
if (is_execution()) {
|
||||
ERR_AI_ACTIONS << "Error #"<<error_code<<" in "<< do_describe();
|
||||
} else {
|
||||
LOG_AI_ACTIONS << "Error #"<<error_code<<" when checking "<< do_describe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -251,7 +251,11 @@ void readonly_context_impl::handle_generic_event(const std::string& /*event_name
|
|||
|
||||
bool readwrite_context_impl::recruit(const std::string& unit_name, map_location loc)
|
||||
{
|
||||
recruit_result_ptr recruit_res = execute_recruit_action(unit_name,loc);
|
||||
recruit_result_ptr recruit_res = check_recruit_action(unit_name,loc);
|
||||
if (!recruit_res->is_ok()) {
|
||||
return false;
|
||||
}
|
||||
recruit_res->execute();
|
||||
if (!recruit_res->is_ok()) {
|
||||
ERR_AI << "recruit failed"<< std::endl;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue