Change: extend the allowed range for max loan setting (#8386)

pull/217/head
Pavel Stupnikov 4 years ago committed by GitHub
parent d989fb516b
commit b2895dfcd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -594,7 +594,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetBankBalance(): 100000 GetBankBalance(): 100000
GetName(): (null : 0x00000000) GetName(): (null : 0x00000000)
GetLoanAmount(): 100000 GetLoanAmount(): 100000
GetMaxLoanAmount(): 500000 GetMaxLoanAmount(): 2000000000
GetLoanInterval(): 10000 GetLoanInterval(): 10000
SetLoanAmount(1): false SetLoanAmount(1): false
SetLoanAmount(100): false SetLoanAmount(100): false
@ -606,8 +606,8 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetBankBalance(): 40000 GetBankBalance(): 40000
GetLoanAmount(): 40000 GetLoanAmount(): 40000
SetLoanAmount(10000): true SetLoanAmount(10000): true
GetBankBalance(): 500000 GetBankBalance(): 2000000000
GetLoanAmount(): 500000 GetLoanAmount(): 2000000000
GetCompanyHQ(): -1 GetCompanyHQ(): -1
BuildCompanyHQ(): true BuildCompanyHQ(): true
GetCompanyHQ(): 33151 GetCompanyHQ(): 33151
@ -848,7 +848,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetAirportWidth(9): -1 GetAirportWidth(9): -1
GetAirportHeight(9): -1 GetAirportHeight(9): -1
GetAirportCoverageRadius(9): -1 GetAirportCoverageRadius(9): -1
GetBankBalance(): 499790 GetBankBalance(): 1999999790
GetPrice(): 5400 GetPrice(): 5400
BuildAirport(): true BuildAirport(): true
IsHangarTile(): false IsHangarTile(): false
@ -858,11 +858,11 @@ ERROR: IsEnd() is invalid as Begin() is never called
IsHangarTile(): true IsHangarTile(): true
IsAirportTile(): true IsAirportTile(): true
GetAirportType(): 0 GetAirportType(): 0
GetBankBalance(): 489890 GetBankBalance(): 1999989890
RemoveAirport(): true RemoveAirport(): true
IsHangarTile(): false IsHangarTile(): false
IsAirportTile(): false IsAirportTile(): false
GetBankBalance(): 489626 GetBankBalance(): 1999989626
BuildAirport(): true BuildAirport(): true
--Bridge-- --Bridge--
@ -7314,7 +7314,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
IsBuoyTile(): false IsBuoyTile(): false
IsLockTile(): false IsLockTile(): false
IsCanalTile(): false IsCanalTile(): false
GetBankBalance(): 479664 GetBankBalance(): 1999979664
BuildWaterDepot(): true BuildWaterDepot(): true
BuildDock(): true BuildDock(): true
BuildBuoy(): true BuildBuoy(): true
@ -7327,7 +7327,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
IsBuoyTile(): true IsBuoyTile(): true
IsLockTile(): true IsLockTile(): true
IsCanalTile(): true IsCanalTile(): true
GetBankBalance(): 465070 GetBankBalance(): 1999965070
--AIWaypointList(BUOY)-- --AIWaypointList(BUOY)--
Count(): 1 Count(): 1
@ -7346,7 +7346,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
IsBuoyTile(): false IsBuoyTile(): false
IsLockTile(): false IsLockTile(): false
IsCanalTile(): false IsCanalTile(): false
GetBankBalance(): 459675 GetBankBalance(): 1999959675
BuildWaterDepot(): true BuildWaterDepot(): true
BuildDock(): true BuildDock(): true

@ -553,7 +553,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
ResetCompanyLivery(c); ResetCompanyLivery(c);
_company_colours[c->index] = (Colours)c->colour; _company_colours[c->index] = (Colours)c->colour;
c->money = c->current_loan = (100000ll * _economy.inflation_prices >> 16) / 50000 * 50000; c->money = c->current_loan = (min(INITIAL_LOAN, _economy.max_loan) * _economy.inflation_prices >> 16) / 50000 * 50000;
c->share_owners[0] = c->share_owners[1] = c->share_owners[2] = c->share_owners[3] = INVALID_OWNER; c->share_owners[0] = c->share_owners[1] = c->share_owners[2] = c->share_owners[3] = INVALID_OWNER;

@ -746,7 +746,7 @@ bool AddInflation(bool check_year)
void RecomputePrices() void RecomputePrices()
{ {
/* Setup maximum loan */ /* Setup maximum loan */
_economy.max_loan = (_settings_game.difficulty.max_loan * _economy.inflation_prices >> 16) / 50000 * 50000; _economy.max_loan = ((uint64)_settings_game.difficulty.max_loan * _economy.inflation_prices >> 16) / 50000 * 50000;
/* Setup price bases */ /* Setup price bases */
for (Price i = PR_BEGIN; i < PR_END; i++) { for (Price i = PR_BEGIN; i < PR_END; i++) {

@ -196,6 +196,8 @@ struct PriceBaseSpec {
/** The "steps" in loan size, in British Pounds! */ /** The "steps" in loan size, in British Pounds! */
static const int LOAN_INTERVAL = 10000; static const int LOAN_INTERVAL = 10000;
/** The size of loan for a new company, in British Pounds! */
static const int64 INITIAL_LOAN = 100000;
/** /**
* Maximum inflation (including fractional part) without causing overflows in int64 price computations. * Maximum inflation (including fractional part) without causing overflows in int64 price computations.

@ -2187,12 +2187,14 @@ struct GameSettingsWindow : Window {
} else { } else {
/* Only open editbox if clicked for the second time, and only for types where it is sensible for. */ /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
if (this->last_clicked == pe && sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) { if (this->last_clicked == pe && sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
int64 value64 = value;
/* Show the correct currency-translated value */ /* Show the correct currency-translated value */
if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; if (sd->desc.flags & SGF_CURRENCY) value64 *= _currency->rate;
this->valuewindow_entry = pe; this->valuewindow_entry = pe;
SetDParam(0, value); SetDParam(0, value64);
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_ENABLE_DEFAULT); /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
} }
this->SetDisplayedHelpText(pe); this->SetDisplayedHelpText(pe);
} }
@ -2217,10 +2219,12 @@ struct GameSettingsWindow : Window {
int32 value; int32 value;
if (!StrEmpty(str)) { if (!StrEmpty(str)) {
value = atoi(str); long long llvalue = atoll(str);
/* Save the correct currency-translated value */ /* Save the correct currency-translated value */
if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate; if (sd->desc.flags & SGF_CURRENCY) llvalue /= _currency->rate;
value = (int32)ClampToI32(llvalue);
} else { } else {
value = (int32)(size_t)sd->desc.def; value = (int32)(size_t)sd->desc.def;
} }

@ -148,8 +148,8 @@ type = SLE_UINT32
from = SLV_97 from = SLV_97
guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO | SGF_CURRENCY guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO | SGF_CURRENCY
def = 300000 def = 300000
min = 100000 min = 0
max = 500000 max = 2000000000
interval = 50000 interval = 50000
str = STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN str = STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN
strhelp = STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN_HELPTEXT strhelp = STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN_HELPTEXT

Loading…
Cancel
Save