mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #5635, overflow when calculating loan interest
Introduces 64-bit money type
This commit is contained in:
parent
e8188a309a
commit
7094bbf74a
|
@ -158,11 +158,13 @@ typedef sint16 fixed16_1dp;
|
|||
typedef sint16 fixed16_2dp;
|
||||
typedef sint32 fixed32_1dp;
|
||||
typedef sint32 fixed32_2dp;
|
||||
typedef sint64 fixed64_1dp;
|
||||
|
||||
// Money is stored as a multiple of 0.10.
|
||||
typedef fixed8_1dp money8;
|
||||
typedef fixed16_1dp money16;
|
||||
typedef fixed32_1dp money32;
|
||||
typedef fixed64_1dp money64;
|
||||
|
||||
// Construct a fixed point number. For example, to create the value 3.65 you
|
||||
// would write FIXED_2DP(3,65)
|
||||
|
|
|
@ -126,8 +126,11 @@ void finance_pay_research()
|
|||
void finance_pay_interest()
|
||||
{
|
||||
money32 current_loan = gBankLoan;
|
||||
sint16 current_interest = gBankLoanInterestRate;
|
||||
money32 tempcost = (current_loan * 5 * current_interest) >> 14; // (5 * interest) / 2^14 is pretty close to
|
||||
uint8 current_interest = gBankLoanInterestRate;
|
||||
|
||||
// This variable uses the 64-bit type as the line below can involve multiplying very large numbers
|
||||
// that will overflow money32 (e.g. in the Alton Towers RCT1 scenario)
|
||||
money64 tempcost = (current_loan * 5 * current_interest) >> 14; // (5 * interest) / 2^14 is pretty close to
|
||||
|
||||
if (gParkFlags & PARK_FLAGS_NO_MONEY)
|
||||
return;
|
||||
|
|
|
@ -56,7 +56,7 @@ extern "C" {
|
|||
// This define specifies which version of network stream current build uses.
|
||||
// It is used for making sure only compatible builds get connected, even within
|
||||
// single OpenRCT2 version.
|
||||
#define NETWORK_STREAM_VERSION "13"
|
||||
#define NETWORK_STREAM_VERSION "14"
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue