don't check observers against observers for the same IP

This commit is contained in:
Gunter Labes 2009-01-15 22:01:09 +00:00
parent 405499d2f0
commit ac12ab186a
2 changed files with 11 additions and 5 deletions

View file

@ -879,7 +879,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";
@ -900,6 +899,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());
}
@ -1122,12 +1122,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

@ -157,7 +157,12 @@ private:
bool is_legal_command(const simple_wml::node& command, bool is_player);
//! 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
//! (i.e. [end_turn] received). This will update the 'turn' attribute for