diff options
author | Patric Stout <truebrain@openttd.org> | 2021-05-29 11:21:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-29 11:21:30 +0200 |
commit | 4d74e519074bec9a07c2997715ab635ac0e8f084 (patch) | |
tree | 3603ab109385b848dce910d12ee3b5211c99b4fb | |
parent | 4c0e083128a4e9c3eefefaab70648057bd1d9fb2 (diff) | |
download | openttd-4d74e519074bec9a07c2997715ab635ac0e8f084.tar.xz |
Fix #9281: acquire a company uses special bookkeeping to make you rich (#9300)
When you buy-out a company, you got your shares back. This is
based on company-value, which includes values for the vehicles etc.
In other words, you not only got the vehicles, but you also got
paid to get them back.
Additionally, you also got the loan of the company, but not the
money for the loan (as that is subtracted from the company-value).
Solve this by changing the rules of a buy-out: don't sell your
shares, get the loan AND the balance and get the infrastructure.
-rw-r--r-- | src/economy.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 09adf81b9..cde08f76a 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -324,8 +324,11 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner) Backup<CompanyID> cur_company2(_current_company, FILE_LINE); const Company *c = Company::Get(old_owner); for (i = 0; i < 4; i++) { - cur_company2.Change(c->share_owners[i]); - if (_current_company != INVALID_OWNER) { + if (c->bankrupt_value == 0 && c->share_owners[i] == new_owner) { + /* You are the one buying the company; so don't sell the shares back to you. */ + Company::Get(new_owner)->share_owners[i] = COMPANY_SPECTATOR; + } else if (c->share_owners[i] != INVALID_OWNER) { + cur_company2.Change(c->share_owners[i]); /* Sell the shares */ 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 @@ -1986,6 +1989,9 @@ static void DoAcquireCompany(Company *c) if (c->bankrupt_value == 0) { Company *owner = Company::Get(_current_company); + + /* Get both the balance and the loan of the company you just bought. */ + SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, -c->money)); owner->current_loan += c->current_loan; } |