Skip to content

Commit

Permalink
remove do_replay s side parameter
Browse files Browse the repository at this point in the history
and use controller->current_side() instead.
  • Loading branch information
gfgtdf committed May 26, 2014
1 parent 52f271a commit 562e1ed
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/playmp_controller.cpp
Expand Up @@ -485,7 +485,7 @@ void playmp_controller::play_network_turn(){
{
bool was_skipping = recorder.is_skipping();
recorder.set_skip(skip_replay_);
if(do_replay(current_side()) == REPLAY_FOUND_END_TURN)
if(do_replay() == REPLAY_FOUND_END_TURN)
{
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/playsingle_controller.cpp
Expand Up @@ -628,7 +628,7 @@ void playsingle_controller::play_turn(bool save)

if (replaying_) {
LOG_NG << "doing replay " << player_number_ << "\n";
replaying_ = ::do_replay(player_number_) == REPLAY_FOUND_END_TURN;
replaying_ = ::do_replay() == REPLAY_FOUND_END_TURN;
LOG_NG << "result of replay: " << (replaying_?"true":"false") << "\n";
} else {
// If a side is dead end the turn, but play at least side=1's
Expand Down
4 changes: 2 additions & 2 deletions src/playturn.cpp
Expand Up @@ -61,7 +61,7 @@ turn_info::~turn_info()
turn_info::PROCESS_DATA_RESULT turn_info::sync_network()
{
//there should be nothing left on the replay and we should get turn_info::PROCESS_CONTINUE back.
turn_info::PROCESS_DATA_RESULT retv = replay_to_process_data_result(do_replay(team_num_));
turn_info::PROCESS_DATA_RESULT retv = replay_to_process_data_result(do_replay());
if(network::nconnections() > 0) {

//receive data first, and then send data. When we sent the end of
Expand Down Expand Up @@ -98,7 +98,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::handle_turn(
recorder.set_skip(skip_replay);
//note, that this function might call itself recursively: do_replay -> ... -> persist_var -> ... -> handle_generic_event -> sync_network -> handle_turn
recorder.add_config(t, replay::MARK_AS_SENT);
PROCESS_DATA_RESULT retv = replay_to_process_data_result(do_replay(team_num_));
PROCESS_DATA_RESULT retv = replay_to_process_data_result(do_replay());
recorder.set_skip(was_skipping);
return retv;
}
Expand Down
10 changes: 5 additions & 5 deletions src/replay.cpp
Expand Up @@ -714,7 +714,7 @@ static void show_oos_error_error_function(const std::string& message, bool /*hea
replay::process_error(message);
}

REPLAY_RETURN do_replay(int side_num)
REPLAY_RETURN do_replay()
{
log_scope("do replay");

Expand All @@ -723,15 +723,15 @@ REPLAY_RETURN do_replay(int side_num)
}

update_locker lock_update(resources::screen->video(),get_replay_source().is_skipping());
return do_replay_handle(side_num);
return do_replay_handle();
}

REPLAY_RETURN do_replay_handle(int side_num)
REPLAY_RETURN do_replay_handle()
{

//team &current_team = (*resources::teams)[side_num - 1];


const int side_num = resources::controller->current_side();
for(;;) {
const config *cfg = get_replay_source().get_next_action();
const bool is_synced = (synced_context::get_synced_state() == synced_context::SYNCED);
Expand Down Expand Up @@ -981,7 +981,7 @@ static std::map<int, config> get_user_choice_internal(const std::string &name, c
/*
there might be speak or similar commands in the replay before the user input.
*/
do_replay_handle(current_side);
do_replay_handle();

/*
these value might change due to player left/reassign during pull_remote_user_input
Expand Down
4 changes: 2 additions & 2 deletions src/replay.hpp
Expand Up @@ -169,9 +169,9 @@ enum REPLAY_RETURN
};
//replays up to one turn from the recorder object
//returns true if it got to the end of the turn without data running out
REPLAY_RETURN do_replay(int side_num);
REPLAY_RETURN do_replay();

REPLAY_RETURN do_replay_handle(int side_num);
REPLAY_RETURN do_replay_handle();

class replay_network_sender
{
Expand Down
2 changes: 1 addition & 1 deletion src/replay_controller.cpp
Expand Up @@ -462,7 +462,7 @@ void replay_controller::play_side(const unsigned int /*team_index*/, bool){
DBG_REPLAY << "doing replay " << player_number_ << "\n";
// 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)
if(do_replay(player_number_) != REPLAY_FOUND_END_TURN) {
if(do_replay() != REPLAY_FOUND_END_TURN) {
// We reached the end of teh replay without finding and end turn tag.
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/synced_context.cpp
Expand Up @@ -266,7 +266,7 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
*/
while(true){

do_replay_handle(current_side);
do_replay_handle();
// the current_side on the server is a lie because it can happen on one client we are already executing side 2
bool is_local_side = (*resources::teams)[side-1].is_local();
bool is_replay_end = get_replay_source().at_end();
Expand Down Expand Up @@ -321,7 +321,7 @@ config synced_context::ask_server(const std::string &name, const mp_sync::user_c
/* The decision has already been made, and must
be extracted from the replay. */
DBG_REPLAY << "MP synchronization: replay server choice\n";
do_replay_handle(resources::controller->current_side());
do_replay_handle();
const config *action = get_replay_source().get_next_action();
if (!action)
{
Expand Down

0 comments on commit 562e1ed

Please sign in to comment.