Mercurial > hg > openttd
changeset 17831:7c8f4c06bbc1 draft
(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.
author | frosch <frosch@openttd.org> |
---|---|
date | Sat, 02 Jul 2011 19:05:42 +0000 |
parents | 45d44aa92d1c |
children | 96058cf233f7 |
files | src/economy.cpp |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -310,7 +310,7 @@ 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 @@ 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 @@ 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();