Skip to content

Commit

Permalink
Codacy: Error-prone Code
Browse files Browse the repository at this point in the history
The class 'playsingle_controller' defines member variable with name 'replay_' also defined in its parent class 'play_controller'.
  • Loading branch information
GregoryLundberg committed Oct 26, 2018
1 parent 7f2ebad commit fad8cc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/playsingle_controller.cpp
Expand Up @@ -75,7 +75,7 @@ playsingle_controller::playsingle_controller(const config& level,
, end_turn_(END_TURN_NONE)
, skip_next_turn_(false)
, ai_fallback_(false)
, replay_()
, replay_controller_()
{
hotkey_handler_.reset(new hotkey_handler(*this, saved_game_)); //upgrade hotkey handler to the sp (whiteboard enabled) version

Expand Down Expand Up @@ -208,11 +208,11 @@ void playsingle_controller::play_scenario_main_loop()
resources::gameboard->teams()[i].set_local(local_players[i]);
}
play_scenario_init();
if (replay_ == nullptr) {
replay_.reset(new replay_controller(*this, false, ex.level, [this](){ on_replay_end(false); } ));
if (replay_controller_ == nullptr) {
replay_controller_.reset(new replay_controller(*this, false, ex.level, [this](){ on_replay_end(false); } ));
}
if(ex.start_replay) {
replay_->play_replay();
replay_controller_->play_replay();
}
}
} //end for loop
Expand Down Expand Up @@ -359,14 +359,14 @@ void playsingle_controller::play_side_impl()
if (!skip_next_turn_) {
end_turn_ = END_TURN_NONE;
}
if(replay_.get() != nullptr) {
if(replay_controller_.get() != nullptr) {
init_side_done_now_ = false;
REPLAY_RETURN res = replay_->play_side_impl();
REPLAY_RETURN res = replay_controller_->play_side_impl();
if(res == REPLAY_FOUND_END_TURN) {
end_turn_ = END_TURN_SYNCED;
}
if (player_type_changed_) {
replay_.reset();
replay_controller_.reset();
}
} else if((current_team().is_local_human() && current_team().is_proxy_human())) {
LOG_NG << "is human...\n";
Expand Down Expand Up @@ -652,8 +652,8 @@ void playsingle_controller::sync_end_turn()

void playsingle_controller::update_viewing_player()
{
if(replay_ && replay_->is_controlling_view()) {
replay_->update_viewing_player();
if(replay_controller_ && replay_controller_->is_controlling_view()) {
replay_controller_->update_viewing_player();
}
//Update viewing team in case it has changed during the loop.
else if(int side_num = play_controller::find_last_visible_team()) {
Expand All @@ -665,9 +665,9 @@ void playsingle_controller::update_viewing_player()

void playsingle_controller::reset_replay()
{
if(replay_ && replay_->allow_reset_replay()) {
replay_->stop_replay();
throw reset_gamestate_exception(replay_->get_reset_state(), false);
if(replay_controller_ && replay_controller_->allow_reset_replay()) {
replay_controller_->stop_replay();
throw reset_gamestate_exception(replay_controller_->get_reset_state(), false);
}
else {
ERR_NG << "received invalid reset replay\n";
Expand All @@ -676,9 +676,9 @@ void playsingle_controller::reset_replay()

void playsingle_controller::enable_replay(bool is_unit_test)
{
replay_.reset(new replay_controller(*this, gamestate().has_human_sides(), std::shared_ptr<config>( new config(saved_game_.get_replay_starting_point())), std::bind(&playsingle_controller::on_replay_end, this, is_unit_test)));
replay_controller_.reset(new replay_controller(*this, gamestate().has_human_sides(), std::shared_ptr<config>( new config(saved_game_.get_replay_starting_point())), std::bind(&playsingle_controller::on_replay_end, this, is_unit_test)));
if(is_unit_test) {
replay_->play_replay();
replay_controller_->play_replay();
}
}

Expand All @@ -687,7 +687,7 @@ bool playsingle_controller::should_return_to_play_side() const
if(player_type_changed_ || is_regular_game_end()) {
return true;
}
else if (end_turn_ == END_TURN_NONE || replay_.get() != 0 || current_team().is_network()) {
else if (end_turn_ == END_TURN_NONE || replay_controller_.get() != 0 || current_team().is_network()) {
return false;
}
else {
Expand All @@ -701,7 +701,7 @@ void playsingle_controller::on_replay_end(bool is_unit_test)
set_player_type_changed();
}
else if(is_unit_test) {
replay_->return_to_play_side();
replay_controller_->return_to_play_side();
if(!is_regular_game_end()) {
end_level_data e;
e.proceed_to_next_level = false;
Expand Down
4 changes: 2 additions & 2 deletions src/playsingle_controller.hpp
Expand Up @@ -58,7 +58,7 @@ class playsingle_controller : public play_controller
bool get_player_type_changed() const { return player_type_changed_; }
void set_player_type_changed() { player_type_changed_ = true; }
virtual bool should_return_to_play_side() const override;
replay_controller * get_replay_controller() { return replay_.get(); }
replay_controller * get_replay_controller() { return replay_controller_.get(); }
bool is_replay() override { return get_replay_controller() != nullptr; }
void enable_replay(bool is_unit_test = false);
void on_replay_end(bool is_unit_test);
Expand Down Expand Up @@ -93,7 +93,7 @@ class playsingle_controller : public play_controller
};
END_TURN_STATE end_turn_;
bool skip_next_turn_, ai_fallback_;
std::unique_ptr<replay_controller> replay_;
std::unique_ptr<replay_controller> replay_controller_;
void linger();
void sync_end_turn() override;
void update_viewing_player() override;
Expand Down

0 comments on commit fad8cc7

Please sign in to comment.