mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-20 13:09:15 +00:00
(svn r26585) -Fix/Feature [FS#5942]: don't truncate money to 32 bits
This commit is contained in:
@@ -196,11 +196,11 @@
|
||||
return LOAN_INTERVAL;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptCompany::SetLoanAmount(int32 loan)
|
||||
/* static */ bool ScriptCompany::SetLoanAmount(Money loan)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, loan >= 0);
|
||||
EnforcePrecondition(false, (loan % GetLoanInterval()) == 0);
|
||||
EnforcePrecondition(false, ((int64)loan % GetLoanInterval()) == 0);
|
||||
EnforcePrecondition(false, loan <= GetMaxLoanAmount());
|
||||
EnforcePrecondition(false, (loan - GetLoanAmount() + GetBankBalance(COMPANY_SELF)) >= 0);
|
||||
|
||||
@@ -211,12 +211,12 @@
|
||||
(loan > GetLoanAmount()) ? CMD_INCREASE_LOAN : CMD_DECREASE_LOAN);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptCompany::SetMinimumLoanAmount(int32 loan)
|
||||
/* static */ bool ScriptCompany::SetMinimumLoanAmount(Money loan)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
||||
EnforcePrecondition(false, loan >= 0);
|
||||
|
||||
int32 over_interval = loan % GetLoanInterval();
|
||||
Money over_interval = (int64)loan % GetLoanInterval();
|
||||
if (over_interval != 0) loan += GetLoanInterval() - over_interval;
|
||||
|
||||
EnforcePrecondition(false, loan <= GetMaxLoanAmount());
|
||||
@@ -226,10 +226,12 @@
|
||||
return GetLoanAmount() == loan;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptCompany::ChangeBankBalance(CompanyID company, int32 delta, ExpensesType expenses_type)
|
||||
/* static */ bool ScriptCompany::ChangeBankBalance(CompanyID company, Money delta, ExpensesType expenses_type)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(false, expenses_type < (ExpensesType)::EXPENSES_END);
|
||||
EnforcePrecondition(false, delta >= INT32_MIN);
|
||||
EnforcePrecondition(false, delta <= INT32_MAX);
|
||||
|
||||
company = ResolveCompanyID(company);
|
||||
EnforcePrecondition(false, company != COMPANY_INVALID);
|
||||
@@ -280,12 +282,14 @@
|
||||
return ::Company::Get((CompanyID)company)->settings.engine_renew_months;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptCompany::SetAutoRenewMoney(uint32 money)
|
||||
/* static */ bool ScriptCompany::SetAutoRenewMoney(Money money)
|
||||
{
|
||||
EnforcePrecondition(false, money >= 0);
|
||||
EnforcePrecondition(false, (int64)money <= UINT32_MAX);
|
||||
return ScriptObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew_money"), money, CMD_CHANGE_COMPANY_SETTING);
|
||||
}
|
||||
|
||||
/* static */ uint32 ScriptCompany::GetAutoRenewMoney(CompanyID company)
|
||||
/* static */ Money ScriptCompany::GetAutoRenewMoney(CompanyID company)
|
||||
{
|
||||
company = ResolveCompanyID(company);
|
||||
if (company == COMPANY_INVALID) return 0;
|
||||
|
Reference in New Issue
Block a user