Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/ci-build.yml # .github/workflows/commit-checker.yml # src/command.cpp # src/company_cmd.cpp # src/company_gui.cpp # src/crashlog.cpp # src/economy.cpp # src/lang/english.txt # src/lang/german.txt # src/lang/korean.txt # src/misc_gui.cpp # src/newgrf_config.cpp # src/openttd.cpp # src/settings_gui.cpp # src/ship_cmd.cpp # src/table/settings/gui_settings.ini
This commit is contained in:
@@ -110,14 +110,33 @@ static PriceMultipliers _price_base_multiplier;
|
||||
|
||||
/**
|
||||
* Calculate the value of the company. That is the value of all
|
||||
* assets (vehicles, stations, etc) and money minus the loan,
|
||||
* assets (vehicles, stations, shares) 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 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)
|
||||
{
|
||||
Money owned_shares_value = 0;
|
||||
|
||||
for (const Company *co : Company::Iterate()) {
|
||||
uint8 shares_owned = 0;
|
||||
|
||||
for (uint8 i = 0; i < 4; i++) {
|
||||
if (co->share_owners[i] == c->index) {
|
||||
shares_owned++;
|
||||
}
|
||||
}
|
||||
|
||||
owned_shares_value += (CalculateCompanyValueExcludingShares(co) / 4) * shares_owned;
|
||||
}
|
||||
|
||||
return std::max<Money>(owned_shares_value + CalculateCompanyValueExcludingShares(c), 1);
|
||||
}
|
||||
|
||||
Money CalculateCompanyValueExcludingShares(const Company *c, bool including_loan)
|
||||
{
|
||||
Owner owner = c->index;
|
||||
|
||||
@@ -892,7 +911,7 @@ static void CompaniesPayInterest()
|
||||
Money up_to_previous_month = yearly_fee * _cur_date_ymd.month / 12;
|
||||
Money up_to_this_month = yearly_fee * (_cur_date_ymd.month + 1) / 12;
|
||||
|
||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_LOAN_INT, up_to_this_month - up_to_previous_month));
|
||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_LOAN_INTEREST, up_to_this_month - up_to_previous_month));
|
||||
|
||||
SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, _price[PR_STATION_VALUE] >> 2));
|
||||
}
|
||||
@@ -1361,7 +1380,7 @@ CargoPayment::~CargoPayment()
|
||||
if (this->visual_transfer != 0) {
|
||||
ShowFeederIncomeAnimation(this->front->x_pos, this->front->y_pos,
|
||||
this->front->z_pos, this->visual_transfer, -this->visual_profit);
|
||||
} else if (this->visual_profit != 0) {
|
||||
} else {
|
||||
ShowCostOrIncomeAnimation(this->front->x_pos, this->front->y_pos,
|
||||
this->front->z_pos, -this->visual_profit);
|
||||
}
|
||||
|
Reference in New Issue
Block a user