Skip to content

Commit

Permalink
wesnothd: refuse to send whispers from observers to players in same game
Browse files Browse the repository at this point in the history
wesnothd <= 1.12 did this too, this restores old behavior

(cherry-picked from commit 1012205)
  • Loading branch information
loonycyborg committed Oct 7, 2018
1 parent 24d4e2b commit 61b2564
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/server/server.cpp
Expand Up @@ -905,12 +905,18 @@ void server::handle_whisper(socket_ptr socket, simple_wml::node& whisper)
auto receiver_iter = player_connections_.get<name_t>().find(whisper["receiver"].to_string());
if(receiver_iter == player_connections_.get<name_t>().end()) {
send_server_message(socket, "Can't find '" + whisper["receiver"].to_string() + "'.");
} else {
simple_wml::document cwhisper;
whisper.copy_into(cwhisper.root().add_child("whisper"));
send_to_player(receiver_iter->socket(), cwhisper);
// TODO: Refuse to send from an observer to a game he observes
return;
}

auto g = player_connections_.find(socket)->get_game();
if(g && g->started() && g->is_player(receiver_iter->socket()) && g->is_member(socket)) {
send_server_message(socket, "You cannot send private messages to players in a running game you observe.");
return;
}

simple_wml::document cwhisper;
whisper.copy_into(cwhisper.root().add_child("whisper"));
send_to_player(receiver_iter->socket(), cwhisper);
}

void server::handle_query(socket_ptr socket, simple_wml::node& query)
Expand Down

0 comments on commit 61b2564

Please sign in to comment.