Skip to content

Commit

Permalink
use synced_context: fix mp observers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gfgtdf committed Apr 16, 2014
1 parent 5b04796 commit f6fbde5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/playmp_controller.cpp
Expand Up @@ -507,6 +507,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();
Expand Down
8 changes: 6 additions & 2 deletions src/playturn.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 2 additions & 6 deletions src/replay.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f6fbde5

Please sign in to comment.