Merge branch 'master' into jgrpp

Remove 'byte' typedef
This commit is contained in:
Jonathan G Rennison
2024-05-07 17:21:50 +01:00
376 changed files with 2220 additions and 2152 deletions

View File

@@ -46,10 +46,10 @@ static const std::string NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.o
static const size_t TCP_MTU = 32767; ///< Number of bytes we can pack in a single TCP packet
static const size_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 = 7; ///< What version of game-info do we use?
static const byte NETWORK_COORDINATOR_VERSION = 6; ///< What version of game-coordinator-protocol do we use?
static const byte NETWORK_SURVEY_VERSION = 2; ///< What version of the survey do we use?
static const uint8_t NETWORK_GAME_ADMIN_VERSION = 3; ///< What version of the admin network do we use?
static const uint8_t NETWORK_GAME_INFO_VERSION = 7; ///< What version of game-info do we use?
static const uint8_t NETWORK_COORDINATOR_VERSION = 6; ///< What version of game-coordinator-protocol do we use?
static const uint8_t NETWORK_SURVEY_VERSION = 2; ///< What version of the survey do we use?
static const uint NETWORK_NAME_LENGTH = 80; ///< The maximum length of the server name and map name, in bytes including '\0'
static const uint NETWORK_COMPANY_NAME_LENGTH = 128; ///< The maximum length of the company name, in bytes including '\0'

View File

