Removed code duplication.

This commit is contained in:
Guillaume Melquiond 2009-06-13 19:21:03 +00:00
parent 3f840d69b4
commit 8167f7eb94
4 changed files with 3 additions and 15 deletions

View File

@ -171,7 +171,7 @@ void play_controller::init(CVideo& video){
if(first_human_team_ != -1) {
gui_->set_team(first_human_team_);
}
else if (team_manager_.is_observer())
else if (is_observer())
{
// Find first team that is allowed to be observered.
// If not set here observer would be without fog untill
@ -424,7 +424,7 @@ void play_controller::init_side(const unsigned int team_index, bool is_replay){
mouse_handler_.set_side(team_index + 1);
// If we are observers we move to watch next team if it is allowed
if (team_manager_.is_observer()
if (is_observer()
&& !current_team.get_disallow_observers()) {
gui_->set_team(size_t(team_index));
}

View File

@ -351,7 +351,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
{
return VICTORY; // this is probably only a story scenario, i.e. has its endlevel in the prestart event
}
const bool obs = team_manager_.is_observer();
const bool obs = is_observer();
if (game_config::exit_at_end) {
exit(0);
}

View File

@ -55,17 +55,6 @@ const std::vector<team>& teams_manager::get_teams()
return *teams;
}
bool teams_manager::is_observer()
{
for(std::vector<team>::const_iterator i = teams->begin(); i != teams->end(); ++i) {
if(i->is_local()) {
return false;
}
}
return true;
}
int teams_manager::get_first_human_team(const config::child_list::const_iterator& cfg, const config::child_list& unit_cfg,
const std::string& client_type, const std::string& login)
{

View File

@ -348,7 +348,6 @@ struct teams_manager {
teams_manager(std::vector<team>& teams);
~teams_manager();
bool is_observer();
static const std::vector<team>& get_teams();
int get_first_human_team(const config::child_list::const_iterator& cfg, const config::child_list& unit_cfg, const std::string& client_type, const std::string& login);
};