diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 6923f5d047..dc8af1628b 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -53,6 +53,7 @@ - Fix: [#19379] “No platforms” station style shows platforms on the Junior Roller Coaster. - Fix: [#19380] Startup crash when no sequences are installed and random sequences are enabled. - Fix: [#19391] String corruption caused by an improper buffer handling in ‘GfxWrapString’. +- Fix: [#19475] Cannot increase loan when more than £1000 in debt. 0.4.3 (2022-12-14) ------------------------------------------------------------------------ diff --git a/src/openrct2/actions/ParkSetLoanAction.cpp b/src/openrct2/actions/ParkSetLoanAction.cpp index bb468ff6b8..1c7384f4cf 100644 --- a/src/openrct2/actions/ParkSetLoanAction.cpp +++ b/src/openrct2/actions/ParkSetLoanAction.cpp @@ -40,19 +40,19 @@ void ParkSetLoanAction::Serialise(DataSerialiser& stream) GameActions::Result ParkSetLoanAction::Query() const { - auto currentLoan = gBankLoan; - auto loanDifference = currentLoan - _value; - if (_value > currentLoan && _value > gMaxBankLoan) + if (_value > gBankLoan && _value > gMaxBankLoan) { return GameActions::Result( GameActions::Status::Disallowed, STR_CANT_BORROW_ANY_MORE_MONEY, STR_BANK_REFUSES_TO_INCREASE_LOAN); } - // FIXME: use money64 literal once it is implemented - if (_value < currentLoan && _value < 0) + if (_value < gBankLoan && _value < 0.00_GBP) { return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_PAY_BACK_LOAN, STR_LOAN_CANT_BE_NEGATIVE); } - if (loanDifference > gCash) + // The “isPayingBack” check is needed to allow increasing the loan when the player is in debt. + const auto isPayingBack = gBankLoan > _value; + const auto amountToPayBack = gBankLoan - _value; + if (isPayingBack && amountToPayBack > gCash) { return GameActions::Result( GameActions::Status::InsufficientFunds, STR_CANT_PAY_BACK_LOAN, STR_NOT_ENOUGH_CASH_AVAILABLE);