Skip to content

Commit

Permalink
replay controller uses game_board to do resets
Browse files Browse the repository at this point in the history
This is not a strict refactor -- the game map will also be reset
to the starting configuration now, when we reset the replay. It
doesn't look like this was the case in the old version, so it's
possible that if a scenario used [replace_map] or similar, the
replay could go out of sync after hitting the reset button.

Regardless of whether the old version was buggy, the new version
should be just as good if not better, and was tested.
  • Loading branch information
cbeck88 committed Jun 1, 2014
1 parent 6fff2e8 commit 471e7ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/replay_controller.cpp
Expand Up @@ -76,9 +76,8 @@ replay_controller::replay_controller(const config& level,
game_state& state_of_game, const int ticks,
const config& game_config, CVideo& video) :
play_controller(level, state_of_game, ticks, game_config, video, false),
teams_start_(gameboard_.teams_),
gamestate_start_(gamestate_),
units_start_(gameboard_.units_),
gameboard_start_(gameboard_),
tod_manager_start_(level),
current_turn_(1),
is_playing_(false),
Expand Down Expand Up @@ -272,9 +271,8 @@ void replay_controller::reset_replay()
tod_manager_= tod_manager_start_;
recorder.start_replay();
recorder.set_skip(false);
gameboard_.units_ = units_start_;
gamestate_ = gamestate_start_;
gameboard_.teams_ = teams_start_;
gameboard_ = gameboard_start_;
if (events_manager_ ){
// NOTE: this double reset is required so that the new
// instance of game_events::manager isn't created before the
Expand Down
4 changes: 1 addition & 3 deletions src/replay_controller.hpp
Expand Up @@ -52,8 +52,6 @@ class replay_controller : public play_controller
virtual void check_end_level() {}
virtual void on_not_observer() {}

std::vector<team> teams_start_;

bool manage_noninteractively();

protected:
Expand Down Expand Up @@ -87,7 +85,7 @@ class replay_controller : public play_controller
}

game_state gamestate_start_;
unit_map units_start_;
game_board gameboard_start_;
tod_manager tod_manager_start_;

unsigned int current_turn_;
Expand Down

0 comments on commit 471e7ab

Please sign in to comment.