Skip to content

Commit

Permalink
fix 'at_end()' assertion faliure when chatting in a mp game
Browse files Browse the repository at this point in the history
See #1857

This commit does 2 things:
1) Ensure that if the replay pos was at_end before a speak was added it will still be at end after the speak was added, fixes the mentioned assertion failure.
2) Make unsyced map_labels use the same logic as speak, this fixes OOS issues when the 'back to turn' mp feature was used in mp, since previously adding map labels while watching a mp replay (is the really possible? not 100% sure) might cause mismatches of replay_pos of other savegames with the current replay data.
  • Loading branch information
gfgtdf committed Sep 6, 2017
1 parent d707f94 commit d08f402
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/replay.cpp
Expand Up @@ -337,8 +337,7 @@ bool replay::add_chat_message_location(int pos)

void replay::speak(const config& cfg)
{
config& cmd = base_->insert_command(base_->size());
cmd["undo"] = false;
config& cmd = add_nonundoable_command();
cmd.add_child("speak",cfg);
add_chat_message_location(base_->size() - 1);
}
Expand Down Expand Up @@ -581,9 +580,13 @@ config& replay::add_command()

config& replay::add_nonundoable_command()
{
config& r = base_->insert_command(base_->get_pos());
const bool was_at_end = at_end();
config& r = base_->insert_command(base_->size());
r["undo"] = false;
base_->set_pos(base_->get_pos() + 1);
if(was_at_end) {
base_->set_pos(base_->get_pos() + 1);
}
assert(was_at_end == at_end());
return r;
}

Expand Down

0 comments on commit d08f402

Please sign in to comment.