More PARK_FLAGS_NO_MONEY updates. Implement finance_update_daily_profit().

This commit is contained in:
Patrick Wijnings 2014-08-31 13:01:50 +02:00
parent 81163506e9
commit b832a7235b
7 changed files with 50 additions and 23 deletions

View File

@ -236,6 +236,7 @@
#define RCT2_ADDRESS_OBJECTIVE_CURRENCY 0x013580FC
#define RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS 0x01358100
#define RCT2_ADDRESS_BALANCE_HISTORY 0x0135812C
#define RCT2_ADDRESS_CURRENT_EXPENDITURE 0x0135832C
#define RCT2_ADDRESS_CURRENT_PROFIT 0x01358330
#define RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY 0x0135833C
#define RCT2_ADDRESS_CURRENT_PARK_VALUE 0x0135853C

View File

@ -57,7 +57,7 @@ void finance_payment(money32 amount, rct_expenditure_type type)
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(new_money);
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount;
if (RCT2_ADDRESS(0x00988E60, uint32)[type] & 1)
RCT2_GLOBAL(0x0135832C, money32) -= amount;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -= amount; // Cumulative amount of money spent this day
RCT2_GLOBAL(0x009A9804, uint32) |= 1; // money diry flag
@ -158,11 +158,10 @@ void finance_init() {
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0;
}
RCT2_GLOBAL(0x0135832C, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0;
RCT2_GLOBAL(0x01358334, uint32) = 0;
RCT2_GLOBAL(0x01358334, money32) = 0;
RCT2_GLOBAL(0x01358338, uint16) = 0;
RCT2_GLOBAL(0x013573DC, money32) = MONEY(10000,00); // Cheat detection
@ -191,23 +190,48 @@ void finance_init() {
*/
void finance_update_daily_profit()
{
// 0x0135832C is related to savegames
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 7 * RCT2_GLOBAL(0x0135832C, money32);
RCT2_GLOBAL(0x0135832C, money32) = 0;
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
int32 eax = 0;
money32 current_profit = 0;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
{
// 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;
// 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;
}
}
}
eax /= 4;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += eax;
RCT2_GLOBAL(0x1358334, money32) += eax;
RCT2_GLOBAL(0x1358338, money32) += 1;
// This is not equivalent to / 4 due to rounding of negative numbers
current_profit = current_profit >> 2;
//invalidate_window(al = 1C, bx = 0)
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) += current_profit;
RCT2_GLOBAL(0x1358334, money32) += RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32);
RCT2_GLOBAL(0x1358338, uint16) += 1;
window_invalidate_by_id(WC_FINANCES, 0);
}
void sub_69E869()

View File

@ -59,4 +59,6 @@ void park_update_histories();
uint8 calculate_guest_initial_happiness(uint8 percentage);
void game_command_set_park_entrance_fee();
#endif

View File

@ -142,7 +142,7 @@ void scenario_load(const char *path)
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES);
// Read ?
sawyercoding_read_chunk(file, (uint8*)0x0135832C);
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_EXPENDITURE);
// Read ?
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_PARK_VALUE);
@ -279,9 +279,9 @@ void scenario_load_and_play(const rct_scenario_basic *scenario)
strcat((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, ".SV6");
memset((void*)0x001357848, 0, 56);
RCT2_GLOBAL(0x0135832C, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32) = 0;
RCT2_GLOBAL(0x01358334, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, money32) = 0;
RCT2_GLOBAL(0x01358334, money32) = 0;
RCT2_GLOBAL(0x01358338, uint16) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000000;
RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0;
@ -577,7 +577,7 @@ void scenario_update()
if ((current_days_in_month * next_month_tick) >> 16 != (current_days_in_month * month_tick) >> 16) {
// daily checks
RCT2_CALLPROC_EBPSAFE(0x0069E79A); // daily profit update
finance_update_daily_profit(); // daily profit update
RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop
get_local_time();
RCT2_CALLPROC_EBPSAFE(0x0066A13C); // objective 6 dragging

View File

@ -204,8 +204,8 @@ typedef struct {
money32 balance_history[128];
// SC6[11]
uint32 dword_0135832C;
uint32 current_profit;
money32 current_expenditure;
money32 current_profit;
uint32 dword_01358334;
uint16 word_01358338;
uint8 pad_0135833A[2];

View File

@ -468,7 +468,7 @@ static void window_new_ride_refresh_widget_sizing(rct_window *w)
window_new_ride_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].type = WWT_GROUPBOX;
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].type = WWT_GROUPBOX;
window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_BUTTON].type = WWT_FLATBTN;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11))
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_new_ride_widgets[WIDX_RESEARCH_FUNDING_BUTTON].type = WWT_FLATBTN;
width = 300;
@ -944,7 +944,7 @@ static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixeli
}
// Price
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11)) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) {
// Get price of ride
int unk2 = RCT2_GLOBAL(0x0097CC68 + (item.type * 2), uint8);
money32 price = RCT2_GLOBAL(0x0097DD78 + (item.type * 4), uint16);

View File

@ -500,7 +500,7 @@ void window_peep_disable_widgets(rct_window* w){
if (!(w->disabled_widgets & (1 << WIDX_PICKUP)))
window_invalidate(w);
}
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_11){
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){
disabled_widgets |= (1 << WIDX_TAB_4); //Disable finance tab if no money
}
w->disabled_widgets = disabled_widgets;