Skip to content

Commit

Permalink
refactor replay_controller in order to unfriend game_board
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 11, 2014
1 parent 4ffb237 commit 15ed9d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/game_board.cpp
Expand Up @@ -83,6 +83,12 @@ void game_board::all_survivors_to_recall() {
}
}

void game_board::reset_all_teams_objectives_changes() {
BOOST_FOREACH(team & t, teams_) {
t.reset_objectives_changed();
}
}

unit_map::iterator game_board::find_visible_unit(const map_location &loc,
const team& current_team, bool see_all)
{
Expand Down
3 changes: 2 additions & 1 deletion src/game_board.hpp
Expand Up @@ -57,7 +57,6 @@ class game_board : public display_context {

//TODO: Remove these when we have refactored enough to make it possible.
friend class play_controller;
friend class replay_controller;
friend class playsingle_controller;
friend class playmp_controller;
friend class events::mouse_handler;
Expand Down Expand Up @@ -111,6 +110,8 @@ class game_board : public display_context {

void all_survivors_to_recall();

void reset_all_teams_objectives_changes();

// Manipulator from playturn

void side_drop_to (int side_num, team::CONTROLLER ctrl);
Expand Down
14 changes: 6 additions & 8 deletions src/replay_controller.cpp
Expand Up @@ -159,9 +159,7 @@ void replay_controller::init_gui(){

gui_->scroll_to_leader(player_number_, display::WARP);
update_locker lock_display((*gui_).video(),false);
BOOST_FOREACH(team & t, gameboard_.teams_) {
t.reset_objectives_changed();
}
gameboard_.reset_all_teams_objectives_changes();

update_replay_ui();
}
Expand Down Expand Up @@ -495,7 +493,7 @@ possible_end_play_signal replay_controller::play_turn(){
bool last_team = false;

while ( (!last_team) && (!recorder.at_end()) && is_playing_ ){
last_team = static_cast<size_t>(player_number_) == gameboard_.teams_.size();
last_team = static_cast<size_t>(player_number_) == gameboard_.teams().size();
PROPOGATE_END_PLAY_SIGNAL( play_side() );
HANDLE_END_PLAY_SIGNAL( play_slice() );
}
Expand Down Expand Up @@ -549,9 +547,9 @@ possible_end_play_signal replay_controller::play_side() {

player_number_++;

if (static_cast<size_t>(player_number_) > gameboard_.teams_.size()) {
//during the orginal game player_number_ would also be gameboard_.teams_.size(),
player_number_ = gameboard_.teams_.size();
if (static_cast<size_t>(player_number_) > gameboard_.teams().size()) {
//during the orginal game player_number_ would also be gameboard_.teams().size(),
player_number_ = gameboard_.teams().size();
finish_turn();
tod_manager_.next_turn();
it_is_a_new_turn_ = true;
Expand All @@ -572,7 +570,7 @@ possible_end_play_signal replay_controller::play_side() {
void replay_controller::update_teams(){

int next_team = player_number_;
if(static_cast<size_t>(next_team) > gameboard_.teams_.size()) {
if(static_cast<size_t>(next_team) > gameboard_.teams().size()) {
next_team = 1;
}

Expand Down

0 comments on commit 15ed9d1

Please sign in to comment.