Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
This commit is contained in:
@@ -35,7 +35,7 @@ const std::string &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:
|
||||
@@ -77,7 +77,7 @@ void NetworkAddress::SetPort(uint16 port)
|
||||
* @param with_family Whether to add the familty to the address (e.g. IPv4).
|
||||
* @return The format string for the address.
|
||||
*/
|
||||
static const char *GetAddressFormatString(uint16 family, bool with_family)
|
||||
static const char *GetAddressFormatString(uint16_t family, bool with_family)
|
||||
{
|
||||
switch (family) {
|
||||
case AF_INET: return with_family ? "{}:{} (IPv4)" : "{}:{}";
|
||||
@@ -169,17 +169,17 @@ bool NetworkAddress::IsInNetmask(const std::string &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:
|
||||
@@ -187,7 +187,7 @@ bool NetworkAddress::IsInNetmask(const std::string &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;
|
||||
@@ -448,14 +448,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));
|
||||
}
|
||||
|
@@ -72,7 +72,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)
|
||||
{
|
||||
@@ -102,8 +102,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
|
||||
@@ -209,7 +209,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 */
|
||||
|
@@ -18,15 +18,15 @@ 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_t UDP_MTU = 1460; ///< Number of bytes we can pack in a single UDP packet
|
||||
|
||||
static const std::string NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.org/participate"; ///< Link with more details & privacy statement of the survey.
|
||||
/*
|
||||
@@ -37,14 +37,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?
|
||||
|
@@ -199,7 +199,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 */
|
||||
@@ -284,7 +284,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;
|
||||
|
@@ -94,8 +94,8 @@ struct NetworkServerGameInfo {
|
||||
GRFConfig *grfconfig; ///< List of NewGRF files used
|
||||
TimerGameCalendar::Date start_date; ///< When the game started
|
||||
TimerGameCalendar::Date game_date; ///< Current date
|
||||
uint16 map_width; ///< Map width
|
||||
uint16 map_height; ///< Map height
|
||||
uint16_t map_width; ///< Map width
|
||||
uint16_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;
|
||||
|
||||
|
@@ -103,13 +103,13 @@ bool Packet::CanWriteToPacket(size_t bytes_to_write)
|
||||
|
||||
/*
|
||||
* The next couple of functions make sure we can send
|
||||
* uint8, uint16, uint32 and uint64 endian-safe
|
||||
* uint8_t, uint16_t, uint32_t and uint64_t endian-safe
|
||||
* over the network. The least significant bytes are
|
||||
* sent first.
|
||||
*
|
||||
* So 0x01234567 would be sent as 67 45 23 01.
|
||||
*
|
||||
* A bool is sent as a uint8 where zero means false
|
||||
* A bool is sent as a uint8_t where zero means false
|
||||
* and non-zero means true.
|
||||
*/
|
||||
|
||||
@@ -126,7 +126,7 @@ void Packet::Send_bool(bool data)
|
||||
* Package a 8 bits integer in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void Packet::Send_uint8(uint8 data)
|
||||
void Packet::Send_uint8(uint8_t data)
|
||||
{
|
||||
assert(this->CanWriteToPacket(sizeof(data)));
|
||||
this->buffer.emplace_back(data);
|
||||
@@ -136,7 +136,7 @@ void Packet::Send_uint8(uint8 data)
|
||||
* Package a 16 bits integer in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void Packet::Send_uint16(uint16 data)
|
||||
void Packet::Send_uint16(uint16_t data)
|
||||
{
|
||||
assert(this->CanWriteToPacket(sizeof(data)));
|
||||
this->buffer.emplace_back(GB(data, 0, 8));
|
||||
@@ -147,7 +147,7 @@ void Packet::Send_uint16(uint16 data)
|
||||
* Package a 32 bits integer in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void Packet::Send_uint32(uint32 data)
|
||||
void Packet::Send_uint32(uint32_t data)
|
||||
{
|
||||
assert(this->CanWriteToPacket(sizeof(data)));
|
||||
this->buffer.emplace_back(GB(data, 0, 8));
|
||||
@@ -160,7 +160,7 @@ void Packet::Send_uint32(uint32 data)
|
||||
* Package a 64 bits integer in the packet.
|
||||
* @param data The data to send.
|
||||
*/
|
||||
void Packet::Send_uint64(uint64 data)
|
||||
void Packet::Send_uint64(uint64_t data)
|
||||
{
|
||||
assert(this->CanWriteToPacket(sizeof(data)));
|
||||
this->buffer.emplace_back(GB(data, 0, 8));
|
||||
@@ -191,8 +191,8 @@ void Packet::Send_string(const std::string_view data)
|
||||
*/
|
||||
void Packet::Send_buffer(const std::vector<byte> &data)
|
||||
{
|
||||
assert(this->CanWriteToPacket(sizeof(uint16) + data.size()));
|
||||
this->Send_uint16((uint16)data.size());
|
||||
assert(this->CanWriteToPacket(sizeof(uint16_t) + data.size()));
|
||||
this->Send_uint16((uint16_t)data.size());
|
||||
this->buffer.insert(this->buffer.end(), data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -314,9 +314,9 @@ bool Packet::Recv_bool()
|
||||
* Read a 8 bits integer from the packet.
|
||||
* @return The read data.
|
||||
*/
|
||||
uint8 Packet::Recv_uint8()
|
||||
uint8_t Packet::Recv_uint8()
|
||||
{
|
||||
uint8 n;
|
||||
uint8_t n;
|
||||
|
||||
if (!this->CanReadFromPacket(sizeof(n), true)) return 0;
|
||||
|
||||
@@ -328,14 +328,14 @@ uint8 Packet::Recv_uint8()
|
||||
* Read a 16 bits integer from the packet.
|
||||
* @return The read data.
|
||||
*/
|
||||
uint16 Packet::Recv_uint16()
|
||||
uint16_t Packet::Recv_uint16()
|
||||
{
|
||||
uint16 n;
|
||||
uint16_t n;
|
||||
|
||||
if (!this->CanReadFromPacket(sizeof(n), true)) return 0;
|
||||
|
||||
n = (uint16)this->buffer[this->pos++];
|
||||
n += (uint16)this->buffer[this->pos++] << 8;
|
||||
n = (uint16_t)this->buffer[this->pos++];
|
||||
n += (uint16_t)this->buffer[this->pos++] << 8;
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -343,16 +343,16 @@ uint16 Packet::Recv_uint16()
|
||||
* Read a 32 bits integer from the packet.
|
||||
* @return The read data.
|
||||
*/
|
||||
uint32 Packet::Recv_uint32()
|
||||
uint32_t Packet::Recv_uint32()
|
||||
{
|
||||
uint32 n;
|
||||
uint32_t n;
|
||||
|
||||
if (!this->CanReadFromPacket(sizeof(n), true)) return 0;
|
||||
|
||||
n = (uint32)this->buffer[this->pos++];
|
||||
n += (uint32)this->buffer[this->pos++] << 8;
|
||||
n += (uint32)this->buffer[this->pos++] << 16;
|
||||
n += (uint32)this->buffer[this->pos++] << 24;
|
||||
n = (uint32_t)this->buffer[this->pos++];
|
||||
n += (uint32_t)this->buffer[this->pos++] << 8;
|
||||
n += (uint32_t)this->buffer[this->pos++] << 16;
|
||||
n += (uint32_t)this->buffer[this->pos++] << 24;
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -360,20 +360,20 @@ uint32 Packet::Recv_uint32()
|
||||
* Read a 64 bits integer from the packet.
|
||||
* @return The read data.
|
||||
*/
|
||||
uint64 Packet::Recv_uint64()
|
||||
uint64_t Packet::Recv_uint64()
|
||||
{
|
||||
uint64 n;
|
||||
uint64_t n;
|
||||
|
||||
if (!this->CanReadFromPacket(sizeof(n), true)) return 0;
|
||||
|
||||
n = (uint64)this->buffer[this->pos++];
|
||||
n += (uint64)this->buffer[this->pos++] << 8;
|
||||
n += (uint64)this->buffer[this->pos++] << 16;
|
||||
n += (uint64)this->buffer[this->pos++] << 24;
|
||||
n += (uint64)this->buffer[this->pos++] << 32;
|
||||
n += (uint64)this->buffer[this->pos++] << 40;
|
||||
n += (uint64)this->buffer[this->pos++] << 48;
|
||||
n += (uint64)this->buffer[this->pos++] << 56;
|
||||
n = (uint64_t)this->buffer[this->pos++];
|
||||
n += (uint64_t)this->buffer[this->pos++] << 8;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 16;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 24;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 32;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 40;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 48;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 56;
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ uint64 Packet::Recv_uint64()
|
||||
*/
|
||||
std::vector<byte> Packet::Recv_buffer()
|
||||
{
|
||||
uint16 size = this->Recv_uint16();
|
||||
uint16_t size = this->Recv_uint16();
|
||||
if (size == 0 || !this->CanReadFromPacket(size, true)) return {};
|
||||
|
||||
std::vector<byte> data;
|
||||
|
@@ -17,8 +17,8 @@
|
||||
#include "core.h"
|
||||
#include "../../string_type.h"
|
||||
|
||||
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,
|
||||
@@ -65,10 +65,10 @@ public:
|
||||
|
||||
bool CanWriteToPacket(size_t bytes_to_write);
|
||||
void Send_bool (bool data);
|
||||
void Send_uint8 (uint8 data);
|
||||
void Send_uint16(uint16 data);
|
||||
void Send_uint32(uint32 data);
|
||||
void Send_uint64(uint64 data);
|
||||
void Send_uint8 (uint8_t data);
|
||||
void Send_uint16(uint16_t data);
|
||||
void Send_uint32(uint32_t data);
|
||||
void Send_uint64(uint64_t data);
|
||||
void Send_string(const std::string_view data);
|
||||
void Send_buffer(const std::vector<byte> &data);
|
||||
size_t Send_bytes (const byte *begin, const byte *end);
|
||||
@@ -82,10 +82,10 @@ public:
|
||||
|
||||
bool CanReadFromPacket(size_t bytes_to_read, bool close_connection = false);
|
||||
bool Recv_bool ();
|
||||
uint8 Recv_uint8 ();
|
||||
uint16 Recv_uint16();
|
||||
uint32 Recv_uint32();
|
||||
uint64 Recv_uint64();
|
||||
uint8_t Recv_uint8 ();
|
||||
uint16_t Recv_uint16();
|
||||
uint32_t Recv_uint32();
|
||||
uint64_t Recv_uint64();
|
||||
std::vector<byte> Recv_buffer();
|
||||
std::string Recv_string(size_t length, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
|
||||
|
||||
|
@@ -114,7 +114,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();
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,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();
|
||||
|
@@ -136,8 +136,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.
|
||||
*/
|
||||
@@ -145,8 +145,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.
|
||||
@@ -156,9 +156,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.
|
||||
@@ -168,7 +168,7 @@ protected:
|
||||
/**
|
||||
* Send chat from the external source:
|
||||
* string Name of the source this message came from.
|
||||
* uint16 TextColour to use for the message.
|
||||
* 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.
|
||||
@@ -194,7 +194,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.
|
||||
*/
|
||||
@@ -216,7 +216,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.
|
||||
*/
|
||||
@@ -224,10 +224,10 @@ protected:
|
||||
|
||||
/**
|
||||
* Inform a just joined admin about the protocol specifics:
|
||||
* uint8 Protocol version.
|
||||
* uint8_t 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).
|
||||
* 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.
|
||||
*/
|
||||
@@ -239,11 +239,11 @@ protected:
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
@@ -265,7 +265,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.
|
||||
*/
|
||||
@@ -273,7 +273,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.
|
||||
*/
|
||||
@@ -281,12 +281,12 @@ protected:
|
||||
|
||||
/**
|
||||
* Client information of a specific client:
|
||||
* uint32 ID of the client.
|
||||
* uint32_t 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).
|
||||
* 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.
|
||||
*/
|
||||
@@ -294,9 +294,9 @@ protected:
|
||||
|
||||
/**
|
||||
* Client update details on a specific client (e.g. after rename or move):
|
||||
* uint32 ID of the client.
|
||||
* uint32_t ID of the client.
|
||||
* string Name of the client.
|
||||
* uint8 ID of the company the client is playing as (255 for spectators).
|
||||
* 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.
|
||||
*/
|
||||
@@ -304,7 +304,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.
|
||||
*/
|
||||
@@ -312,8 +312,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.
|
||||
*/
|
||||
@@ -321,7 +321,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.
|
||||
*/
|
||||
@@ -329,12 +329,12 @@ protected:
|
||||
|
||||
/**
|
||||
* Company information on a specific company:
|
||||
* uint8 ID of the company.
|
||||
* uint8_t ID of the company.
|
||||
* string Name of the company.
|
||||
* string Name of the companies manager.
|
||||
* uint8 Main company colour.
|
||||
* uint8_t Main company colour.
|
||||
* bool Company is password protected.
|
||||
* uint32 Year the company was inaugurated.
|
||||
* 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.
|
||||
@@ -343,16 +343,16 @@ protected:
|
||||
|
||||
/**
|
||||
* Company information of a specific company:
|
||||
* uint8 ID of the company.
|
||||
* uint8_t ID of the company.
|
||||
* string Name of the company.
|
||||
* string Name of the companies manager.
|
||||
* uint8 Main company colour.
|
||||
* uint8_t 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 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.
|
||||
*/
|
||||
@@ -360,8 +360,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.
|
||||
*/
|
||||
@@ -369,17 +369,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.
|
||||
*/
|
||||
@@ -387,17 +387,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.
|
||||
*/
|
||||
@@ -405,11 +405,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.
|
||||
* 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 Money (only when it is a 'give money' action).
|
||||
* 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.
|
||||
*/
|
||||
@@ -417,7 +417,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Result of an rcon command:
|
||||
* uint16 Colour as it would be used on the server or a client.
|
||||
* 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.
|
||||
@@ -445,7 +445,7 @@ protected:
|
||||
*
|
||||
* These three fields are repeated until the packet is full:
|
||||
* bool Data to follow.
|
||||
* uint16 ID of the DoCommand.
|
||||
* 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.
|
||||
@@ -461,12 +461,12 @@ 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_t ID of the client sending the command.
|
||||
* uint8_t ID of the company (0..MAX_COMPANIES-1).
|
||||
* uint16_t ID of the command.
|
||||
* <var> Command specific buffer with encoded parameters of variable length.
|
||||
* The content differs per command and can change without notification.
|
||||
* uint32 Frame of execution.
|
||||
* uint32_t Frame of execution.
|
||||
* @param p The packet that was just received.
|
||||
* @return The state the network should have.
|
||||
*/
|
||||
@@ -474,7 +474,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.
|
||||
*/
|
||||
|
@@ -27,7 +27,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)
|
||||
{
|
||||
@@ -41,7 +41,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) {
|
||||
|
@@ -26,9 +26,9 @@ protected:
|
||||
/**
|
||||
* Client requesting a list of content info:
|
||||
* byte type
|
||||
* uint32 openttd version (or 0xFFFFFFFF if using a list)
|
||||
* uint32_t openttd version (or 0xFFFFFFFF if using a list)
|
||||
* Only if the above value is 0xFFFFFFFF:
|
||||
* uint8 count
|
||||
* uint8_t count
|
||||
* string branch-name ("vanilla" for upstream OpenTTD)
|
||||
* string release version (like "12.0")
|
||||
* @param p The packet that was just received.
|
||||
@@ -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.
|
||||
@@ -77,15 +77,15 @@ protected:
|
||||
/**
|
||||
* Server sending list of content info:
|
||||
* byte type (invalid ID == does not exist)
|
||||
* uint32 id
|
||||
* uint32 file_size
|
||||
* uint32_t id
|
||||
* uint32_t 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
|
||||
* 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,8 +103,8 @@ protected:
|
||||
|
||||
/**
|
||||
* Server sending list of content info:
|
||||
* uint32 unique id
|
||||
* uint32 file size (0 == does not exist)
|
||||
* 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.
|
||||
|
@@ -62,13 +62,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
|
||||
|
@@ -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,9 +89,9 @@ 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.
|
||||
* 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).
|
||||
*
|
||||
@@ -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.
|
||||
* uint8_t Game Coordinator protocol version.
|
||||
* uint8_t 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.
|
||||
* 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.
|
||||
@@ -215,9 +215,9 @@ protected:
|
||||
* the indicated peer, which is a Server.
|
||||
*
|
||||
* 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.
|
||||
* string Hostname of the peer.
|
||||
* uint16 Port of the peer.
|
||||
* uint16_t Port of the peer.
|
||||
*
|
||||
* @param p The packet that was just received.
|
||||
* @return True upon success, otherwise false.
|
||||
@@ -242,9 +242,9 @@ protected:
|
||||
/**
|
||||
* Client/server informs the Game Coordinator the result of a STUN request.
|
||||
*
|
||||
* uint8 Game Coordinator protocol version.
|
||||
* uint8_t Game Coordinator protocol version.
|
||||
* string Token to track the current connect request.
|
||||
* uint8 Interface number, as given during STUN 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.
|
||||
@@ -258,10 +258,10 @@ protected:
|
||||
* 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.
|
||||
* uint8_t Tracking number to track current connect request.
|
||||
* uint8_t Interface number, as given during STUN request.
|
||||
* string Host of the peer.
|
||||
* uint16 Port of the peer.
|
||||
* uint16_t Port of the peer.
|
||||
*
|
||||
* @param p The packet that was just received.
|
||||
* @return True upon success, otherwise false.
|
||||
@@ -273,10 +273,10 @@ 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.
|
||||
* 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.
|
||||
*
|
||||
@@ -296,7 +296,7 @@ protected:
|
||||
* peer, which is a TURN server.
|
||||
*
|
||||
* 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.
|
||||
* string Ticket to hand over to the TURN server.
|
||||
* string Connection string of the TURN server.
|
||||
*
|
||||
|
@@ -176,15 +176,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);
|
||||
@@ -204,8 +204,8 @@ 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).
|
||||
* 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.
|
||||
*/
|
||||
@@ -219,7 +219,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Indication to the client that the server needs a company password:
|
||||
* uint32 Generation seed.
|
||||
* uint32_t Generation seed.
|
||||
* string Network ID of the server.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
@@ -227,7 +227,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Send a password to the server to authorize:
|
||||
* uint8 Password type (see NetworkPasswordType).
|
||||
* uint8_t Password type (see NetworkPasswordType).
|
||||
* string The password.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
@@ -235,7 +235,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Send a password to the server to authorize
|
||||
* uint8 Password type (see NetworkPasswordType).
|
||||
* uint8_t Password type (see NetworkPasswordType).
|
||||
* string The password.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
@@ -243,8 +243,8 @@ protected:
|
||||
|
||||
/**
|
||||
* The client is joined and ready to receive their map:
|
||||
* uint32 Own client ID.
|
||||
* uint32 Generation seed.
|
||||
* uint32_t Own client ID.
|
||||
* uint32_t Generation seed.
|
||||
* string Network ID of the server.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
@@ -252,28 +252,28 @@ protected:
|
||||
|
||||
/**
|
||||
* 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);
|
||||
@@ -299,79 +299,79 @@ 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).
|
||||
* uint8_t ID of the company (0..MAX_COMPANIES-1).
|
||||
* uint32_t ID of the command (see command.h).
|
||||
* <var> Command specific buffer with encoded parameters of variable length.
|
||||
* The content differs per command and can change without notification.
|
||||
* uint8 ID of the callback.
|
||||
* 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).
|
||||
* uint8_t ID of the company (0..MAX_COMPANIES-1).
|
||||
* uint32_t ID of the command (see command.h).
|
||||
* <var> Command specific buffer with encoded parameters of variable length.
|
||||
* The content differs per command and can change without notification.
|
||||
* uint8 ID of the callback.
|
||||
* uint32 Frame of execution.
|
||||
* 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).
|
||||
* 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 data (used e.g. for 'give money' actions).
|
||||
* 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).
|
||||
* 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 data (used e.g. for 'give money' actions).
|
||||
* 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);
|
||||
@@ -379,7 +379,7 @@ protected:
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
@@ -408,22 +408,22 @@ 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
@@ -442,7 +442,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.
|
||||
*/
|
||||
@@ -458,9 +458,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);
|
||||
@@ -473,15 +473,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.
|
||||
*/
|
||||
@@ -489,15 +489,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);
|
||||
@@ -507,8 +507,8 @@ 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
|
||||
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.
|
||||
|
||||
|
@@ -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.size() == 0);
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -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.
|
||||
|
@@ -63,20 +63,20 @@ bool _is_network_server; ///< Does this client wants to be a network-server?
|
||||
NetworkCompanyState *_network_company_states = nullptr; ///< Statistics about some companies.
|
||||
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
|
||||
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 _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.
|
||||
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 _sync_seed_1; ///< Seed to compare during sync checks.
|
||||
uint32_t _sync_seed_1; ///< Seed to compare during sync checks.
|
||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
||||
uint32 _sync_seed_2; ///< Second part of the seed.
|
||||
uint32_t _sync_seed_2; ///< Second part of the seed.
|
||||
#endif
|
||||
uint32 _sync_frame; ///< The frame to perform the sync check.
|
||||
uint32_t _sync_frame; ///< The frame to perform the sync check.
|
||||
bool _network_first_time; ///< Whether we have finished joining or not.
|
||||
CompanyMask _network_company_passworded; ///< Bitmask of the password status of all companies.
|
||||
|
||||
@@ -173,7 +173,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;
|
||||
|
||||
@@ -213,7 +213,7 @@ bool NetworkCompanyIsPassworded(CompanyID company_id)
|
||||
/* This puts a text-message to the console, or in the future, the chat-box,
|
||||
* (to keep it all a bit more general)
|
||||
* If 'self_send' is true, this is the client who is sending the message */
|
||||
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str, int64 data, const std::string &data_str)
|
||||
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str, int64_t data, const std::string &data_str)
|
||||
{
|
||||
StringID strid;
|
||||
switch (action) {
|
||||
@@ -466,7 +466,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;
|
||||
auto [_, err] = std::from_chars(company_string.data(), company_string.data() + company_string.size(), company_value);
|
||||
if (err == std::errc()) {
|
||||
if (company_value != COMPANY_NEW_COMPANY && company_value != COMPANY_SPECTATOR) {
|
||||
@@ -500,7 +500,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);
|
||||
|
||||
@@ -520,9 +520,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);
|
||||
}
|
||||
@@ -535,9 +535,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);
|
||||
}
|
||||
@@ -695,7 +695,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);
|
||||
@@ -1056,10 +1056,10 @@ void NetworkGameLoop()
|
||||
/* Loading of the debug commands from -ddesync>=1 */
|
||||
static FILE *f = FioFOpenFile("commands.log", "rb", SAVE_DIR);
|
||||
static Date next_date = 0;
|
||||
static uint32 next_date_fract;
|
||||
static uint32_t next_date_fract;
|
||||
static CommandPacket *cp = nullptr;
|
||||
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;
|
||||
|
@@ -396,13 +396,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);
|
||||
@@ -448,7 +448,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats()
|
||||
* @param msg The actual message.
|
||||
* @param data Arbitrary extra data.
|
||||
*/
|
||||
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data)
|
||||
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data)
|
||||
{
|
||||
Packet *p = new Packet(ADMIN_PACKET_SERVER_CHAT);
|
||||
|
||||
@@ -481,7 +481,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);
|
||||
|
||||
@@ -522,7 +522,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 '{}' ({}): {}", this->admin_name, this->admin_version, d1);
|
||||
|
||||
@@ -571,7 +571,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);
|
||||
|
||||
@@ -586,11 +586,11 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames()
|
||||
{
|
||||
Packet *p = new Packet(ADMIN_PACKET_SERVER_CMD_NAMES);
|
||||
|
||||
for (uint16 i = 0; i < CMD_END; i++) {
|
||||
for (uint16_t i = 0; i < CMD_END; i++) {
|
||||
const char *cmdname = GetCommandName(static_cast<Commands>(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);
|
||||
@@ -693,7 +693,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:
|
||||
@@ -790,7 +790,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(P
|
||||
std::string msg = p->Recv_string(NETWORK_CHAT_LENGTH);
|
||||
|
||||
if (!IsValidConsoleColour(colour)) {
|
||||
Debug(net, 1, "[admin] Not supported chat colour {} ({}, {}, {}) from '{}' ({}).", (uint16)colour, source, user, msg, this->admin_name, this->admin_version);
|
||||
Debug(net, 1, "[admin] Not supported chat colour {} ({}, {}, {}) from '{}' ({}).", (uint16_t)colour, source, user, msg, this->admin_name, this->admin_version);
|
||||
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
|
||||
}
|
||||
|
||||
@@ -913,7 +913,7 @@ void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bc
|
||||
/**
|
||||
* Send chat to the admin network (if they did opt in for the respective update).
|
||||
*/
|
||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data, bool from_admin)
|
||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data, bool from_admin)
|
||||
{
|
||||
if (from_admin) return;
|
||||
|
||||
|
@@ -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.
|
||||
@@ -62,8 +62,8 @@ public:
|
||||
NetworkRecvStatus SendCompanyEconomy();
|
||||
NetworkRecvStatus SendCompanyStats();
|
||||
|
||||
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data);
|
||||
NetworkRecvStatus SendRcon(uint16 colour, const std::string_view command);
|
||||
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data);
|
||||
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();
|
||||
@@ -107,7 +107,7 @@ void NetworkAdminCompanyInfo(const Company *company, bool new_company);
|
||||
void NetworkAdminCompanyUpdate(const Company *company);
|
||||
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr);
|
||||
|
||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data = 0, bool from_admin = false);
|
||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data = 0, bool from_admin = false);
|
||||
void NetworkAdminUpdate(AdminUpdateFrequency freq);
|
||||
void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const std::string_view string);
|
||||
void NetworkAdminConsole(const std::string_view origin, const std::string_view string);
|
||||
|
@@ -58,7 +58,7 @@ static std::chrono::steady_clock::time_point _chatmessage_dirty_time;
|
||||
* the left and pixels from the bottom. The height is the maximum height.
|
||||
*/
|
||||
static PointDimension _chatmsg_box;
|
||||
static uint8 *_chatmessage_backup = nullptr; ///< Backup in case text is moved.
|
||||
static uint8_t *_chatmessage_backup = nullptr; ///< Backup in case text is moved.
|
||||
|
||||
/**
|
||||
* Test if there are any chat messages to display.
|
||||
@@ -436,7 +436,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;
|
||||
@@ -464,7 +464,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) {
|
||||
|
@@ -310,15 +310,15 @@ 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 _password_game_seed;
|
||||
static uint32_t _password_game_seed;
|
||||
/** The other bit of 'entropy' used to generate a salt for the company passwords. */
|
||||
static std::string _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;
|
||||
|
||||
@@ -427,7 +427,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendCommand(const CommandPacke
|
||||
}
|
||||
|
||||
/** Send a chat-packet over the network */
|
||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data)
|
||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data)
|
||||
{
|
||||
Packet *p = new Packet(PACKET_CLIENT_CHAT);
|
||||
|
||||
@@ -783,7 +783,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;
|
||||
@@ -857,9 +857,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FRAME(Packet *p
|
||||
/* Test if the server supports this option
|
||||
* and if we are at the frame the server is */
|
||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
||||
if (p->CanReadFromPacket(sizeof(uint32) + sizeof(uint32))) {
|
||||
if (p->CanReadFromPacket(sizeof(uint32_t) + sizeof(uint32_t))) {
|
||||
#else
|
||||
if (p->CanReadFromPacket(sizeof(uint32))) {
|
||||
if (p->CanReadFromPacket(sizeof(uint32_t))) {
|
||||
#endif
|
||||
_sync_frame = _frame_counter_server;
|
||||
_sync_seed_1 = p->Recv_uint32();
|
||||
@@ -869,7 +869,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 {}", _frame_counter_server);
|
||||
|
||||
@@ -927,7 +927,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p)
|
||||
ClientID client_id = (ClientID)p->Recv_uint32();
|
||||
bool self_send = p->Recv_bool();
|
||||
std::string msg = p->Recv_string(NETWORK_CHAT_LENGTH);
|
||||
int64 data = p->Recv_uint64();
|
||||
int64_t data = p->Recv_uint64();
|
||||
|
||||
ci_to = NetworkClientInfo::GetByClientID(client_id);
|
||||
if (ci_to == nullptr) return NETWORK_RECV_STATUS_OKAY;
|
||||
@@ -1121,7 +1121,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);
|
||||
|
||||
@@ -1291,7 +1291,7 @@ void NetworkUpdateClientName(const std::string &client_name)
|
||||
* @param msg The actual message.
|
||||
* @param data Arbitrary extra data.
|
||||
*/
|
||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data)
|
||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data)
|
||||
{
|
||||
MyClient::SendChat(action, type, dest, msg, data);
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@ public:
|
||||
static NetworkRecvStatus SendGamePassword(const std::string &password);
|
||||
static NetworkRecvStatus SendCompanyPassword(const std::string &password);
|
||||
|
||||
static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data);
|
||||
static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data);
|
||||
static NetworkRecvStatus SendSetPassword(const std::string &password);
|
||||
static NetworkRecvStatus SendSetName(const std::string &name);
|
||||
static NetworkRecvStatus SendRCon(const std::string &password, const std::string &command);
|
||||
|
@@ -457,7 +457,7 @@ void NetworkGameSocketHandler::SendCommand(Packet *p, const CommandPacket *cp)
|
||||
Debug(net, 0, "Unknown callback for command; no callback sent (command: {})", cp->cmd);
|
||||
callback = 0; // _callback_table[0] == nullptr
|
||||
}
|
||||
p->Send_uint8 ((uint8)callback);
|
||||
p->Send_uint8 ((uint8_t)callback);
|
||||
}
|
||||
|
||||
/** Helper to process a single ClientID argument. */
|
||||
|
@@ -236,9 +236,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);
|
||||
@@ -265,11 +265,11 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
this->Connect();
|
||||
|
||||
assert(cv->size() < 255);
|
||||
assert(cv->size() < (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
|
||||
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? MD5_HASH_BYTES : 0)));
|
||||
assert(cv->size() < (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8_t)) /
|
||||
(sizeof(uint8_t) + sizeof(uint32_t) + (send_md5sum ? MD5_HASH_BYTES : 0)));
|
||||
|
||||
Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID, TCP_MTU);
|
||||
p->Send_uint8((uint8)cv->size());
|
||||
p->Send_uint8((uint8_t)cv->size());
|
||||
|
||||
for (const ContentInfo *ci : *cv) {
|
||||
p->Send_uint8((byte)ci->type);
|
||||
@@ -361,9 +361,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);
|
||||
|
@@ -136,7 +136,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(); }
|
||||
|
||||
|
@@ -140,7 +140,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widge
|
||||
/* 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);
|
||||
@@ -873,7 +873,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) {
|
||||
|
@@ -22,7 +22,7 @@ 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
|
||||
uint32_t cur_id; ///< The current ID of the downloaded file
|
||||
std::string name; ///< The current name of the downloaded file
|
||||
|
||||
public:
|
||||
|
@@ -35,7 +35,7 @@ std::string _network_server_invite_code = ""; ///< Our invite code as indicated
|
||||
class NetworkDirectConnecter : public TCPConnecter {
|
||||
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.
|
||||
|
||||
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
|
||||
{
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
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.
|
||||
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;
|
||||
|
@@ -59,7 +59,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:
|
||||
@@ -86,14 +86,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();
|
||||
|
@@ -28,7 +28,7 @@ extern NetworkCompanyState *_network_company_states;
|
||||
|
||||
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;
|
||||
@@ -46,7 +46,7 @@ void NetworkReboot();
|
||||
void NetworkDisconnect(bool blocking = false, 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);
|
||||
|
||||
@@ -56,7 +56,7 @@ bool NetworkClientConnectGame(const std::string &connection_string, CompanyID de
|
||||
void NetworkClientJoinGame();
|
||||
void NetworkClientRequestMove(CompanyID company, const std::string &pass = "");
|
||||
void NetworkClientSendRcon(const std::string &password, const std::string &command);
|
||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data = 0);
|
||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data = 0);
|
||||
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
|
||||
bool NetworkCompanyIsPassworded(CompanyID company_id);
|
||||
uint NetworkMaxCompaniesAllowed();
|
||||
@@ -75,7 +75,7 @@ bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_na
|
||||
|
||||
void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
|
||||
void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const std::string &string);
|
||||
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64 data = 0, bool from_admin = false);
|
||||
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64_t data = 0, bool from_admin = false);
|
||||
void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg);
|
||||
|
||||
void NetworkServerKickClient(ClientID client_id, const std::string &reason);
|
||||
|
@@ -565,7 +565,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());
|
||||
|
||||
@@ -824,7 +824,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;
|
||||
|
||||
@@ -1196,7 +1196,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();
|
||||
@@ -2145,9 +2145,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;
|
||||
@@ -2165,7 +2165,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:
|
||||
|
@@ -34,7 +34,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, ..)
|
||||
};
|
||||
|
@@ -65,39 +65,39 @@ 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 uint32_t _sync_seed_1;
|
||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
||||
extern uint32 _sync_seed_2;
|
||||
extern uint32_t _sync_seed_2;
|
||||
#endif
|
||||
extern uint32 _sync_frame;
|
||||
extern uint32_t _sync_frame;
|
||||
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();
|
||||
@@ -111,7 +111,7 @@ struct CommandPacket {
|
||||
CommandPacket() : next(nullptr), company(INVALID_COMPANY), frame(0), my_cmd(false) {}
|
||||
CommandPacket *next; ///< the next command packet (if in queue)
|
||||
CompanyID company; ///< company that is executing the command
|
||||
uint32 frame; ///< the frame in which this packet is executed
|
||||
uint32_t frame; ///< the frame in which this packet is executed
|
||||
bool my_cmd; ///< did the command originate from "me"
|
||||
|
||||
Commands cmd; ///< command being executed.
|
||||
@@ -127,15 +127,15 @@ void NetworkSyncCommandQueue(NetworkClientSocket *cs);
|
||||
void NetworkReplaceCommandClientId(CommandPacket &cp, ClientID client_id);
|
||||
|
||||
void ShowNetworkError(StringID error_string);
|
||||
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str = "", int64 data = 0, const std::string &data_str = "");
|
||||
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str = "", int64_t data = 0, const std::string &data_str = "");
|
||||
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::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32_t password_game_seed);
|
||||
|
||||
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();
|
||||
|
||||
|
@@ -197,7 +197,7 @@ struct PacketWriter : SaveFilter {
|
||||
|
||||
/* Fast-track the size to the client. */
|
||||
this->current = new Packet(PACKET_SERVER_MAP_SIZE);
|
||||
this->current->Send_uint32((uint32)this->total_size);
|
||||
this->current->Send_uint32((uint32_t)this->total_size);
|
||||
this->PrependQueue();
|
||||
}
|
||||
};
|
||||
@@ -658,7 +658,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCommand(const CommandPacke
|
||||
* @param msg The actual message.
|
||||
* @param data Arbitrary extra data.
|
||||
*/
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64 data)
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64_t data)
|
||||
{
|
||||
if (this->status < STATUS_PRE_ACTIVE) return NETWORK_RECV_STATUS_OKAY;
|
||||
|
||||
@@ -747,7 +747,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)
|
||||
{
|
||||
Packet *p = new Packet(PACKET_SERVER_RCON);
|
||||
|
||||
@@ -777,7 +777,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyUpdate()
|
||||
{
|
||||
Packet *p = new Packet(PACKET_SERVER_COMPANY_UPDATE);
|
||||
|
||||
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;
|
||||
@@ -838,7 +838,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) || _openttd_newgrf_version != newgrf_version) {
|
||||
@@ -1136,7 +1136,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) {
|
||||
@@ -1152,7 +1152,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
|
||||
@@ -1185,7 +1185,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(Packet *p)
|
||||
* @param data Arbitrary data.
|
||||
* @param from_admin Whether the origin is an admin or not.
|
||||
*/
|
||||
void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, const std::string &msg, ClientID from_id, int64 data, bool from_admin)
|
||||
void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, const std::string &msg, ClientID from_id, int64_t data, bool from_admin)
|
||||
{
|
||||
const NetworkClientInfo *ci, *ci_own, *ci_to;
|
||||
|
||||
@@ -1323,7 +1323,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet *p)
|
||||
int dest = p->Recv_uint32();
|
||||
|
||||
std::string msg = p->Recv_string(NETWORK_CHAT_LENGTH);
|
||||
int64 data = p->Recv_uint64();
|
||||
int64_t data = p->Recv_uint64();
|
||||
|
||||
NetworkClientInfo *ci = this->GetInfo();
|
||||
switch (action) {
|
||||
|
@@ -64,7 +64,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
|
||||
@@ -87,12 +87,12 @@ 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 SendMove(ClientID client_id, CompanyID company_id);
|
||||
|
||||
NetworkRecvStatus SendClientInfo(NetworkClientInfo *ci);
|
||||
NetworkRecvStatus SendError(NetworkErrorCode error, const std::string &reason = {});
|
||||
NetworkRecvStatus SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64 data);
|
||||
NetworkRecvStatus SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64_t data);
|
||||
NetworkRecvStatus SendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg);
|
||||
NetworkRecvStatus SendJoin(ClientID client_id);
|
||||
NetworkRecvStatus SendFrame();
|
||||
|
@@ -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>();
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
class ClientNetworkStunSocketHandler : public NetworkStunSocketHandler {
|
||||
private:
|
||||
std::string token; ///< Token of this STUN handler.
|
||||
uint8 family = AF_UNSPEC; ///< Family 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:
|
||||
@@ -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 */
|
||||
|
@@ -272,7 +272,7 @@ static void SurveyGrfs(nlohmann::json &survey)
|
||||
|
||||
grf["is_static"] = HasBit(c->flags, GCF_STATIC);
|
||||
|
||||
std::vector<uint32> parameters;
|
||||
std::vector<uint32_t> parameters;
|
||||
for (int i = 0; i < c->num_params; i++) {
|
||||
parameters.push_back(c->param[i]);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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 */
|
||||
|
@@ -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;
|
||||
|
@@ -33,7 +33,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 {
|
||||
|
Reference in New Issue
Block a user