Skip to content

Commit

Permalink
check for empty parameters before looping over all players
Browse files Browse the repository at this point in the history
(cherry-picked from commit 0362e36)
  • Loading branch information
soliton- authored and Vultraz committed Oct 7, 2018
1 parent 1a72f04 commit e4100fc
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/server/server.cpp
Expand Up @@ -2288,21 +2288,20 @@ void server::version_handler(
const std::string& /*issuer_name*/, const std::string& /*query*/, std::string& parameters, std::ostringstream* out)
{
assert(out != nullptr);



if(parameters.empty()) {
*out << "Server version is " << game_config::version;
return;
}

for(const auto& player : player_connections_) {
if(parameters == player.info().name()) {
*out << "Player " << parameters << " is using wesnoth " << player.info().version();
return;
}
}
if(parameters.empty()) {
*out << "Server version is " << game_config::version;

}
else {
*out << "Player " << parameters << " not found.";
}

*out << "Player '" << parameters << "' not found.";
}

void server::status_handler(
Expand Down

0 comments on commit e4100fc

Please sign in to comment.