summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-10-17 17:37:45 +0000
committerrubidium <rubidium@openttd.org>2010-10-17 17:37:45 +0000
commitae20cb4f3dff0f3a9478e918b90ef61279c8b33c (patch)
treecca6bae2b5da57805e9e050e463d835f34a406ef /src/network/core
parentfe44944f326b08e6b005aef8bfcf546467b5b136 (diff)
downloadopenttd-ae20cb4f3dff0f3a9478e918b90ef61279c8b33c.tar.xz
(svn r20970) -Add: company change notification to remote admins (dihedral)
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/tcp_admin.cpp8
-rw-r--r--src/network/core/tcp_admin.h53
2 files changed, 61 insertions, 0 deletions
diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp
index ee254968a..41855feeb 100644
--- a/src/network/core/tcp_admin.cpp
+++ b/src/network/core/tcp_admin.cpp
@@ -69,6 +69,10 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p)
ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_UPDATE)
ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_QUIT)
ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_ERROR)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_NEW)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_INFO)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_UPDATE)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_REMOVE)
default:
if (this->HasClientQuit()) {
@@ -133,5 +137,9 @@ DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_INFO)
DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_UPDATE)
DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_QUIT)
DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_ERROR)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_NEW)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_INFO)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_UPDATE)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_REMOVE)
#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h
index 656fa9503..fdd9cf81c 100644
--- a/src/network/core/tcp_admin.h
+++ b/src/network/core/tcp_admin.h
@@ -45,6 +45,10 @@ enum PacketAdminType {
ADMIN_PACKET_SERVER_CLIENT_UPDATE, ///< The server gives the admin an information update on a client.
ADMIN_PACKET_SERVER_CLIENT_QUIT, ///< The server tells the admin that a client quit.
ADMIN_PACKET_SERVER_CLIENT_ERROR, ///< The server tells the admin that a client caused an error.
+ ADMIN_PACKET_SERVER_COMPANY_NEW, ///< The server tells the admin that a new company has started.
+ ADMIN_PACKET_SERVER_COMPANY_INFO, ///< The server gives the admin information about a company.
+ ADMIN_PACKET_SERVER_COMPANY_UPDATE, ///< The server gives the admin an information update on a company.
+ ADMIN_PACKET_SERVER_COMPANY_REMOVE, ///< The server tells the admin that a company was removed.
INVALID_ADMIN_PACKET = 0xFF, ///< An invalid marker for admin packets.
};
@@ -60,6 +64,7 @@ enum AdminStatus {
enum AdminUpdateType {
ADMIN_UPDATE_DATE, ///< Updates about the date of the game.
ADMIN_UPDATE_CLIENT_INFO, ///< Updates about the information of clients.
+ ADMIN_UPDATE_COMPANY_INFO, ///< Updates about the generic information of companies.
ADMIN_UPDATE_END ///< Must ALWAYS be on the end of this list!! (period)
};
@@ -75,6 +80,13 @@ enum AdminUpdateFrequency {
};
DECLARE_ENUM_AS_BIT_SET(AdminUpdateFrequency);
+/** Reasons for removing a company - communicated to admins. */
+enum AdminCompanyRemoveReason {
+ ADMIN_CRR_MANUAL, ///< The company is manually removed.
+ ADMIN_CRR_AUTOCLEAN, ///< The company is removed due to autoclean.
+ ADMIN_CRR_BANKRUPT ///< The company went belly-up.
+};
+
#define DECLARE_ADMIN_RECEIVE_COMMAND(type) virtual NetworkRecvStatus NetworkPacketReceive_## type ##_command(Packet *p)
#define DEF_ADMIN_RECEIVE_COMMAND(cls, type) NetworkRecvStatus cls ##NetworkAdminSocketHandler::NetworkPacketReceive_ ## type ## _command(Packet *p)
@@ -110,6 +122,7 @@ protected:
* uint8 #AdminUpdateType the server should answer for, only if #AdminUpdateFrequency #ADMIN_FREQUENCY_POLL is advertised in the PROTOCOL packet.
* uint32 ID relevant to the packet type, e.g.
* - the client ID for #ADMIN_UPDATE_CLIENT_INFO. Use UINT32_MAX to show all clients.
+ * - the company ID for #ADMIN_UPDATE_COMPANY_INFO. Use UINT32_MAX to show all companies.
*/
DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_POLL);
@@ -206,6 +219,46 @@ protected:
*/
DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_ERROR);
+ /**
+ * Notification of a new company:
+ * uint8 ID of the new company.
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_NEW);
+
+ /**
+ * Company information on a specific company:
+ * uint8 ID of the company.
+ * string Name of the company.
+ * string Name of the companies manager.
+ * uint8 Main company colour.
+ * bool Company is password protected.
+ * uint32 Year the company was inaugurated.
+ * bool Company is an AI.
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_INFO);
+
+ /**
+ * Company information of a specific company:
+ * uint8 ID of the company.
+ * string Name of the company.
+ * string Name of the companies manager.
+ * uint8 Main company colour.
+ * bool Company is password protected.
+ * uint8 Quarters of bankruptcy.
+ * uint8 Owner of share 1.
+ * uint8 Owner of share 2.
+ * uint8 Owner of share 3.
+ * uint8 Owner of share 4.
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_UPDATE);
+
+ /**
+ * Notification about a removed company (e.g. due to banrkuptcy).
+ * uint8 ID of the company.
+ * uint8 Reason for being removed (see #AdminCompanyRemoveReason).
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_REMOVE);
+
NetworkRecvStatus HandlePacket(Packet *p);
public:
NetworkRecvStatus CloseConnection(bool error = true);