Skip to content

Commit

Permalink
cleanup check_victory in ai actions
Browse files Browse the repository at this point in the history
do_execute which calls run_in_synced_context can throw end_level
exception because run_in_synced context calls check_victory. So we don't
need the additional check_victory in action_result::execute anymore.
  • Loading branch information
gfgtdf committed May 25, 2014
1 parent 684d1c3 commit 9f399d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ai/actions.cpp
Expand Up @@ -93,10 +93,9 @@ void action_result::execute()
init_for_execution();
check_before();
if (is_success()){
do_execute();
try {
resources::controller->check_victory();
} catch (...) {
do_execute();
} catch (end_level_exception&) {
is_ok(); //Silences "unchecked result" warning
throw;
}
Expand Down Expand Up @@ -285,6 +284,7 @@ void attack_result::do_execute()
resources::tod_manager->get_time_of_day()));
set_scontext_synced sync;
attack_unit_and_advance(attacker_loc_, defender_loc_, attacker_weapon, defender_weapon, true, advancements_);
resources::controller->check_victory();
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/playsingle_controller.cpp
Expand Up @@ -943,6 +943,9 @@ void playsingle_controller::play_ai_turn(){
try {
ai::manager::play_turn(player_number_);
} catch (end_turn_exception&) {
} catch (end_level_exception&) {
turn_data.sync_network();
throw;
}
recorder.end_turn();
turn_data.sync_network();
Expand Down

0 comments on commit 9f399d8

Please sign in to comment.