Adding of _t to (u)int types, and WChar to char32_t

See: eaae0bb5e
This commit is contained in:
Jonathan G Rennison
2024-01-07 16:41:53 +00:00
parent 55d78a23be
commit 97e6f3062e
655 changed files with 7555 additions and 7555 deletions

View File

@@ -35,7 +35,7 @@ const char *NetworkAddress::GetHostname()
* Get the port.
* @return the port.
*/
uint16 NetworkAddress::GetPort() const
uint16_t NetworkAddress::GetPort() const
{
switch (this->address.ss_family) {
case AF_UNSPEC:
@@ -54,7 +54,7 @@ uint16 NetworkAddress::GetPort() const
* Set the port.
* @param port set the port number.
*/
void NetworkAddress::SetPort(uint16 port)
void NetworkAddress::SetPort(uint16_t port)
{
switch (this->address.ss_family) {
case AF_UNSPEC:
@@ -191,17 +191,17 @@ bool NetworkAddress::IsInNetmask(const char *netmask)
if (mask_address.GetAddressLength() == 0) return false;
uint32 *ip;
uint32 *mask;
uint32_t *ip;
uint32_t *mask;
switch (this->address.ss_family) {
case AF_INET:
ip = (uint32*)&((struct sockaddr_in*)&this->address)->sin_addr.s_addr;
mask = (uint32*)&((struct sockaddr_in*)&mask_address.address)->sin_addr.s_addr;
ip = (uint32_t*)&((struct sockaddr_in*)&this->address)->sin_addr.s_addr;
mask = (uint32_t*)&((struct sockaddr_in*)&mask_address.address)->sin_addr.s_addr;
break;
case AF_INET6:
ip = (uint32*)&((struct sockaddr_in6*)&this->address)->sin6_addr;
mask = (uint32*)&((struct sockaddr_in6*)&mask_address.address)->sin6_addr;
ip = (uint32_t*)&((struct sockaddr_in6*)&this->address)->sin6_addr;
mask = (uint32_t*)&((struct sockaddr_in6*)&mask_address.address)->sin6_addr;
break;
default:
@@ -209,7 +209,7 @@ bool NetworkAddress::IsInNetmask(const char *netmask)
}
while (cidr > 0) {
uint32 msk = cidr >= 32 ? (uint32)-1 : htonl(-(1 << (32 - cidr)));
uint32_t msk = cidr >= 32 ? (uint32_t)-1 : htonl(-(1 << (32 - cidr)));
if ((*mask++ & msk) != (*ip++ & msk)) return false;
cidr -= 32;
@@ -471,14 +471,14 @@ void NetworkAddress::Listen(int socktype, SocketList *sockets)
* @param company Pointer to the company variable to set iff indicated.
* @return A valid ServerAddress of the parsed information.
*/
/* static */ ServerAddress ServerAddress::Parse(const std::string &connection_string, uint16 default_port, CompanyID *company_id)
/* static */ ServerAddress ServerAddress::Parse(const std::string &connection_string, uint16_t default_port, CompanyID *company_id)
{
if (StrStartsWith(connection_string, "+")) {
std::string_view invite_code = ParseCompanyFromConnectionString(connection_string, company_id);
return ServerAddress(SERVER_ADDRESS_INVITE_CODE, std::string(invite_code));
}
uint16 port = default_port;
uint16_t port = default_port;
std::string_view ip = ParseFullConnectionString(connection_string, port, company_id);
return ServerAddress(SERVER_ADDRESS_DIRECT, std::string(ip) + ":" + std::to_string(port));
}

View File

@@ -75,7 +75,7 @@ public:
* @param port the port
* @param family the address family
*/
NetworkAddress(std::string_view hostname = "", uint16 port = 0, int family = AF_UNSPEC) :
NetworkAddress(std::string_view hostname = "", uint16_t port = 0, int family = AF_UNSPEC) :
address_length(0),
resolved(false)
{
@@ -106,8 +106,8 @@ public:
return this->address_length;
}
uint16 GetPort() const;
void SetPort(uint16 port);
uint16_t GetPort() const;
void SetPort(uint16_t port);
/**
* Check whether the IP address has been resolved already
@@ -226,7 +226,7 @@ public:
ServerAddressType type; ///< The type of this ServerAddress.
std::string connection_string; ///< The connection string for this ServerAddress.
static ServerAddress Parse(const std::string &connection_string, uint16 default_port, CompanyID *company_id = nullptr);
static ServerAddress Parse(const std::string &connection_string, uint16_t default_port, CompanyID *company_id = nullptr);
};
#endif /* NETWORK_CORE_ADDRESS_H */

View File

@@ -18,16 +18,16 @@ const char *NetworkContentServerConnectionString();
const char *NetworkContentMirrorUriString();
const char *NetworkSurveyUriString();
static const uint16 NETWORK_COORDINATOR_SERVER_PORT = 3976; ///< The default port of the Game Coordinator server (TCP)
static const uint16 NETWORK_STUN_SERVER_PORT = 3975; ///< The default port of the STUN server (TCP)
static const uint16 NETWORK_TURN_SERVER_PORT = 3974; ///< The default port of the TURN server (TCP)
static const uint16 NETWORK_CONTENT_SERVER_PORT = 3978; ///< The default port of the content server (TCP)
static const uint16 NETWORK_DEFAULT_PORT = 3979; ///< The default port of the game server (TCP & UDP)
static const uint16 NETWORK_ADMIN_PORT = 3977; ///< The default port for admin network
static const uint16 NETWORK_DEFAULT_DEBUGLOG_PORT = 3982; ///< The default port debug-log is sent to (TCP)
static const uint16_t NETWORK_COORDINATOR_SERVER_PORT = 3976; ///< The default port of the Game Coordinator server (TCP)
static const uint16_t NETWORK_STUN_SERVER_PORT = 3975; ///< The default port of the STUN server (TCP)
static const uint16_t NETWORK_TURN_SERVER_PORT = 3974; ///< The default port of the TURN server (TCP)
static const uint16_t NETWORK_CONTENT_SERVER_PORT = 3978; ///< The default port of the content server (TCP)
static const uint16_t NETWORK_DEFAULT_PORT = 3979; ///< The default port of the game server (TCP & UDP)
static const uint16_t NETWORK_ADMIN_PORT = 3977; ///< The default port for admin network
static const uint16_t NETWORK_DEFAULT_DEBUGLOG_PORT = 3982; ///< The default port debug-log is sent to (TCP)
static const uint16 UDP_MTU = 1460; ///< Number of bytes we can pack in a single UDP packet
static const uint16 UDP_MTU_SHORT = 1400; ///< Number of bytes we can pack in a single UDP packet (conservative)
static const uint16_t UDP_MTU = 1460; ///< Number of bytes we can pack in a single UDP packet
static const uint16_t UDP_MTU_SHORT = 1400; ///< Number of bytes we can pack in a single UDP packet (conservative)
static const std::string NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.org/participate"; ///< Link with more details & privacy statement of the survey.
/*
@@ -38,14 +38,14 @@ static const std::string NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.o
* 00000000 00000000 0bbbbbbb aaaaaaaa -> aaaaaaaa 0bbbbbbb
* Send_uint16(GB(size, 0, 15)
*
* Packets up to 1 GiB, first uint16 has high bit set so it knows to read a
* next uint16 for the remaining bits of the size.
* Packets up to 1 GiB, first uint16_t has high bit set so it knows to read a
* next uint16_t for the remaining bits of the size.
* 00dddddd cccccccc bbbbbbbb aaaaaaaa -> cccccccc 10dddddd aaaaaaaa bbbbbbbb
* Send_uint16(GB(size, 16, 14) | 0b10 << 14)
* Send_uint16(GB(size, 0, 16))
*/
static const uint16 TCP_MTU = 32767; ///< Number of bytes we can pack in a single TCP packet
static const uint16 COMPAT_MTU = 1460; ///< Number of bytes we can pack in a single packet for backward compatibility
static const uint16_t TCP_MTU = 32767; ///< Number of bytes we can pack in a single TCP packet
static const uint16_t COMPAT_MTU = 1460; ///< Number of bytes we can pack in a single packet for backward compatibility
static const byte NETWORK_GAME_ADMIN_VERSION = 3; ///< What version of the admin network do we use?
static const byte NETWORK_GAME_INFO_VERSION = 6; ///< What version of game-info do we use?
@@ -97,6 +97,6 @@ static const uint NETWORK_MAX_GRF_COUNT = 255;
/**
* Maximum version supported in PACKET_SERVER_GAME_INFO_EXTENDED
*/
static const uint8 SERVER_GAME_INFO_EXTENDED_MAX_VERSION = 1;
static const uint8_t SERVER_GAME_INFO_EXTENDED_MAX_VERSION = 1;
#endif /* NETWORK_CORE_CONFIG_H */

View File

@@ -27,7 +27,7 @@
#include "../../safeguards.h"
extern const uint8 _out_of_band_grf_md5[16];
extern const uint8_t _out_of_band_grf_md5[16];
/**
* How many hex digits of the git hash to include in network revision string.
@@ -207,7 +207,7 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool
/* NETWORK_GAME_INFO_VERSION = 5 */
GameInfo *game_info = Game::GetInfo();
p->Send_uint32(game_info == nullptr ? -1 : (uint32)game_info->GetVersion());
p->Send_uint32(game_info == nullptr ? -1 : (uint32_t)game_info->GetVersion());
p->Send_string(game_info == nullptr ? "" : game_info->GetName());
/* NETWORK_GAME_INFO_VERSION = 4 */
@@ -223,7 +223,7 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool
for (c = info->grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) count++;
}
p->Send_uint8(ClampTo<uint8>(std::min<uint>(count, NETWORK_MAX_GRF_COUNT))); // Send number of GRFs
p->Send_uint8(ClampTo<uint8_t>(std::min<uint>(count, NETWORK_MAX_GRF_COUNT))); // Send number of GRFs
/* Send actual GRF Identifications */
for (c = info->grfconfig; c != nullptr; c = c->next) {
@@ -251,7 +251,7 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool
p->Send_uint8 (info->clients_on);
p->Send_uint8 (info->spectators_on);
auto encode_map_size = [&](uint32 in) -> uint16 {
auto encode_map_size = [&](uint32_t in) -> uint16_t {
if (in < UINT16_MAX) {
return in;
} else {
@@ -269,9 +269,9 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool
* @param p the packet to write the data to
* @param info the NetworkGameInfo struct to serialize
*/
void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *info, uint16 flags, uint16 version, bool send_newgrf_names)
void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *info, uint16_t flags, uint16_t version, bool send_newgrf_names)
{
version = std::max<uint16>(version, 1); // Version 1 is the max supported
version = std::max<uint16_t>(version, 1); // Version 1 is the max supported
p->Send_uint8(version); // version num
@@ -295,7 +295,7 @@ void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *in
if (version >= 1) {
GameInfo *game_info = Game::GetInfo();
p->Send_uint32(game_info == nullptr ? -1 : (uint32)game_info->GetVersion());
p->Send_uint32(game_info == nullptr ? -1 : (uint32_t)game_info->GetVersion());
p->Send_string(game_info == nullptr ? "" : game_info->GetName());
p->Send_uint8(send_newgrf_names ? NST_GRFID_MD5_NAME : NST_GRFID_MD5);
@@ -361,7 +361,7 @@ void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfo
/* Ensure that the maximum number of NewGRFs and the field in the network
* protocol are matched to eachother. If that is not the case anymore a
* check must be added to ensure the received data is still valid. */
static_assert(std::numeric_limits<uint8>::max() == NETWORK_MAX_GRF_COUNT);
static_assert(std::numeric_limits<uint8_t>::max() == NETWORK_MAX_GRF_COUNT);
uint num_grfs = p->Recv_uint8();
GRFConfig **dst = &info->grfconfig;
@@ -424,7 +424,7 @@ void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfo
}
if (game_info_version < 6) while (p->Recv_uint8() != 0) {} // Used to contain the map-name.
auto decode_map_size = [&](uint16 in) -> uint32 {
auto decode_map_size = [&](uint16_t in) -> uint32_t {
if (in >= 65000) {
return 1 << (in - 65000);
} else {
@@ -450,7 +450,7 @@ void DeserializeNetworkGameInfoExtended(Packet *p, NetworkGameInfo *info)
{
static const Date MAX_DATE = ConvertYMDToDate(MAX_YEAR, 11, 31); // December is month 11
const uint8 version = p->Recv_uint8();
const uint8_t version = p->Recv_uint8();
if (version > SERVER_GAME_INFO_EXTENDED_MAX_VERSION) return; // Unknown version
NewGRFSerializationType newgrf_serialisation = NST_GRFID_MD5;

View File

@@ -94,8 +94,8 @@ struct NetworkServerGameInfo {
GRFConfig *grfconfig; ///< List of NewGRF files used
Date start_date; ///< When the game started
Date game_date; ///< Current date
uint32 map_width; ///< Map width
uint32 map_height; ///< Map height
uint32_t map_width; ///< Map width
uint32_t map_height; ///< Map height
std::string server_name; ///< Server name
std::string server_revision; ///< The version number the server is using (e.g.: 'r304' or 0.5.0)
bool dedicated; ///< Is this a dedicated server?
@@ -128,7 +128,7 @@ struct NamedGRFIdentifier {
std::string name; ///< The name of the NewGRF.
};
/** Lookup table for the GameInfo in case of #NST_LOOKUP_ID. */
typedef std::unordered_map<uint32, NamedGRFIdentifier> GameInfoNewGRFLookupTable;
typedef std::unordered_map<uint32_t, NamedGRFIdentifier> GameInfoNewGRFLookupTable;
extern NetworkServerGameInfo _network_game_info;
@@ -146,6 +146,6 @@ void SerializeGRFIdentifier(Packet *p, const GRFIdentifier *grf);
void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfoNewGRFLookupTable *newgrf_lookup_table = nullptr);
void DeserializeNetworkGameInfoExtended(Packet *p, NetworkGameInfo *info);
void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool send_newgrf_names = true);
void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *info, uint16 flags, uint16 version, bool send_newgrf_names = true);
void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *info, uint16_t flags, uint16_t version, bool send_newgrf_names = true);
#endif /* NETWORK_CORE_GAME_INFO_H */

View File

@@ -204,7 +204,7 @@ bool ShutdownSocket(SOCKET d, bool read, bool write, uint linger_timeout)
{
if (!read && !write) return true;
#ifdef _WIN32
LINGER ln = { 1U, (uint16) linger_timeout };
LINGER ln = { 1U, (uint16_t) linger_timeout };
#else
struct linger ln = { 1, (int) linger_timeout };
#endif

View File

@@ -85,7 +85,7 @@ bool Packet::CanWriteToPacket(size_t bytes_to_write)
return this->Size() + bytes_to_write <= this->limit;
}
void Packet::WriteAtOffset_uint16(size_t offset, uint16 data)
void Packet::WriteAtOffset_uint16(size_t offset, uint16_t data)
{
assert(offset + 1 < this->buffer.size());
this->buffer[offset] = GB(data, 0, 8);

View File

@@ -22,8 +22,8 @@
#include <limits>
#include <vector>
typedef uint16 PacketSize; ///< Size of the whole packet.
typedef uint8 PacketType; ///< Identifier for the packet
typedef uint16_t PacketSize; ///< Size of the whole packet.
typedef uint8_t PacketType; ///< Identifier for the packet
/**
* Internal entity of a packet. As everything is sent as a packet,
@@ -75,7 +75,7 @@ public:
bool CanWriteToPacket(size_t bytes_to_write);
void WriteAtOffset_uint16(size_t offset, uint16);
void WriteAtOffset_uint16(size_t offset, uint16_t);
/* Reading/receiving of packets */
size_t ReadRawPacketSize() const;

View File

@@ -127,7 +127,7 @@ private:
public:
TCPConnecter() {};
TCPConnecter(const std::string &connection_string, uint16 default_port, const NetworkAddress &bind_address = {}, int family = AF_UNSPEC);
TCPConnecter(const std::string &connection_string, uint16_t default_port, const NetworkAddress &bind_address = {}, int family = AF_UNSPEC);
virtual ~TCPConnecter();
/**
@@ -156,7 +156,7 @@ private:
public:
ServerAddress server_address; ///< Address we are connecting to.
TCPServerConnecter(const std::string &connection_string, uint16 default_port);
TCPServerConnecter(const std::string &connection_string, uint16_t default_port);
void SetConnected(SOCKET sock);
void SetFailure();

View File

@@ -135,8 +135,8 @@ protected:
/**
* Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet):
* uint16 Update type (see #AdminUpdateType). Note integer type - see "Certain Packet Information" in docs/admin_network.md.
* uint16 Update frequency (see #AdminUpdateFrequency), setting #ADMIN_FREQUENCY_POLL is always ignored.
* uint16_t Update type (see #AdminUpdateType). Note integer type - see "Certain Packet Information" in docs/admin_network.md.
* uint16_t 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.
*/
@@ -144,8 +144,8 @@ protected:
/**
* Poll the server for certain updates, an invalid poll (e.g. not existent id) gets silently dropped:
* uint8 #AdminUpdateType the server should answer for, only if #AdminUpdateFrequency #ADMIN_FREQUENCY_POLL is advertised in the PROTOCOL packet. Note integer type - see "Certain Packet Information" in docs/admin_network.md.
* uint32 ID relevant to the packet type, e.g.
* uint8_t #AdminUpdateType the server should answer for, only if #AdminUpdateFrequency #ADMIN_FREQUENCY_POLL is advertised in the PROTOCOL packet. Note integer type - see "Certain Packet Information" in docs/admin_network.md.
* uint32_t 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.
@@ -155,9 +155,9 @@ protected:
/**
* 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.
* uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see #NetworkAction).
* uint8_t Destination type such as DESTTYPE_BROADCAST (see #DestType).
* uint32_t 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.
@@ -166,10 +166,10 @@ protected:
/**
* 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.
* string Name of the source this message came from.
* uint16_t 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.
*/
@@ -193,7 +193,7 @@ protected:
/**
* Ping the server, requiring the server to reply with a pong packet.
* uint32 Integer value to pass to the server, which is quoted in the reply.
* uint32_t Integer value to pass to the server, which is quoted in the reply.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -215,7 +215,7 @@ protected:
/**
* An error was caused by this admin connection (connection gets closed).
* uint8 NetworkErrorCode the error caused.
* uint8_t NetworkErrorCode the error caused.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -223,10 +223,10 @@ protected:
/**
* Inform a just joined admin about the protocol specifics:
* uint8 Protocol version.
* bool Further protocol data follows (repeats through all update packet types).
* uint16 Update packet type.
* uint16 Frequencies allowed for this update packet (bitwise).
* uint8_t Protocol version.
* bool Further protocol data follows (repeats through all update packet types).
* uint16_t Update packet type.
* uint16_t Frequencies allowed for this update packet (bitwise).
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -234,15 +234,15 @@ protected:
/**
* Welcome a connected admin to the game:
* string Name of the Server.
* string OpenTTD version string.
* bool Server is dedicated.
* string Name of the Map.
* uint32 Random seed of the Map.
* uint8 Landscape of the Map.
* uint32 Start date of the Map.
* uint16 Map width.
* uint16 Map height.
* string Name of the Server.
* string OpenTTD version string.
* bool Server is dedicated.
* string Name of the Map.
* uint32_t Random seed of the Map.
* uint8_t Landscape of the Map.
* uint32_t Start date of the Map.
* uint16_t Map width.
* uint16_t Map height.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -264,7 +264,7 @@ protected:
/**
* Send the current date of the game:
* uint32 Current game date.
* uint32_t Current game date.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -272,7 +272,7 @@ protected:
/**
* Notification of a new client:
* uint32 ID of the new client.
* uint32_t ID of the new client.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -280,12 +280,12 @@ protected:
/**
* Client information of a specific client:
* uint32 ID of the client.
* string Network address of the client.
* string Name of the client.
* 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).
* uint32_t ID of the client.
* string Network address of the client.
* string Name of the client.
* uint8_t Language of the client.
* uint32_t Date the client joined the game.
* uint8_t 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.
*/
@@ -293,9 +293,9 @@ protected:
/**
* 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).
* uint32_t ID of the client.
* string Name of the client.
* uint8_t 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.
*/
@@ -303,7 +303,7 @@ protected:
/**
* Notification about a client leaving the game.
* uint32 ID of the client that just left.
* uint32_t ID of the client that just left.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -311,8 +311,8 @@ protected:
/**
* 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).
* uint32_t ID of the client that made the error.
* uint8_t Error the client made (see NetworkErrorCode).
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -320,7 +320,7 @@ protected:
/**
* Notification of a new company:
* uint8 ID of the new company.
* uint8_t ID of the new company.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -328,13 +328,13 @@ protected:
/**
* 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.
* uint8_t ID of the company.
* string Name of the company.
* string Name of the companies manager.
* uint8_t Main company colour.
* bool Company is password protected.
* uint32_t 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.
*/
@@ -342,16 +342,16 @@ protected:
/**
* 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.
* uint8_t ID of the company.
* string Name of the company.
* string Name of the companies manager.
* uint8_t Main company colour.
* bool Company is password protected.
* uint8_t Quarters of bankruptcy.
* uint8_t Owner of share 1.
* uint8_t Owner of share 2.
* uint8_t Owner of share 3.
* uint8_t Owner of share 4.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -359,8 +359,8 @@ protected:
/**
* Notification about a removed company (e.g. due to bankruptcy).
* uint8 ID of the company.
* uint8 Reason for being removed (see #AdminCompanyRemoveReason).
* uint8_t ID of the company.
* uint8_t Reason for being removed (see #AdminCompanyRemoveReason).
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -368,17 +368,17 @@ protected:
/**
* Economy update of a specific company:
* uint8 ID of the company.
* uint64 Money.
* uint64 Loan.
* int64 Income.
* uint16 Delivered cargo (this quarter).
* uint64 Company value (last quarter).
* uint16 Performance (last quarter).
* uint16 Delivered cargo (last quarter).
* uint64 Company value (previous quarter).
* uint16 Performance (previous quarter).
* uint16 Delivered cargo (previous quarter).
* uint8_t ID of the company.
* uint64_t Money.
* uint64_t Loan.
* int64_t Income.
* uint16_t Delivered cargo (this quarter).
* uint64_t Company value (last quarter).
* uint16_t Performance (last quarter).
* uint16_t Delivered cargo (last quarter).
* uint64_t Company value (previous quarter).
* uint16_t Performance (previous quarter).
* uint16_t Delivered cargo (previous quarter).
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -386,17 +386,17 @@ protected:
/**
* Company statistics on stations and vehicles:
* uint8 ID of the company.
* uint16 Number of trains.
* uint16 Number of lorries.
* uint16 Number of busses.
* uint16 Number of planes.
* uint16 Number of ships.
* uint16 Number of train stations.
* uint16 Number of lorry stations.
* uint16 Number of bus stops.
* uint16 Number of airports and heliports.
* uint16 Number of harbours.
* uint8_t ID of the company.
* uint16_t Number of trains.
* uint16_t Number of lorries.
* uint16_t Number of busses.
* uint16_t Number of planes.
* uint16_t Number of ships.
* uint16_t Number of train stations.
* uint16_t Number of lorry stations.
* uint16_t Number of bus stops.
* uint16_t Number of airports and heliports.
* uint16_t Number of harbours.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -404,11 +404,11 @@ protected:
/**
* 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).
* uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see #NetworkAction).
* uint8_t Destination type such as DESTTYPE_BROADCAST (see #DestType).
* uint32_t ID of the client who sent this message.
* string Message.
* uint64_t Money (only when it is a 'give money' action).
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -416,8 +416,8 @@ protected:
/**
* Result of an rcon command:
* uint16 Colour as it would be used on the server or a client.
* string Output of the executed command.
* uint16_t 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.
*/
@@ -443,9 +443,9 @@ protected:
* Data provided in this packet is for logging purposes only.
*
* These three fields are repeated until the packet is full:
* bool Data to follow.
* uint16 ID of the DoCommand.
* string Name of DoCommand.
* bool Data to follow.
* uint16_t ID of the DoCommand.
* string Name of DoCommand.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -460,14 +460,14 @@ protected:
* across different versions / revisions of OpenTTD.
* Data provided in this packet is for logging purposes only.
*
* uint32 ID of the client sending the command.
* uint8 ID of the company (0..MAX_COMPANIES-1).
* uint16 ID of the command.
* uint32 P1 (variable data passed to the command).
* uint32 P2 (variable data passed to the command).
* uint32 Tile where this is taking place.
* string Text passed to the command.
* uint32 Frame of execution.
* uint32_t ID of the client sending the command.
* uint8_t ID of the company (0..MAX_COMPANIES-1).
* uint16_t ID of the command.
* uint32_t P1 (variable data passed to the command).
* uint32_t P2 (variable data passed to the command).
* uint32_t Tile where this is taking place.
* string Text passed to the command.
* uint32_t Frame of execution.
* @param p The packet that was just received.
* @return The state the network should have.
*/
@@ -475,7 +475,7 @@ protected:
/**
* Send a ping-reply (pong) to the admin that sent us the ping packet.
* uint32 Integer identifier - should be the same as read from the admins ping packet.
* uint32_t Integer identifier - should be the same as read from the admins ping packet.
* @param p The packet that was just received.
* @return The state the network should have.
*/

View File

@@ -28,7 +28,7 @@ static std::vector<TCPConnecter *> _tcp_connecters;
* @param default_port If not indicated in connection_string, what port to use.
* @param bind_address The local bind address to use. Defaults to letting the OS find one.
*/
TCPConnecter::TCPConnecter(const std::string &connection_string, uint16 default_port, const NetworkAddress &bind_address, int family) :
TCPConnecter::TCPConnecter(const std::string &connection_string, uint16_t default_port, const NetworkAddress &bind_address, int family) :
bind_address(bind_address),
family(family)
{
@@ -42,7 +42,7 @@ TCPConnecter::TCPConnecter(const std::string &connection_string, uint16 default_
* @param connection_string The address to connect to.
* @param default_port If not indicated in connection_string, what port to use.
*/
TCPServerConnecter::TCPServerConnecter(const std::string &connection_string, uint16 default_port) :
TCPServerConnecter::TCPServerConnecter(const std::string &connection_string, uint16_t default_port) :
server_address(ServerAddress::Parse(connection_string, default_port))
{
switch (this->server_address.type) {

View File

@@ -25,12 +25,12 @@ protected:
/**
* Client requesting a list of content info:
* byte type
* uint32 openttd version (or 0xFFFFFFFF if using a list)
* byte type
* uint32_t openttd version (or 0xFFFFFFFF if using a list)
* Only if the above value is 0xFFFFFFFF:
* uint8 count
* string branch-name ("vanilla" for upstream OpenTTD)
* string release version (like "12.0")
* uint8_t count
* string branch-name ("vanilla" for upstream OpenTTD)
* string release version (like "12.0")
* @param p The packet that was just received.
* @return True upon success, otherwise false.
*/
@@ -38,8 +38,8 @@ protected:
/**
* Client requesting a list of content info:
* uint16 count of ids
* uint32 id (count times)
* uint16_t count of ids
* uint32_t id (count times)
* @param p The packet that was just received.
* @return True upon success, otherwise false.
*/
@@ -50,10 +50,10 @@ protected:
* 'unique' id; GRF ID for NewGRFS, shortname and for base
* graphics and AIs.
* Scenarios and AI libraries are not supported
* uint8 count of requests
* uint8_t count of requests
* for each request:
* uint8 type
* unique id (uint32)
* uint8_t type
* unique id (uint32_t)
* @param p The packet that was just received.
* @return True upon success, otherwise false.
*/
@@ -64,10 +64,10 @@ protected:
* 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and
* xor-ed MD5 checksums for base graphics and AIs.
* Scenarios and AI libraries are not supported
* uint8 count of requests
* uint8_t count of requests
* for each request:
* uint8 type
* unique id (uint32)
* uint8_t type
* unique id (uint32_t)
* md5 (16 bytes)
* @param p The packet that was just received.
* @return True upon success, otherwise false.
@@ -76,17 +76,17 @@ protected:
/**
* Server sending list of content info:
* byte type (invalid ID == does not exist)
* uint32 id
* uint32 file_size
* string name (max 32 characters)
* string version (max 16 characters)
* uint32 unique id
* uint8 md5sum (16 bytes)
* uint8 dependency count
* uint32 unique id of dependency (dependency count times)
* uint8 tag count
* string tag (max 32 characters for tag count times)
* byte type (invalid ID == does not exist)
* uint32_t id
* uint32_t file_size
* string name (max 32 characters)
* string version (max 16 characters)
* uint32_t unique id
* uint8_t md5sum (16 bytes)
* uint8_t dependency count
* uint32_t unique id of dependency (dependency count times)
* uint8_t tag count
* string tag (max 32 characters for tag count times)
* @param p The packet that was just received.
* @return True upon success, otherwise false.
*/
@@ -94,8 +94,8 @@ protected:
/**
* Client requesting the actual content:
* uint16 count of unique ids
* uint32 unique id (count times)
* uint16_t count of unique ids
* uint32_t unique id (count times)
* @param p The packet that was just received.
* @return True upon success, otherwise false.
*/
@@ -103,9 +103,9 @@ protected:
/**
* Server sending list of content info:
* uint32 unique id
* uint32 file size (0 == does not exist)
* string file name (max 48 characters)
* uint32_t unique id
* uint32_t file size (0 == does not exist)
* string file name (max 48 characters)
* After this initial packet, packets with the actual data are send using
* the same packet type.
* @param p The packet that was just received.

View File

@@ -63,13 +63,13 @@ struct ContentInfo {
ContentType type = INVALID_CONTENT_TYPE; ///< Type of content
ContentID id = INVALID_CONTENT_ID; ///< Unique (server side) ID for the content
uint32 filesize = 0; ///< Size of the file
uint32_t filesize = 0; ///< Size of the file
std::string filename; ///< Filename (for the .tar.gz; only valid on download)
std::string name; ///< Name of the content
std::string version; ///< Version of the content
std::string url; ///< URL related to the content
std::string description; ///< Description of the content
uint32 unique_id = 0; ///< Unique ID; either GRF ID or shortname
uint32_t unique_id = 0; ///< Unique ID; either GRF ID or shortname
MD5Hash md5sum; ///< The MD5 checksum
std::vector<ContentID> dependencies; ///< The dependencies (unique server side ids)
StringList tags; ///< Tags associated with the content

View File

@@ -77,7 +77,7 @@ protected:
* permanent error causing the connection to be dropped, or in response
* to a request that is invalid.
*
* uint8 Type of error (see NetworkCoordinatorErrorType).
* uint8_t Type of error (see NetworkCoordinatorErrorType).
* string Details of the error.
*
* @param p The packet that was just received.
@@ -89,11 +89,11 @@ protected:
* Server is starting a multiplayer game and wants to let the
* Game Coordinator know.
*
* uint8 Game Coordinator protocol version.
* uint8 Type of game (see ServerGameType).
* uint16 Local port of the server.
* string Invite code the server wants to use (can be empty; coordinator will assign a new invite code).
* string Secret that belongs to the invite code (empty if invite code is empty).
* uint8_t Game Coordinator protocol version.
* uint8_t Type of game (see ServerGameType).
* uint16_t Local port of the server.
* string Invite code the server wants to use (can be empty; coordinator will assign a new invite code).
* string Secret that belongs to the invite code (empty if invite code is empty).
*
* @param p The packet that was just received.
* @return True upon success, otherwise false.
@@ -105,7 +105,7 @@ protected:
*
* string Invite code that can be used to join this server.
* string Secret that belongs to the invite code (only needed if reusing the invite code on next SERVER_REGISTER).
* uint8 Type of connection was detected (see ConnectionType).
* uint8_t Type of connection was detected (see ConnectionType).
*
* @param p The packet that was just received.
* @return True upon success, otherwise false.
@@ -115,7 +115,7 @@ protected:
/**
* Send an update of the current state of the server to the Game Coordinator.
*
* uint8 Game Coordinator protocol version.
* uint8_t Game Coordinator protocol version.
* Serialized NetworkGameInfo. See game_info.hpp for details.
*
* @param p The packet that was just received.
@@ -126,10 +126,10 @@ protected:
/**
* Client requests a list of all public servers.
*
* uint8 Game Coordinator protocol version.
* uint8 Game-info version used by this client.
* string Revision of the client.
* uint32 (Game Coordinator protocol >= 4) Cursor as received from GC_NEWGRF_LOOKUP, or zero.
* uint8_t Game Coordinator protocol version.
* uint8_t Game-info version used by this client.
* string Revision of the client.
* uint32_t (Game Coordinator protocol >= 4) Cursor as received from GC_NEWGRF_LOOKUP, or zero.
*
* @param p The packet that was just received.
* @return True upon success, otherwise false.
@@ -141,7 +141,7 @@ protected:
* of these packets are received after a request till all servers are
* sent over. Last packet will have server count of 0.
*
* uint16 Amount of public servers in this packet.
* uint16_t Amount of public servers in this packet.
* For each server:
* string Connection string for this server.
* Serialized NetworkGameInfo. See game_info.hpp for details.
@@ -154,7 +154,7 @@ protected:
/**
* Client wants to connect to a Server.
*
* uint8 Game Coordinator protocol version.
* uint8_t Game Coordinator protocol version.
* string Invite code of the Server to join.
*
* @param p The packet that was just received.
@@ -177,9 +177,9 @@ protected:
/**
* Client or Server failed to connect to the remote side.
*
* uint8 Game Coordinator protocol version.
* uint8_t Game Coordinator protocol version.
* string Token to track the current connect request.
* uint8 Tracking number to track current connect request.
* uint8_t Tracking number to track current connect request.
*
* @param p The packet that was just received.
* @return True upon success, otherwise false.
@@ -202,7 +202,7 @@ protected:
* Client informs the Game Coordinator the connection with the Server is
* established. The Client will disconnect from the Game Coordinator next.
*
* uint8 Game Coordinator protocol version.
* uint8_t Game Coordinator protocol version.
* string Token to track the current connect request.
*
* @param p The packet that was just received.
@@ -214,10 +214,10 @@ protected:
* Game Coordinator requests that the Client makes a direct connection to
* the indicated peer, which is a Server.
*
* string Token to track the current connect request.
* uint8 Tracking number to track current connect request.
* string Hostname of the peer.
* uint16 Port of the peer.
* string Token to track the current connect request.
* uint8_t Tracking number to track current connect request.
* string Hostname of the peer.
* uint16_t Port of the peer.
*
* @param p The packet that was just received.
* @return True upon success, otherwise false.
@@ -242,10 +242,10 @@ protected:
/**
* Client/server informs the Game Coordinator the result of a STUN request.
*
* uint8 Game Coordinator protocol version.
* string Token to track the current connect request.
* uint8 Interface number, as given during STUN request.
* bool Whether the STUN connection was successful.
* uint8_t Game Coordinator protocol version.
* string Token to track the current connect request.
* uint8_t Interface number, as given during STUN request.
* bool Whether the STUN connection was successful.
*
* @param p The packet that was just received.
* @return True upon success, otherwise false.
@@ -257,11 +257,11 @@ protected:
* of the other side). It should start a connect() to this peer ASAP with
* the local address as used with the STUN request.
*
* string Token to track the current connect request.
* uint8 Tracking number to track current connect request.
* uint8 Interface number, as given during STUN request.
* string Host of the peer.
* uint16 Port of the peer.
* string Token to track the current connect request.
* uint8_t Tracking number to track current connect request.
* uint8_t Interface number, as given during STUN request.
* string Host of the peer.
* uint16_t Port of the peer.
*
* @param p The packet that was just received.
* @return True upon success, otherwise false.
@@ -273,12 +273,12 @@ protected:
* as used by the NewGRF deserialization in GC_LISTING.
* This packet is sent after a CLIENT_LISTING request, but before GC_LISTING.
*
* uint32 Lookup table cursor.
* uint16 Number of NewGRFs in the packet, with for each of the NewGRFs:
* uint32 Lookup table index for the NewGRF.
* uint32 Unique NewGRF ID.
* byte[16] MD5 checksum of the NewGRF
* string Name of the NewGRF.
* uint32_t Lookup table cursor.
* uint16_t Number of NewGRFs in the packet, with for each of the NewGRFs:
* uint32_t Lookup table index for the NewGRF.
* uint32_t Unique NewGRF ID.
* byte[16] MD5 checksum of the NewGRF
* string Name of the NewGRF.
*
* The lookup table built using these packets are used by the deserialisation
* of the NewGRFs for servers in the GC_LISTING. These updates are additive,
@@ -295,10 +295,10 @@ protected:
* Game Coordinator requests that we make a connection to the indicated
* peer, which is a TURN server.
*
* string Token to track the current connect request.
* uint8 Tracking number to track current connect request.
* string Ticket to hand over to the TURN server.
* string Connection string of the TURN server.
* string Token to track the current connect request.
* uint8_t Tracking number to track current connect request.
* string Ticket to hand over to the TURN server.
* string Connection string of the TURN server.
*
* @param p The packet that was just received.
* @return True upon success, otherwise false.

View File

@@ -191,15 +191,15 @@ protected:
* Try to join the server:
* string OpenTTD revision (norev000 if no revision).
* string Name of the client (max NETWORK_NAME_LENGTH).
* uint8 ID of the company to play as (1..MAX_COMPANIES).
* uint8 ID of the clients Language.
* uint8_t ID of the company to play as (1..MAX_COMPANIES).
* uint8_t ID of the clients Language.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p);
/**
* The client made an error:
* uint8 Error code caused (see NetworkErrorCode).
* uint8_t Error code caused (see NetworkErrorCode).
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p);
@@ -226,9 +226,9 @@ protected:
/**
* Send information about a client:
* uint32 ID of the client (always unique on a server. 1 = server, 0 is invalid).
* uint8 ID of the company the client is playing as (255 for spectators).
* string Name of the client.
* uint32_t ID of the client (always unique on a server. 1 = server, 0 is invalid).
* uint8_t ID of the company the client is playing as (255 for spectators).
* string Name of the client.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p);
@@ -241,32 +241,32 @@ protected:
/**
* Indication to the client that the server needs a company password:
* uint32 Generation seed.
* string Network ID of the server.
* uint32_t Generation seed.
* string Network ID of the server.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p);
/**
* Send a password to the server to authorize:
* uint8 Password type (see NetworkPasswordType).
* string The password.
* uint8_t Password type (see NetworkPasswordType).
* string The password.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p);
/**
* Send a password to the server to authorize
* uint8 Password type (see NetworkPasswordType).
* string The password.
* uint8_t Password type (see NetworkPasswordType).
* string The password.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet *p);
/**
* Send a password to the server to authorize
* uint8 Password type (see NetworkPasswordType).
* string The password.
* uint8_t Password type (see NetworkPasswordType).
* string The password.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_SETTINGS_PASSWORD(Packet *p);
@@ -280,37 +280,37 @@ protected:
/**
* The client is joined and ready to receive their map:
* uint32 Own client ID.
* uint32 Generation seed.
* string Network ID of the server.
* uint32_t Own client ID.
* uint32_t Generation seed.
* string Network ID of the server.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p);
/**
* Request the map from the server.
* uint32 NewGRF version (release versions of OpenTTD only).
* uint32_t NewGRF version (release versions of OpenTTD only).
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p);
/**
* Notification that another client is currently receiving the map:
* uint8 Number of clients waiting in front of you.
* uint8_t Number of clients waiting in front of you.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet *p);
/**
* Sends that the server will begin with sending the map to the client:
* uint32 Current frame.
* uint32_t Current frame.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p);
/**
* Sends the size of the map to the client.
* uint32 Size of the (compressed) map (in bytes).
* uint32_t Size of the (compressed) map (in bytes).
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p);
@@ -336,93 +336,93 @@ protected:
/**
* A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO:
* uint32 ID of the client that just joined the game.
* uint32_t ID of the client that just joined the game.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet *p);
/**
* Sends the current frame counter to the client:
* uint32 Frame counter
* uint32 Frame counter max (how far may the client walk before the server?)
* uint32 General seed 1 (dependent on compile settings, not default).
* uint32 General seed 2 (dependent on compile settings, not default).
* uint8 Random token to validate the client is actually listening (only occasionally present).
* uint32_t Frame counter
* uint32_t Frame counter max (how far may the client walk before the server?)
* uint32_t General seed 1 (dependent on compile settings, not default).
* uint32_t General seed 2 (dependent on compile settings, not default).
* uint8_t Random token to validate the client is actually listening (only occasionally present).
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet *p);
/**
* Sends a sync-check to the client:
* uint32 Frame counter.
* uint32 General seed 1.
* uint32 General seed 2 (dependent on compile settings, not default).
* uint32_t Frame counter.
* uint32_t General seed 1.
* uint32_t General seed 2 (dependent on compile settings, not default).
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet *p);
/**
* Tell the server we are done with this frame:
* uint32 Current frame counter of the client.
* uint8 The random token that the server sent in the PACKET_SERVER_FRAME packet.
* uint32_t Current frame counter of the client.
* uint8_t The random token that the server sent in the PACKET_SERVER_FRAME packet.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_ACK(Packet *p);
/**
* Send a DoCommand to the Server:
* uint8 ID of the company (0..MAX_COMPANIES-1).
* uint32 ID of the command (see command.h).
* uint32 P1 (free variables used in DoCommand).
* uint32 P2
* uint32 Tile where this is taking place.
* string Text.
* uint8 ID of the callback.
* uint8_t ID of the company (0..MAX_COMPANIES-1).
* uint32_t ID of the command (see command.h).
* uint32_t P1 (free variables used in DoCommand).
* uint32_t P2
* uint32_t Tile where this is taking place.
* string Text.
* uint8_t ID of the callback.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_COMMAND(Packet *p);
/**
* Sends a DoCommand to the client:
* uint8 ID of the company (0..MAX_COMPANIES-1).
* uint32 ID of the command (see command.h).
* uint32 P1 (free variable used in DoCommand).
* uint32 P2.
* uint32 Tile where this is taking place.
* string Text.
* uint8 ID of the callback.
* uint32 Frame of execution.
* uint8_t ID of the company (0..MAX_COMPANIES-1).
* uint32_t ID of the command (see command.h).
* uint32_t P1 (free variable used in DoCommand).
* uint32_t P2.
* uint32_t Tile where this is taking place.
* string Text.
* uint8_t ID of the callback.
* uint32_t Frame of execution.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p);
/**
* Sends a chat-packet to the server:
* uint8 ID of the action (see NetworkAction).
* uint8 ID of the destination type (see DestType).
* uint32 ID of the client or company (destination of the chat).
* string Message (max NETWORK_CHAT_LENGTH).
* uint64 data (used e.g. for 'give money' actions).
* uint8_t ID of the action (see NetworkAction).
* uint8_t ID of the destination type (see DestType).
* uint32_t ID of the client or company (destination of the chat).
* string Message (max NETWORK_CHAT_LENGTH).
* uint64_t data (used e.g. for 'give money' actions).
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p);
/**
* Sends a chat-packet to the client:
* uint8 ID of the action (see NetworkAction).
* uint32 ID of the client (origin of the chat).
* string Message (max NETWORK_CHAT_LENGTH).
* uint64 data (used e.g. for 'give money' actions).
* uint8_t ID of the action (see NetworkAction).
* uint32_t ID of the client (origin of the chat).
* string Message (max NETWORK_CHAT_LENGTH).
* uint64_t data (used e.g. for 'give money' actions).
* @param p The packet that was just received.
*/
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).
* string Name of the source this message came from.
* uint16_t 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);
@@ -449,7 +449,7 @@ protected:
/**
* The client made an error and is quitting the game.
* uint8 Error of the code caused (see NetworkErrorCode).
* uint8_t Error of the code caused (see NetworkErrorCode).
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p);
@@ -460,15 +460,15 @@ protected:
/**
* Notification that a client left the game:
* uint32 ID of the client.
* uint32_t ID of the client.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet *p);
/**
* Inform all clients that one client made an error and thus has quit/been disconnected:
* uint32 ID of the client that caused the error.
* uint8 Code of the error caused (see NetworkErrorCode).
* uint32_t ID of the client that caused the error.
* uint8_t Code of the error caused (see NetworkErrorCode).
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet *p);
@@ -487,7 +487,7 @@ protected:
/**
* Send the result of an issues RCon command back to the client:
* uint16 Colour code.
* uint16_t Colour code.
* string Output of the RCon command
* @param p The packet that was just received.
*/
@@ -503,9 +503,9 @@ protected:
/**
* Sends information about all used GRFs to the client:
* uint8 Amount of GRFs (the following data is repeated this many times, i.e. per GRF data).
* uint32 GRF ID
* 16 * uint8 MD5 checksum of the GRF
* uint8_t Amount of GRFs (the following data is repeated this many times, i.e. per GRF data).
* uint32_t GRF ID
* 16 * uint8_t MD5 checksum of the GRF
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet *p);
@@ -518,15 +518,15 @@ protected:
/**
* Move a client from one company into another:
* uint32 ID of the client.
* uint8 ID of the new company.
* uint32_t ID of the client.
* uint8_t ID of the new company.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet *p);
/**
* Request the server to move this client into another company:
* uint8 ID of the company the client wants to join.
* uint8_t ID of the company the client wants to join.
* string Password, if the company is password protected.
* @param p The packet that was just received.
*/
@@ -534,15 +534,15 @@ protected:
/**
* Update the clients knowledge of which company is password protected:
* uint16 Bitwise representation of each company
* uint16_t Bitwise representation of each company
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p);
/**
* Update the clients knowledge of the max settings:
* uint8 Maximum number of companies allowed.
* uint8 Maximum number of spectators allowed.
* uint8_t Maximum number of companies allowed.
* uint8_t Maximum number of spectators allowed.
* @param p The packet that was just received.
*/
virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p);
@@ -551,12 +551,12 @@ protected:
NetworkGameSocketHandler(SOCKET s);
public:
ClientID client_id; ///< Client identifier
uint32 last_frame; ///< Last frame we have executed
uint32 last_frame_server; ///< Last frame the server has executed
CommandQueue incoming_queue; ///< The command-queue awaiting handling
ClientID client_id; ///< Client identifier
uint32_t last_frame; ///< Last frame we have executed
uint32_t last_frame_server; ///< Last frame the server has executed
CommandQueue incoming_queue; ///< The command-queue awaiting handling
std::chrono::steady_clock::time_point last_packet; ///< Time we received the last frame.
PacketGameType last_pkt_type;///< Last received packet type
PacketGameType last_pkt_type; ///< Last received packet type
NetworkRecvStatus CloseConnection(bool error = true) override;

View File

@@ -140,7 +140,7 @@ public:
* @param port The port to listen on.
* @return true if listening succeeded.
*/
static bool Listen(uint16 port)
static bool Listen(uint16_t port)
{
assert(sockets.empty());

View File

@@ -31,9 +31,9 @@ protected:
* Send a STUN request to the STUN server letting the Game Coordinator know
* what our actually public IP:port is.
*
* uint8 Game Coordinator protocol version.
* uint8_t Game Coordinator protocol version.
* string Token to track the current STUN request.
* uint8 Which interface number this is (for example, IPv4 or IPv6).
* uint8_t Which interface number this is (for example, IPv4 or IPv6).
* The Game Coordinator relays this number back in later packets.
*
* @param p The packet that was just received.

View File

@@ -44,7 +44,7 @@ protected:
* Client or servers wants to connect to the TURN server (on request by
* the Game Coordinator).
*
* uint8 Game Coordinator protocol version.
* uint8_t Game Coordinator protocol version.
* string Token to track the current TURN request.
*
* @param p The packet that was just received.

View File

@@ -35,7 +35,7 @@ NetworkUDPSocketHandler::NetworkUDPSocketHandler(NetworkAddressList *bind)
this->bind.emplace_back("", 0, AF_INET6);
}
this->fragment_token = ((uint64) InteractiveRandom()) | (((uint64) InteractiveRandom()) << 32);
this->fragment_token = ((uint64_t) InteractiveRandom()) | (((uint64_t) InteractiveRandom()) << 32);
}
@@ -82,21 +82,21 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a
if (p->Size() > MTU) {
p->PrepareToSend();
uint64 token = this->fragment_token++;
uint64_t token = this->fragment_token++;
const uint PAYLOAD_MTU = MTU - (1 + 2 + 8 + 1 + 1 + 2);
const size_t packet_size = p->Size();
const uint8 frag_count = (uint8)((packet_size + PAYLOAD_MTU - 1) / PAYLOAD_MTU);
const uint8_t frag_count = (uint8_t)((packet_size + PAYLOAD_MTU - 1) / PAYLOAD_MTU);
Packet frag(PACKET_UDP_EX_MULTI);
uint8 current_frag = 0;
uint8_t current_frag = 0;
size_t offset = 0;
while (offset < packet_size) {
uint16 payload_size = (uint16)std::min<size_t>(PAYLOAD_MTU, packet_size - offset);
uint16_t payload_size = (uint16_t)std::min<size_t>(PAYLOAD_MTU, packet_size - offset);
frag.Send_uint64(token);
frag.Send_uint8 (current_frag);
frag.Send_uint8 (frag_count);
frag.Send_uint16 (payload_size);
frag.Send_uint8(current_frag);
frag.Send_uint8(frag_count);
frag.Send_uint16(payload_size);
frag.Send_binary(p->GetBufferData() + offset, payload_size);
current_frag++;
offset += payload_size;
@@ -210,10 +210,10 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, NetworkAddress *client_
void NetworkUDPSocketHandler::Receive_EX_MULTI(Packet *p, NetworkAddress *client_addr)
{
uint64 token = p->Recv_uint64();
uint8 index = p->Recv_uint8 ();
uint8 total = p->Recv_uint8 ();
uint16 payload_size = p->Recv_uint16();
uint64_t token = p->Recv_uint64();
uint8_t index = p->Recv_uint8 ();
uint8_t total = p->Recv_uint8 ();
uint16_t payload_size = p->Recv_uint16();
DEBUG(net, 6, "[udp] received multi-part packet from %s: " OTTD_PRINTFHEX64 ", %u/%u, %u bytes",
NetworkAddressDumper().GetAddressAsString(client_addr), token, index, total, payload_size);

View File

@@ -37,10 +37,10 @@ protected:
/** The opened sockets. */
SocketList sockets;
uint64 fragment_token;
uint64_t fragment_token;
struct FragmentSet {
uint64 token;
uint64_t token;
NetworkAddress address;
time_t create_time;
std::vector<std::string> fragments;

View File

@@ -63,36 +63,36 @@ static_assert(NetworkClientInfoPool::MAX_SIZE == NetworkClientSocketPool::MAX_SI
NetworkClientInfoPool _networkclientinfo_pool("NetworkClientInfo");
INSTANTIATE_POOL_METHODS(NetworkClientInfo)
bool _networking; ///< are we in networking mode?
bool _network_server; ///< network-server is active
bool _network_available; ///< is network mode available?
bool _network_dedicated; ///< are we a dedicated server?
bool _is_network_server; ///< Does this client wants to be a network-server?
bool _network_settings_access; ///< Can this client change server settings?
bool _networking; ///< are we in networking mode?
bool _network_server; ///< network-server is active
bool _network_available; ///< is network mode available?
bool _network_dedicated; ///< are we a dedicated server?
bool _is_network_server; ///< Does this client wants to be a network-server?
bool _network_settings_access; ///< Can this client change server settings?
NetworkCompanyState *_network_company_states = nullptr; ///< Statistics about some companies.
std::string _network_company_server_id; ///< Server ID string used for company passwords
uint8 _network_company_password_storage_token[16]; ///< Non-secret token for storage of company passwords in savegames
uint8 _network_company_password_storage_key[32]; ///< Key for storage of company passwords in savegames
ClientID _network_own_client_id; ///< Our client identifier.
ClientID _redirect_console_to_client; ///< If not invalid, redirect the console output to a client.
uint8 _network_reconnect; ///< Reconnect timeout
StringList _network_bind_list; ///< The addresses to bind on.
StringList _network_host_list; ///< The servers we know.
StringList _network_ban_list; ///< The banned clients.
uint32 _frame_counter_server; ///< The frame_counter of the server, if in network-mode
uint32 _frame_counter_max; ///< To where we may go with our clients
uint32 _frame_counter; ///< The current frame.
uint32 _last_sync_frame; ///< Used in the server to store the last time a sync packet was sent to clients.
NetworkAddressList _broadcast_list; ///< List of broadcast addresses.
uint32 _sync_seed_1; ///< Seed to compare during sync checks.
uint64 _sync_state_checksum; ///< State checksum to compare during sync checks.
uint32 _sync_frame; ///< The frame to perform the sync check.
Date _last_sync_date; ///< The game date of the last successfully received sync frame
DateFract _last_sync_date_fract; ///< "
uint8 _last_sync_tick_skip_counter; ///< "
uint32 _last_sync_frame_counter; ///< "
bool _network_first_time; ///< Whether we have finished joining or not.
CompanyMask _network_company_passworded; ///< Bitmask of the password status of all companies.
std::string _network_company_server_id; ///< Server ID string used for company passwords
uint8_t _network_company_password_storage_token[16]; ///< Non-secret token for storage of company passwords in savegames
uint8_t _network_company_password_storage_key[32]; ///< Key for storage of company passwords in savegames
ClientID _network_own_client_id; ///< Our client identifier.
ClientID _redirect_console_to_client; ///< If not invalid, redirect the console output to a client.
uint8_t _network_reconnect; ///< Reconnect timeout
StringList _network_bind_list; ///< The addresses to bind on.
StringList _network_host_list; ///< The servers we know.
StringList _network_ban_list; ///< The banned clients.
uint32_t _frame_counter_server; ///< The frame_counter of the server, if in network-mode
uint32_t _frame_counter_max; ///< To where we may go with our clients
uint32_t _frame_counter; ///< The current frame.
uint32_t _last_sync_frame; ///< Used in the server to store the last time a sync packet was sent to clients.
NetworkAddressList _broadcast_list; ///< List of broadcast addresses.
uint32_t _sync_seed_1; ///< Seed to compare during sync checks.
uint64_t _sync_state_checksum; ///< State checksum to compare during sync checks.
uint32_t _sync_frame; ///< The frame to perform the sync check.
Date _last_sync_date; ///< The game date of the last successfully received sync frame
DateFract _last_sync_date_fract; ///< "
uint8_t _last_sync_tick_skip_counter; ///< "
uint32_t _last_sync_frame_counter; ///< "
bool _network_first_time; ///< Whether we have finished joining or not.
CompanyMask _network_company_passworded; ///< Bitmask of the password status of all companies.
ring_buffer<NetworkSyncRecord> _network_sync_records;
ring_buffer<uint> _network_sync_record_counts;
@@ -195,7 +195,7 @@ std::string NetworkChangeCompanyPassword(CompanyID company_id, std::string passw
* @param password_game_seed Game seed.
* @return The hashed password.
*/
std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32 password_game_seed)
std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32_t password_game_seed)
{
if (password.empty()) return password;
@@ -229,7 +229,7 @@ std::string GenerateCompanyPasswordHash(const std::string &password, const std::
* @param password_game_seed Game seed.
* @return The hashed password.
*/
std::vector<uint8> GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64 password_game_seed)
std::vector<uint8_t> GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64_t password_game_seed)
{
if (password.empty()) return {};
@@ -532,7 +532,7 @@ std::string_view ParseCompanyFromConnectionString(const std::string &connection_
std::string_view company_string = ip.substr(offset + 1);
ip = ip.substr(0, offset);
uint8 company_value;
uint8_t company_value;
bool success = IntFromChars(company_string.data(), company_string.data() + company_string.size(), company_value);
if (success) {
if (company_value != COMPANY_NEW_COMPANY && company_value != COMPANY_SPECTATOR) {
@@ -566,7 +566,7 @@ std::string_view ParseCompanyFromConnectionString(const std::string &connection_
* @param company_id The company ID to set, if available.
* @return A std::string_view into the connection string with the (IP) address part.
*/
std::string_view ParseFullConnectionString(const std::string &connection_string, uint16 &port, CompanyID *company_id)
std::string_view ParseFullConnectionString(const std::string &connection_string, uint16_t &port, CompanyID *company_id)
{
std::string_view ip = ParseCompanyFromConnectionString(connection_string, company_id);
@@ -586,9 +586,9 @@ std::string_view ParseFullConnectionString(const std::string &connection_string,
* @param default_port The port to use if none is given.
* @return The normalized connection string.
*/
std::string NormalizeConnectionString(const std::string &connection_string, uint16 default_port)
std::string NormalizeConnectionString(const std::string &connection_string, uint16_t default_port)
{
uint16 port = default_port;
uint16_t port = default_port;
std::string_view ip = ParseFullConnectionString(connection_string, port);
return std::string(ip) + ":" + std::to_string(port);
}
@@ -601,9 +601,9 @@ std::string NormalizeConnectionString(const std::string &connection_string, uint
* @param default_port The default port to set port to if not in connection_string.
* @return A valid NetworkAddress of the parsed information.
*/
NetworkAddress ParseConnectionString(const std::string &connection_string, uint16 default_port)
NetworkAddress ParseConnectionString(const std::string &connection_string, uint16_t default_port)
{
uint16 port = default_port;
uint16_t port = default_port;
std::string_view ip = ParseFullConnectionString(connection_string, port);
return NetworkAddress(ip, port);
}
@@ -772,7 +772,7 @@ NetworkGameList *NetworkAddServer(const std::string &connection_string, bool man
* @param addresses the list to write to.
* @param port the port to bind to.
*/
void GetBindAddresses(NetworkAddressList *addresses, uint16 port)
void GetBindAddresses(NetworkAddressList *addresses, uint16_t port)
{
for (const auto &iter : _network_bind_list) {
addresses->emplace_back(iter.c_str(), port);
@@ -1177,7 +1177,7 @@ void NetworkGameLoop()
static uint next_tick_skip_counter;
static std::unique_ptr<CommandPacket> cp;
static bool check_sync_state = false;
static uint32 sync_state[2];
static uint32_t sync_state[2];
if (f == nullptr && next_date == 0) {
DEBUG(desync, 0, "Cannot open commands.log");
next_date = 1;
@@ -1370,7 +1370,7 @@ static void NetworkGenerateServerId()
std::string NetworkGenerateRandomKeyString(uint bytes)
{
uint8 *key = AllocaM(uint8, bytes);
uint8_t *key = AllocaM(uint8_t, bytes);
NetworkRandomBytesWithFallback(key, bytes);
return FormatArrayAsHex({key, bytes});

View File

@@ -104,7 +104,7 @@ ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler()
{
for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::Iterate()) {
if (as->status == ADMIN_STATUS_INACTIVE && std::chrono::steady_clock::now() > as->connect_time + ADMIN_AUTHORISATION_TIMEOUT) {
DEBUG(net, 2, "[admin] Admin did not send its authorisation within %d seconds", (uint32)std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
DEBUG(net, 2, "[admin] Admin did not send its authorisation within %d seconds", (uint32_t)std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
as->CloseConnection(true);
continue;
}
@@ -394,13 +394,13 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyEconomy()
p->Send_uint64(company->money);
p->Send_uint64(company->current_loan);
p->Send_uint64(income);
p->Send_uint16(static_cast<uint16>(std::min<uint64>(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum<OverflowSafeInt64>())));
p->Send_uint16(static_cast<uint16_t>(std::min<uint64_t>(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum<OverflowSafeInt64>())));
/* Send stats for the last 2 quarters. */
for (uint i = 0; i < 2; i++) {
p->Send_uint64(company->old_economy[i].company_value);
p->Send_uint16(company->old_economy[i].performance_history);
p->Send_uint16(static_cast<uint16>(std::min<uint64>(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum<OverflowSafeInt64>())));
p->Send_uint16(static_cast<uint16_t>(std::min<uint64_t>(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum<OverflowSafeInt64>())));
}
this->SendPacket(p);
@@ -479,7 +479,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRconEnd(const std::string
* @param colour The colour of the text.
* @param result The result of the command.
*/
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16 colour, const std::string_view result)
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16_t colour, const std::string_view result)
{
Packet *p = new Packet(ADMIN_PACKET_SERVER_RCON);
@@ -520,7 +520,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_PING(Packet *p)
{
if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
uint32 d1 = p->Recv_uint32();
uint32_t d1 = p->Recv_uint32();
DEBUG(net, 6, "[admin] Ping from '%s' (%s): %d", this->admin_name.c_str(), this->admin_version.c_str(), d1);
@@ -564,7 +564,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(const std::str
}
/** Send ping-reply (pong) to admin **/
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendPong(uint32 d1)
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendPong(uint32_t d1)
{
Packet *p = new Packet(ADMIN_PACKET_SERVER_PONG);
@@ -583,7 +583,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames()
const char *cmdname = GetCommandName(i);
/* Should COMPAT_MTU be exceeded, start a new packet
* (magic 5: 1 bool "more data" and one uint16 "command id", one
* (magic 5: 1 bool "more data" and one uint16_t "command id", one
* byte for string '\0' termination and 1 bool "no more data" */
if (!p->CanWriteToPacket(strlen(cmdname) + 5)) {
p->Send_bool(false);
@@ -617,7 +617,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdLogging(ClientID clien
p->Send_uint8 (cp->company);
p->Send_uint16(cp->cmd & CMD_ID_MASK);
p->Send_uint16(4 + 4 + 8 + 4 + (uint16)cp->text.size() + 1);
p->Send_uint16(4 + 4 + 8 + 4 + (uint16_t)cp->text.size() + 1);
{
p->Send_uint32(cp->p1);
p->Send_uint32(cp->p2);
@@ -695,7 +695,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p)
if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
AdminUpdateType type = (AdminUpdateType)p->Recv_uint8();
uint32 d1 = p->Recv_uint32();
uint32_t d1 = p->Recv_uint32();
switch (type) {
case ADMIN_UPDATE_DATE:
@@ -793,7 +793,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(P
if (!IsValidConsoleColour(colour)) {
DEBUG(net, 1, "[admin] Not supported chat colour %d (%s, %s, %s) from '%s' (%s).",
(uint16)colour, source.c_str(), user.c_str(), msg.c_str(), this->admin_name.c_str(), this->admin_version.c_str());
(uint16_t)colour, source.c_str(), user.c_str(), msg.c_str(), this->admin_name.c_str(), this->admin_version.c_str());
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
}

View File

@@ -35,7 +35,7 @@ protected:
NetworkRecvStatus Receive_ADMIN_PING(Packet *p) override;
NetworkRecvStatus SendProtocol();
NetworkRecvStatus SendPong(uint32 d1);
NetworkRecvStatus SendPong(uint32_t d1);
public:
AdminUpdateFrequency update_frequency[ADMIN_UPDATE_END]; ///< Admin requested update intervals.
std::chrono::steady_clock::time_point connect_time; ///< Time of connection.
@@ -63,7 +63,7 @@ public:
NetworkRecvStatus SendCompanyStats();
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, NetworkTextMessageData data);
NetworkRecvStatus SendRcon(uint16 colour, const std::string_view command);
NetworkRecvStatus SendRcon(uint16_t colour, const std::string_view command);
NetworkRecvStatus SendConsole(const std::string_view origin, const std::string_view command);
NetworkRecvStatus SendGameScript(const std::string_view json);
NetworkRecvStatus SendCmdNames();

View File

@@ -27,8 +27,8 @@ struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_p
CompanyID client_playas; ///< As which company is this client playing (CompanyID)
Date join_date; ///< Gamedate the client has joined
DateFract join_date_fract;
uint8 join_tick_skip_counter;
uint32 join_frame;
uint8_t join_tick_skip_counter;
uint32_t join_frame;
/**
* Create a new client.

View File

@@ -442,7 +442,7 @@ struct NetworkChatWindow : public Window {
}
}
Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
{
Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height };
return pt;
@@ -470,7 +470,7 @@ struct NetworkChatWindow : public Window {
}
}
EventState OnKeyPress(WChar key, uint16 keycode) override
EventState OnKeyPress(char32_t key, uint16_t keycode) override
{
EventState state = ES_NOT_HANDLED;
if (keycode == WKC_TAB) {

View File

@@ -389,21 +389,21 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
ClientNetworkGameSocketHandler * ClientNetworkGameSocketHandler::my_client = nullptr;
/** Last frame we performed an ack. */
static uint32 last_ack_frame;
static uint32_t last_ack_frame;
/** One bit of 'entropy' used to generate a salt for the company passwords. */
static uint32 _company_password_game_seed;
static uint32_t _company_password_game_seed;
/** Network server's x25519 public key, used for key derivation */
static byte _server_x25519_pub_key[32];
/** Key message ID counter */
static uint64 _next_key_message_id;
static uint64_t _next_key_message_id;
/** The other bit of 'entropy' used to generate a salt for the server, rcon, and settings passwords. */
static std::string _password_server_id;
/** The other bit of 'entropy' used to generate a salt for the company passwords. */
static std::string _company_password_server_id;
/** Maximum number of companies of the currently joined server. */
static uint8 _network_server_max_companies;
static uint8_t _network_server_max_companies;
/** The current name of the server you are on. */
std::string _network_server_name;
@@ -446,10 +446,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendKeyPasswordPacket(PacketTy
if (payload != nullptr) buffer.Send_string(*payload);
/* Message authentication code */
uint8 mac[16];
uint8_t mac[16];
/* Use only once per key: random */
uint8 nonce[24];
uint8_t nonce[24];
NetworkRandomBytesWithFallback(nonce, 24);
/* Encrypt in place, use first half of hash as key */
@@ -619,7 +619,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendDesyncLog(const std::strin
for (size_t offset = 0; offset < log.size();) {
Packet *p = new Packet(PACKET_CLIENT_DESYNC_LOG, SHRT_MAX);
size_t size = std::min<size_t>(log.size() - offset, SHRT_MAX - 2 - p->Size());
p->Send_uint16((uint16)size);
p->Send_uint16((uint16_t)size);
p->Send_binary((const byte *)(log.data() + offset), size);
my_client->SendPacket(p);
@@ -646,7 +646,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendDesyncSyncData()
if (_network_sync_record_counts.empty()) return NETWORK_RECV_STATUS_OKAY;
uint total = 0;
for (uint32 count : _network_sync_record_counts) {
for (uint32_t count : _network_sync_record_counts) {
total += count;
}
@@ -656,9 +656,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendDesyncSyncData()
}
Packet *p = new Packet(PACKET_CLIENT_DESYNC_SYNC_DATA, SHRT_MAX);
p->Send_uint32((uint32)_network_sync_record_counts.size());
uint32 offset = 0;
for (uint32 count : _network_sync_record_counts) {
p->Send_uint32((uint32_t)_network_sync_record_counts.size());
uint32_t offset = 0;
for (uint32_t count : _network_sync_record_counts) {
p->Send_uint32(count);
for (uint i = 0; i < count; i++) {
const NetworkSyncRecord &record = _network_sync_records[offset + i];
@@ -1012,7 +1012,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DATA(Packet
/* We are still receiving data, put it to the file */
this->savegame->AddPacket(p);
_network_join_bytes = (uint32)this->savegame->written_bytes;
_network_join_bytes = (uint32_t)this->savegame->written_bytes;
SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
return NETWORK_RECV_STATUS_OKAY;
@@ -1099,7 +1099,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FRAME(Packet *p
}
#endif
/* Receive the token. */
if (p->CanReadFromPacket(sizeof(uint8))) this->token = p->Recv_uint8();
if (p->CanReadFromPacket(sizeof(uint8_t))) this->token = p->Recv_uint8();
DEBUG(net, 7, "Received FRAME %d", _frame_counter_server);
@@ -1381,7 +1381,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE(
{
if (this->status < STATUS_ACTIVE) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
static_assert(sizeof(_network_company_passworded) <= sizeof(uint16));
static_assert(sizeof(_network_company_passworded) <= sizeof(uint16_t));
_network_company_passworded = p->Recv_uint16();
SetWindowClassesDirty(WC_COMPANY);

View File

@@ -147,7 +147,7 @@ static CommandQueue _local_execution_queue;
* @param company The company that wants to send the command
* @param aux_data Auxiliary command data
*/
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company, const CommandAuxiliaryBase *aux_data)
void NetworkSendCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd, CommandCallback *callback, const char *text, CompanyID company, const CommandAuxiliaryBase *aux_data)
{
assert((cmd & CMD_FLAGS_MASK) == 0);
@@ -344,7 +344,7 @@ const char *NetworkGameSocketHandler::ReceiveCommand(Packet *p, CommandPacket *c
cp->callback = _callback_table[callback];
uint16 aux_data_size = p->Recv_uint16();
uint16_t aux_data_size = p->Recv_uint16();
if (aux_data_size > 0 && p->CanReadFromPacket(aux_data_size, true)) {
CommandAuxiliarySerialised *aux_data = new CommandAuxiliarySerialised();
cp->aux_data.reset(aux_data);
@@ -386,6 +386,6 @@ void NetworkGameSocketHandler::SendCommand(Packet *p, const CommandPacket *cp)
if (cp->aux_data != nullptr) {
CommandSerialisationBuffer serialiser(p->GetSerialisationBuffer(), p->GetSerialisationLimit());
cp->aux_data->Serialise(serialiser);
p->WriteAtOffset_uint16(aux_data_size_pos, (uint16)(p->Size() - aux_data_size_pos - 2));
p->WriteAtOffset_uint16(aux_data_size_pos, (uint16_t)(p->Size() - aux_data_size_pos - 2));
}
}

View File

@@ -235,9 +235,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(uint count, const Con
while (count > 0) {
/* We can "only" send a limited number of IDs in a single packet.
* A packet begins with the packet size and a byte for the type.
* Then this packet adds a uint16 for the count in this packet.
* Then this packet adds a uint16_t for the count in this packet.
* The rest of the packet can be used for the IDs. */
uint p_count = std::min<uint>(count, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16)) / sizeof(uint32));
uint p_count = std::min<uint>(count, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16_t)) / sizeof(uint32_t));
Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_ID, TCP_MTU);
p->Send_uint16(p_count);
@@ -263,15 +263,15 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
this->Connect();
const uint max_per_packet = std::min<uint>(255, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? MD5_HASH_BYTES : 0))) - 1;
const uint max_per_packet = std::min<uint>(255, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8_t)) /
(sizeof(uint8_t) + sizeof(uint32_t) + (send_md5sum ? MD5_HASH_BYTES : 0))) - 1;
uint offset = 0;
while (cv->size() > offset) {
Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID, TCP_MTU);
const uint to_send = std::min<uint>(static_cast<uint>(cv->size() - offset), max_per_packet);
p->Send_uint8(static_cast<uint8>(to_send));
p->Send_uint8(static_cast<uint8_t>(to_send));
for (uint i = 0; i < to_send; i++) {
const ContentInfo *ci = (*cv)[offset + i];
@@ -367,9 +367,9 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const Co
while (count > 0) {
/* We can "only" send a limited number of IDs in a single packet.
* A packet begins with the packet size and a byte for the type.
* Then this packet adds a uint16 for the count in this packet.
* Then this packet adds a uint16_t for the count in this packet.
* The rest of the packet can be used for the IDs. */
uint p_count = std::min<uint>(count, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16)) / sizeof(uint32));
uint p_count = std::min<uint>(count, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16_t)) / sizeof(uint32_t));
Packet *p = new Packet(PACKET_CONTENT_CLIENT_CONTENT, TCP_MTU);
p->Send_uint16(p_count);

View File

@@ -138,7 +138,7 @@ public:
/** Get the begin of the content inf iterator. */
ConstContentIterator Begin() const { return this->infos.data(); }
/** Get the nth position of the content inf iterator. */
ConstContentIterator Get(uint32 index) const { return this->infos.data() + index; }
ConstContentIterator Get(uint32_t index) const { return this->infos.data() + index; }
/** Get the end of the content inf iterator. */
ConstContentIterator End() const { return this->Begin() + this->Length(); }

View File

@@ -141,7 +141,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID
/* Draw the % complete with a bar and a text */
DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
DrawFrameRect(ir.WithWidth((uint64)ir.Width() * this->downloaded_bytes / this->total_bytes, false), COLOUR_MAUVE, FR_NONE);
DrawFrameRect(ir.WithWidth((uint64_t)ir.Width() * this->downloaded_bytes / this->total_bytes, false), COLOUR_MAUVE, FR_NONE);
SetDParam(0, this->downloaded_bytes);
SetDParam(1, this->total_bytes);
SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes);
@@ -877,7 +877,7 @@ public:
}
}
EventState OnKeyPress(WChar key, uint16 keycode) override
EventState OnKeyPress(char32_t key, uint16_t keycode) override
{
if (this->vscroll->UpdateListPositionOnKeyPress(this->list_pos, keycode) == ES_NOT_HANDLED) {
switch (keycode) {

View File

@@ -22,8 +22,8 @@ protected:
uint total_files; ///< Number of files to download
uint downloaded_files; ///< Number of files downloaded
uint32 cur_id; ///< The current ID of the downloaded file
std::string name; ///< The current name of the downloaded file
uint32_t cur_id; ///< The current ID of the downloaded file
std::string name; ///< The current name of the downloaded file
public:
/**

View File

@@ -34,8 +34,8 @@ std::string _network_server_invite_code = ""; ///< Our invite code as indicated
/** Connect to a game server by IP:port. */
class NetworkDirectConnecter : public TCPConnecter {
private:
std::string token; ///< Token of this connection.
uint8 tracking_number; ///< Tracking number of this connection.
std::string token; ///< Token of this connection.
uint8_t tracking_number; ///< Tracking number of this connection.
public:
/**
@@ -45,7 +45,7 @@ public:
* @param token The token as given by the Game Coordinator to track this connection attempt.
* @param tracking_number The tracking number as given by the Game Coordinator to track this connection attempt.
*/
NetworkDirectConnecter(const std::string &hostname, uint16 port, const std::string &token, uint8 tracking_number) : TCPConnecter(hostname, port), token(token), tracking_number(tracking_number) {}
NetworkDirectConnecter(const std::string &hostname, uint16_t port, const std::string &token, uint8_t tracking_number) : TCPConnecter(hostname, port), token(token), tracking_number(tracking_number) {}
void OnFailure() override
{
@@ -62,9 +62,9 @@ public:
/** Connecter used after STUN exchange to connect from both sides to each other. */
class NetworkReuseStunConnecter : public TCPConnecter {
private:
std::string token; ///< Token of this connection.
uint8 tracking_number; ///< Tracking number of this connection.
uint8 family; ///< Family of this connection.
std::string token; ///< Token of this connection.
uint8_t tracking_number; ///< Tracking number of this connection.
uint8_t family; ///< Family of this connection.
public:
/**
@@ -76,7 +76,7 @@ public:
* @param tracking_number The tracking number of the connection.
* @param family The family this connection is using.
*/
NetworkReuseStunConnecter(const std::string &hostname, uint16 port, const NetworkAddress &bind_address, std::string token, uint8 tracking_number, uint8 family) :
NetworkReuseStunConnecter(const std::string &hostname, uint16_t port, const NetworkAddress &bind_address, std::string token, uint8_t tracking_number, uint8_t family) :
TCPConnecter(hostname, port, bind_address),
token(token),
tracking_number(tracking_number),
@@ -232,7 +232,7 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_REGISTER_ACK(Packet *p)
bool ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING(Packet *p)
{
uint8 servers = p->Recv_uint16();
uint8_t servers = p->Recv_uint16();
/* End of list; we can now remove all expired items from the list. */
if (servers == 0) {
@@ -296,9 +296,9 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_CONNECT_FAILED(Packet *p)
bool ClientNetworkCoordinatorSocketHandler::Receive_GC_DIRECT_CONNECT(Packet *p)
{
std::string token = p->Recv_string(NETWORK_TOKEN_LENGTH);
uint8 tracking_number = p->Recv_uint8();
uint8_t tracking_number = p->Recv_uint8();
std::string hostname = p->Recv_string(NETWORK_HOSTNAME_LENGTH);
uint16 port = p->Recv_uint16();
uint16_t port = p->Recv_uint16();
/* Ensure all other pending connection attempts are killed. */
if (this->game_connecter != nullptr) {
@@ -322,10 +322,10 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_STUN_REQUEST(Packet *p)
bool ClientNetworkCoordinatorSocketHandler::Receive_GC_STUN_CONNECT(Packet *p)
{
std::string token = p->Recv_string(NETWORK_TOKEN_LENGTH);
uint8 tracking_number = p->Recv_uint8();
uint8 family = p->Recv_uint8();
uint8_t tracking_number = p->Recv_uint8();
uint8_t family = p->Recv_uint8();
std::string host = p->Recv_string(NETWORK_HOSTNAME_PORT_LENGTH);
uint16 port = p->Recv_uint16();
uint16_t port = p->Recv_uint16();
/* Check if we know this token. */
auto stun_it = this->stun_handlers.find(token);
@@ -357,9 +357,9 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_NEWGRF_LOOKUP(Packet *p)
{
this->newgrf_lookup_table_cursor = p->Recv_uint32();
uint16 newgrfs = p->Recv_uint16();
uint16_t newgrfs = p->Recv_uint16();
for (; newgrfs> 0; newgrfs--) {
uint32 index = p->Recv_uint32();
uint32_t index = p->Recv_uint32();
DeserializeGRFIdentifierWithName(p, &this->newgrf_lookup_table[index]);
}
return true;
@@ -368,7 +368,7 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_NEWGRF_LOOKUP(Packet *p)
bool ClientNetworkCoordinatorSocketHandler::Receive_GC_TURN_CONNECT(Packet *p)
{
std::string token = p->Recv_string(NETWORK_TOKEN_LENGTH);
uint8 tracking_number = p->Recv_uint8();
uint8_t tracking_number = p->Recv_uint8();
std::string ticket = p->Recv_string(NETWORK_TOKEN_LENGTH);
std::string connection_string = p->Recv_string(NETWORK_HOSTNAME_PORT_LENGTH);
@@ -542,7 +542,7 @@ void ClientNetworkCoordinatorSocketHandler::ConnectToServer(const std::string &i
* @param token Token of the connecter that failed.
* @param tracking_number Tracking number of the connecter that failed.
*/
void ClientNetworkCoordinatorSocketHandler::ConnectFailure(const std::string &token, uint8 tracking_number)
void ClientNetworkCoordinatorSocketHandler::ConnectFailure(const std::string &token, uint8_t tracking_number)
{
/* Connecter will destroy itself. */
this->game_connecter = nullptr;
@@ -604,7 +604,7 @@ void ClientNetworkCoordinatorSocketHandler::ConnectSuccess(const std::string &to
* This helps the Game Coordinator not to wait for a timeout on its end, but
* rather react as soon as the client/server knows the result.
*/
void ClientNetworkCoordinatorSocketHandler::StunResult(const std::string &token, uint8 family, bool result)
void ClientNetworkCoordinatorSocketHandler::StunResult(const std::string &token, uint8_t family, bool result)
{
Packet *p = new Packet(PACKET_COORDINATOR_SERCLI_STUN_RESULT);
p->Send_uint8(NETWORK_COORDINATOR_VERSION);
@@ -619,7 +619,7 @@ void ClientNetworkCoordinatorSocketHandler::StunResult(const std::string &token,
* @param token The token used for the STUN handlers.
* @param family The family of STUN handlers to close. AF_UNSPEC to close all STUN handlers for this token.
*/
void ClientNetworkCoordinatorSocketHandler::CloseStunHandler(const std::string &token, uint8 family)
void ClientNetworkCoordinatorSocketHandler::CloseStunHandler(const std::string &token, uint8_t family)
{
auto stun_it = this->stun_handlers.find(token);
if (stun_it == this->stun_handlers.end()) return;

View File

@@ -60,7 +60,7 @@ private:
std::map<std::string, std::unique_ptr<ClientNetworkTurnSocketHandler>> turn_handlers; ///< Pending TURN handler (if any), stored by token.
TCPConnecter *game_connecter = nullptr; ///< Pending connecter to the game server.
uint32 newgrf_lookup_table_cursor = 0; ///< Last received cursor for the #GameInfoNewGRFLookupTable updates.
uint32_t newgrf_lookup_table_cursor = 0; ///< Last received cursor for the #GameInfoNewGRFLookupTable updates.
GameInfoNewGRFLookupTable newgrf_lookup_table; ///< Table to look up NewGRFs in the GC_LISTING packets.
protected:
@@ -87,14 +87,14 @@ public:
NetworkRecvStatus CloseConnection(bool error = true) override;
void SendReceive();
void ConnectFailure(const std::string &token, uint8 tracking_number);
void ConnectFailure(const std::string &token, uint8_t tracking_number);
void ConnectSuccess(const std::string &token, SOCKET sock, NetworkAddress &address);
void StunResult(const std::string &token, uint8 family, bool result);
void StunResult(const std::string &token, uint8_t family, bool result);
void Connect();
void CloseToken(const std::string &token);
void CloseAllConnections();
void CloseStunHandler(const std::string &token, uint8 family = AF_UNSPEC);
void CloseStunHandler(const std::string &token, uint8_t family = AF_UNSPEC);
void CloseTurnHandler(const std::string &token);
void Register();

View File

@@ -26,12 +26,12 @@
extern NetworkCompanyState *_network_company_states;
extern std::string _network_company_server_id;
extern uint8 _network_company_password_storage_token[16];
extern uint8 _network_company_password_storage_key[32];
extern uint8_t _network_company_password_storage_token[16];
extern uint8_t _network_company_password_storage_key[32];
extern ClientID _network_own_client_id;
extern ClientID _redirect_console_to_client;
extern uint8 _network_reconnect;
extern uint8_t _network_reconnect;
extern StringList _network_bind_list;
extern StringList _network_host_list;
extern StringList _network_ban_list;
@@ -50,7 +50,7 @@ void NetworkReboot();
void NetworkDisconnect(bool close_admins = true);
void NetworkGameLoop();
void NetworkBackgroundLoop();
std::string_view ParseFullConnectionString(const std::string &connection_string, uint16 &port, CompanyID *company_id = nullptr);
std::string_view ParseFullConnectionString(const std::string &connection_string, uint16_t &port, CompanyID *company_id = nullptr);
void NetworkStartDebugLog(const std::string &connection_string);
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);

View File

@@ -531,7 +531,7 @@ public:
{
switch (widget) {
case WID_NG_MATRIX: {
uint16 y = r.top;
uint16_t y = r.top;
const int max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size());
@@ -789,7 +789,7 @@ public:
this->SetDirty();
}
EventState OnKeyPress(WChar key, uint16 keycode) override
EventState OnKeyPress(char32_t key, uint16_t keycode) override
{
EventState state = ES_NOT_HANDLED;
@@ -1146,7 +1146,7 @@ struct NetworkStartServerWindow : public Window {
if (this->widget_id == WID_NSS_SETPWD) {
_settings_client.network.server_password = str;
} else {
int32 value = atoi(str);
int32_t value = atoi(str);
this->SetWidgetDirty(this->widget_id);
switch (this->widget_id) {
default: NOT_REACHED();
@@ -2090,9 +2090,9 @@ void ShowClientList()
}
NetworkJoinStatus _network_join_status; ///< The status of joining.
uint8 _network_join_waiting; ///< The number of clients waiting in front of us.
uint32 _network_join_bytes; ///< The number of bytes we already downloaded.
uint32 _network_join_bytes_total; ///< The total number of bytes to download.
uint8_t _network_join_waiting; ///< The number of clients waiting in front of us.
uint32_t _network_join_bytes; ///< The number of bytes we already downloaded.
uint32_t _network_join_bytes_total; ///< The total number of bytes to download.
struct NetworkJoinStatusWindow : Window {
NetworkPasswordType password_type;
@@ -2110,7 +2110,7 @@ struct NetworkJoinStatusWindow : Window {
/* Draw the % complete with a bar and a text */
DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
uint8 progress; // used for progress bar
uint8_t progress; // used for progress bar
switch (_network_join_status) {
case NETWORK_JOIN_STATUS_CONNECTING:
case NETWORK_JOIN_STATUS_AUTHORIZING:

View File

@@ -35,7 +35,7 @@ struct NetworkCompanyInfo : NetworkCompanyStats {
Money company_value; ///< The company value
Money money; ///< The amount of money the company has
Money income; ///< How much did the company earn last year
uint16 performance; ///< What was his performance last month?
uint16_t performance; ///< What was his performance last month?
bool use_password; ///< Is there a password
std::string clients; ///< The clients that control this company (Name1, name2, ..)
};

View File

@@ -20,7 +20,7 @@
#include <vector>
static const uint32 FIND_SERVER_EXTENDED_TOKEN = 0x2A49582A;
static const uint32_t FIND_SERVER_EXTENDED_TOKEN = 0x2A49582A;
#ifdef RANDOM_DEBUG
/**
@@ -63,41 +63,41 @@ enum NetworkJoinStatus {
NETWORK_JOIN_STATUS_END,
};
extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
extern uint32 _frame_counter_max; // To where we may go with our clients
extern uint32 _frame_counter;
extern uint32_t _frame_counter_server; // The frame_counter of the server, if in network-mode
extern uint32_t _frame_counter_max; // To where we may go with our clients
extern uint32_t _frame_counter;
extern uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
extern uint32_t _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
/* networking settings */
extern NetworkAddressList _broadcast_list;
extern uint32 _sync_seed_1;
extern uint64 _sync_state_checksum;
extern uint32 _sync_frame;
extern uint32_t _sync_seed_1;
extern uint64_t _sync_state_checksum;
extern uint32_t _sync_frame;
extern Date _last_sync_date;
extern DateFract _last_sync_date_fract;
extern uint8 _last_sync_tick_skip_counter;
extern uint32 _last_sync_frame_counter;
extern uint8_t _last_sync_tick_skip_counter;
extern uint32_t _last_sync_frame_counter;
extern bool _network_first_time;
/* Vars needed for the join-GUI */
extern NetworkJoinStatus _network_join_status;
extern uint8 _network_join_waiting;
extern uint32 _network_join_bytes;
extern uint32 _network_join_bytes_total;
extern uint8_t _network_join_waiting;
extern uint32_t _network_join_bytes;
extern uint32_t _network_join_bytes_total;
extern ConnectionType _network_server_connection_type;
extern std::string _network_server_invite_code;
/* Variable available for clients. */
extern std::string _network_server_name;
extern uint8 _network_reconnect;
extern uint8_t _network_reconnect;
extern CompanyMask _network_company_passworded;
void NetworkQueryServer(const std::string &connection_string);
void GetBindAddresses(NetworkAddressList *addresses, uint16 port);
void GetBindAddresses(NetworkAddressList *addresses, uint16_t port);
struct NetworkGameList *NetworkAddServer(const std::string &connection_string, bool manually = true, bool never_expire = false);
void NetworkRebuildHostList();
void UpdateNetworkGameWindow();
@@ -124,7 +124,7 @@ struct CommandPacket : CommandContainer {
/** Make sure the pointer is nullptr. */
CommandPacket() : next(nullptr), frame(0), client_id(INVALID_CLIENT_ID), company(INVALID_COMPANY), my_cmd(false) {}
CommandPacket *next; ///< the next command packet (if in queue)
uint32 frame; ///< the frame in which this packet is executed
uint32_t frame; ///< the frame in which this packet is executed
ClientID client_id; ///< originating client ID (or INVALID_CLIENT_ID if not specified)
CompanyID company; ///< company that is executing the command
bool my_cmd; ///< did the command originate from "me"
@@ -140,13 +140,13 @@ void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send,
uint NetworkCalculateLag(const NetworkClientSocket *cs);
StringID GetNetworkErrorMsg(NetworkErrorCode err);
bool NetworkMakeClientNameUnique(std::string &new_name);
std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32 password_game_seed);
std::vector<uint8> GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64 password_game_seed);
std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32_t password_game_seed);
std::vector<uint8_t> GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64_t password_game_seed);
std::string NetworkGenerateRandomKeyString(uint bytes);
std::string_view ParseCompanyFromConnectionString(const std::string &connection_string, CompanyID *company_id);
NetworkAddress ParseConnectionString(const std::string &connection_string, uint16 default_port);
std::string NormalizeConnectionString(const std::string &connection_string, uint16 default_port);
NetworkAddress ParseConnectionString(const std::string &connection_string, uint16_t default_port);
std::string NormalizeConnectionString(const std::string &connection_string, uint16_t default_port);
void ClientNetworkEmergencySave();

View File

@@ -185,7 +185,7 @@ struct PacketWriter : SaveFilter {
/* Fast-track the size to the client. */
this->map_size_packet.reset(new Packet(PACKET_SERVER_MAP_SIZE, SHRT_MAX));
this->map_size_packet->Send_uint32((uint32)this->total_size);
this->map_size_packet->Send_uint32((uint32_t)this->total_size);
}
};
@@ -216,7 +216,7 @@ ServerNetworkGameSocketHandler::~ServerNetworkGameSocketHandler()
if (_redirect_console_to_client == this->client_id) _redirect_console_to_client = INVALID_CLIENT_ID;
OrderBackup::ResetUser(this->client_id);
extern void RemoveVirtualTrainsOfUser(uint32 user);
extern void RemoveVirtualTrainsOfUser(uint32_t user);
RemoveVirtualTrainsOfUser(this->client_id);
if (this->savegame != nullptr) {
@@ -265,7 +265,7 @@ bool ServerNetworkGameSocketHandler::ParseKeyPasswordPacket(Packet *p, NetworkSh
/* Decrypt in place, use first half of hash as key */
if (crypto_aead_unlock(message.data(), mac, ss.shared_data, nonce, client_pub_key, 32, message.data(), message.size()) == 0) {
SubPacketDeserialiser spd(p, message);
uint64 message_id = spd.Recv_uint64();
uint64_t message_id = spd.Recv_uint64();
if (message_id < this->min_key_message_id) {
/* ID has not increased monotonically, reject the message */
return false;
@@ -419,7 +419,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfo()
return NETWORK_RECV_STATUS_OKAY;
}
NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfoExtended(PacketGameType reply_type, uint16 flags, uint16 version)
NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfoExtended(PacketGameType reply_type, uint16_t flags, uint16_t version)
{
Packet *p = new Packet(reply_type, SHRT_MAX);
SerializeNetworkGameInfoExtended(p, GetCurrentNetworkServerGameInfo(), flags, version);
@@ -483,7 +483,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendDesyncLog(const std::strin
for (size_t offset = 0; offset < log.size();) {
Packet *p = new Packet(PACKET_SERVER_DESYNC_LOG, SHRT_MAX);
size_t size = std::min<size_t>(log.size() - offset, SHRT_MAX - 2 - p->Size());
p->Send_uint16(static_cast<uint16>(size));
p->Send_uint16(static_cast<uint16_t>(size));
p->Send_binary((const byte *)(log.data() + offset), size);
this->SendPacket(p);
@@ -503,7 +503,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck()
if (!HasBit(c->flags, GCF_STATIC)) grf_count++;
}
p->Send_uint32 (grf_count);
p->Send_uint32(grf_count);
for (c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) SerializeGRFIdentifier(p, &c->ident);
}
@@ -835,7 +835,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGame()
* @param colour The colour of the result.
* @param command The command that was executed.
*/
NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16 colour, const std::string &command)
NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16_t colour, const std::string &command)
{
assert(this->rcon_reply_key != nullptr);
@@ -845,10 +845,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16 colour,
buffer.Send_string(command);
/* Message authentication code */
uint8 mac[16];
uint8_t mac[16];
/* Use only once per key: random */
uint8 nonce[24];
uint8_t nonce[24];
NetworkRandomBytesWithFallback(nonce, 24);
/* Encrypt in place, use first half of hash as key */
@@ -893,7 +893,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyUpdate()
{
Packet *p = new Packet(PACKET_SERVER_COMPANY_UPDATE, SHRT_MAX);
static_assert(sizeof(_network_company_passworded) <= sizeof(uint16));
static_assert(sizeof(_network_company_passworded) <= sizeof(uint16_t));
p->Send_uint16(_network_company_passworded);
this->SendPacket(p);
return NETWORK_RECV_STATUS_OKAY;
@@ -928,8 +928,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GAME_INFO(Packe
{
if (p->CanReadFromPacket(9) && p->Recv_uint32() == FIND_SERVER_EXTENDED_TOKEN) {
PacketGameType reply_type = (PacketGameType)p->Recv_uint8();
uint16 flags = p->Recv_uint16();
uint16 version = p->Recv_uint16();
uint16_t flags = p->Recv_uint16();
uint16_t version = p->Recv_uint16();
return this->SendGameInfoExtended(reply_type, flags, version);
} else {
return this->SendGameInfo();
@@ -970,7 +970,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
}
std::string client_revision = p->Recv_string(NETWORK_REVISION_LENGTH);
uint32 newgrf_version = p->Recv_uint32();
uint32_t newgrf_version = p->Recv_uint32();
/* Check if the client has revision control enabled */
if (!IsNetworkCompatibleVersion(client_revision.c_str()) || _openttd_newgrf_version != newgrf_version) {
@@ -1258,7 +1258,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
char client_name[NETWORK_CLIENT_NAME_LENGTH];
NetworkErrorCode errorno = (NetworkErrorCode)p->Recv_uint8();
NetworkRecvStatus rx_status = p->CanReadFromPacket(1) ? (NetworkRecvStatus)p->Recv_uint8() : NETWORK_RECV_STATUS_OKAY;
int8 status = p->CanReadFromPacket(1) ? (int8)p->Recv_uint8() : -1;
int8_t status = p->CanReadFromPacket(1) ? (int8_t)p->Recv_uint8() : -1;
PacketGameType last_pkt_type = p->CanReadFromPacket(1) ? (PacketGameType)p->Recv_uint8() : PACKET_END;
/* The client was never joined.. thank the client for the packet, but ignore it */
@@ -1293,7 +1293,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
this->SendDesyncLog(server_desync_log);
// decrease the sync frequency for this point onwards
_settings_client.network.sync_freq = std::min<uint16>(_settings_client.network.sync_freq, 16);
_settings_client.network.sync_freq = std::min<uint16_t>(_settings_client.network.sync_freq, 16);
// have the server and all clients run some sanity checks
NetworkSendCommand(0, 0, 0, 0, CMD_DESYNC_CHECK, nullptr, nullptr, _local_company, nullptr);
@@ -1321,18 +1321,18 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_MSG(Pack
{
Date date = p->Recv_uint32();
DateFract date_fract = p->Recv_uint16();
uint8 tick_skip_counter = p->Recv_uint8();
uint8_t tick_skip_counter = p->Recv_uint8();
std::string msg;
p->Recv_string(msg);
DEBUG(desync, 0, "Client-id %d desync msg: %s", this->client_id, msg.c_str());
extern void LogRemoteDesyncMsg(Date date, DateFract date_fract, uint8 tick_skip_counter, uint32 src_id, std::string msg);
extern void LogRemoteDesyncMsg(Date date, DateFract date_fract, uint8_t tick_skip_counter, uint32_t src_id, std::string msg);
LogRemoteDesyncMsg(date, date_fract, tick_skip_counter, this->client_id, std::move(msg));
return NETWORK_RECV_STATUS_OKAY;
}
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_SYNC_DATA(Packet *p)
{
uint32 frame_count = p->Recv_uint32();
uint32_t frame_count = p->Recv_uint32();
DEBUG(net, 2, "Received desync sync data: %u frames", frame_count);
@@ -1341,10 +1341,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_SYNC_DAT
size_t record_count_offset = 0;
size_t record_offset = 0;
for (uint i = 0; i < frame_count; i++) {
uint32 item_count = p->Recv_uint32();
uint32_t item_count = p->Recv_uint32();
if (item_count == 0) continue;
uint32 local_item_count = 0;
uint32 frame = 0;
uint32_t local_item_count = 0;
uint32_t frame = 0;
NetworkSyncRecordEvents event = NSRE_BEGIN;
for (uint j = 0; j < item_count; j++) {
if (j == 0) {
@@ -1360,8 +1360,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_SYNC_DAT
} else {
event = (NetworkSyncRecordEvents)p->Recv_uint32();
}
uint32 seed_1 = p->Recv_uint32();
uint64 state_checksum = p->Recv_uint64();
uint32_t seed_1 = p->Recv_uint32();
uint64_t state_checksum = p->Recv_uint64();
if (j == local_item_count) {
this->desync_frame_info = stdstr_fmt("Desync subframe count mismatch: extra client record: %08X, %s", frame, GetSyncRecordEventName(event));
return NETWORK_RECV_STATUS_OKAY;
@@ -1422,7 +1422,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(Packet *p)
return this->SendError(NETWORK_ERROR_NOT_AUTHORIZED);
}
uint32 frame = p->Recv_uint32();
uint32_t frame = p->Recv_uint32();
/* The client is trying to catch up with the server */
if (this->status == STATUS_PRE_ACTIVE) {
@@ -1438,7 +1438,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(Packet *p)
}
/* Get, and validate the token. */
uint8 token = p->Recv_uint8();
uint8_t token = p->Recv_uint8();
if (token == this->last_token) {
/* We differentiate between last_token_frame and last_frame so the lag
* test uses the actual lag of the client instead of the lag for getting

View File

@@ -23,7 +23,7 @@ extern NetworkClientSocketPool _networkclientsocket_pool;
/** Class for handling the server side of the game connection. */
class ServerNetworkGameSocketHandler : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkGameSocketHandler, public TCPListenHandler<ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED> {
NetworkGameKeys intl_keys;
uint64 min_key_message_id = 0;
uint64_t min_key_message_id = 0;
byte *rcon_reply_key = nullptr;
protected:
@@ -49,7 +49,7 @@ protected:
NetworkRecvStatus Receive_CLIENT_MOVE(Packet *p) override;
NetworkRecvStatus SendGameInfo();
NetworkRecvStatus SendGameInfoExtended(PacketGameType reply_type, uint16 flags, uint16 version);
NetworkRecvStatus SendGameInfoExtended(PacketGameType reply_type, uint16_t flags, uint16_t version);
NetworkRecvStatus SendNewGRFCheck();
NetworkRecvStatus SendWelcome();
NetworkRecvStatus SendNeedGamePassword();
@@ -78,7 +78,7 @@ public:
byte lag_test; ///< Byte used for lag-testing the client
byte last_token; ///< The last random token we did send to verify the client is listening
uint32 last_token_frame; ///< The last frame we received the right token
uint32_t last_token_frame; ///< The last frame we received the right token
ClientStatus status; ///< Status of this client
CommandQueue outgoing_queue; ///< The command-queue awaiting delivery
size_t receive_limit; ///< Amount of bytes that we can receive at this moment
@@ -109,7 +109,7 @@ public:
NetworkRecvStatus SendQuit(ClientID client_id);
NetworkRecvStatus SendShutdown();
NetworkRecvStatus SendNewGame();
NetworkRecvStatus SendRConResult(uint16 colour, const std::string &command);
NetworkRecvStatus SendRConResult(uint16_t colour, const std::string &command);
NetworkRecvStatus SendRConDenied();
NetworkRecvStatus SendMove(ClientID client_id, CompanyID company_id);

View File

@@ -20,7 +20,7 @@ class NetworkStunConnecter : public TCPConnecter {
private:
ClientNetworkStunSocketHandler *stun_handler;
std::string token;
uint8 family;
uint8_t family;
public:
/**
@@ -28,7 +28,7 @@ public:
* @param stun_handler The handler for this request.
* @param connection_string The address of the server.
*/
NetworkStunConnecter(ClientNetworkStunSocketHandler *stun_handler, const std::string &connection_string, const std::string &token, uint8 family) :
NetworkStunConnecter(ClientNetworkStunSocketHandler *stun_handler, const std::string &connection_string, const std::string &token, uint8_t family) :
TCPConnecter(connection_string, NETWORK_STUN_SERVER_PORT, NetworkAddress(), family),
stun_handler(stun_handler),
token(token),
@@ -66,7 +66,7 @@ public:
* @param token The token as received from the Game Coordinator.
* @param family What IP family to use.
*/
void ClientNetworkStunSocketHandler::Connect(const std::string &token, uint8 family)
void ClientNetworkStunSocketHandler::Connect(const std::string &token, uint8_t family)
{
this->token = token;
this->family = family;
@@ -80,7 +80,7 @@ void ClientNetworkStunSocketHandler::Connect(const std::string &token, uint8 fam
* @param family What IP family this STUN request is for.
* @return The handler for this STUN request.
*/
std::unique_ptr<ClientNetworkStunSocketHandler> ClientNetworkStunSocketHandler::Stun(const std::string &token, uint8 family)
std::unique_ptr<ClientNetworkStunSocketHandler> ClientNetworkStunSocketHandler::Stun(const std::string &token, uint8_t family)
{
auto stun_handler = std::make_unique<ClientNetworkStunSocketHandler>();

View File

@@ -15,9 +15,9 @@
/** Class for handling the client side of the STUN connection. */
class ClientNetworkStunSocketHandler : public NetworkStunSocketHandler {
private:
std::string token; ///< Token of this STUN handler.
uint8 family = AF_UNSPEC; ///< Family of this STUN handler.
bool sent_result = false; ///< Did we sent the result of the STUN connection?
std::string token; ///< Token of this STUN handler.
uint8_t family = AF_UNSPEC; ///< Family of this STUN handler.
bool sent_result = false; ///< Did we sent the result of the STUN connection?
public:
TCPConnecter *connecter = nullptr; ///< Connecter instance.
@@ -27,9 +27,9 @@ public:
~ClientNetworkStunSocketHandler() override;
void SendReceive();
void Connect(const std::string &token, uint8 family);
void Connect(const std::string &token, uint8_t family);
static std::unique_ptr<ClientNetworkStunSocketHandler> Stun(const std::string &token, uint8 family);
static std::unique_ptr<ClientNetworkStunSocketHandler> Stun(const std::string &token, uint8_t family);
};
#endif /* NETWORK_STUN_H */

View File

@@ -14,15 +14,15 @@
/* Sync debugging */
struct NetworkSyncRecord {
uint32 frame;
uint32 seed_1;
uint64 state_checksum;
uint32_t frame;
uint32_t seed_1;
uint64_t state_checksum;
};
extern ring_buffer<NetworkSyncRecord> _network_sync_records;
extern ring_buffer<uint> _network_sync_record_counts;
extern bool _record_sync_records;
enum NetworkSyncRecordEvents : uint32 {
enum NetworkSyncRecordEvents : uint32_t {
NSRE_BEGIN,
NSRE_CMD,
NSRE_AUX_TILE,

View File

@@ -86,7 +86,7 @@ void ClientNetworkTurnSocketHandler::Connect()
* @param connection_string Connection string of the TURN server.
* @return The handler for this TURN connection.
*/
/* static */ std::unique_ptr<ClientNetworkTurnSocketHandler> ClientNetworkTurnSocketHandler::Turn(const std::string &token, uint8 tracking_number, const std::string &ticket, const std::string &connection_string)
/* static */ std::unique_ptr<ClientNetworkTurnSocketHandler> ClientNetworkTurnSocketHandler::Turn(const std::string &token, uint8_t tracking_number, const std::string &ticket, const std::string &connection_string)
{
auto turn_handler = std::make_unique<ClientNetworkTurnSocketHandler>(token, tracking_number, connection_string);

View File

@@ -16,7 +16,7 @@
class ClientNetworkTurnSocketHandler : public NetworkTurnSocketHandler {
private:
std::string token; ///< Token of this connection.
uint8 tracking_number; ///< Tracking number of this connection.
uint8_t tracking_number; ///< Tracking number of this connection.
std::string connection_string; ///< The connection string of the TURN server we are connecting to.
protected:
@@ -27,7 +27,7 @@ public:
TCPConnecter *connecter = nullptr; ///< Connecter instance.
bool connect_started = false; ///< Whether we started the connection.
ClientNetworkTurnSocketHandler(const std::string &token, uint8 tracking_number, const std::string &connection_string) : token(token), tracking_number(tracking_number), connection_string(connection_string) {}
ClientNetworkTurnSocketHandler(const std::string &token, uint8_t tracking_number, const std::string &connection_string) : token(token), tracking_number(tracking_number), connection_string(connection_string) {}
NetworkRecvStatus CloseConnection(bool error = true) override;
~ClientNetworkTurnSocketHandler() override;
@@ -36,7 +36,7 @@ public:
void Connect();
void ConnectFailure();
static std::unique_ptr<ClientNetworkTurnSocketHandler> Turn(const std::string &token, uint8 tracking_number, const std::string &ticket, const std::string &connection_string);
static std::unique_ptr<ClientNetworkTurnSocketHandler> Turn(const std::string &token, uint8_t tracking_number, const std::string &ticket, const std::string &connection_string);
};
#endif /* NETWORK_TURN_H */

View File

@@ -37,24 +37,24 @@ enum NetworkVehicleType {
* Game type the server can be using.
* Used on the network protocol to communicate with Game Coordinator.
*/
enum ServerGameType : uint8 {
enum ServerGameType : uint8_t {
SERVER_GAME_TYPE_LOCAL = 0,
SERVER_GAME_TYPE_PUBLIC,
SERVER_GAME_TYPE_INVITE_ONLY,
};
/** 'Unique' identifier to be given to clients */
enum ClientID : uint32 {
enum ClientID : uint32_t {
INVALID_CLIENT_ID = 0, ///< Client is not part of anything
CLIENT_ID_SERVER = 1, ///< Servers always have this ID
CLIENT_ID_FIRST = 2, ///< The first client ID
};
/** Indices into the client tables */
typedef uint8 ClientIndex;
typedef uint8_t ClientIndex;
/** Indices into the admin tables. */
typedef uint8 AdminIndex;
typedef uint8_t AdminIndex;
/** Maximum number of allowed admins. */
static const AdminIndex MAX_ADMINS = 16;
@@ -63,15 +63,15 @@ static const AdminIndex INVALID_ADMIN_ID = UINT8_MAX;
/** Simple calculated statistics of a company */
struct NetworkCompanyStats {
uint16 num_vehicle[NETWORK_VEH_END]; ///< How many vehicles are there of this type?
uint16 num_station[NETWORK_VEH_END]; ///< How many stations are there of this type?
uint16_t num_vehicle[NETWORK_VEH_END]; ///< How many vehicles are there of this type?
uint16_t num_station[NETWORK_VEH_END]; ///< How many stations are there of this type?
bool ai; ///< Is this company an AI
};
/** Some state information of a company, especially for servers */
struct NetworkCompanyState {
std::string password; ///< The password for the company
uint16 months_empty; ///< How many months the company is empty
uint16_t months_empty; ///< How many months the company is empty
};
struct NetworkClientInfo;
@@ -148,10 +148,10 @@ enum NetworkErrorCode {
};
struct NetworkTextMessageData {
int64 data;
int64 auxdata;
int64_t data;
int64_t auxdata;
NetworkTextMessageData(int64 data = 0, int64 auxdata = 0)
NetworkTextMessageData(int64_t data = 0, int64_t auxdata = 0)
: data(data), auxdata(auxdata) { }
template <typename T> void recv(T *p) {

View File

@@ -35,7 +35,7 @@
#include "../safeguards.h"
static bool _network_udp_server; ///< Is the UDP server started?
static uint16 _network_udp_broadcast; ///< Timeout for the UDP broadcasts.
static uint16_t _network_udp_broadcast; ///< Timeout for the UDP broadcasts.
/** Some information about a socket, which exists before the actual socket has been created to provide locking and the likes. */
struct UDPSocket {
@@ -100,8 +100,8 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(Packet *p, Networ
void ServerNetworkUDPSocketHandler::Reply_CLIENT_FIND_SERVER_extended(Packet *p, NetworkAddress *client_addr)
{
[[maybe_unused]] uint16 flags = p->Recv_uint16();
uint16 version = p->Recv_uint16();
[[maybe_unused]] uint16_t flags = p->Recv_uint16();
uint16_t version = p->Recv_uint16();
Packet packet(PACKET_UDP_EX_SERVER_RESPONSE);
this->SendPacket(&packet, client_addr);