diff options
author | rubidium <rubidium@openttd.org> | 2010-10-17 17:40:18 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-10-17 17:40:18 +0000 |
commit | d9602f4ef936b79c1d1ee785477323618e46f9cf (patch) | |
tree | 1420d0f86e4559de83ab250a109d2c7f7bca5f53 /src/network/core | |
parent | 459514afe4f550a08d98958745d6cd8311c53fdd (diff) | |
download | openttd-d9602f4ef936b79c1d1ee785477323618e46f9cf.tar.xz |
(svn r20973) -Add: chat sending and receiving support for remote admins (dihedral)
Diffstat (limited to 'src/network/core')
-rw-r--r-- | src/network/core/tcp_admin.cpp | 4 | ||||
-rw-r--r-- | src/network/core/tcp_admin.h | 22 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp index 0d2d09fdd..b2da7475f 100644 --- a/src/network/core/tcp_admin.cpp +++ b/src/network/core/tcp_admin.cpp @@ -54,6 +54,7 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p) ADMIN_COMMAND(ADMIN_PACKET_ADMIN_QUIT) ADMIN_COMMAND(ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY) ADMIN_COMMAND(ADMIN_PACKET_ADMIN_POLL) + ADMIN_COMMAND(ADMIN_PACKET_ADMIN_CHAT) ADMIN_COMMAND(ADMIN_PACKET_SERVER_FULL) ADMIN_COMMAND(ADMIN_PACKET_SERVER_BANNED) @@ -75,6 +76,7 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p) ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_REMOVE) ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_ECONOMY) ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_STATS) + ADMIN_COMMAND(ADMIN_PACKET_SERVER_CHAT) default: if (this->HasClientQuit()) { @@ -124,6 +126,7 @@ DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_JOIN) DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_QUIT) DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY) DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_POLL) +DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_CHAT) DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_FULL) DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_BANNED) @@ -145,5 +148,6 @@ DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_UPDATE) DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_REMOVE) DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_ECONOMY) DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_STATS) +DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CHAT) #endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index 15f3ba0a7..e73d0202e 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -30,6 +30,7 @@ enum PacketAdminType { ADMIN_PACKET_ADMIN_QUIT, ///< The admin tells the server that it is quitting. ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY, ///< The admin tells the server the update frequency of a particular piece of information. ADMIN_PACKET_ADMIN_POLL, ///< The admin explicitly polls for a piece of information. + ADMIN_PACKET_ADMIN_CHAT, ///< The admin sends a chat message to be distributed. 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. @@ -51,6 +52,7 @@ enum PacketAdminType { ADMIN_PACKET_SERVER_COMPANY_REMOVE, ///< The server tells the admin that a company was removed. ADMIN_PACKET_SERVER_COMPANY_ECONOMY, ///< The server gives the admin some economy related company information. ADMIN_PACKET_SERVER_COMPANY_STATS, ///< The server gives the admin some statistics about a company. + ADMIN_PACKET_SERVER_CHAT, ///< The server received a chat message and relays it. INVALID_ADMIN_PACKET = 0xFF, ///< An invalid marker for admin packets. }; @@ -69,6 +71,7 @@ enum AdminUpdateType { ADMIN_UPDATE_COMPANY_INFO, ///< Updates about the generic information of companies. ADMIN_UPDATE_COMPANY_ECONOMY, ///< Updates about the economy of companies. ADMIN_UPDATE_COMPANY_STATS, ///< Updates about the statistics of companies. + ADMIN_UPDATE_CHAT, ///< The admin would like to have chat messages. ADMIN_UPDATE_END ///< Must ALWAYS be on the end of this list!! (period) }; @@ -131,6 +134,15 @@ protected: DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_POLL); /** + * Send chat as the server: + * uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see #NetworkAction). + * uint8 Destination type such as DESTTYPE_BROADCAST (see #DestType). + * uint32 ID of the destination such as company or client id. + * string Message. + */ + DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_CHAT); + + /** * The server is full (connection gets closed). */ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_FULL); @@ -294,6 +306,16 @@ protected: */ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_STATS); + /** + * Send chat from the game into the admin network: + * uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see #NetworkAction). + * uint8 Destination type such as DESTTYPE_BROADCAST (see #DestType). + * uint32 ID of the client who sent this message. + * string Message. + * uint64 Money (only when it is a 'give money' action). + */ + DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CHAT); + NetworkRecvStatus HandlePacket(Packet *p); public: NetworkRecvStatus CloseConnection(bool error = true); |