From 31cf9e888b1129ed8147a0ce1ee0bdbf7c121c9b Mon Sep 17 00:00:00 2001 From: dP Date: Mon, 20 Sep 2021 00:09:06 +0300 Subject: Add: [Network] external chat messages for remote admins (#9563) --- src/network/core/tcp_admin.cpp | 2 ++ src/network/core/tcp_admin.h | 12 ++++++++++++ src/network/core/tcp_game.cpp | 2 ++ src/network/core/tcp_game.h | 11 +++++++++++ 4 files changed, 27 insertions(+) (limited to 'src/network/core') diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp index e1b18549c..de1c22131 100644 --- a/src/network/core/tcp_admin.cpp +++ b/src/network/core/tcp_admin.cpp @@ -53,6 +53,7 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p) case ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY: return this->Receive_ADMIN_UPDATE_FREQUENCY(p); case ADMIN_PACKET_ADMIN_POLL: return this->Receive_ADMIN_POLL(p); case ADMIN_PACKET_ADMIN_CHAT: return this->Receive_ADMIN_CHAT(p); + case ADMIN_PACKET_ADMIN_EXTERNAL_CHAT: return this->Receive_ADMIN_EXTERNAL_CHAT(p); case ADMIN_PACKET_ADMIN_RCON: return this->Receive_ADMIN_RCON(p); case ADMIN_PACKET_ADMIN_GAMESCRIPT: return this->Receive_ADMIN_GAMESCRIPT(p); case ADMIN_PACKET_ADMIN_PING: return this->Receive_ADMIN_PING(p); @@ -132,6 +133,7 @@ NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_QUIT(Packet *p) { ret NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY); } NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_POLL); } NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_CHAT(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_CHAT); } +NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_EXTERNAL_CHAT); } NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_RCON(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_RCON); } NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_GAMESCRIPT); } NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_PING(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_PING); } diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index 6d498ce5d..33ab7b049 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -30,6 +30,7 @@ enum PacketAdminType { ADMIN_PACKET_ADMIN_RCON, ///< The admin sends a remote console command. ADMIN_PACKET_ADMIN_GAMESCRIPT, ///< The admin sends a JSON string for the GameScript. ADMIN_PACKET_ADMIN_PING, ///< The admin sends a ping to the server, expecting a ping-reply (PONG) packet. + ADMIN_PACKET_ADMIN_EXTERNAL_CHAT, ///< The admin sends a chat message from external source. ADMIN_PACKET_SERVER_FULL = 100, ///< The server tells the admin it cannot accept the admin. ADMIN_PACKET_SERVER_BANNED, ///< The server tells the admin it is banned. @@ -163,6 +164,17 @@ protected: */ virtual NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p); + /** + * Send chat from the external source: + * string Name of the source this message came from. + * uint16 TextColour to use for the message. + * string Name of the user who sent the messsage. + * string Message. + * @param p The packet that was just received. + * @return The state the network should have. + */ + virtual NetworkRecvStatus Receive_ADMIN_EXTERNAL_CHAT(Packet *p); + /** * Execute a command on the servers console: * string Command to be executed. diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp index 9ac53c597..2e9965913 100644 --- a/src/network/core/tcp_game.cpp +++ b/src/network/core/tcp_game.cpp @@ -94,6 +94,7 @@ NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet *p) case PACKET_SERVER_COMMAND: return this->Receive_SERVER_COMMAND(p); case PACKET_CLIENT_CHAT: return this->Receive_CLIENT_CHAT(p); case PACKET_SERVER_CHAT: return this->Receive_SERVER_CHAT(p); + case PACKET_SERVER_EXTERNAL_CHAT: return this->Receive_SERVER_EXTERNAL_CHAT(p); case PACKET_CLIENT_SET_PASSWORD: return this->Receive_CLIENT_SET_PASSWORD(p); case PACKET_CLIENT_SET_NAME: return this->Receive_CLIENT_SET_NAME(p); case PACKET_CLIENT_QUIT: return this->Receive_CLIENT_QUIT(p); @@ -180,6 +181,7 @@ NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_COMMAND(Packet *p) { NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_COMMAND(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_COMMAND); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_CHAT); } NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_CHAT); } +NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_EXTERNAL_CHAT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_EXTERNAL_CHAT); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_SET_PASSWORD(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_SET_PASSWORD); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_SET_NAME(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_SET_NAME); } NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_QUIT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_QUIT); } diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index 833b9077f..591a91ac1 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -99,6 +99,7 @@ enum PacketGameType { /* Human communication! */ PACKET_CLIENT_CHAT, ///< Client said something that should be distributed. PACKET_SERVER_CHAT, ///< Server distributing the message of a client (or itself). + PACKET_SERVER_EXTERNAL_CHAT, ///< Server distributing the message from external source. /* Remote console. */ PACKET_CLIENT_RCON, ///< Client asks the server to execute some command. @@ -378,6 +379,16 @@ protected: */ virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p); + /** + * Sends a chat-packet for external source to the client: + * string Name of the source this message came from. + * uint16 TextColour to use for the message. + * string Name of the user who sent the messsage. + * string Message (max NETWORK_CHAT_LENGTH). + * @param p The packet that was just received. + */ + virtual NetworkRecvStatus Receive_SERVER_EXTERNAL_CHAT(Packet *p); + /** * Set the password for the clients current company: * string The password. -- cgit v1.2.3-70-g09d2