summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/network/core/tcp_admin.cpp151
-rw-r--r--src/network/core/tcp_admin.h125
-rw-r--r--src/network/network_admin.cpp12
-rw-r--r--src/network/network_admin.h12
4 files changed, 175 insertions, 125 deletions
diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp
index 3765b070c..f7d982825 100644
--- a/src/network/core/tcp_admin.cpp
+++ b/src/network/core/tcp_admin.cpp
@@ -35,12 +35,6 @@ NetworkRecvStatus NetworkAdminSocketHandler::CloseConnection(bool error)
}
/**
- * Defines a simple (switch) case for each network packet.
- * @param type the packet type to create the case for.
- */
-#define ADMIN_COMMAND(type) case type: return this->NetworkPacketReceive_ ## type ## _command(p); break;
-
-/**
* Handle the given packet, i.e. pass it to the right parser receive command.
* @param p the packet to handle.
* @return #NetworkRecvStatus of handling.
@@ -50,38 +44,38 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p)
PacketAdminType type = (PacketAdminType)p->Recv_uint8();
switch (this->HasClientQuit() ? INVALID_ADMIN_PACKET : type) {
- ADMIN_COMMAND(ADMIN_PACKET_ADMIN_JOIN)
- 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_ADMIN_RCON)
-
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_FULL)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_BANNED)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_ERROR)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_PROTOCOL)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_WELCOME)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_NEWGAME)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_SHUTDOWN)
-
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_DATE)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_JOIN)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_INFO)
- 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)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_ECONOMY)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_COMPANY_STATS)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_CHAT)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_RCON)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_CONSOLE)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_CMD_NAMES)
- ADMIN_COMMAND(ADMIN_PACKET_SERVER_CMD_LOGGING)
+ case ADMIN_PACKET_ADMIN_JOIN: return this->Receive_ADMIN_JOIN(p);
+ case ADMIN_PACKET_ADMIN_QUIT: return this->Receive_ADMIN_QUIT(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_RCON: return this->Receive_ADMIN_RCON(p);
+
+ case ADMIN_PACKET_SERVER_FULL: return this->Receive_SERVER_FULL(p);
+ case ADMIN_PACKET_SERVER_BANNED: return this->Receive_SERVER_BANNED(p);
+ case ADMIN_PACKET_SERVER_ERROR: return this->Receive_SERVER_ERROR(p);
+ case ADMIN_PACKET_SERVER_PROTOCOL: return this->Receive_SERVER_PROTOCOL(p);
+ case ADMIN_PACKET_SERVER_WELCOME: return this->Receive_SERVER_WELCOME(p);
+ case ADMIN_PACKET_SERVER_NEWGAME: return this->Receive_SERVER_NEWGAME(p);
+ case ADMIN_PACKET_SERVER_SHUTDOWN: return this->Receive_SERVER_SHUTDOWN(p);
+
+ case ADMIN_PACKET_SERVER_DATE: return this->Receive_SERVER_DATE(p);
+ case ADMIN_PACKET_SERVER_CLIENT_JOIN: return this->Receive_SERVER_CLIENT_JOIN(p);
+ case ADMIN_PACKET_SERVER_CLIENT_INFO: return this->Receive_SERVER_CLIENT_INFO(p);
+ case ADMIN_PACKET_SERVER_CLIENT_UPDATE: return this->Receive_SERVER_CLIENT_UPDATE(p);
+ case ADMIN_PACKET_SERVER_CLIENT_QUIT: return this->Receive_SERVER_CLIENT_QUIT(p);
+ case ADMIN_PACKET_SERVER_CLIENT_ERROR: return this->Receive_SERVER_CLIENT_ERROR(p);
+ case ADMIN_PACKET_SERVER_COMPANY_NEW: return this->Receive_SERVER_COMPANY_NEW(p);
+ case ADMIN_PACKET_SERVER_COMPANY_INFO: return this->Receive_SERVER_COMPANY_INFO(p);
+ case ADMIN_PACKET_SERVER_COMPANY_UPDATE: return this->Receive_SERVER_COMPANY_UPDATE(p);
+ case ADMIN_PACKET_SERVER_COMPANY_REMOVE: return this->Receive_SERVER_COMPANY_REMOVE(p);
+ case ADMIN_PACKET_SERVER_COMPANY_ECONOMY: return this->Receive_SERVER_COMPANY_ECONOMY(p);
+ case ADMIN_PACKET_SERVER_COMPANY_STATS: return this->Receive_SERVER_COMPANY_STATS(p);
+ case ADMIN_PACKET_SERVER_CHAT: return this->Receive_SERVER_CHAT(p);
+ case ADMIN_PACKET_SERVER_RCON: return this->Receive_SERVER_RCON(p);
+ case ADMIN_PACKET_SERVER_CONSOLE: return this->Receive_SERVER_CONSOLE(p);
+ case ADMIN_PACKET_SERVER_CMD_NAMES: return this->Receive_SERVER_CMD_NAMES(p);
+ case ADMIN_PACKET_SERVER_CMD_LOGGING: return this->Receive_SERVER_CMD_LOGGING(p);
default:
if (this->HasClientQuit()) {
@@ -114,50 +108,47 @@ NetworkRecvStatus NetworkAdminSocketHandler::ReceivePackets()
}
/**
- * Create stub implementations for all receive commands that only
- * show a warning that the given command is not available for the
- * socket where the packet came from.
- * @param type the packet type to create the stub for.
+ * Helper for logging receiving invalid packets.
+ * @param type The received packet type.
+ * @return The status the network should have, in this case: "malformed packet error".
*/
-#define DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(type) \
-NetworkRecvStatus NetworkAdminSocketHandler::NetworkPacketReceive_## type ##_command(Packet *p) \
-{ \
- DEBUG(net, 0, "[tcp/admin] received illegal packet type %d from admin %s (%s)", \
- type, this->admin_name, this->admin_version); \
- return NETWORK_RECV_STATUS_MALFORMED_PACKET; \
+NetworkRecvStatus NetworkAdminSocketHandler::ReceiveInvalidPacket(PacketAdminType type)
+{
+ DEBUG(net, 0, "[tcp/admin] received illegal packet type %d from admin %s (%s)", type, this->admin_name, this->admin_version);
+ return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}
-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_ADMIN_RCON)
-
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_FULL)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_BANNED)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_ERROR)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_PROTOCOL)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_WELCOME)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_NEWGAME)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_SHUTDOWN)
-
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_DATE)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_JOIN)
-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)
-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)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_RCON)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CONSOLE)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CMD_NAMES)
-DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CMD_LOGGING)
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_JOIN(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_JOIN); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_QUIT(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_QUIT); }
+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_RCON(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_ADMIN_RCON); }
+
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_FULL(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_FULL); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_BANNED(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_BANNED); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_ERROR(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_ERROR); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PROTOCOL(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_PROTOCOL); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_WELCOME(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_WELCOME); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_NEWGAME(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_NEWGAME); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_SHUTDOWN(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_SHUTDOWN); }
+
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_DATE(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_DATE); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_JOIN(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_JOIN); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_INFO(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_INFO); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_UPDATE(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_UPDATE); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_QUIT(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_QUIT); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_ERROR(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CLIENT_ERROR); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_NEW(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_NEW); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_INFO(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_INFO); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_UPDATE(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_UPDATE); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_REMOVE(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_REMOVE); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_ECONOMY(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_ECONOMY); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_STATS(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_COMPANY_STATS); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CHAT(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CHAT); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_RCON); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CONSOLE(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CONSOLE); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_NAMES); }
+NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_LOGGING); }
#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h
index 7f875c155..cb3ff8e5b 100644
--- a/src/network/core/tcp_admin.h
+++ b/src/network/core/tcp_admin.h
@@ -102,9 +102,6 @@ enum AdminCompanyRemoveReason {
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)
-
/** Main socket handler for admin related connections. */
class NetworkAdminSocketHandler : public NetworkTCPSocketHandler {
protected:
@@ -112,25 +109,33 @@ protected:
char admin_version[NETWORK_REVISION_LENGTH]; ///< Version string of the admin.
AdminStatus status; ///< Status of this admin.
+ NetworkRecvStatus ReceiveInvalidPacket(PacketAdminType type);
+
/**
* Join the admin network:
* string Password the server is expecting for this network.
* string Name of the application being used to connect.
* string Version string of the application being used to connect.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_JOIN);
+ virtual NetworkRecvStatus Receive_ADMIN_JOIN(Packet *p);
/**
* Notification to the server that this admin is quitting.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_QUIT);
+ virtual NetworkRecvStatus Receive_ADMIN_QUIT(Packet *p);
/**
* Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet):
* uint16 Update type (see #AdminUpdateType).
* uint16 Update frequency (see #AdminUpdateFrequency), setting #ADMIN_FREQUENCY_POLL is always ignored.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY);
+ virtual NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet *p);
/**
* Poll the server for certain updates, an invalid poll (e.g. not existent id) gets silently dropped:
@@ -138,8 +143,10 @@ protected:
* 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.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_POLL);
+ virtual NetworkRecvStatus Receive_ADMIN_POLL(Packet *p);
/**
* Send chat as the server:
@@ -147,30 +154,40 @@ protected:
* uint8 Destination type such as DESTTYPE_BROADCAST (see #DestType).
* uint32 ID of the destination such as company or client id.
* string Message.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_CHAT);
+ virtual NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p);
/**
* Execute a command on the servers console:
* string Command to be executed.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_RCON);
+ virtual NetworkRecvStatus Receive_ADMIN_RCON(Packet *p);
/**
* The server is full (connection gets closed).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_FULL);
+ virtual NetworkRecvStatus Receive_SERVER_FULL(Packet *p);
/**
* The source IP address is banned (connection gets closed).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_BANNED);
+ virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet *p);
/**
* An error was caused by this admin connection (connection gets closed).
* uint8 NetworkErrorCode the error caused.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_ERROR);
+ virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p);
/**
* Inform a just joined admin about the protocol specifics:
@@ -178,8 +195,10 @@ protected:
* bool Further protocol data follows (repeats through all update packet types).
* uint16 Update packet type.
* uint16 Frequencies allowed for this update packet (bitwise).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_PROTOCOL);
+ virtual NetworkRecvStatus Receive_SERVER_PROTOCOL(Packet *p);
/**
* Welcome a connected admin to the game:
@@ -192,30 +211,40 @@ protected:
* uint32 Start date of the Map.
* uint16 Map width.
* uint16 Map height.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_WELCOME);
+ virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p);
/**
* Notification about a newgame.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_NEWGAME);
+ virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet *p);
/**
* Notification about the server shutting down.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_SHUTDOWN);
+ virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet *p);
/**
* Send the current date of the game:
* uint32 Current game date.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_DATE);
+ virtual NetworkRecvStatus Receive_SERVER_DATE(Packet *p);
/**
* Notification of a new client:
* uint32 ID of the new client.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_JOIN);
+ virtual NetworkRecvStatus Receive_SERVER_CLIENT_JOIN(Packet *p);
/**
* Client information of a specific client:
@@ -225,35 +254,45 @@ protected:
* uint8 Language of the client.
* uint32 Date the client joined the game.
* uint8 ID of the company the client is playing as (255 for spectators).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_INFO);
+ virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p);
/**
* Client update details on a specific client (e.g. after rename or move):
* uint32 ID of the client.
* string Name of the client.
* uint8 ID of the company the client is playing as (255 for spectators).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_UPDATE);
+ virtual NetworkRecvStatus Receive_SERVER_CLIENT_UPDATE(Packet *p);
/**
* Notification about a client leaving the game.
* uint32 ID of the client that just left.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_QUIT);
+ virtual NetworkRecvStatus Receive_SERVER_CLIENT_QUIT(Packet *p);
/**
* Notification about a client error (and thus the clients disconnection).
* uint32 ID of the client that made the error.
* uint8 Error the client made (see NetworkErrorCode).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_ERROR);
+ virtual NetworkRecvStatus Receive_SERVER_CLIENT_ERROR(Packet *p);
/**
* Notification of a new company:
* uint8 ID of the new company.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_NEW);
+ virtual NetworkRecvStatus Receive_SERVER_COMPANY_NEW(Packet *p);
/**
* Company information on a specific company:
@@ -264,8 +303,10 @@ protected:
* bool Company is password protected.
* uint32 Year the company was inaugurated.
* bool Company is an AI.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_INFO);
+ virtual NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet *p);
/**
* Company information of a specific company:
@@ -279,15 +320,19 @@ protected:
* uint8 Owner of share 2.
* uint8 Owner of share 3.
* uint8 Owner of share 4.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_UPDATE);
+ virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p);
/**
* Notification about a removed company (e.g. due to banrkuptcy).
* uint8 ID of the company.
* uint8 Reason for being removed (see #AdminCompanyRemoveReason).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_REMOVE);
+ virtual NetworkRecvStatus Receive_SERVER_COMPANY_REMOVE(Packet *p);
/**
* Economy update of a specific company:
@@ -301,8 +346,10 @@ protected:
* uint64 Company value (previous quarter).
* uint16 Performance (previous quarter).
* uint16 Delivered cargo (previous quarter).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_ECONOMY);
+ virtual NetworkRecvStatus Receive_SERVER_COMPANY_ECONOMY(Packet *p);
/**
* Company statistics on stations and vehicles:
@@ -317,8 +364,10 @@ protected:
* uint16 Number of bus stops.
* uint16 Number of airports and heliports.
* uint16 Number of harbours.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_COMPANY_STATS);
+ virtual NetworkRecvStatus Receive_SERVER_COMPANY_STATS(Packet *p);
/**
* Send chat from the game into the admin network:
@@ -327,22 +376,28 @@ protected:
* uint32 ID of the client who sent this message.
* string Message.
* uint64 Money (only when it is a 'give money' action).
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CHAT);
+ virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p);
/**
* Result of an rcon command:
* uint16 Colour as it would be used on the server or a client.
* string Output of the executed command.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_RCON);
+ virtual NetworkRecvStatus Receive_SERVER_RCON(Packet *p);
/**
* Send what would be printed on the server's console also into the admin network.
* string The origin of the text, e.g. "console" for console, or "net" for network related (debug) messages.
* string Text as found on the console of the server.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CONSOLE);
+ virtual NetworkRecvStatus Receive_SERVER_CONSOLE(Packet *p);
/**
* Send DoCommand names to the bot upon request only.
@@ -358,8 +413,10 @@ protected:
* bool Data to follow.
* uint16 ID of the DoCommand.
* string Name of DoCommand.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CMD_NAMES);
+ virtual NetworkRecvStatus Receive_SERVER_CMD_NAMES(Packet *p);
/**
* Send incoming command packets to the admin network.
@@ -378,8 +435,10 @@ protected:
* uint32 Tile where this is taking place.
* string Text passed to the command.
* uint32 Frame of execution.
+ * @param p The packet that was just received.
+ * @return The state the network should have.
*/
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CMD_LOGGING);
+ virtual NetworkRecvStatus Receive_SERVER_CMD_LOGGING(Packet *p);
NetworkRecvStatus HandlePacket(Packet *p);
public:
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp
index 3bda0ae84..052323e3d 100644
--- a/src/network/network_admin.cpp
+++ b/src/network/network_admin.cpp
@@ -425,7 +425,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16 colour, const
return NETWORK_RECV_STATUS_OKAY;
}
-DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_RCON)
+NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(Packet *p)
{
if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
@@ -509,7 +509,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdLogging(ClientID clien
* Receiving functions
************/
-DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_JOIN)
+NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(Packet *p)
{
if (this->status != ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
@@ -535,13 +535,13 @@ DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_JOIN)
return this->SendProtocol();
}
-DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_QUIT)
+NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_QUIT(Packet *p)
{
/* The admin is leaving nothing else to do */
return this->CloseConnection();
}
-DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY)
+NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY(Packet *p)
{
if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
@@ -559,7 +559,7 @@ DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY)
return NETWORK_RECV_STATUS_OKAY;
}
-DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_POLL)
+NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p)
{
if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
@@ -622,7 +622,7 @@ DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_POLL)
return NETWORK_RECV_STATUS_OKAY;
}
-DEF_ADMIN_RECEIVE_COMMAND(Server, ADMIN_PACKET_ADMIN_CHAT)
+NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT(Packet *p)
{
if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
diff --git a/src/network/network_admin.h b/src/network/network_admin.h
index 4ca2ef2c7..e05637ea7 100644
--- a/src/network/network_admin.h
+++ b/src/network/network_admin.h
@@ -27,12 +27,12 @@ extern NetworkAdminSocketPool _networkadminsocket_pool;
/** Class for handling the server side of the game connection. */
class ServerNetworkAdminSocketHandler : public NetworkAdminSocketPool::PoolItem<&_networkadminsocket_pool>, public NetworkAdminSocketHandler, public TCPListenHandler<ServerNetworkAdminSocketHandler, ADMIN_PACKET_SERVER_FULL, ADMIN_PACKET_SERVER_BANNED> {
protected:
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_JOIN);
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_QUIT);
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY);
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_POLL);
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_CHAT);
- DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_RCON);
+ virtual NetworkRecvStatus Receive_ADMIN_JOIN(Packet *p);
+ virtual NetworkRecvStatus Receive_ADMIN_QUIT(Packet *p);
+ virtual NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet *p);
+ virtual NetworkRecvStatus Receive_ADMIN_POLL(Packet *p);
+ virtual NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p);
+ virtual NetworkRecvStatus Receive_ADMIN_RCON(Packet *p);
NetworkRecvStatus SendProtocol();
public: