Merge branch 'openttd'

This commit is contained in:
dP
2021-08-19 23:05:44 +03:00
45 changed files with 396 additions and 104 deletions

View File

@@ -1550,13 +1550,12 @@ static void NetworkAutoCleanCompanies()
bool NetworkMakeClientNameUnique(std::string &name)
{
bool is_name_unique = false;
uint number = 0;
std::string original_name = name;
while (!is_name_unique) {
for (uint number = 1; !is_name_unique && number <= MAX_CLIENTS; number++) { // Something's really wrong when there're more names than clients
is_name_unique = true;
for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
if (ci->client_name.compare(name) == 0) {
if (ci->client_name == name) {
/* Name already in use */
is_name_unique = false;
break;
@@ -1565,7 +1564,7 @@ bool NetworkMakeClientNameUnique(std::string &name)
/* Check if it is the same as the server-name */
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER);
if (ci != nullptr) {
if (ci->client_name.compare(name) == 0) is_name_unique = false; // name already in use
if (ci->client_name == name) is_name_unique = false; // name already in use
}
if (!is_name_unique) {
@@ -1670,9 +1669,9 @@ void NetworkServer_Tick(bool send_frame)
/* Client did still not report in within the specified limit. */
IConsolePrint(CC_WARNING, cs->last_packet + std::chrono::milliseconds(lag * MILLISECONDS_PER_TICK) > std::chrono::steady_clock::now() ?
/* A packet was received in the last three game days, so the client is likely lagging behind. */
"Client #%u (IP: %s) is dropped because the client's game state is more than %d ticks behind." :
"Client #{} (IP: {}) is dropped because the client's game state is more than {} ticks behind." :
/* No packet was received in the last three game days; sounds like a lost connection. */
"Client #%u (IP: %s) is dropped because the client did not respond for more than %d ticks.",
"Client #{} (IP: {}) is dropped because the client did not respond for more than {} ticks.",
cs->client_id, cs->GetClientIP(), lag);
cs->SendError(NETWORK_ERROR_TIMEOUT_COMPUTER);
continue;