mirror of https://github.com/OpenTTD/OpenTTD
(svn r21970) -Fix [FS#4464]: Crash when a multiplayer company goes bankrupt with 'you' in it
parent
bdf5a1c2f7
commit
50d646ca7b
|
@ -285,13 +285,16 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
|
||||||
/* use INVALID_OWNER as new_owner to delete the company. */
|
/* use INVALID_OWNER as new_owner to delete the company. */
|
||||||
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
||||||
{
|
{
|
||||||
|
/* We need to set _current_company to old_owner before we try to move
|
||||||
|
* the client. This is needed as it needs to know whether "you" really
|
||||||
|
* are the current local company. */
|
||||||
|
Backup<CompanyByte> cur_company(_current_company, old_owner, FILE_LINE);
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
/* In all cases, make spectators of clients connected to that company */
|
/* In all cases, make spectators of clients connected to that company */
|
||||||
if (_networking) NetworkClientsToSpectators(old_owner);
|
if (_networking) NetworkClientsToSpectators(old_owner);
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
Town *t;
|
Town *t;
|
||||||
Backup<CompanyByte> cur_company(_current_company, old_owner, FILE_LINE);
|
|
||||||
|
|
||||||
assert(old_owner != new_owner);
|
assert(old_owner != new_owner);
|
||||||
|
|
||||||
|
@ -520,8 +523,16 @@ static void CompanyCheckBankrupt(Company *c)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Actually remove the company. */
|
/* Actually remove the company, but not when we're a network client.
|
||||||
DoCommand(0, 2 | (c->index << 16), 0, DC_EXEC, CMD_COMPANY_CTRL);
|
* In case of network clients we will be getting a command from the
|
||||||
|
* server. It is done in this way as we are called from the
|
||||||
|
* StateGameLoop which can't change the current company, and thus
|
||||||
|
* updating the local company triggers an assert later on. In the
|
||||||
|
* case of a network game the command will be processed at a time
|
||||||
|
* that changing the current company is okay. In case of single
|
||||||
|
* player we are sure (the above check) that we are not the local
|
||||||
|
* company and thus we won't be moved. */
|
||||||
|
if (!_networking || _network_server) DoCommandP(0, 2 | (c->index << 16), 0, CMD_COMPANY_CTRL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue