wesnothd: Fix lobby messages and whispers not being truncated as they should
For lobby messages, there was a length cap in place already, but the
truncated message was lost in processing because it ended up in a WML
document that isn't the one relayed to listening clients.
On the other hand, whisper messages were missing the truncate logic
entirely. Oops.
(The logic for in-game messages does truncate messages correctly as far
as I can tell, and additionally the client UI doesn't allow overlong
messages.)
Thanks to Soliton for pointing me towards the faulty code.
(cherry-picked from commit cdc8da25ae
)
This commit is contained in:
parent
b14b1e9509
commit
7e51f119de
2 changed files with 13 additions and 4 deletions
|
@ -48,6 +48,8 @@
|
|||
### Graphics
|
||||
* Tweaked the Ruffian's attack animation timing.
|
||||
* New attack animation for the Peasant.
|
||||
### Multiplayer server
|
||||
* Fixed lobby and whisper messages not having a maximum length.
|
||||
### Miscellaneous and bug fixes
|
||||
* Added an advanced preference to enable experimental PRNG combat.
|
||||
* Fixed MP admins being unable to observe private games.
|
||||
|
|
|
@ -1082,7 +1082,12 @@ void server::handle_whisper(socket_ptr socket, simple_wml::node& whisper)
|
|||
}
|
||||
|
||||
simple_wml::document cwhisper;
|
||||
whisper.copy_into(cwhisper.root().add_child("whisper"));
|
||||
|
||||
simple_wml::node& trunc_whisper = cwhisper.root().add_child("whisper");
|
||||
whisper.copy_into(trunc_whisper);
|
||||
|
||||
const simple_wml::string_span& msg = trunc_whisper["message"];
|
||||
chat_message::truncate_message(msg, trunc_whisper);
|
||||
|
||||
send_to_player(receiver_iter->socket(), cwhisper);
|
||||
}
|
||||
|
@ -1305,10 +1310,12 @@ void server::handle_message(socket_ptr socket, simple_wml::node& message)
|
|||
|
||||
simple_wml::document relay_message;
|
||||
message.set_attr_dup("sender", user->name().c_str());
|
||||
message.copy_into(relay_message.root().add_child("message"));
|
||||
|
||||
const simple_wml::string_span& msg = message["message"];
|
||||
chat_message::truncate_message(msg, message);
|
||||
simple_wml::node& trunc_message = relay_message.root().add_child("message");
|
||||
message.copy_into(trunc_message);
|
||||
|
||||
const simple_wml::string_span& msg = trunc_message["message"];
|
||||
chat_message::truncate_message(msg, trunc_message);
|
||||
|
||||
if(msg.size() >= 3 && simple_wml::string_span(msg.begin(), 4) == "/me ") {
|
||||
LOG_SERVER << client_address(socket) << "\t<" << user->name()
|
||||
|
|
Loading…
Add table
Reference in a new issue