1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

add global macro: gBankLoanInterestRate

This commit is contained in:
Ted John
2016-04-23 02:06:56 +01:00
parent 3c52983178
commit 5cb25c390f
5 changed files with 14 additions and 17 deletions

View File

@@ -472,11 +472,7 @@ static void editor_clear_map_for_editing()
MONEY(5000000,00)
);
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8) = clamp(
5,
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8),
80
);
gBankLoanInterestRate = clamp(5, gBankLoanInterestRate, 80);
}
climate_reset(RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, uint8));

View File

@@ -110,7 +110,7 @@ void finance_pay_research()
void finance_pay_interest()
{
money32 current_loan = gBankLoan;
sint16 current_interest = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint16);
sint16 current_interest = gBankLoanInterestRate;
money32 tempcost = (current_loan * 5 * current_interest) >> 14; // (5 * interest) / 2^14 is pretty close to
if (gParkFlags & PARK_FLAGS_NO_MONEY)
@@ -183,7 +183,7 @@ void finance_init() {
RCT2_GLOBAL(0x013587D0, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8) = 10;
gBankLoanInterestRate = 10;
gParkValue = 0;
gCompanyValue = 0;
RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, money32) = MONEY32_UNDEFINED;

View File

@@ -48,6 +48,7 @@ enum {
#define gCashEncrypted RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32)
#define gBankLoan RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32)
#define gBankLoanInterestRate RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint8)
extern const money32 research_cost_table[4];

View File

@@ -542,11 +542,11 @@ static void window_editor_scenario_options_financial_mousedown(int widgetIndex,
window_invalidate(w);
break;
case WIDX_INTEREST_RATE_INCREASE:
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32) < 80) {
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32) < 0) {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32) = 0;
if (gBankLoanInterestRate < 80) {
if (gBankLoanInterestRate < 0) {
gBankLoanInterestRate = 0;
} else {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32)++;
gBankLoanInterestRate++;
}
} else {
window_error_open(3254, STR_NONE);
@@ -554,11 +554,11 @@ static void window_editor_scenario_options_financial_mousedown(int widgetIndex,
window_invalidate(w);
break;
case WIDX_INTEREST_RATE_DECREASE:
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32) > 0) {
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32) > 80) {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32) = 80;
if (gBankLoanInterestRate > 0) {
if (gBankLoanInterestRate > 80) {
gBankLoanInterestRate = 80;
} else {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32)--;
gBankLoanInterestRate--;
}
} else {
window_error_open(3255, STR_NONE);
@@ -685,7 +685,7 @@ static void window_editor_scenario_options_financial_paint(rct_window *w, rct_dr
x = w->x + w->widgets[WIDX_INTEREST_RATE].left + 1;
y = w->y + w->widgets[WIDX_INTEREST_RATE].top;
money16 interestRate = (money16)clamp(INT16_MIN, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, money32), INT16_MAX);
money16 interestRate = (money16)clamp(INT16_MIN, gBankLoanInterestRate, INT16_MAX);
gfx_draw_string_left(dpi, 3247, &interestRate, 0, x, y);
}
}

View File

@@ -734,7 +734,7 @@ static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi)
// Loan and interest rate
gfx_draw_string_left(dpi, STR_FINANCES_SUMMARY_LOAN, NULL, 0, w->x + 4, w->y + 229);
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8);
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = gBankLoanInterestRate;
gfx_draw_string_left(dpi, STR_FINANCES_SUMMARY_AT_X_PER_YEAR, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, w->x + 156, w->y + 229);
// Current cash