2014-05-05 22:16:34 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* Copyright (c) 2014 Matthias Lanzinger
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* This file is part of OpenRCT2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../addresses.h"
|
2015-01-24 20:07:35 +01:00
|
|
|
#include "../game.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../interface/window.h"
|
2015-01-24 20:07:35 +01:00
|
|
|
#include "../localisation/localisation.h"
|
2014-10-06 20:41:43 +02:00
|
|
|
#include "../peep/peep.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "../ride/ride.h"
|
|
|
|
#include "../world/park.h"
|
|
|
|
#include "../world/sprite.h"
|
2014-05-05 22:16:34 +02:00
|
|
|
#include "finance.h"
|
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
// Monthly staff wages
|
|
|
|
const money32 wage_table[4] = {
|
|
|
|
MONEY(50,00), // Handyman
|
|
|
|
MONEY(80,00), // Mechanic
|
|
|
|
MONEY(60,00), // Security guard
|
|
|
|
MONEY(55,00) // Entertainer
|
|
|
|
};
|
|
|
|
|
|
|
|
// Monthly research funding costs
|
|
|
|
const money32 research_cost_table[4] = {
|
|
|
|
MONEY( 0,00), // No funding
|
|
|
|
MONEY(100,00), // Minimum funding
|
|
|
|
MONEY(200,00), // Normal funding
|
|
|
|
MONEY(400,00) // Maximum funding
|
|
|
|
};
|
2014-05-05 22:16:34 +02:00
|
|
|
|
2015-02-08 15:31:37 +01:00
|
|
|
int dword_988E60[] = { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0 };
|
|
|
|
|
2015-06-20 18:28:17 +02:00
|
|
|
money32 *gCashHistory = RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, money32);
|
|
|
|
money32 *gWeeklyProfitHistory = RCT2_ADDRESS(RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY, money32);
|
|
|
|
money32 *gParkValueHistory = RCT2_ADDRESS(RCT2_ADDRESS_PARK_VALUE_HISTORY, money32);
|
|
|
|
|
2014-05-05 22:16:34 +02:00
|
|
|
/**
|
2014-07-09 17:00:39 +02:00
|
|
|
* Pay an amount of money.
|
2014-05-05 22:16:34 +02:00
|
|
|
* rct2: 0x069C674
|
|
|
|
* @param amount (eax)
|
|
|
|
* @param type passed via global var 0x0141F56C, our type is that var/4.
|
|
|
|
**/
|
2014-05-23 13:15:08 +02:00
|
|
|
void finance_payment(money32 amount, rct_expenditure_type type)
|
2014-05-05 22:16:34 +02:00
|
|
|
{
|
2014-05-23 13:15:08 +02:00
|
|
|
money32 cur_money = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32));
|
|
|
|
money32 new_money = cur_money - amount;
|
2014-05-05 22:16:34 +02:00
|
|
|
|
|
|
|
//overflow check
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(new_money);
|
2014-05-23 13:15:08 +02:00
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount;
|
2015-02-08 15:31:37 +01:00
|
|
|
if (dword_988E60[type] & 1)
|
2014-08-31 13:01:50 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -= amount; // Cumulative amount of money spent this day
|
2015-10-20 20:16:30 +02:00
|
|
|
|
2014-05-05 22:16:34 +02:00
|
|
|
|
2015-01-07 21:25:48 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= BTM_TB_DIRTY_FLAG_MONEY;
|
2014-10-16 03:02:43 +02:00
|
|
|
window_invalidate_by_class(WC_FINANCES);
|
2014-05-05 22:16:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pays the wages of all active staff members in the park.
|
|
|
|
* rct2: 0x006C18A9
|
|
|
|
**/
|
|
|
|
void finance_pay_wages()
|
|
|
|
{
|
|
|
|
rct_peep* peep;
|
2014-05-27 19:03:25 +02:00
|
|
|
uint16 spriteIndex;
|
2014-05-05 22:16:34 +02:00
|
|
|
|
2014-08-30 15:11:19 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
|
2014-05-05 22:16:34 +02:00
|
|
|
return;
|
|
|
|
|
2014-05-27 19:03:25 +02:00
|
|
|
FOR_ALL_STAFF(spriteIndex, peep)
|
|
|
|
finance_payment(wage_table[peep->staff_type] / 4, RCT_EXPENDITURE_TYPE_WAGES);
|
2014-05-05 22:16:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pays the current research level's cost.
|
|
|
|
* rct2: 0x00684DA5
|
|
|
|
**/
|
|
|
|
void finance_pay_research()
|
|
|
|
{
|
|
|
|
uint8 level;
|
|
|
|
|
2014-08-30 15:11:19 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
|
2014-05-05 22:16:34 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
|
|
|
|
finance_payment(research_cost_table[level] / 4, RCT_EXPENDITURE_TYPE_RESEARCH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pay interest on current loans.
|
|
|
|
* rct2: 0x0069E092
|
|
|
|
**/
|
|
|
|
void finance_pay_interest()
|
|
|
|
{
|
2014-05-23 13:15:08 +02:00
|
|
|
money32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32);
|
2014-05-05 22:16:34 +02:00
|
|
|
sint16 current_interest = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, sint16);
|
2014-05-23 13:15:08 +02:00
|
|
|
money32 tempcost = (current_loan * 5 * current_interest) >> 14; // (5 * interest) / 2^14 is pretty close to
|
2014-05-05 22:16:34 +02:00
|
|
|
|
2014-08-30 15:11:19 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)
|
2014-05-05 22:16:34 +02:00
|
|
|
return;
|
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
finance_payment(tempcost, RCT_EXPENDITURE_TYPE_INTEREST);
|
2014-05-05 22:16:34 +02:00
|
|
|
}
|
2014-05-06 23:04:09 +02:00
|
|
|
|
2014-05-11 23:17:20 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006AC885
|
|
|
|
*/
|
|
|
|
void finance_pay_ride_upkeep()
|
|
|
|
{
|
2014-05-27 19:03:25 +02:00
|
|
|
int i;
|
2014-05-11 23:17:20 +02:00
|
|
|
rct_ride* ride;
|
|
|
|
|
2014-05-27 19:03:25 +02:00
|
|
|
FOR_ALL_RIDES(i, ride) {
|
2014-05-22 02:02:55 +02:00
|
|
|
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)) {
|
2014-05-11 23:17:20 +02:00
|
|
|
ride->build_date = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
|
2015-03-22 16:01:01 +01:00
|
|
|
ride->reliability = RIDE_INITIAL_RELIABILITY;
|
2014-05-11 23:17:20 +02:00
|
|
|
|
|
|
|
}
|
2014-08-30 15:11:19 +02:00
|
|
|
if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
|
2014-05-11 23:17:20 +02:00
|
|
|
sint16 upkeep = ride->upkeep_cost;
|
|
|
|
if (upkeep != -1) {
|
2014-09-06 01:58:02 +02:00
|
|
|
ride->total_profit -= upkeep;
|
2015-03-23 01:28:15 +01:00
|
|
|
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME;
|
2015-02-08 15:31:37 +01:00
|
|
|
finance_payment(upkeep, RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS);
|
2014-05-11 23:17:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 02:50:50 +02:00
|
|
|
void finance_reset_history()
|
|
|
|
{
|
2015-06-20 18:28:17 +02:00
|
|
|
for (int i = 0; i < 128; i++) {
|
|
|
|
gCashHistory[i] = MONEY32_UNDEFINED;
|
|
|
|
gWeeklyProfitHistory[i] = MONEY32_UNDEFINED;
|
|
|
|
gParkValueHistory[i] = MONEY32_UNDEFINED;
|
2014-05-28 02:50:50 +02:00
|
|
|
}
|
|
|
|
}
|
2014-05-11 23:17:20 +02:00
|
|
|
|
2014-05-06 23:04:09 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0069DEFB
|
|
|
|
*/
|
|
|
|
void finance_init() {
|
|
|
|
|
2015-05-19 05:12:06 +02:00
|
|
|
// It only initializes the first month
|
|
|
|
for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++) {
|
2014-05-23 13:15:08 +02:00
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0;
|
2014-05-06 23:04:09 +02:00
|
|
|
}
|
|
|
|
|
2014-08-31 13:01:50 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0;
|
2014-05-23 13:15:08 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0;
|
2014-05-06 23:04:09 +02:00
|
|
|
|
2014-08-31 13:01:50 +02:00
|
|
|
RCT2_GLOBAL(0x01358334, money32) = 0;
|
2014-05-06 23:04:09 +02:00
|
|
|
RCT2_GLOBAL(0x01358338, uint16) = 0;
|
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
RCT2_GLOBAL(0x013573DC, money32) = MONEY(10000,00); // Cheat detection
|
2014-05-06 23:04:09 +02:00
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(MONEY(10000,00));
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) = MONEY(10000,00);
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32) = MONEY(20000,00);
|
2014-05-06 23:04:09 +02:00
|
|
|
|
|
|
|
RCT2_GLOBAL(0x013587D0, uint32) = 0;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_INTEREST_RATE, uint8) = 10;
|
2014-05-23 13:15:08 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, money32) = MONEY32_UNDEFINED;
|
2014-05-06 23:04:09 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, uint32) = 0;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x013587D8, uint16) = 0x3F;
|
|
|
|
|
2015-08-13 09:00:49 +02:00
|
|
|
finance_update_loan_hash();
|
2014-05-07 23:40:23 +02:00
|
|
|
}
|
2014-05-17 17:04:19 +02:00
|
|
|
|
2014-08-30 15:11:19 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0069E79A
|
|
|
|
*/
|
|
|
|
void finance_update_daily_profit()
|
|
|
|
{
|
2014-08-31 13:01:50 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 7 * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32);
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) = 0; // Reset daily expenditure
|
2014-08-30 15:11:19 +02:00
|
|
|
|
2014-08-31 13:01:50 +02:00
|
|
|
money32 current_profit = 0;
|
2014-08-30 15:11:19 +02:00
|
|
|
|
|
|
|
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
|
|
|
|
{
|
2014-08-31 13:01:50 +02:00
|
|
|
// Staff costs
|
|
|
|
uint16 sprite_index;
|
|
|
|
rct_peep *peep;
|
|
|
|
|
|
|
|
FOR_ALL_STAFF(sprite_index, peep) {
|
|
|
|
uint8 staff_type = peep->staff_type;
|
|
|
|
current_profit -= wage_table[peep->staff_type];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Research costs
|
|
|
|
uint8 level = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8);
|
|
|
|
current_profit -= research_cost_table[level];
|
|
|
|
|
|
|
|
// Loan costs
|
|
|
|
money32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
|
|
|
|
current_profit -= current_loan / 600;
|
2014-08-30 15:11:19 +02:00
|
|
|
|
2014-08-31 13:01:50 +02:00
|
|
|
// Ride costs
|
|
|
|
rct_ride *ride;
|
|
|
|
int i;
|
|
|
|
FOR_ALL_RIDES(i, ride) {
|
|
|
|
if (ride->status != RIDE_STATUS_CLOSED && ride->upkeep_cost != -1) {
|
|
|
|
current_profit -= 2 * ride->upkeep_cost;
|
|
|
|
}
|
|
|
|
}
|
2014-08-30 15:11:19 +02:00
|
|
|
}
|
|
|
|
|
2014-08-31 13:01:50 +02:00
|
|
|
// This is not equivalent to / 4 due to rounding of negative numbers
|
|
|
|
current_profit = current_profit >> 2;
|
2014-08-30 15:11:19 +02:00
|
|
|
|
2014-08-31 13:01:50 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += current_profit;
|
2014-08-31 13:06:24 +02:00
|
|
|
|
|
|
|
// These are related to weekly profit graph
|
2014-08-31 13:01:50 +02:00
|
|
|
RCT2_GLOBAL(0x1358334, money32) += RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32);
|
|
|
|
RCT2_GLOBAL(0x1358338, uint16) += 1;
|
|
|
|
|
2014-10-16 03:02:43 +02:00
|
|
|
window_invalidate_by_class(WC_FINANCES);
|
2014-08-30 15:11:19 +02:00
|
|
|
}
|
|
|
|
|
2015-08-12 16:12:34 +02:00
|
|
|
// This subroutine is used to mark loan changes as 'legitimate', to prevent cheat detection from incorrectly interfering
|
2015-08-13 09:00:49 +02:00
|
|
|
void finance_update_loan_hash()
|
2014-05-23 13:15:08 +02:00
|
|
|
{
|
2014-05-17 17:04:19 +02:00
|
|
|
sint32 value = 0x70093A;
|
2015-01-24 20:07:35 +01:00
|
|
|
value -= RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32);
|
2014-05-17 17:04:19 +02:00
|
|
|
value = ror32(value, 5);
|
2014-05-23 13:15:08 +02:00
|
|
|
value -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
|
2014-05-17 17:04:19 +02:00
|
|
|
value = ror32(value, 7);
|
2014-05-23 13:15:08 +02:00
|
|
|
value += RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32);
|
2014-05-17 17:04:19 +02:00
|
|
|
value = ror32(value, 3);
|
|
|
|
RCT2_GLOBAL(0x013587C4, sint32) = value;
|
2014-05-21 16:27:31 +02:00
|
|
|
}
|
2015-01-24 20:07:35 +01:00
|
|
|
|
|
|
|
void finance_set_loan(money32 loan)
|
|
|
|
{
|
|
|
|
game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, loan, GAME_COMMAND_SET_CURRENT_LOAN, 0, 0);
|
|
|
|
}
|
|
|
|
|
2015-06-02 03:41:40 +02:00
|
|
|
money32 finance_get_initial_cash()
|
|
|
|
{
|
|
|
|
return RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32);
|
|
|
|
}
|
|
|
|
|
|
|
|
money32 finance_get_current_loan()
|
|
|
|
{
|
|
|
|
return RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
|
|
|
|
}
|
|
|
|
|
|
|
|
money32 finance_get_maximum_loan()
|
|
|
|
{
|
|
|
|
return RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32);
|
|
|
|
}
|
|
|
|
|
|
|
|
money32 finance_get_current_cash()
|
|
|
|
{
|
|
|
|
return DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32));
|
|
|
|
}
|
|
|
|
|
2015-01-24 20:07:35 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2015-02-08 15:31:37 +01:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_INTEREST * 4;
|
2015-01-24 20:07:35 +01:00
|
|
|
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);
|
2015-08-13 09:00:49 +02:00
|
|
|
finance_update_loan_hash();
|
2015-01-24 20:07:35 +01:00
|
|
|
|
|
|
|
window_invalidate_by_class(WC_FINANCES);
|
|
|
|
RCT2_GLOBAL(0x009A9804, uint16) |= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ebx = 0;
|
2015-03-22 16:01:01 +01:00
|
|
|
}
|
2015-05-19 05:12:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shift the expenditure table history one month to the left
|
|
|
|
* If the table is full, acumulate the sum of the oldest month first
|
|
|
|
* rct2: 0x0069DEAD
|
|
|
|
*/
|
|
|
|
|
|
|
|
void finance_shift_expenditure_table() {
|
|
|
|
|
|
|
|
// If EXPENDITURE_TABLE_MONTH_COUNT months have passed then is full, sum the oldest month
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16) >= EXPENDITURE_TABLE_MONTH_COUNT) {
|
|
|
|
money32 sum = 0;
|
|
|
|
for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - RCT_EXPENDITURE_TYPE_COUNT; i < EXPENDITURE_TABLE_TOTAL_COUNT; i++) {
|
|
|
|
sum += RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i];
|
|
|
|
}
|
|
|
|
RCT2_GLOBAL(0x013587D0, money32) += sum;
|
|
|
|
}
|
|
|
|
// Shift the table
|
|
|
|
for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - 1; i >= RCT_EXPENDITURE_TYPE_COUNT; i--) {
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] =
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i - RCT_EXPENDITURE_TYPE_COUNT];
|
|
|
|
}
|
|
|
|
// Zero the beggining of the table, which is the new month
|
|
|
|
for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++) {
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0;
|
|
|
|
}
|
|
|
|
// Invalidate the expenditure table window
|
|
|
|
window_invalidate_by_number(0x1C, 0);
|
2015-07-02 19:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2015-07-02 19:39:32 +02:00
|
|
|
* rct2: 0x0069E89B
|
|
|
|
*/
|
|
|
|
void finance_reset_cash_to_initial()
|
|
|
|
{
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32) = ENCRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_INITIAL_CASH, money32));
|
|
|
|
}
|