From e43f0dad210ce4803180f3980e69968ca9b492d9 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 1 May 2017 14:50:45 +0100 Subject: [PATCH] Fix crashes/issues with non-broadcast network chat. --- src/network/network_chat_gui.cpp | 4 +++- src/network/network_type.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 2d5aea5f17..fc193d5a13 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -272,6 +272,7 @@ void NetworkDrawChatMessage() static void SendChat(const char *buf, DestType type, int dest) { if (StrEmpty(buf)) return; + assert(type >= DESTTYPE_BROADCAST && type <= DESTTYPE_CLIENT); if (!_network_server) { MyClient::SendChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, NetworkTextMessageData()); } else { @@ -303,7 +304,8 @@ struct NetworkChatWindow : public Window { static const StringID chat_captions[] = { STR_NETWORK_CHAT_ALL_CAPTION, STR_NETWORK_CHAT_COMPANY_CAPTION, - STR_NETWORK_CHAT_CLIENT_CAPTION + STR_NETWORK_CHAT_CLIENT_CAPTION, + STR_NULL, }; assert((uint)this->dtype < lengthof(chat_captions)); this->dest_string = chat_captions[this->dtype]; diff --git a/src/network/network_type.h b/src/network/network_type.h index 0e04c64d2d..33124fdbaa 100644 --- a/src/network/network_type.h +++ b/src/network/network_type.h @@ -81,9 +81,9 @@ enum NetworkPasswordType { /** Destination of our chat messages. */ enum DestType { DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All) - DESTTYPE_BROADCAST_SS, ///< Send message/notice to all clients (All), but tag the broadcast to self as a self-send DESTTYPE_TEAM, ///< Send message/notice to everyone playing the same company (Team) DESTTYPE_CLIENT, ///< Send message/notice to only a certain client (Private) + DESTTYPE_BROADCAST_SS, ///< Send message/notice to all clients (All), but tag the broadcast to self as a self-send }; /** Actions that can be used for NetworkTextMessage */