1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-19 18:32:35 +01:00

Fix: server's client is shown incorrectly in some cases

This commit is contained in:
Rubidium
2024-05-05 19:53:21 +02:00
committed by rubidium42
parent 4740eeaa43
commit 455e202e03
3 changed files with 29 additions and 10 deletions

View File

@@ -884,7 +884,7 @@ static void NetworkInitGameInfo()
/* There should be always space for the server. */
assert(NetworkClientInfo::CanAllocateItem());
NetworkClientInfo *ci = new NetworkClientInfo(CLIENT_ID_SERVER);
ci->client_playas = _network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST;
ci->client_playas = COMPANY_SPECTATOR;
ci->client_name = _settings_client.network.client_name;
}
@@ -987,6 +987,30 @@ bool NetworkServerStart()
return true;
}
/**
* Perform tasks when the server is started. This consists of things
* like putting the server's client in a valid company and resetting the restart time.
*/
void NetworkOnGameStart()
{
if (!_network_server) return;
/* Update the static game info to set the values from the new game. */
NetworkServerUpdateGameInfo();
ChangeNetworkRestartTime(true);
if (!_network_dedicated) {
Company *c = Company::GetIfValid(GetFirstPlayableCompanyID());
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER);
if (c != nullptr && ci != nullptr) {
ci->client_playas = c->index;
}
ShowClientList();
}
}
/* The server is rebooting...
* The only difference with NetworkDisconnect, is the packets that is sent */
void NetworkReboot()