Skip to content

Commit

Permalink
treat local choices as like sycned contexts in replay.cpp
Browse files Browse the repository at this point in the history
this makes more sense as the game cannot handle sycned commands while
executing local choices. It also fixes an OOS in
wesnoth.synchronize_choices
  • Loading branch information
gfgtdf committed Mar 31, 2018
1 parent ef2db56 commit 4cd9882
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/replay.cpp
Expand Up @@ -700,8 +700,9 @@ REPLAY_RETURN do_replay_handle(bool one_move)
{
const config *cfg = resources::recorder->get_next_action();
const bool is_synced = synced_context::is_synced();
const bool is_unsynced = synced_context::get_synced_state() == synced_context::UNSYNCED;

DBG_REPLAY << "in do replay with is_synced=" << is_synced << "\n";
DBG_REPLAY << "in do replay with is_synced=" << is_synced << "is_unsynced=" << is_unsynced << "\n";

if (cfg != nullptr)
{
Expand Down Expand Up @@ -782,7 +783,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
else if (cfg->child("init_side"))
{

if(is_synced)
if(!is_unsynced)
{
replay::process_error("found side initialization in replay expecting a user choice\n" );
resources::recorder->revert_action();
Expand All @@ -800,7 +801,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
//if there is an end turn directive
else if (const config& end_turn = cfg->child("end_turn"))
{
if(is_synced)
if(!is_unsynced)
{
replay::process_error("found turn end in replay while expecting a user choice\n" );
resources::recorder->revert_action();
Expand Down Expand Up @@ -832,7 +833,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
}
else if ((*cfg)["dependent"].to_bool(false))
{
if(!is_synced)
if(is_unsynced)
{
replay::process_error("found dependent command in replay while is_synced=false\n" );
//ignore this command
Expand All @@ -854,7 +855,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
const std::string & commandname = cfg->ordered_begin()->key;
config data = cfg->ordered_begin()->cfg;

if(is_synced)
if(!is_unsynced)
{
replay::process_error("found [" + commandname + "] command in replay expecting a user choice\n" );
resources::recorder->revert_action();
Expand Down

0 comments on commit 4cd9882

Please sign in to comment.