1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-20 06:12:57 +01:00

implement game_command_set_current_loan

This commit is contained in:
IntelOrca
2015-01-24 19:07:35 +00:00
parent 475c98c540
commit dfb1f055b9
5 changed files with 58 additions and 5 deletions

View File

@@ -904,7 +904,7 @@ static uint32 game_do_command_table[58] = {
0x006E5597, 0x006E5597,
0x006B893C, 0x006B893C,
0x006B8E1B, 0x006B8E1B,
0x0069DFB3, 0,
0, 0,
0x006D13FE, 0x006D13FE,
0, 0,
@@ -967,7 +967,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = {
game_command_emptysub, game_command_emptysub,
game_command_emptysub, game_command_emptysub,
game_command_emptysub, game_command_emptysub,
game_command_emptysub, game_command_set_current_loan,
game_command_set_research_funding, game_command_set_research_funding,
game_command_emptysub, game_command_emptysub,
game_command_start_campaign, game_command_start_campaign,

View File

@@ -822,6 +822,7 @@ enum {
STR_TILE_SMOOTHING_TIP = 2362, STR_TILE_SMOOTHING_TIP = 2362,
STR_GRIDLINES = 2363, STR_GRIDLINES = 2363,
STR_GRIDLINES_TIP = 2364, STR_GRIDLINES_TIP = 2364,
STR_BANK_REFUSES_TO_INCREASE_LOAN = 2365,
STR_CELSIUS = 2366, STR_CELSIUS = 2366,
STR_FAHRENHEIT = 2367, STR_FAHRENHEIT = 2367,
//STR_NONE = 2368, //STR_NONE = 2368,

View File

@@ -19,7 +19,9 @@
*****************************************************************************/ *****************************************************************************/
#include "../addresses.h" #include "../addresses.h"
#include "../game.h"
#include "../interface/window.h" #include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h" #include "../peep/peep.h"
#include "../ride/ride.h" #include "../ride/ride.h"
#include "../world/park.h" #include "../world/park.h"
@@ -239,7 +241,7 @@ void sub_69E869()
{ {
// This subroutine is loan related and is used for cheat detection // This subroutine is loan related and is used for cheat detection
sint32 value = 0x70093A; sint32 value = 0x70093A;
value -= RCT2_GLOBAL(0x013573DC, money32); // Cheat detection value -= RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32);
value = ror32(value, 5); value = ror32(value, 5);
value -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32); value -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
value = ror32(value, 7); value = ror32(value, 7);
@@ -247,3 +249,50 @@ void sub_69E869()
value = ror32(value, 3); value = ror32(value, 3);
RCT2_GLOBAL(0x013587C4, sint32) = value; RCT2_GLOBAL(0x013587C4, sint32) = value;
} }
void finance_set_loan(money32 loan)
{
game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, loan, GAME_COMMAND_SET_CURRENT_LOAN, 0, 0);
}
/**
*
* rct2: 0x0069DFB3
*/
void game_command_set_current_loan(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp)
{
money32 money, loanDifference, currentLoan;
money32 newLoan = *edx;
currentLoan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
money = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32));
loanDifference = currentLoan - newLoan;
RCT2_GLOBAL(0x0141F56C, uint8) = 52;
if (newLoan > currentLoan) {
if (newLoan > RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32)) {
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_BANK_REFUSES_TO_INCREASE_LOAN;
*ebx = MONEY32_UNDEFINED;
return;
}
} else {
if (loanDifference > money) {
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_NOT_ENOUGH_CASH_AVAILABLE;
*ebx = MONEY32_UNDEFINED;
return;
}
}
if (*ebx & GAME_COMMAND_FLAG_APPLY) {
money -= loanDifference;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) = newLoan;
RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32) = money;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32) = ENCRYPT_MONEY(money);
sub_69E869();
window_invalidate_by_class(WC_FINANCES);
RCT2_GLOBAL(0x009A9804, uint16) |= 1;
}
*ebx = 0;
}

View File

@@ -44,4 +44,7 @@ void finance_init();
void finance_update_daily_profit(); void finance_update_daily_profit();
void sub_69E869(); void sub_69E869();
void finance_set_loan(money32 loan);
void game_command_set_current_loan(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
#endif #endif

View File

@@ -599,13 +599,13 @@ static void window_finances_summary_mousedown(int widgetIndex, rct_window*w, rct
case WIDX_LOAN_INCREASE: case WIDX_LOAN_INCREASE:
newLoan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) + MONEY(1000, 00); newLoan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) + MONEY(1000, 00);
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_BORROW_ANY_MORE_MONEY; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_BORROW_ANY_MORE_MONEY;
game_do_command(0, 1, 0, newLoan, GAME_COMMAND_SET_CURRENT_LOAN, 0, 0); finance_set_loan(newLoan);
break; break;
case WIDX_LOAN_DECREASE: case WIDX_LOAN_DECREASE:
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) > 0) { if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) > 0) {
newLoan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) - MONEY(1000, 00); newLoan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) - MONEY(1000, 00);
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_PAY_BACK_LOAN; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_PAY_BACK_LOAN;
game_do_command(0, 1, 0, newLoan, GAME_COMMAND_SET_CURRENT_LOAN, 0, 0); finance_set_loan(newLoan);
} }
break; break;
} }