use synced_context: fix mp observers

with the new synced_context system, the old code would bring code in the wrong order onto the replay if we received data during get_user_choice
which now could be called during turn_info::handle_turn.

also previous code would fail to process
[turn]
[command]
[move]
x = 3,4,5
y = 4,3,3
[/move]
[/command]
[/turn]
[turn]
[command]
dependent = yes
[input]
[/input]
[/command]
[/turn]
because [input] would be processed after [move] was processed, but
[move] need [input] on the replay to work properly.
(if luas sync_choice was called from a moveto event)

this commit is part or pr 121.
This commit is contained in:
gfgtdf 2014-03-24 19:00:11 +01:00
parent 75d81ee49c
commit da4cdef146
3 changed files with 18 additions and 8 deletions

View file

@ -468,6 +468,16 @@ void playmp_controller::play_network_turn(){
break;
}
}
/*
we might have data left in replay that we recieved during prestart events. (or maybe other events.)
*/
else if(!recorder.at_end())
{
if(do_replay(current_side()))
{
break;
}
}
}
play_slice();

View file

@ -93,8 +93,11 @@ void turn_info::handle_turn(
replay_.append(t);
replay_.set_skip(skip_replay);
turn_end = do_replay(team_num_, &replay_);
//turn_end = do_replay(team_num_, &replay_);
//note, that this cunfion might call itself recursively: do_replay -> ... -> persist_var -> ... -> handle_generic_event -> sync_network -> handle_turn
recorder.add_config(t, replay::MARK_AS_SENT);
turn_end = do_replay(team_num_);
} else {
//this turn has finished, so push the remaining moves
@ -159,8 +162,9 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
BOOST_FOREACH(const config &t, turns)
{
handle_turn(turn_end, t, skip_replay, backlog);
recorder.add_config(t, replay::MARK_AS_SENT);
}
handle_turn(turn_end, config(), skip_replay, backlog);
resources::whiteboard->process_network_data(cfg);

View file

@ -809,11 +809,6 @@ void replay::add_config(const config& cfg, MARK_SENT mark)
BOOST_FOREACH(const config &cmd, cfg.child_range("command"))
{
config &cfg = cfg_.add_child("command", cmd);
if (cfg.child("speak"))
{
pos_ = ncommands();
add_chat_message_location();
}
if(mark == MARK_AS_SENT) {
cfg["sent"] = true;
}
@ -1405,9 +1400,10 @@ void replay_network_sender::commit_and_sync()
{
if(network::nconnections() > 0) {
resources::whiteboard->send_network_data();
config cfg;
const config& data = cfg.add_child("turn",obj_.get_data_range(upto_,obj_.ncommands()));
if(data.empty() == false) {
network::send_data(cfg, 0);
}