(svn r19809) -Codechange: make some unnamed network related enums/defines static const variables

This commit is contained in:
rubidium 2010-05-13 09:04:41 +00:00
parent 6fa962b867
commit 2555522eab
5 changed files with 62 additions and 61 deletions

View File

@ -15,58 +15,58 @@
#define NETWORK_CORE_CONFIG_H #define NETWORK_CORE_CONFIG_H
/** DNS hostname of the masterserver */ /** DNS hostname of the masterserver */
#define NETWORK_MASTER_SERVER_HOST "master.openttd.org" static const char * const NETWORK_MASTER_SERVER_HOST = "master.openttd.org";
/** DNS hostname of the content server */ /** DNS hostname of the content server */
#define NETWORK_CONTENT_SERVER_HOST "content.openttd.org" static const char * const NETWORK_CONTENT_SERVER_HOST = "content.openttd.org";
/** DNS hostname of the HTTP-content mirror server */ /** DNS hostname of the HTTP-content mirror server */
#define NETWORK_CONTENT_MIRROR_HOST "binaries.openttd.org" static const char * const NETWORK_CONTENT_MIRROR_HOST = "binaries.openttd.org";
/** URL of the HTTP mirror system */ /** URL of the HTTP mirror system */
#define NETWORK_CONTENT_MIRROR_URL "/bananas" static const char * const NETWORK_CONTENT_MIRROR_URL = "/bananas";
/** Message sent to the masterserver to 'identify' this client as OpenTTD */ /** Message sent to the masterserver to 'identify' this client as OpenTTD */
#define NETWORK_MASTER_SERVER_WELCOME_MESSAGE "OpenTTDRegister" static const char * const NETWORK_MASTER_SERVER_WELCOME_MESSAGE = "OpenTTDRegister";
enum { static const uint16 NETWORK_MASTER_SERVER_PORT = 3978; ///< The default port of the master server (UDP)
NETWORK_MASTER_SERVER_PORT = 3978, ///< The default port of the master server (UDP) static const uint16 NETWORK_CONTENT_SERVER_PORT = 3978; ///< The default port of the content server (TCP)
NETWORK_CONTENT_SERVER_PORT = 3978, ///< The default port of the content server (TCP) static const uint16 NETWORK_CONTENT_MIRROR_PORT = 80; ///< The default port of the content mirror (TCP)
NETWORK_CONTENT_MIRROR_PORT = 80, ///< The default port of the content mirror (TCP) static const uint16 NETWORK_DEFAULT_PORT = 3979; ///< The default port of the game server (TCP & UDP)
NETWORK_DEFAULT_PORT = 3979, ///< The default port of the game server (TCP & UDP) static const uint16 NETWORK_DEFAULT_DEBUGLOG_PORT = 3982; ///< The default port debug-log is sent too (TCP)
NETWORK_DEFAULT_DEBUGLOG_PORT = 3982, ///< The default port debug-log is sent too (TCP)
SEND_MTU = 1460, ///< Number of bytes we can pack in a single packet static const uint16 SEND_MTU = 1460; ///< Number of bytes we can pack in a single packet
NETWORK_GAME_INFO_VERSION = 4, ///< What version of game-info do we use? static const byte NETWORK_GAME_INFO_VERSION = 4; ///< What version of game-info do we use?
NETWORK_COMPANY_INFO_VERSION = 6, ///< What version of company info is this? static const byte NETWORK_COMPANY_INFO_VERSION = 6; ///< What version of company info is this?
NETWORK_MASTER_SERVER_VERSION = 2, ///< What version of master-server-protocol do we use? static const byte NETWORK_MASTER_SERVER_VERSION = 2; ///< What version of master-server-protocol do we use?
NETWORK_NAME_LENGTH = 80, ///< The maximum length of the server name and map name, in bytes including '\0' static const uint NETWORK_NAME_LENGTH = 80; ///< The maximum length of the server name and map name, in bytes including '\0'
NETWORK_COMPANY_NAME_LENGTH = 31, ///< The maximum length of the company name, in bytes including '\0' static const uint NETWORK_COMPANY_NAME_LENGTH = 31; ///< The maximum length of the company name, in bytes including '\0'
NETWORK_HOSTNAME_LENGTH = 80, ///< The maximum length of the host name, in bytes including '\0' static const uint NETWORK_HOSTNAME_LENGTH = 80; ///< The maximum length of the host name, in bytes including '\0'
NETWORK_SERVER_ID_LENGTH = 33, ///< The maximum length of the network id of the servers, in bytes including '\0' static const uint NETWORK_SERVER_ID_LENGTH = 33; ///< The maximum length of the network id of the servers, in bytes including '\0'
NETWORK_REVISION_LENGTH = 15, ///< The maximum length of the revision, in bytes including '\0' static const uint NETWORK_REVISION_LENGTH = 15; ///< The maximum length of the revision, in bytes including '\0'
NETWORK_PASSWORD_LENGTH = 33, ///< The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH) static const uint NETWORK_PASSWORD_LENGTH = 33; ///< The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH)
NETWORK_CLIENTS_LENGTH = 200, ///< The maximum length for the list of clients that controls a company, in bytes including '\0' static const uint NETWORK_CLIENTS_LENGTH = 200; ///< The maximum length for the list of clients that controls a company, in bytes including '\0'
NETWORK_CLIENT_NAME_LENGTH = 25, ///< The maximum length of a client's name, in bytes including '\0' static const uint NETWORK_CLIENT_NAME_LENGTH = 25; ///< The maximum length of a client's name, in bytes including '\0'
NETWORK_RCONCOMMAND_LENGTH = 500, ///< The maximum length of a rconsole command, in bytes including '\0' static const uint NETWORK_RCONCOMMAND_LENGTH = 500; ///< The maximum length of a rconsole command, in bytes including '\0'
NETWORK_CHAT_LENGTH = 900, ///< The maximum length of a chat message, in bytes including '\0' static const uint NETWORK_CHAT_LENGTH = 900; ///< The maximum length of a chat message, in bytes including '\0'
NETWORK_GRF_NAME_LENGTH = 80, ///< Maximum length of the name of a GRF static const uint NETWORK_GRF_NAME_LENGTH = 80; ///< Maximum length of the name of a GRF
/**
* Maximum number of GRFs that can be sent.
* This value is related to number of handles (files) OpenTTD can open.
* This is currently 64. Two are used for configuration and sound.
*/
NETWORK_MAX_GRF_COUNT = 62,
NETWORK_NUM_LANGUAGES = 36, ///< Number of known languages (to the network protocol) + 1 for 'any'. /**
/** * Maximum number of GRFs that can be sent.
* The number of landscapes in OpenTTD. * This value is related to number of handles (files) OpenTTD can open.
* This number must be equal to NUM_LANDSCAPE, but as this number is used * This is currently 64. Two are used for configuration and sound.
* within the network code and that the network code is shared with the */
* masterserver/updater, it has to be declared in here too. In network.cpp static const uint NETWORK_MAX_GRF_COUNT = 62;
* there is a compile assertion to check that this NUM_LANDSCAPE is equal
* to NETWORK_NUM_LANDSCAPES. static const uint NETWORK_NUM_LANGUAGES = 36; ///< Number of known languages (to the network protocol) + 1 for 'any'.
*/
NETWORK_NUM_LANDSCAPES = 4, /**
}; * The number of landscapes in OpenTTD.
* This number must be equal to NUM_LANDSCAPE, but as this number is used
* within the network code and that the network code is shared with the
* masterserver/updater, it has to be declared in here too. In network.cpp
* there is a compile assertion to check that this NUM_LANDSCAPE is equal
* to NETWORK_NUM_LANDSCAPES.
*/
static const uint NETWORK_NUM_LANDSCAPES = 4;
#endif /* NETWORK_CORE_CONFIG_H */ #endif /* NETWORK_CORE_CONFIG_H */

View File

@ -27,7 +27,7 @@
* it protects old clients from joining newer servers * it protects old clients from joining newer servers
* (because SERVER_ERROR is the respond to a wrong revision) * (because SERVER_ERROR is the respond to a wrong revision)
*/ */
enum { enum TCPPacketType {
PACKET_SERVER_FULL, PACKET_SERVER_FULL,
PACKET_SERVER_BANNED, PACKET_SERVER_BANNED,
PACKET_CLIENT_JOIN, PACKET_CLIENT_JOIN,

View File

@ -423,10 +423,12 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
company_info->income = p->Recv_uint64(); company_info->income = p->Recv_uint64();
company_info->performance = p->Recv_uint16(); company_info->performance = p->Recv_uint16();
company_info->use_password = p->Recv_bool(); company_info->use_password = p->Recv_bool();
for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++) for (uint i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
company_info->num_vehicle[i] = p->Recv_uint16(); company_info->num_vehicle[i] = p->Recv_uint16();
for (int i = 0; i < NETWORK_STATION_TYPES; i++) }
for (uint i = 0; i < NETWORK_STATION_TYPES; i++) {
company_info->num_station[i] = p->Recv_uint16(); company_info->num_station[i] = p->Recv_uint16();
}
company_info->ai = p->Recv_bool(); company_info->ai = p->Recv_bool();
p->Recv_string(company_info->clients, sizeof(company_info->clients)); p->Recv_string(company_info->clients, sizeof(company_info->clients));

View File

@ -1375,11 +1375,11 @@ void NetworkSocketHandler::Send_CompanyInformation(Packet *p, const Company *c,
/* Send 1 if there is a passord for the company else send 0 */ /* Send 1 if there is a passord for the company else send 0 */
p->Send_bool (!StrEmpty(_network_company_states[c->index].password)); p->Send_bool (!StrEmpty(_network_company_states[c->index].password));
for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++) { for (uint i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
p->Send_uint16(stats->num_vehicle[i]); p->Send_uint16(stats->num_vehicle[i]);
} }
for (int i = 0; i < NETWORK_STATION_TYPES; i++) { for (uint i = 0; i < NETWORK_STATION_TYPES; i++) {
p->Send_uint16(stats->num_station[i]); p->Send_uint16(stats->num_station[i]);
} }

View File

@ -16,21 +16,20 @@
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
enum { /** How many clients can we have */
/** How many clients can we have */ static const uint MAX_CLIENTS = 255;
MAX_CLIENTS = 255,
/** /**
* The number of slots; must be at least 1 more than MAX_CLIENTS. It must * The number of slots; must be at least 1 more than MAX_CLIENTS. It must
* furthermore be less than or equal to 256 as client indices (sent over * furthermore be less than or equal to 256 as client indices (sent over
* the network) are 8 bits. It needs 1 more for the dedicated server. * the network) are 8 bits. It needs 1 more for the dedicated server.
*/ */
MAX_CLIENT_SLOTS = 256, static const uint MAX_CLIENT_SLOTS = 256;
/** How many vehicle/station types we put over the network */ /** How many vehicle types we put over the network */
NETWORK_VEHICLE_TYPES = 5, static const uint NETWORK_VEHICLE_TYPES = 5;
NETWORK_STATION_TYPES = 5, /** How many station types we put over the network */
}; static const uint NETWORK_STATION_TYPES = 5;
/** 'Unique' identifier to be given to clients */ /** 'Unique' identifier to be given to clients */
enum ClientID { enum ClientID {