Skip to content

Commit

Permalink
stop replay when we have reached the end.
Browse files Browse the repository at this point in the history
the old code used to execute one last [end_turn] after the end of the
replay was reached, This doesn't work because the wml might require
[message][option] or similar during "turn end" events and we don't have
the data for that.
  • Loading branch information
gfgtdf committed Apr 16, 2014
1 parent 192bb9e commit a1ebe02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/replay.cpp
Expand Up @@ -963,7 +963,8 @@ static config get_user_choice_internal(const std::string &name, const mp_sync::u
{
//this should never change during the execution of this function.
int current_side = resources::controller->current_side();

bool is_mp_game = network::nconnections() != 0;

if(current_side != side)
{
//if side != current_side we send the data over the network, that means undoing is impossible
Expand Down Expand Up @@ -1004,6 +1005,7 @@ static config get_user_choice_internal(const std::string &name, const mp_sync::u
//we are in a mp game, and the data has not been recieved yet.
DBG_REPLAY << "MP synchronization: waiting for remote choice\n";

assert(is_mp_game);
synced_context::pull_remote_user_input();

SDL_Delay(10);
Expand Down
11 changes: 9 additions & 2 deletions src/replay_controller.cpp
Expand Up @@ -440,14 +440,21 @@ void replay_controller::play_side(const unsigned int /*team_index*/, bool){

try{
// If a side is empty skip over it.
bool has_end_turn = true;
if (!current_team().is_empty()) {
statistics::reset_turn_stats(current_team().save_id());

play_controller::init_side(player_number_ - 1, true);

DBG_REPLAY << "doing replay " << player_number_ << "\n";
do_replay(player_number_);

// if have reached the end we don't want to execute finish_side_turn and finish_turn
// becasue we might not have enough data to execute them (like advancements during turn_end for example)
// !has_end_turn == we reached the end of teh replay without finding and end turn tag.
has_end_turn = do_replay(player_number_);
if(!has_end_turn)
{
return;
}
finish_side_turn();
}

Expand Down

0 comments on commit a1ebe02

Please sign in to comment.