diff options
author | frosch <frosch@openttd.org> | 2011-07-02 19:05:42 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-07-02 19:05:42 +0000 |
commit | a3ede3cea184c98e67ca57ff87dc39dd0082ca29 (patch) | |
tree | 414ba89c052a12998f6dc48db44a55e98397586d /src/economy.cpp | |
parent | 7bf8b1d96e9bf3932465666c2c1db8538a48d846 (diff) | |
download | openttd-a3ede3cea184c98e67ca57ff87dc39dd0082ca29.tar.xz |
(svn r22622) -Fix: When closing down companies their shares in other companies must be sold even if share trading is disabled at that point of time.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r-- | src/economy.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 4d7d85885..a2edd3e99 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -310,7 +310,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner) for (i = 0; i < 4; i++) { if (c->share_owners[i] == old_owner) { /* Sell his shares */ - CommandCost res = DoCommand(0, c->index, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY); + CommandCost res = DoCommand(0, c->index, 0, DC_EXEC | DC_BANKRUPT, CMD_SELL_SHARE_IN_COMPANY); /* Because we are in a DoCommand, we can't just execute another one and * expect the money to be removed. We need to do it ourself! */ SubtractMoneyFromCompany(res); @@ -325,7 +325,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner) cur_company2.Change(c->share_owners[i]); if (_current_company != INVALID_OWNER) { /* Sell the shares */ - CommandCost res = DoCommand(0, old_owner, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY); + CommandCost res = DoCommand(0, old_owner, 0, DC_EXEC | DC_BANKRUPT, CMD_SELL_SHARE_IN_COMPANY); /* Because we are in a DoCommand, we can't just execute another one and * expect the money to be removed. We need to do it ourself! */ SubtractMoneyFromCompany(res); @@ -1600,9 +1600,12 @@ CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1 CompanyID target_company = (CompanyID)p1; Company *c = Company::GetIfValid(target_company); - /* Check if selling shares is allowed (protection against modified clients) - * Cannot sell own shares */ - if (c == NULL || !_settings_game.economy.allow_shares || _current_company == target_company) return CMD_ERROR; + /* Cannot sell own shares */ + if (c == NULL || _current_company == target_company) return CMD_ERROR; + + /* Check if selling shares is allowed (protection against modified clients). + * However, we must sell shares of companies being closed down. */ + if (!_settings_game.economy.allow_shares && !(flags & DC_BANKRUPT)) return CMD_ERROR; /* Those lines are here for network-protection (clients can be slow) */ if (GetAmountOwnedBy(c, _current_company) == 0) return CommandCost(); |