Mercurial > hg > openttd
diff src/economy.cpp @ 14353:098ac3e84f3b draft
(svn r18908) -Fix [FS#3561]: on bankruptcy the company value did include the loan and as such the value at which you bought the company was too low
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 24 Jan 2010 11:05:26 +0000 |
parents | a899d4e5ee1a |
children | a2d95ade0e87 |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -110,7 +110,16 @@ Money _additional_cash_required; static PriceMultipliers _price_base_multiplier; -Money CalculateCompanyValue(const Company *c) +/** + * Calculate the value of the company. That is the value of all + * assets (vehicles, stations, etc) and money minus the loan, + * except when including_loan is \c false which is useful when + * we want to calculate the value for bankruptcy. + * @param c the company to get the value of. + * @param including_loan include the loan in the company value. + * @return the value of the company. + */ +Money CalculateCompanyValue(const Company *c, bool including_loan) { Owner owner = c->index; Money value = 0; @@ -137,7 +146,7 @@ } /* Add real money value */ - value -= c->current_loan; + if (including_loan) value -= c->current_loan; value += c->money; return max(value, (Money)1); @@ -507,7 +516,7 @@ case 3: { /* Check if the company has any value.. if not, declare it bankrupt * right now */ - Money val = CalculateCompanyValue(c); + Money val = CalculateCompanyValue(c, false); if (val > 0) { c->bankrupt_value = val; c->bankrupt_asked = 1 << c->index; // Don't ask the owner