don't check observers against observers for the same IP

This commit is contained in:
Gunter Labes 2009-01-15 21:55:20 +00:00
parent fdb8c2feda
commit a59437768e
2 changed files with 11 additions and 5 deletions

View file

@ -904,7 +904,6 @@ bool game::add_player(const network::connection player, bool observer) {
}
user->second.mark_available(id_, name_);
DBG_GAME << debug_player_info();
std::string clones = has_same_ip(network::ip_address(player));
bool became_observer = false;
if (!started_ && !observer && take_side(user)) {
DBG_GAME << "adding player...\n";
@ -925,6 +924,7 @@ bool game::add_player(const network::connection player, bool observer) {
}
DBG_GAME << debug_player_info();
const std::string clones = has_same_ip(player, observer || became_observer);
if (!clones.empty()) {
send_and_record_server_message((user->second.name() + " has the same IP as: " + clones).c_str());
}
@ -1143,12 +1143,13 @@ bool game::is_on_team(const simple_wml::string_span& team, const network::connec
return false;
}
std::string game::has_same_ip(const std::string& ip) const {
user_vector users = all_game_users();
std::string game::has_same_ip(const network::connection& user, bool observer) const {
const user_vector users = observer ? players_ : all_game_users();
const std::string ip = network::ip_address(user);
std::string clones;
bool first = true;
for (user_vector::const_iterator i = users.begin(); i != users.end(); ++i) {
if (ip == network::ip_address(*i)) {
if (ip == network::ip_address(*i) && user != *i) {
if (!first) clones += ", ";
else first = false;
const player_map::const_iterator pl = player_info_->find(*i);

View file

@ -227,7 +227,12 @@ private:
/** Function which returns true iff 'player' is on 'team'. */
bool is_on_team(const simple_wml::string_span& team, const network::connection player) const;
std::string has_same_ip(const std::string& ip) const;
/**
* Checks whether a user has the same IP as members of this game.
* If observer is true it only checks against players.
* @return A comma separated string of members with matching IPs.
*/
std::string has_same_ip(const network::connection& user, bool observer) const;
/**
* Function which should be called every time a player ends their turn