@@ -155,7 +155,7 @@ const NetworkServerGameInfo &GetCurrentNetworkServerGameInfo()
* - invite_code
* These don't need to be updated manually here.
*/
_network_game_info.companies_on = (byte)Company::GetNumItems();
_network_game_info.companies_on = (uint8_t)Company::GetNumItems();
_network_game_info.spectators_on = NetworkSpectatorCount();
_network_game_info.calendar_date = CalTime::CurDate();
_network_game_info.ticks_playing = _scaled_tick_counter;
@@ -338,7 +338,7 @@ void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfo
{
static const CalTime::Date MAX_DATE = CalTime::ConvertYMDToDate(CalTime::MAX_YEAR, 11, 31); // December is month 11
byte game_info_version = p.Recv_uint8();
uint8_t game_info_version = p.Recv_uint8();
NewGRFSerializationType newgrf_serialisation = NST_GRFID_MD5;
/*

View File

@@ -103,12 +103,12 @@ struct NetworkServerGameInfo {
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?
bool use_password; ///< Is this server passworded?
byte clients_on; ///< Current count of clients on server
byte clients_max; ///< Max clients allowed on server
byte companies_on; ///< How many started companies do we have
byte companies_max; ///< Max companies allowed on server
byte spectators_on; ///< How many spectators do we have?
byte landscape; ///< The used landscape
uint8_t clients_on; ///< Current count of clients on server
uint8_t clients_max; ///< Max clients allowed on server
uint8_t companies_on; ///< How many started companies do we have
uint8_t companies_max; ///< Max companies allowed on server
uint8_t spectators_on; ///< How many spectators do we have?
uint8_t landscape; ///< The used landscape
int gamescript_version; ///< Version of the gamescript.
std::string gamescript_name; ///< Name of the gamescript.
};

View File

@@ -49,7 +49,7 @@ private:
/** The current read/write position in the packet */
PacketSize pos;
/** The buffer of this packet. */
std::vector<byte> buffer;
std::vector<uint8_t> buffer;
/** The limit for the packet size. */
size_t limit;
@@ -65,10 +65,10 @@ public:
/* Sending/writing of packets */
void PrepareToSend();
std::vector<byte> &GetSerialisationBuffer() { return this->buffer; }
std::vector<uint8_t> &GetSerialisationBuffer() { return this->buffer; }
size_t GetSerialisationLimit() const { return this->limit; }
const byte *GetDeserialisationBuffer() const { return this->buffer.data(); }
const uint8_t *GetDeserialisationBuffer() const { return this->buffer.data(); }
size_t GetDeserialisationBufferSize() const { return this->buffer.size(); }
PacketSize &GetDeserialisationPosition() { return this->pos; }
bool CanDeserialiseBytes(size_t bytes_to_read, bool raise_error) { return this->CanReadFromPacket(bytes_to_read, raise_error); }
@@ -89,7 +89,7 @@ public:
size_t RemainingBytesToTransfer() const;
const byte *GetBufferData() const { return this->buffer.data(); }
const uint8_t *GetBufferData() const { return this->buffer.data(); }
PacketSize GetRawPos() const { return this->pos; }
void ReserveBuffer(size_t size) { this->buffer.reserve(size); }
@@ -194,14 +194,14 @@ public:
struct SubPacketDeserialiser : public BufferDeserialisationHelper<SubPacketDeserialiser> {
NetworkSocketHandler *cs;
const byte *data;
const uint8_t *data;
size_t size;
PacketSize pos;
SubPacketDeserialiser(Packet &p, const byte *data, size_t size, PacketSize pos = 0) : cs(p.GetParentSocket()), data(data), size(size), pos(pos) {}
SubPacketDeserialiser(Packet &p, const std::vector<byte> &buffer, PacketSize pos = 0) : cs(p.GetParentSocket()), data(buffer.data()), size(buffer.size()), pos(pos) {}
SubPacketDeserialiser(Packet &p, const uint8_t *data, size_t size, PacketSize pos = 0) : cs(p.GetParentSocket()), data(data), size(size), pos(pos) {}
SubPacketDeserialiser(Packet &p, const std::vector<uint8_t> &buffer, PacketSize pos = 0) : cs(p.GetParentSocket()), data(buffer.data()), size(buffer.size()), pos(pos) {}
const byte *GetDeserialisationBuffer() const { return this->data; }
const uint8_t *GetDeserialisationBuffer() const { return this->data; }
size_t GetDeserialisationBufferSize() const { return this->size; }
PacketSize &GetDeserialisationPosition() { return this->pos; }
bool CanDeserialiseBytes(size_t bytes_to_read, bool raise_error);

View File

@@ -25,7 +25,7 @@ protected:
/**
* Client requesting a list of content info:
* byte type
* uint8_t type
* uint32_t openttd version (or 0xFFFFFFFF if using a list)
* Only if the above value is 0xFFFFFFFF:
* uint8_t count
@@ -76,7 +76,7 @@ protected:
/**
* Server sending list of content info:
* byte type (invalid ID == does not exist)
* uint8_t type (invalid ID == does not exist)
* uint32_t id
* uint32_t file_size
* string name (max 32 characters)

View File

@@ -277,8 +277,8 @@ protected:
* 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.
* uint8_t[16] MD5 checksum of the NewGRF
* string Name of the NewGRF.
*
* The lookup table built using these packets are used by the deserialisation
* of the NewGRFs for servers in the GC_LISTING. These updates are additive,

View File

@@ -239,7 +239,7 @@ void NetworkUDPSocketHandler::Receive_EX_MULTI(Packet &p, NetworkAddress &client
Packet merged(this, TCP_MTU, 0);
merged.ReserveBuffer(total_payload);
for (auto &frag : fs.fragments) {
merged.Send_binary((const byte *)frag.data(), frag.size());
merged.Send_binary((const uint8_t *)frag.data(), frag.size());
}
merged.ParsePacketSize();
merged.PrepareToRead();

View File

@@ -101,7 +101,7 @@ bool _record_sync_records = false;
static_assert((int)NETWORK_COMPANY_NAME_LENGTH == MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH);
/** The amount of clients connected */
byte _network_clients_connected = 0;
uint8_t _network_clients_connected = 0;
extern std::string GenerateUid(std::string_view subject);
@@ -151,9 +151,9 @@ NetworkClientInfo::~NetworkClientInfo()
return nullptr;
}
byte NetworkSpectatorCount()
uint8_t NetworkSpectatorCount()
{
byte count = 0;
uint8_t count = 0;
for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
if (ci->client_playas == COMPANY_SPECTATOR) count++;
@@ -233,7 +233,7 @@ std::vector<uint8_t> GenerateGeneralPasswordHash(const std::string &password, co
{
if (password.empty()) return {};
std::vector<byte> data;
std::vector<uint8_t> data;
data.reserve(password_server_id.size() + password.size() + 10);
BufferSerialiser buffer(data);
@@ -241,7 +241,7 @@ std::vector<uint8_t> GenerateGeneralPasswordHash(const std::string &password, co
buffer.Send_string(password_server_id);
buffer.Send_string(password);
std::vector<byte> output;
std::vector<uint8_t> output;
output.resize(64);
crypto_blake2b(output.data(), output.size(), data.data(), data.size());
@@ -295,8 +295,8 @@ void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send,
SetDParam(1, data.auxdata >> 16);
SetDParamStr(0, GetString(STR_NETWORK_MESSAGE_MONEY_GIVE_SRC_DESCRIPTION));
extern byte GetCurrentGrfLangID();
byte lang_id = GetCurrentGrfLangID();
extern uint8_t GetCurrentGrfLangID();
uint8_t lang_id = GetCurrentGrfLangID();
bool use_specific_string = lang_id <= 2 || lang_id == 0x15 || lang_id == 0x3A || lang_id == 0x3D; // English, German, Korean, Czech
if (use_specific_string && self_send) {
strid = STR_NETWORK_MESSAGE_GAVE_MONEY_AWAY;
@@ -1254,7 +1254,7 @@ void NetworkGameLoop()
if (aux_str[0] == '<' && aux_str[1] != '>') {
auto aux = std::make_unique<CommandAuxiliarySerialised>();
for (const char *data = aux_str + 1; data[0] != 0 && data[1] != 0 && data[0] != '>'; data += 2) {
byte e = 0;
uint8_t e = 0;
std::from_chars(data, data + 2, e, 16);
aux->serialised_data.emplace_back(e);
}

View File

@@ -33,7 +33,7 @@
AdminIndex _redirect_console_to_admin = INVALID_ADMIN_ID;
/** The amount of admins connected. */
byte _network_admins_connected = 0;
uint8_t _network_admins_connected = 0;
/** The pool with sockets/clients. */
NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket");

View File

@@ -51,10 +51,10 @@ static void ResetClientConnectionKeyStates();
struct PacketReader : LoadFilter {
static const size_t CHUNK = 32 * 1024; ///< 32 KiB chunks of memory.
std::vector<byte *> blocks; ///< Buffer with blocks of allocated memory.
byte *buf; ///< Buffer we're going to write to/read from.
byte *bufe; ///< End of the buffer we write to/read from.
byte **block; ///< The block we're reading from/writing to.
std::vector<uint8_t *> blocks; ///< Buffer with blocks of allocated memory.
uint8_t *buf; ///< Buffer we're going to write to/read from.
uint8_t *bufe; ///< End of the buffer we write to/read from.
uint8_t **block; ///< The block we're reading from/writing to.
size_t written_bytes; ///< The total number of bytes we've written.
size_t read_bytes; ///< The total number of read bytes.
@@ -98,18 +98,18 @@ struct PacketReader : LoadFilter {
if (p.RemainingBytesToTransfer() == 0) return;
/* Allocate a new chunk and add the remaining data. */
this->blocks.push_back(this->buf = CallocT<byte>(CHUNK));
this->blocks.push_back(this->buf = CallocT<uint8_t>(CHUNK));
this->bufe = this->buf + CHUNK;
p.TransferOutWithLimit(TransferOutMemCopy, this->bufe - this->buf, this);
}
size_t Read(byte *rbuf, size_t size) override
size_t Read(uint8_t *rbuf, size_t size) override
{
/* Limit the amount to read to whatever we still have. */
size_t ret_size = size = std::min(this->written_bytes - this->read_bytes, size);
this->read_bytes += ret_size;
const byte *rbufe = rbuf + ret_size;
const uint8_t *rbufe = rbuf + ret_size;
while (rbuf != rbufe) {
if (this->buf == this->bufe) {
@@ -396,7 +396,7 @@ static uint32_t last_ack_frame;
/** One bit of 'entropy' used to generate a salt for the company passwords. */
static uint32_t _company_password_game_seed;
/** Network server's x25519 public key, used for key derivation */
static std::array<byte, 32> _server_x25519_pub_key;
static std::array<uint8_t, 32> _server_x25519_pub_key;
/** Key message ID counter */
static uint64_t _next_key_message_id;
/** The other bit of 'entropy' used to generate a salt for the server, rcon, and settings passwords. */
@@ -431,14 +431,14 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendKeyPasswordPacket(PacketTy
crypto_blake2b_update(&ctx, shared_secret.data(), shared_secret.size()); // Shared secret
crypto_blake2b_update(&ctx, keys.x25519_pub_key.data(), keys.x25519_pub_key.size()); // Client pub key
crypto_blake2b_update(&ctx, _server_x25519_pub_key.data(), _server_x25519_pub_key.size()); // Server pub key
crypto_blake2b_update(&ctx, (const byte *)password.data(), password.size()); // Password
crypto_blake2b_update(&ctx, (const uint8_t *)password.data(), password.size()); // Password
crypto_blake2b_final (&ctx, ss.shared_data.data());
/* NetworkSharedSecrets::shared_data now contains 2 keys worth of hash, first key is used for up direction, second key for down direction (if any) */
crypto_wipe(shared_secret.data(), shared_secret.size());
std::vector<byte> message;
std::vector<uint8_t> message;
BufferSerialiser buffer(message);
/* Put monotonically increasing counter in message */
@@ -623,7 +623,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendDesyncLog(const std::strin
auto p = std::make_unique<Packet>(PACKET_CLIENT_DESYNC_LOG, TCP_MTU);
size_t size = std::min<size_t>(log.size() - offset, TCP_MTU - 2 - p->Size());
p->Send_uint16((uint16_t)size);
p->Send_binary((const byte *)(log.data() + offset), size);
p->Send_binary((const uint8_t *)(log.data() + offset), size);
my_client->SendPacket(std::move(p));
offset += size;
@@ -1239,7 +1239,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_DESYNC_LOG(Pack
{
uint size = p.Recv_uint16();
this->server_desync_log.resize(this->server_desync_log.size() + size);
p.Recv_binary((byte *)(this->server_desync_log.data() + this->server_desync_log.size() - size), size);
p.Recv_binary((uint8_t *)(this->server_desync_log.data() + this->server_desync_log.size() - size), size);
DEBUG(net, 2, "Received %u bytes of server desync log", size);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -1324,7 +1324,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_RCON(Packet &p)
p.Recv_binary(nonce);
p.Recv_binary(mac);
std::vector<byte> message = p.Recv_binary(p.RemainingBytesToTransfer());
std::vector<uint8_t> message = p.Recv_binary(p.RemainingBytesToTransfer());
static_assert(std::tuple_size<decltype(NetworkSharedSecrets::shared_data)>::value == 64);
if (crypto_aead_unlock(message.data(), mac.data(), this->last_rcon_shared_secrets.shared_data.data() + 32, nonce.data(), nullptr, 0, message.data(), message.size()) == 0) {

View File

@@ -15,9 +15,9 @@
/** Class for handling the client side of the game connection. */
class ClientNetworkGameSocketHandler : public NetworkGameSocketHandler {
private:
std::string connection_string; ///< Address we are connected to.
std::string connection_string; ///< Address we are connected to.
std::shared_ptr<struct PacketReader> savegame; ///< Packet reader for reading the savegame.
byte token; ///< The token we need to send back to the server to prove we're the right client.
uint8_t token; ///< The token we need to send back to the server to prove we're the right client.
NetworkSharedSecrets last_rcon_shared_secrets; ///< Keys for last rcon (and incoming replies)
/** Status of the connection with the server. */

View File

@@ -275,7 +275,7 @@ const char *NetworkGameSocketHandler::ReceiveCommand(Packet &p, CommandPacket &c
StringValidationSettings settings = (!_network_server && GetCommandFlags(cp.cmd) & CMD_STR_CTRL) != 0 ? SVS_ALLOW_CONTROL_CODE | SVS_REPLACE_WITH_QUESTION_MARK : SVS_REPLACE_WITH_QUESTION_MARK;
p.Recv_string(cp.text, settings);
byte callback = p.Recv_uint8();
uint8_t callback = p.Recv_uint8();
if (callback >= lengthof(_callback_table)) return "invalid callback";
cp.callback = _callback_table[callback];
@@ -306,7 +306,7 @@ void NetworkGameSocketHandler::SendCommand(Packet &p, const CommandPacket &cp)
p.Send_uint32(cp.tile);
p.Send_string(cp.text.c_str());
byte callback = 0;
uint8_t callback = 0;
while (callback < lengthof(_callback_table) && _callback_table[callback] != cp.callback) {
callback++;
}

View File

@@ -205,7 +205,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentType type)
this->Connect();
auto p = std::make_unique<Packet>(PACKET_CONTENT_CLIENT_INFO_LIST);
p->Send_uint8 ((byte)type);
p->Send_uint8 ((uint8_t)type);
p->Send_uint32(0xffffffff);
p->Send_uint8 (2);
p->Send_string("vanilla");
@@ -237,7 +237,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(uint count, const Con
* A packet begins with the packet size and a byte for the type.
* 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_t)) / sizeof(uint32_t));
uint p_count = std::min<uint>(count, (TCP_MTU - sizeof(PacketSize) - sizeof(uint8_t) - sizeof(uint16_t)) / sizeof(uint32_t));
auto p = std::make_unique<Packet>(PACKET_CONTENT_CLIENT_INFO_ID, TCP_MTU);
p->Send_uint16(p_count);
@@ -263,7 +263,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
this->Connect();
const uint max_per_packet = std::min<uint>(255, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8_t)) /
const uint max_per_packet = std::min<uint>(255, (TCP_MTU - sizeof(PacketSize) - sizeof(uint8_t) - sizeof(uint8_t)) /
(sizeof(uint8_t) + sizeof(uint32_t) + (send_md5sum ? MD5_HASH_BYTES : 0))) - 1;
uint offset = 0;
@@ -275,7 +275,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
for (uint i = 0; i < to_send; i++) {
const ContentInfo *ci = (*cv)[offset + i];
p->Send_uint8((byte)ci->type);
p->Send_uint8((uint8_t)ci->type);
p->Send_uint32(ci->unique_id);
if (!send_md5sum) continue;
@@ -369,7 +369,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const Co
* A packet begins with the packet size and a byte for the type.
* 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_t)) / sizeof(uint32_t));
uint p_count = std::min<uint>(count, (TCP_MTU - sizeof(PacketSize) - sizeof(uint8_t) - sizeof(uint16_t)) / sizeof(uint32_t));
auto p = std::make_unique<Packet>(PACKET_CONTENT_CLIENT_CONTENT, TCP_MTU);
p->Send_uint16(p_count);
@@ -426,7 +426,7 @@ static bool GunzipFile(const ContentInfo *ci)
if (fin == nullptr || fout == nullptr) {
ret = false;
} else {
byte buff[8192];
uint8_t buff[8192];
for (;;) {
int read = gzread(fin, buff, sizeof(buff));
if (read == 0) {

View File

@@ -36,7 +36,7 @@ extern StringList _network_bind_list;
extern StringList _network_host_list;
extern StringList _network_ban_list;
byte NetworkSpectatorCount();
uint8_t NetworkSpectatorCount();
uint NetworkClientCount();
bool NetworkIsValidClientName(const std::string_view client_name);
bool NetworkValidateOurClientName();

View File

@@ -139,7 +139,7 @@ struct PacketWriter : SaveFilter {
return last_packet;
}
void Write(byte *buf, size_t size) override
void Write(uint8_t *buf, size_t size) override
{
std::lock_guard<std::mutex> lock(this->mutex);
@@ -148,7 +148,7 @@ struct PacketWriter : SaveFilter {
if (this->current == nullptr) this->current = std::make_unique<Packet>(PACKET_SERVER_MAP_DATA, TCP_MTU);
byte *bufe = buf + size;
uint8_t *bufe = buf + size;
while (buf != bufe) {
size_t written = this->current->Send_binary_until_full(buf, bufe);
buf += written;
@@ -240,14 +240,14 @@ bool ServerNetworkGameSocketHandler::ParseKeyPasswordPacket(Packet &p, NetworkSh
crypto_blake2b_update(&ctx, shared_secret.data(), shared_secret.size()); // Shared secret
crypto_blake2b_update(&ctx, client_pub_key.data(), client_pub_key.size()); // Client pub key
crypto_blake2b_update(&ctx, keys.x25519_pub_key.data(), keys.x25519_pub_key.size()); // Server pub key
crypto_blake2b_update(&ctx, (const byte *)password.data(), password.size()); // Password
crypto_blake2b_update(&ctx, (const uint8_t *)password.data(), password.size()); // Password
crypto_blake2b_final (&ctx, ss.shared_data.data());
/* NetworkSharedSecrets::shared_data now contains 2 keys worth of hash, first key is used for up direction, second key for down direction (if any) */
crypto_wipe(shared_secret.data(), shared_secret.size());
std::vector<byte> message = p.Recv_binary(p.RemainingBytesToTransfer());
std::vector<uint8_t> message = p.Recv_binary(p.RemainingBytesToTransfer());
if (message.size() < 8) return false;
if ((message.size() == 8) != (payload == nullptr)) {
/* Payload expected but not present, or vice versa, just give up */
@@ -329,7 +329,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
/* We just lost one client :( */
if (this->status >= STATUS_AUTHORIZED) _network_game_info.clients_on--;
extern byte _network_clients_connected;
extern uint8_t _network_clients_connected;
_network_clients_connected--;
this->SendPackets(true);
@@ -347,7 +347,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
*/
/* static */ bool ServerNetworkGameSocketHandler::AllowConnection()
{
extern byte _network_clients_connected;
extern uint8_t _network_clients_connected;
bool accept = _network_clients_connected < MAX_CLIENTS;
/* We can't go over the MAX_CLIENTS limit here. However, the
@@ -476,7 +476,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendDesyncLog(const std::strin
auto p = std::make_unique<Packet>(PACKET_SERVER_DESYNC_LOG, TCP_MTU);
size_t size = std::min<size_t>(log.size() - offset, TCP_MTU - 2 - p->Size());
p->Send_uint16(static_cast<uint16_t>(size));
p->Send_binary((const byte *)(log.data() + offset), size);
p->Send_binary((const uint8_t *)(log.data() + offset), size);
this->SendPacket(std::move(p));
offset += size;
@@ -845,7 +845,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16_t colour
{
assert(this->rcon_reply_key != nullptr);
std::vector<byte> message;
std::vector<uint8_t> message;
BufferSerialiser buffer(message);
buffer.Send_uint16(colour);
buffer.Send_string(command);
@@ -1294,7 +1294,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_LOG(Pack
{
uint size = p.Recv_uint16();
this->desync_log.resize(this->desync_log.size() + size);
p.Recv_binary((byte *)(this->desync_log.data() + this->desync_log.size() - size), size);
p.Recv_binary((uint8_t *)(this->desync_log.data() + this->desync_log.size() - size), size);
DEBUG(net, 2, "Received %u bytes of client desync log", size);
this->receive_limit += p.Size();
return NETWORK_RECV_STATUS_OKAY;
@@ -1760,7 +1760,7 @@ void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
/* Go through all vehicles and count the type of vehicles */
for (const Vehicle *v : Vehicle::IterateFrontOnly()) {
if (!Company::IsValidID(v->owner) || !v->IsPrimaryVehicle() || HasBit(v->subtype, GVSF_VIRTUAL)) continue;
byte type = 0;
uint8_t type = 0;
switch (v->type) {
case VEH_TRAIN: type = NETWORK_VEH_TRAIN; break;
case VEH_ROAD: type = RoadVehicle::From(v)->IsBus() ? NETWORK_VEH_BUS : NETWORK_VEH_LORRY; break;

View File

@@ -24,7 +24,7 @@ extern NetworkClientSocketPool _networkclientsocket_pool;
class ServerNetworkGameSocketHandler : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkGameSocketHandler, public TCPListenHandler<ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED> {
NetworkGameKeys intl_keys;
uint64_t min_key_message_id = 0;
byte *rcon_reply_key = nullptr;
uint8_t *rcon_reply_key = nullptr;
protected:
NetworkRecvStatus Receive_CLIENT_JOIN(Packet &p) override;
@@ -76,8 +76,8 @@ public:
static const char *GetClientStatusName(ClientStatus status);
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
uint8_t lag_test; ///< Byte used for lag-testing the client
uint8_t last_token; ///< The last random token we did send to verify the client is listening
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; conceptually more a bucket to gather commands in, after which the whole bucket is sent to the client.

View File

@@ -88,7 +88,7 @@ enum NetworkPasswordType {
* Destination of our chat messages.
* @warning The values of the enum items are part of the admin network API. Only append at the end.
*/
enum DestType : byte {
enum DestType : uint8_t {
DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All)
DESTTYPE_TEAM, ///< Send message/notice to everyone playing the same company (Team)
DESTTYPE_CLIENT, ///< Send message/notice to only a certain client (Private)