Update to 1.11.0-beta1

This commit is contained in:
dP
2021-01-23 17:31:11 +03:00
parent d3c06c25c8
commit 5e4506f493
1045 changed files with 23534 additions and 60345 deletions

View File

@@ -68,7 +68,7 @@ struct PacketReader : LoadFilter {
assert(this->read_bytes == 0);
size_t in_packet = p->size - p->pos;
size_t to_write = min((size_t)(this->bufe - this->buf), in_packet);
size_t to_write = std::min<size_t>(this->bufe - this->buf, in_packet);
const byte *pbuf = p->buffer + p->pos;
this->written_bytes += in_packet;
@@ -93,7 +93,7 @@ struct PacketReader : LoadFilter {
size_t Read(byte *rbuf, size_t size) override
{
/* Limit the amount to read to whatever we still have. */
size_t ret_size = size = min(this->written_bytes - this->read_bytes, size);
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;
@@ -103,7 +103,7 @@ struct PacketReader : LoadFilter {
this->bufe = this->buf + CHUNK;
}
size_t to_write = min(this->bufe - this->buf, rbufe - rbuf);
size_t to_write = std::min(this->bufe - this->buf, rbufe - rbuf);
memcpy(rbuf, this->buf, to_write);
rbuf += to_write;
this->buf += to_write;
@@ -211,16 +211,24 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
default: errorno = NETWORK_ERROR_GENERAL; break;
}
/* This means we fucked up and the server closed the connection */
if (res != NETWORK_RECV_STATUS_SERVER_ERROR && res != NETWORK_RECV_STATUS_SERVER_FULL &&
res != NETWORK_RECV_STATUS_SERVER_BANNED) {
if (res == NETWORK_RECV_STATUS_SERVER_ERROR || res == NETWORK_RECV_STATUS_SERVER_FULL ||
res == NETWORK_RECV_STATUS_SERVER_BANNED) {
/* This means the server closed the connection. Emergency save is
* already created if this was appropriate during handling of the
* disconnect. */
this->CloseConnection(res);
} else {
/* This means we as client made a boo-boo. */
SendError(errorno);
/* Close connection before we make an emergency save, as the save can
* take a bit of time; better that the server doesn't stall while we
* are doing the save, and already disconnects us. */
this->CloseConnection(res);
ClientNetworkEmergencySave();
}
ClientNetworkEmergencySave();
_switch_mode = SM_MENU;
this->CloseConnection(res);
_networking = false;
}
@@ -323,7 +331,7 @@ const char *_network_join_server_password = nullptr;
const char *_network_join_company_password = nullptr;
/** Make sure the server ID length is the same as a md5 hash. */
assert_compile(NETWORK_SERVER_ID_LENGTH == 16 * 2 + 1);
static_assert(NETWORK_SERVER_ID_LENGTH == 16 * 2 + 1);
/***********
* Sending functions
@@ -540,7 +548,7 @@ bool ClientNetworkGameSocketHandler::IsConnected()
* DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
************/
extern bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = nullptr);
extern bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = nullptr);
NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FULL(Packet *p)
{
@@ -681,7 +689,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR(Packet *p
STR_NETWORK_ERROR_TIMEOUT_MAP, // NETWORK_ERROR_TIMEOUT_MAP
STR_NETWORK_ERROR_TIMEOUT_JOIN, // NETWORK_ERROR_TIMEOUT_JOIN
};
assert_compile(lengthof(network_error_strings) == NETWORK_ERROR_END);
static_assert(lengthof(network_error_strings) == NETWORK_ERROR_END);
NetworkErrorCode error = (NetworkErrorCode)p->Recv_uint8();
@@ -866,7 +874,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
/* The map is done downloading, load it */
ClearErrorMessages();
bool load_success = SafeLoad(nullptr, SLO_LOAD, DFT_GAME_FILE, GM_NORMAL, NO_DIRECTORY, lf);
bool load_success = SafeLoad({}, SLO_LOAD, DFT_GAME_FILE, GM_NORMAL, NO_DIRECTORY, lf);
/* Long savegame loads shouldn't affect the lag calculation! */
this->last_packet = _realtime_tick;
@@ -992,11 +1000,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p)
ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
break;
/* For speaking to company or giving money, we need the company-name */
case NETWORK_ACTION_GIVE_MONEY:
if (!Company::IsValidID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
FALLTHROUGH;
/* For speaking to company, we need the company-name */
case NETWORK_ACTION_CHAT_COMPANY: {
StringID str = Company::IsValidID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);