mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 04:53:12 +01:00
implement park_update_histories
This commit is contained in:
@@ -388,9 +388,11 @@
|
||||
|
||||
#define RCT2_ADDRESS_PEEP_SPAWNS 0x013573F2
|
||||
|
||||
#define RCT2_ADDRESS_GUEST_CHANGE_MODIFIER 0x013573FE
|
||||
#define RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL 0x013573FF
|
||||
#define RCT2_ADDRESS_EXPENDITURE_TABLE 0x01357848
|
||||
|
||||
#define RCT2_ADDRESS_LAST_GUESTS_IN_PARK 0x01357BC8
|
||||
#define RCT2_ADDRESS_HANDYMAN_COLOUR 0x01357BCD
|
||||
#define RCT2_ADDRESS_MECHANIC_COLOUR 0x01357BCE
|
||||
#define RCT2_ADDRESS_SECURITY_COLOUR 0x01357BCF
|
||||
|
||||
@@ -398,7 +398,7 @@ static int editor_read_s6(const char *path)
|
||||
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_GUESTS_IN_PARK);
|
||||
|
||||
// Read ?
|
||||
sawyercoding_read_chunk(file, (uint8*)0x01357BC8);
|
||||
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_LAST_GUESTS_IN_PARK);
|
||||
|
||||
// Read park rating
|
||||
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_PARK_RATING);
|
||||
@@ -449,8 +449,8 @@ static int editor_read_s6(const char *path)
|
||||
sub_6BD3A4();
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(0x01357BC8, uint16) = 0;
|
||||
RCT2_GLOBAL(0x013573FE, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAST_GUESTS_IN_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUEST_CHANGE_MODIFIER, uint16) = 0;
|
||||
if (s6Header->type != S6_TYPE_SCENARIO) {
|
||||
research_populate_list_random();
|
||||
research_remove_non_separate_vehicle_types();
|
||||
|
||||
@@ -46,6 +46,10 @@ const money32 research_cost_table[4] = {
|
||||
|
||||
int dword_988E60[] = { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0 };
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* Pay an amount of money.
|
||||
* rct2: 0x069C674
|
||||
@@ -143,11 +147,10 @@ void finance_pay_ride_upkeep()
|
||||
|
||||
void finance_reset_history()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 128; i++) {
|
||||
RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, money32)[i] = MONEY32_UNDEFINED;
|
||||
RCT2_ADDRESS(RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY, money32)[i] = MONEY32_UNDEFINED;
|
||||
RCT2_ADDRESS(RCT2_ADDRESS_PARK_VALUE_HISTORY, money32)[i] = MONEY32_UNDEFINED;
|
||||
for (int i = 0; i < 128; i++) {
|
||||
gCashHistory[i] = MONEY32_UNDEFINED;
|
||||
gWeeklyProfitHistory[i] = MONEY32_UNDEFINED;
|
||||
gParkValueHistory[i] = MONEY32_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ enum {
|
||||
|
||||
extern const money32 research_cost_table[4];
|
||||
|
||||
extern money32 *gCashHistory;
|
||||
extern money32 *gWeeklyProfitHistory;
|
||||
extern money32 *gParkValueHistory;
|
||||
|
||||
void finance_payment(money32 amount, rct_expenditure_type type);
|
||||
void finance_pay_wages();
|
||||
void finance_pay_research();
|
||||
|
||||
@@ -198,8 +198,8 @@ void rct1_fix_landscape()
|
||||
ride_init_all();
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(0x01357BC8, uint16) = 0;
|
||||
RCT2_GLOBAL(0x013573FE, uint8) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAST_GUESTS_IN_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUEST_CHANGE_MODIFIER, uint8) = 0;
|
||||
RCT2_CALLPROC_EBPSAFE(0x0069F44B);
|
||||
sub_69F06A();
|
||||
RCT2_CALLPROC_EBPSAFE(0x0069F143);
|
||||
|
||||
@@ -151,7 +151,7 @@ int scenario_load(const char *path)
|
||||
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_GUESTS_IN_PARK);
|
||||
|
||||
// Read ?
|
||||
sawyercoding_read_chunk(file, (uint8*)0x01357BC8);
|
||||
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_LAST_GUESTS_IN_PARK);
|
||||
|
||||
// Read park rating
|
||||
sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_PARK_RATING);
|
||||
|
||||
@@ -866,9 +866,8 @@ static void window_finances_financial_graph_paint()
|
||||
|
||||
// Calculate the Y axis scale (log2 of highest [+/-]balance)
|
||||
int yAxisScale = 0;
|
||||
money32 *balanceHistory = RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, money32);
|
||||
for (i = 0; i < 64; i++) {
|
||||
money32 balance = balanceHistory[i];
|
||||
money32 balance = gCashHistory[i];
|
||||
if (balance == MONEY32_UNDEFINED)
|
||||
continue;
|
||||
|
||||
@@ -893,7 +892,7 @@ static void window_finances_financial_graph_paint()
|
||||
// X axis labels and values
|
||||
x = graphLeft + 98;
|
||||
y = graphTop + 17;
|
||||
graph_draw_money32(dpi, balanceHistory, 64, x, y, yAxisScale, 128);
|
||||
graph_draw_money32(dpi, gCashHistory, 64, x, y, yAxisScale, 128);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -985,9 +984,8 @@ static void window_finances_park_value_graph_paint()
|
||||
|
||||
// Calculate the Y axis scale (log2 of highest [+/-]balance)
|
||||
int yAxisScale = 0;
|
||||
money32 *parkValueHistory = RCT2_ADDRESS(RCT2_ADDRESS_PARK_VALUE_HISTORY, money32);
|
||||
for (i = 0; i < 64; i++) {
|
||||
money32 balance = parkValueHistory[i];
|
||||
money32 balance = gParkValueHistory[i];
|
||||
if (balance == MONEY32_UNDEFINED)
|
||||
continue;
|
||||
|
||||
@@ -1012,7 +1010,7 @@ static void window_finances_park_value_graph_paint()
|
||||
// X axis labels and values
|
||||
x = graphLeft + 98;
|
||||
y = graphTop + 17;
|
||||
graph_draw_money32(dpi, parkValueHistory, 64, x, y, yAxisScale, 0);
|
||||
graph_draw_money32(dpi, gParkValueHistory, 64, x, y, yAxisScale, 0);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -1104,9 +1102,8 @@ static void window_finances_profit_graph_paint()
|
||||
|
||||
// Calculate the Y axis scale (log2 of highest [+/-]balance)
|
||||
int yAxisScale = 0;
|
||||
money32 *weeklyProfitHistory = RCT2_ADDRESS(RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY, money32);
|
||||
for (i = 0; i < 64; i++) {
|
||||
money32 balance = weeklyProfitHistory[i];
|
||||
money32 balance = gWeeklyProfitHistory[i];
|
||||
if (balance == MONEY32_UNDEFINED)
|
||||
continue;
|
||||
|
||||
@@ -1131,7 +1128,7 @@ static void window_finances_profit_graph_paint()
|
||||
// X axis labels and values
|
||||
x = graphLeft + 98;
|
||||
y = graphTop + 17;
|
||||
graph_draw_money32(dpi, weeklyProfitHistory, 64, x, y, yAxisScale, 128);
|
||||
graph_draw_money32(dpi, gWeeklyProfitHistory, 64, x, y, yAxisScale, 128);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
@@ -411,7 +411,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r
|
||||
// Draw guests
|
||||
gfx_draw_string_centred(
|
||||
dpi,
|
||||
STR_NUM_GUESTS + RCT2_GLOBAL(0x013573FE, uint8),
|
||||
STR_NUM_GUESTS + RCT2_GLOBAL(RCT2_ADDRESS_GUEST_CHANGE_MODIFIER, uint8),
|
||||
x, y,
|
||||
(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) == 2 && RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, sint32) == WIDX_GUESTS ? 2 : w->colours[0] & 0x7F),
|
||||
(void*)RCT2_ADDRESS_GUESTS_IN_PARK
|
||||
|
||||
@@ -1296,7 +1296,6 @@ static void window_park_rating_paint()
|
||||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
rct_widget *widget;
|
||||
uint8 *history;
|
||||
|
||||
window_paint_get_registers(w, dpi);
|
||||
|
||||
@@ -1317,8 +1316,7 @@ static void window_park_rating_paint()
|
||||
x += widget->left + 22;
|
||||
y += widget->top + 26;
|
||||
|
||||
history = RCT2_ADDRESS(RCT2_ADDRESS_PARK_RATING_HISTORY, uint8);
|
||||
graph_draw_uint8(dpi, history, 32, x, y);
|
||||
graph_draw_uint8(dpi, gParkRatingHistory, 32, x, y);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -1430,7 +1428,6 @@ static void window_park_guests_paint()
|
||||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
rct_widget *widget;
|
||||
uint8 *history;
|
||||
|
||||
window_paint_get_registers(w, dpi);
|
||||
|
||||
@@ -1451,8 +1448,7 @@ static void window_park_guests_paint()
|
||||
x += widget->left + 22;
|
||||
y += widget->top + 26;
|
||||
|
||||
history = RCT2_ADDRESS(RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY, uint8);
|
||||
graph_draw_uint8(dpi, history, 32, x, y);
|
||||
graph_draw_uint8(dpi, gGuestsInParkHistory, 32, x, y);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
#include "sprite.h"
|
||||
#include "../config.h"
|
||||
|
||||
uint8 *gParkRatingHistory = RCT2_ADDRESS(RCT2_ADDRESS_PARK_RATING_HISTORY, uint8);
|
||||
uint8 *gGuestsInParkHistory = RCT2_ADDRESS(RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY, uint8);
|
||||
|
||||
/**
|
||||
* In a difficult guest generation scenario, no guests will be generated if over this value.
|
||||
*/
|
||||
@@ -67,9 +70,9 @@ void park_init()
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MECHANIC_COLOUR, uint8) = 28;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SECURITY_COLOUR, uint8) = 28;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(0x01357BC8, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAST_GUESTS_IN_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK, uint16) = 0;
|
||||
RCT2_GLOBAL(0x013573FE, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUEST_CHANGE_MODIFIER, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, uint16) = 0;
|
||||
_guestGenerationProbability = 0;
|
||||
RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, uint16) = 0;
|
||||
@@ -119,10 +122,9 @@ void park_init()
|
||||
*/
|
||||
void park_reset_history()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 32; i++) {
|
||||
RCT2_ADDRESS(RCT2_ADDRESS_PARK_RATING_HISTORY, uint8)[i] = 255;
|
||||
RCT2_ADDRESS(RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY, uint8)[i] = 255;
|
||||
for (int i = 0; i < 32; i++) {
|
||||
gParkRatingHistory[i] = 255;
|
||||
gGuestsInParkHistory[i] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,7 +577,55 @@ uint8 calculate_guest_initial_happiness(uint8 percentage) {
|
||||
*/
|
||||
void park_update_histories()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x0066A231);
|
||||
int guestsInPark = RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16);
|
||||
int lastGuestsInPark = RCT2_GLOBAL(RCT2_ADDRESS_LAST_GUESTS_IN_PARK, uint16);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAST_GUESTS_IN_PARK, uint16) = guestsInPark;
|
||||
RCT2_GLOBAL(0x009A9804, uint16) |= 4;
|
||||
|
||||
int changeInGuestsInPark = guestsInPark - lastGuestsInPark;
|
||||
int guestChangeModifier = 1;
|
||||
if (changeInGuestsInPark > -20) {
|
||||
guestChangeModifier++;
|
||||
if (changeInGuestsInPark < 20)
|
||||
guestChangeModifier = 0;
|
||||
}
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GUEST_CHANGE_MODIFIER, uint8) = guestChangeModifier;
|
||||
|
||||
// Update park rating history
|
||||
for (int i = 31; i > 0; i--)
|
||||
gParkRatingHistory[i] = gParkRatingHistory[i - 1];
|
||||
gParkRatingHistory[0] = calculate_park_rating() / 4;
|
||||
window_invalidate_by_class(WC_PARK_INFORMATION);
|
||||
|
||||
// Update guests in park history
|
||||
for (int i = 31; i > 0; i--)
|
||||
gGuestsInParkHistory[i] = gGuestsInParkHistory[i - 1];
|
||||
gGuestsInParkHistory[0] = min(guestsInPark, 5000) / 20;
|
||||
window_invalidate_by_class(WC_PARK_INFORMATION);
|
||||
|
||||
// Update current cash history
|
||||
for (int i = 127; i > 0; i--)
|
||||
gCashHistory[i] = gCashHistory[i - 1];
|
||||
gCashHistory[0] = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32)) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
|
||||
window_invalidate_by_class(WC_FINANCES);
|
||||
|
||||
// Update weekly profit history
|
||||
money32 currentWeeklyProfit = RCT2_GLOBAL(0x01358334, money32);
|
||||
if (RCT2_GLOBAL(0x01358338, uint16) != 0)
|
||||
currentWeeklyProfit /= RCT2_GLOBAL(0x01358338, uint16);
|
||||
|
||||
for (int i = 127; i > 0; i--)
|
||||
gWeeklyProfitHistory[i] = gWeeklyProfitHistory[i - 1];
|
||||
gWeeklyProfitHistory[0] = currentWeeklyProfit;
|
||||
|
||||
RCT2_GLOBAL(0x01358334, money32) = 0;
|
||||
RCT2_GLOBAL(0x01358338, uint16) = 0;
|
||||
window_invalidate_by_class(WC_FINANCES);
|
||||
|
||||
// Update park value history
|
||||
for (int i = 127; i > 0; i--)
|
||||
gParkValueHistory[i] = gParkValueHistory[i - 1];
|
||||
gParkValueHistory[0] = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32);
|
||||
}
|
||||
|
||||
void park_set_entrance_fee(money32 value)
|
||||
|
||||
@@ -45,6 +45,9 @@ enum {
|
||||
PARK_FLAGS_SIX_FLAGS = (1 << 19)
|
||||
};
|
||||
|
||||
extern uint8 *gParkRatingHistory;
|
||||
extern uint8 *gGuestsInParkHistory;
|
||||
|
||||
int park_is_open();
|
||||
void park_init();
|
||||
void park_reset_history();
|
||||
|
||||
Reference in New Issue
Block a user