1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-24 20:54:08 +01:00

Codechange: strongly type CompanyID

This commit is contained in:
Rubidium
2025-02-10 18:08:53 +01:00
committed by rubidium42
parent 5401ab1f7b
commit ab8177ea77
37 changed files with 92 additions and 97 deletions

View File

@@ -879,13 +879,13 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_IDENTIFY(Packet
if (this->HasClientQuit()) return NETWORK_RECV_STATUS_CLIENT_QUIT;
/* join another company does not affect these values */
switch (playas) {
case COMPANY_NEW_COMPANY: // New company
switch (playas.base()) {
case COMPANY_NEW_COMPANY.base(): // New company
if (Company::GetNumItems() >= _settings_client.network.max_companies) {
return this->SendError(NETWORK_ERROR_FULL);
}
break;
case COMPANY_SPECTATOR: // Spectator
case COMPANY_SPECTATOR.base(): // Spectator
break;
default: // Join another company (companies 1..MAX_COMPANIES (index 0..(MAX_COMPANIES-1)))
if (!Company::IsValidHumanID(playas)) {
@@ -918,7 +918,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_IDENTIFY(Packet
ci->client_name = client_name;
ci->client_playas = playas;
ci->public_key = this->peer_public_key;
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", TimerGameEconomy::date, TimerGameEconomy::date_fract, (int)ci->client_playas, ci->index);
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", TimerGameEconomy::date, TimerGameEconomy::date_fract, ci->client_playas, ci->index);
/* Make sure companies to which people try to join are not autocleaned */
Company *c = Company::GetIfValid(playas);
@@ -1531,7 +1531,7 @@ void NetworkUpdateClientInfo(ClientID client_id)
if (ci == nullptr) return;
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:04x}", TimerGameEconomy::date, TimerGameEconomy::date_fract, (int)ci->client_playas, client_id);
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:04x}", TimerGameEconomy::date, TimerGameEconomy::date_fract, ci->client_playas, client_id);
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
if (cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {