diff options
author | frosch <frosch@openttd.org> | 2011-07-02 19:31:01 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-07-02 19:31:01 +0000 |
commit | 63d3d8505edeca3c4de1e0d8176319ae9fd3cb51 (patch) | |
tree | 19e965004021862333dc15cbe7bac54eb7ba974b /src/economy.cpp | |
parent | 0b33df7a8fbbf8de0f594a657635aa2ff289bdf8 (diff) | |
download | openttd-63d3d8505edeca3c4de1e0d8176319ae9fd3cb51.tar.xz |
(svn r22624) -Fix [FS#4654]: When closing an AI company the local player cheated to, we need to cheat him to another company.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r-- | src/economy.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 669569e99..a55b6c934 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -296,6 +296,21 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner) /* In all cases, make spectators of clients connected to that company */ if (_networking) NetworkClientsToSpectators(old_owner); #endif /* ENABLE_NETWORK */ + if (old_owner == _local_company) { + /* Single player cheated to AI company. + * There are no specatators in single player, so we must pick some other company. */ + assert(!_networking); + Backup<CompanyByte> cur_company(_current_company, FILE_LINE); + Company *c; + FOR_ALL_COMPANIES(c) { + if (c->index != old_owner) { + SetLocalCompany(c->index); + break; + } + } + cur_company.Restore(); + assert(old_owner != _local_company); + } Town *t; |