Skip to content

Commit

Permalink
give do_replays return a better name
Browse files Browse the repository at this point in the history
I forgot what my real intention with this change was, but i still think this is a good change, becasue now people don't have to look up the comments to see what do_replay returns.
So i committed it.
  • Loading branch information
gfgtdf committed Apr 16, 2014
1 parent 3dadc9b commit 925c5a4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/playmp_controller.cpp
Expand Up @@ -512,7 +512,7 @@ void playmp_controller::play_network_turn(){
{
bool was_skipping = recorder.is_skipping();
recorder.set_skip(skip_replay_);
if(do_replay(current_side()))
if(do_replay(current_side()) == REPLAY_FOUND_END_TURN)
{
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/playsingle_controller.cpp
Expand Up @@ -618,7 +618,7 @@ void playsingle_controller::play_turn(bool save)

if (replaying_) {
LOG_NG << "doing replay " << player_number_ << "\n";
replaying_ = ::do_replay(player_number_);
replaying_ = ::do_replay(player_number_) == 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
2 changes: 1 addition & 1 deletion src/playturn.cpp
Expand Up @@ -101,7 +101,7 @@ void turn_info::handle_turn(
//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_);
turn_end = do_replay(team_num_) == REPLAY_FOUND_END_TURN;
recorder.set_skip(was_skipping);

} else {
Expand Down
10 changes: 5 additions & 5 deletions src/replay.cpp
Expand Up @@ -692,7 +692,7 @@ static void show_oos_error_error_function(const std::string& message, bool /*hea
replay::process_error(message);
}

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

Expand All @@ -704,7 +704,7 @@ bool do_replay(int side_num)
return do_replay_handle(side_num);
}

bool do_replay_handle(int side_num)
REPLAY_RETURN do_replay_handle(int side_num)
{

//team &current_team = (*resources::teams)[side_num - 1];
Expand All @@ -728,7 +728,7 @@ bool do_replay_handle(int side_num)
//if there is nothing more in the records
if(cfg == NULL) {
//replayer.set_skip(false);
return false;
return REPLAY_RETURN_AT_END;
}

config::all_children_itors ch_itors = cfg->all_children_range();
Expand Down Expand Up @@ -815,7 +815,7 @@ bool do_replay_handle(int side_num)
verify(*resources::units, child);
}

return true;
return REPLAY_FOUND_END_TURN;
}
else if (const config &child = cfg->child("countdown_update"))
{
Expand Down Expand Up @@ -850,7 +850,7 @@ bool do_replay_handle(int side_num)
std::string child_name = cfg->all_children_range().first->key;
DBG_REPLAY << "got an dependent action name = " << child_name <<"\n";
get_replay_source().revert_action();
return false;
return REPLAY_FOUND_DEPENDENT;
}
else
{
Expand Down
10 changes: 8 additions & 2 deletions src/replay.hpp
Expand Up @@ -154,11 +154,17 @@ replay& get_replay_source();

extern replay recorder;

enum REPLAY_RETURN
{
REPLAY_RETURN_AT_END,
REPLAY_FOUND_DEPENDENT,
REPLAY_FOUND_END_TURN
};
//replays up to one turn from the recorder object
//returns true if it got to the end of the turn without data running out
bool do_replay(int side_num);
REPLAY_RETURN do_replay(int side_num);

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

class replay_network_sender
{
Expand Down
2 changes: 1 addition & 1 deletion src/replay_controller.cpp
Expand Up @@ -444,7 +444,7 @@ void replay_controller::play_side(const unsigned int /*team_index*/, bool){
// 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_);
has_end_turn = do_replay(player_number_) == REPLAY_FOUND_END_TURN;
if(!has_end_turn)
{
return;
Expand Down

0 comments on commit 925c5a4

Please sign in to comment.