use replay::process_error instead of ERR_REPLAY for OOS
since replay::process_error might throw we cannot do this in set_sconext_synced destructor anymore and have to call do_final_checkup() ealier.
This commit is contained in:
parent
7dc3969eec
commit
277fffcb0c
9 changed files with 34 additions and 12 deletions
|
@ -1270,6 +1270,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
|
|||
set_scontext_synced sync;
|
||||
size_t r = move_unit_internal(undo_stack, show_move, interrupted, mover);
|
||||
resources::controller->check_victory();
|
||||
sync.do_final_checkup();
|
||||
return r;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -929,7 +929,7 @@ bool undo_list::recall_action::redo(int side)
|
|||
if ( msg.empty() ) {
|
||||
recorder.redo(replay_data);
|
||||
replay_data.clear();
|
||||
set_scontext_synced sco;
|
||||
set_scontext_synced sync;
|
||||
recall_unit(id, current_team, loc, from, true, false);
|
||||
|
||||
// Quick error check. (Abuse of [allow_undo]?)
|
||||
|
@ -940,6 +940,7 @@ bool undo_list::recall_action::redo(int side)
|
|||
// undoing this works.
|
||||
route.front() = loc;
|
||||
}
|
||||
sync.do_final_checkup();
|
||||
} else {
|
||||
gui::dialog(gui, "", msg, gui::OK_ONLY).show();
|
||||
return false;
|
||||
|
@ -976,7 +977,7 @@ bool undo_list::recruit_action::redo(int side)
|
|||
current_team.set_action_bonus_count(1 + current_team.action_bonus_count());
|
||||
recorder.redo(replay_data);
|
||||
replay_data.clear();
|
||||
set_scontext_synced sco;
|
||||
set_scontext_synced sync;
|
||||
recruit_unit(u_type, side, loc, from, true, false);
|
||||
|
||||
// Quick error check. (Abuse of [allow_undo]?)
|
||||
|
@ -987,6 +988,7 @@ bool undo_list::recruit_action::redo(int side)
|
|||
// undoing this works.
|
||||
route.front() = loc;
|
||||
}
|
||||
sync.do_final_checkup();
|
||||
} else {
|
||||
gui::dialog(gui, "", msg, gui::OK_ONLY).show();
|
||||
return false;
|
||||
|
|
|
@ -292,6 +292,7 @@ void attack_result::do_execute()
|
|||
set_scontext_synced sync;
|
||||
attack_unit_and_advance(attacker_loc_, defender_loc_, attacker_weapon, defender_weapon, true, advancements_);
|
||||
resources::controller->check_victory();
|
||||
sync.do_final_checkup();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -382,10 +382,11 @@ void play_controller::maybe_do_init_side(bool is_replay, bool only_visual) {
|
|||
return;
|
||||
}
|
||||
|
||||
if(!only_visual){
|
||||
if(!only_visual) {
|
||||
recorder.init_side();
|
||||
set_scontext_synced sync;
|
||||
do_init_side(is_replay);
|
||||
sync.do_final_checkup();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -529,6 +530,7 @@ void play_controller::finish_side_turn(){
|
|||
pump().fire("side "+ side_num + " turn end");
|
||||
pump().fire("side turn " + turn_num + " end");
|
||||
pump().fire("side " + side_num + " turn " + turn_num + " end");
|
||||
sync.do_final_checkup();
|
||||
}
|
||||
// This is where we refog, after all of a side's events are done.
|
||||
actions::recalculate_fog(player_number_);
|
||||
|
@ -551,6 +553,7 @@ void play_controller::finish_turn()
|
|||
const std::string turn_num = str_cast(turn());
|
||||
pump().fire("turn end");
|
||||
pump().fire("turn " + turn_num + " end");
|
||||
sync.do_final_checkup();
|
||||
}
|
||||
|
||||
bool play_controller::enemies_visible() const
|
||||
|
|
|
@ -251,7 +251,7 @@ boost::optional<LEVEL_RESULT> playsingle_controller::play_scenario_init(end_leve
|
|||
assert(false && "caugh end_turn exception in a bad place... terminating.");
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
sync.do_final_checkup();
|
||||
gui_->recalculate_minimap();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -828,6 +828,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
|
|||
{
|
||||
set_scontext_synced sync;
|
||||
resources::controller->do_init_side(true);
|
||||
sync.do_final_checkup();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ void replay_controller::reset_replay()
|
|||
|
||||
// Scenario initialization. (c.f. playsingle_controller::play_scenario())
|
||||
fire_preload();
|
||||
if(true){ //block for set_scontext_synced
|
||||
{ //block for set_scontext_synced
|
||||
if(recorder.add_start_if_not_there_yet())
|
||||
{
|
||||
ERR_REPLAY << "inserted missing [start]" << std::endl;
|
||||
|
@ -388,6 +388,7 @@ void replay_controller::reset_replay()
|
|||
fire_prestart();
|
||||
init_gui();
|
||||
fire_start(true);
|
||||
sync.do_final_checkup();
|
||||
}
|
||||
// Since we did not fire the start event, it_is_a_new_turn_ has the wrong value.
|
||||
it_is_a_new_turn_ = true;
|
||||
|
|
|
@ -75,7 +75,7 @@ bool synced_context::run_in_synced_context(const std::string& commandname, const
|
|||
use this after recorder.add_synced_command
|
||||
because set_scontext_synced sets the checkup to the last added command
|
||||
*/
|
||||
set_scontext_synced sco;
|
||||
set_scontext_synced sync;
|
||||
synced_command::map::iterator it = synced_command::registry().find(commandname);
|
||||
if(it == synced_command::registry().end())
|
||||
{
|
||||
|
@ -95,6 +95,7 @@ bool synced_context::run_in_synced_context(const std::string& commandname, const
|
|||
// this might also be a good point to call resources::controller->check_victory();
|
||||
// because before for example if someone kills all units during a moveto event they don't loose.
|
||||
resources::controller->check_victory();
|
||||
sync.do_final_checkup();
|
||||
DBG_REPLAY << "run_in_synced_context end\n";
|
||||
return true;
|
||||
}
|
||||
|
@ -389,14 +390,16 @@ void set_scontext_synced::init()
|
|||
synced_context::reset_is_simultaneously();
|
||||
|
||||
synced_context::set_last_unit_id(n_unit::id_manager::instance().get_save_id());
|
||||
did_final_checkup_ = false;
|
||||
old_checkup_ = checkup_instance;
|
||||
checkup_instance = &*new_checkup_;
|
||||
old_rng_ = random_new::generator;
|
||||
random_new::generator = new_rng_.get();
|
||||
}
|
||||
|
||||
void set_scontext_synced::do_final_checkup()
|
||||
void set_scontext_synced::do_final_checkup(bool dont_throw)
|
||||
{
|
||||
assert(!did_final_checkup_);
|
||||
std::stringstream msg;
|
||||
config co;
|
||||
config cn = config_of
|
||||
|
@ -422,8 +425,16 @@ void set_scontext_synced::do_final_checkup()
|
|||
if(!msg.str().empty())
|
||||
{
|
||||
msg << co.debug() << std::endl;
|
||||
ERR_REPLAY << msg.str() << std::flush;
|
||||
if(dont_throw)
|
||||
{
|
||||
ERR_REPLAY << msg.str() << std::flush;
|
||||
}
|
||||
else
|
||||
{
|
||||
replay::process_error(msg.str());
|
||||
}
|
||||
}
|
||||
did_final_checkup_ = true;
|
||||
}
|
||||
|
||||
set_scontext_synced::~set_scontext_synced()
|
||||
|
@ -431,9 +442,10 @@ set_scontext_synced::~set_scontext_synced()
|
|||
LOG_REPLAY << "set_scontext_synced:: destructor\n";
|
||||
assert(synced_context::get_synced_state() == synced_context::SYNCED);
|
||||
assert(checkup_instance == &*new_checkup_);
|
||||
|
||||
do_final_checkup();
|
||||
|
||||
if(!did_final_checkup_)
|
||||
{
|
||||
do_final_checkup(true);
|
||||
}
|
||||
random_new::generator = old_rng_;
|
||||
synced_context::set_synced_state(synced_context::UNSYNCED);
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public:
|
|||
set_scontext_synced(int num);
|
||||
~set_scontext_synced();
|
||||
int get_random_calls();
|
||||
void do_final_checkup();
|
||||
void do_final_checkup(bool dont_throw = false);
|
||||
private:
|
||||
//only called by contructors.
|
||||
void init();
|
||||
|
@ -159,6 +159,7 @@ private:
|
|||
checkup* old_checkup_;
|
||||
boost::scoped_ptr<checkup> new_checkup_;
|
||||
events::command_disabler disabler_;
|
||||
bool did_final_checkup_;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue