Fix #6544: Don't join AI company when loading network game in singleplayer

This commit is contained in:
Tyler Trahan
2022-01-19 16:46:51 -07:00
committed by rubidium42
parent 5ea55f3948
commit ec90fb4c99
4 changed files with 41 additions and 10 deletions

View File

@@ -823,10 +823,12 @@ bool AfterLoadGame()
* a company does not exist yet. So create one here.
* 1 exception: network-games. Those can have 0 companies
* But this exception is not true for non-dedicated network servers! */
if (!Company::IsValidID(COMPANY_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated))) {
DoStartupNewCompany(false);
Company *c = Company::Get(COMPANY_FIRST);
c->settings = _settings_client.company;
if (!_networking || (_networking && _network_server && !_network_dedicated)) {
CompanyID first_human_company = GetFirstPlayableCompanyID();
if (!Company::IsValidID(first_human_company)) {
Company *c = DoStartupNewCompany(false, first_human_company);
c->settings = _settings_client.company;
}
}
/* Fix the cache for cargo payments. */
@@ -1006,10 +1008,10 @@ bool AfterLoadGame()
/* When loading a game, _local_company is not yet set to the correct value.
* However, in a dedicated server we are a spectator, so nothing needs to
* happen. In case we are not a dedicated server, the local company always
* becomes company 0, unless we are in the scenario editor where all the
* companies are 'invalid'.
* becomes the first available company, unless we are in the scenario editor
* where all the companies are 'invalid'.
*/
Company *c = Company::GetIfValid(COMPANY_FIRST);
Company *c = Company::GetIfValid(GetFirstPlayableCompanyID());
if (!_network_dedicated && c != nullptr) {
c->settings = _settings_client.company;
}