mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 14:24:33 +01:00
Refactor expenditure table and history graph
This commit is contained in:
committed by
GitHub
parent
d342272dda
commit
3a2aeda398
@@ -706,10 +706,11 @@ static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
|
||||
// Month expenditures
|
||||
money32 profit = 0;
|
||||
money32 *expenditures = &gExpenditureTable[i * RCT_EXPENDITURE_TYPE_COUNT];
|
||||
for (j = 0; j < RCT_EXPENDITURE_TYPE_COUNT; j++) {
|
||||
money32 expenditure = expenditures[j];
|
||||
if (expenditure != 0) {
|
||||
for (j = 0; j < RCT_EXPENDITURE_TYPE_COUNT; j++)
|
||||
{
|
||||
money32 expenditure = gExpenditureTable[i][j];
|
||||
if (expenditure != 0)
|
||||
{
|
||||
profit += expenditure;
|
||||
gfx_draw_string_right(
|
||||
dpi,
|
||||
|
||||
@@ -63,7 +63,7 @@ uint16 gWeeklyProfitAverageDivisor;
|
||||
money32 gCashHistory[FINANCE_GRAPH_SIZE];
|
||||
money32 gWeeklyProfitHistory[FINANCE_GRAPH_SIZE];
|
||||
money32 gParkValueHistory[FINANCE_GRAPH_SIZE];
|
||||
money32 gExpenditureTable[EXPENDITURE_TABLE_TOTAL_COUNT];
|
||||
money32 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][RCT_EXPENDITURE_TYPE_COUNT];
|
||||
|
||||
uint8 gCommandExpenditureType;
|
||||
|
||||
@@ -82,7 +82,7 @@ void finance_payment(money32 amount, rct_expenditure_type type)
|
||||
new_money = add_clamp_money32(cur_money, -amount);
|
||||
|
||||
gCashEncrypted = ENCRYPT_MONEY(new_money);
|
||||
gExpenditureTable[type] -= amount;
|
||||
gExpenditureTable[0][type] -= amount;
|
||||
if (dword_988E60[type] & 1)
|
||||
{
|
||||
// Cumulative amount of money spent this day
|
||||
@@ -207,7 +207,7 @@ void finance_init()
|
||||
// It only initialises the first month
|
||||
for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++)
|
||||
{
|
||||
gExpenditureTable[i] = 0;
|
||||
gExpenditureTable[0][i] = 0;
|
||||
}
|
||||
|
||||
gCurrentExpenditure = 0;
|
||||
@@ -370,23 +370,26 @@ void finance_shift_expenditure_table()
|
||||
if (gDateMonthsElapsed >= EXPENDITURE_TABLE_MONTH_COUNT)
|
||||
{
|
||||
money32 sum = 0;
|
||||
for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - RCT_EXPENDITURE_TYPE_COUNT; i < EXPENDITURE_TABLE_TOTAL_COUNT; i++)
|
||||
for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++)
|
||||
{
|
||||
sum += gExpenditureTable[i];
|
||||
sum += gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT - 1][i];
|
||||
}
|
||||
gHistoricalProfit += sum;
|
||||
}
|
||||
|
||||
// Shift the table
|
||||
for (uint32 i = EXPENDITURE_TABLE_TOTAL_COUNT - 1; i >= RCT_EXPENDITURE_TYPE_COUNT; i--)
|
||||
for (size_t i = EXPENDITURE_TABLE_MONTH_COUNT - 1; i >= 1; i--)
|
||||
{
|
||||
gExpenditureTable[i] = gExpenditureTable[i - RCT_EXPENDITURE_TYPE_COUNT];
|
||||
for (size_t j = 0; j < RCT_EXPENDITURE_TYPE_COUNT; j++)
|
||||
{
|
||||
gExpenditureTable[i][j] = gExpenditureTable[i - 1][j];
|
||||
}
|
||||
}
|
||||
|
||||
// Zero the beginning of the table, which is the new month
|
||||
for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++)
|
||||
{
|
||||
gExpenditureTable[i] = 0;
|
||||
gExpenditureTable[0][i] = 0;
|
||||
}
|
||||
|
||||
window_invalidate_by_class(WC_FINANCES);
|
||||
@@ -409,7 +412,8 @@ money32 finance_get_last_month_shop_profit()
|
||||
money32 profit = 0;
|
||||
if (gDateMonthsElapsed != 0)
|
||||
{
|
||||
money32 * lastMonthExpenditure = &gExpenditureTable[RCT_EXPENDITURE_TYPE_COUNT];
|
||||
money32 * lastMonthExpenditure = gExpenditureTable[1];
|
||||
|
||||
profit += lastMonthExpenditure[RCT_EXPENDITURE_TYPE_SHOP_SHOP_SALES];
|
||||
profit += lastMonthExpenditure[RCT_EXPENDITURE_TYPE_SHOP_STOCK];
|
||||
profit += lastMonthExpenditure[RCT_EXPENDITURE_TYPE_FOODDRINK_SALES];
|
||||
|
||||
@@ -41,7 +41,6 @@ enum {
|
||||
};
|
||||
|
||||
#define EXPENDITURE_TABLE_MONTH_COUNT 16
|
||||
#define EXPENDITURE_TABLE_TOTAL_COUNT (EXPENDITURE_TABLE_MONTH_COUNT * RCT_EXPENDITURE_TYPE_COUNT)
|
||||
#define FINANCE_GRAPH_SIZE 128
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -70,7 +69,7 @@ extern uint16 gWeeklyProfitAverageDivisor;
|
||||
extern money32 gCashHistory[FINANCE_GRAPH_SIZE];
|
||||
extern money32 gWeeklyProfitHistory[FINANCE_GRAPH_SIZE];
|
||||
extern money32 gParkValueHistory[FINANCE_GRAPH_SIZE];
|
||||
extern money32 gExpenditureTable[EXPENDITURE_TABLE_TOTAL_COUNT];
|
||||
extern money32 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][RCT_EXPENDITURE_TYPE_COUNT];
|
||||
|
||||
extern uint8 gCommandExpenditureType;
|
||||
|
||||
|
||||
@@ -620,7 +620,7 @@ typedef struct rct1_s4 {
|
||||
uint32 ride_feature_2[128];
|
||||
uint16 guests_in_park;
|
||||
uint16 unk_198C9E;
|
||||
money32 expenditure[14 * 16];
|
||||
money32 expenditure[RCT12_EXPENDITURE_TABLE_MONTH_COUNT][RCT12_EXPENDITURE_TYPE_COUNT];
|
||||
uint32 guests_in_park_2;
|
||||
uint8 unk_199024;
|
||||
colour_t handman_colour;
|
||||
@@ -660,13 +660,13 @@ typedef struct rct1_s4 {
|
||||
uint8 marketing_status[20];
|
||||
uint8 marketing_assoc[20];
|
||||
uint8 unk_199582[2];
|
||||
money32 cash_history[128];
|
||||
money32 cash_history[RCT12_FINANCE_GRAPH_SIZE];
|
||||
money32 total_expenditure;
|
||||
money32 profit;
|
||||
uint8 unk_199788[8];
|
||||
money32 weekly_profit_history[128];
|
||||
money32 weekly_profit_history[RCT12_FINANCE_GRAPH_SIZE];
|
||||
money32 park_value;
|
||||
money32 park_value_history[128];
|
||||
money32 park_value_history[RCT12_FINANCE_GRAPH_SIZE];
|
||||
uint32 scenario_objective_score;
|
||||
uint32 num_admissions;
|
||||
money32 admission_total_income;
|
||||
|
||||
@@ -1736,16 +1736,19 @@ private:
|
||||
gParkValue = CorrectRCT1ParkValue(_s4.park_value);
|
||||
gCurrentProfit = _s4.profit;
|
||||
|
||||
for (size_t i = 0; i < 128; i++)
|
||||
for (size_t i = 0; i < RCT12_FINANCE_GRAPH_SIZE; i++)
|
||||
{
|
||||
gCashHistory[i] = _s4.cash_history[i];
|
||||
gParkValueHistory[i] = CorrectRCT1ParkValue(_s4.park_value_history[i]);
|
||||
gWeeklyProfitHistory[i] = _s4.weekly_profit_history[i];
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < EXPENDITURE_TABLE_TOTAL_COUNT; i++)
|
||||
for (size_t i = 0; i < RCT12_EXPENDITURE_TABLE_MONTH_COUNT; i++)
|
||||
{
|
||||
gExpenditureTable[i] = _s4.expenditure[i];
|
||||
for (size_t j = 0; j < RCT12_EXPENDITURE_TYPE_COUNT; j++)
|
||||
{
|
||||
gExpenditureTable[i][j] = _s4.expenditure[i][j];
|
||||
}
|
||||
}
|
||||
gCurrentExpenditure = _s4.total_expenditure;
|
||||
|
||||
|
||||
@@ -20,18 +20,22 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define RCT12_MAX_AWARDS 4
|
||||
#define RCT12_MAX_NEWS_ITEMS 61
|
||||
#define RCT12_MAX_STATIONS_PER_RIDE 4
|
||||
#define RCT12_MAX_PEEP_SPAWNS 2
|
||||
#define RCT12_MAX_PARK_ENTRANCES 4
|
||||
#define RCT12_MAX_AWARDS 4
|
||||
#define RCT12_MAX_NEWS_ITEMS 61
|
||||
#define RCT12_MAX_STATIONS_PER_RIDE 4
|
||||
#define RCT12_MAX_PEEP_SPAWNS 2
|
||||
#define RCT12_MAX_PARK_ENTRANCES 4
|
||||
// The number of elements in the patrol_areas array per staff member. Every bit in the array represents a 4x4 square.
|
||||
// In RCT1, that's an 8-bit array. 8 * 128 = 1024 bits, which is also the number of 4x4 squares on a 128x128 map.
|
||||
// For RCT2, it's a 32-bit array. 32 * 128 = 4096 bits, which is also the number of 4x4 squares on a 256x256 map.
|
||||
#define RCT12_PATROL_AREA_SIZE 128
|
||||
#define RCT12_STAFF_TYPE_COUNT 4
|
||||
#define RCT12_NUM_COLOUR_SCHEMES 4
|
||||
#define RCT12_SOUND_ID_NULL 0xFF
|
||||
#define RCT12_PATROL_AREA_SIZE 128
|
||||
#define RCT12_STAFF_TYPE_COUNT 4
|
||||
#define RCT12_NUM_COLOUR_SCHEMES 4
|
||||
#define RCT12_SOUND_ID_NULL 0xFF
|
||||
|
||||
#define RCT12_EXPENDITURE_TABLE_MONTH_COUNT 16
|
||||
#define RCT12_EXPENDITURE_TYPE_COUNT 14
|
||||
#define RCT12_FINANCE_GRAPH_SIZE 128
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
||||
@@ -233,7 +233,13 @@ public:
|
||||
gNumGuestsInPark = _s6.guests_in_park;
|
||||
gNumGuestsHeadingForPark = _s6.guests_heading_for_park;
|
||||
|
||||
memcpy(gExpenditureTable, _s6.expenditure_table, sizeof(_s6.expenditure_table));
|
||||
for (size_t i = 0; i < RCT12_EXPENDITURE_TABLE_MONTH_COUNT; i++)
|
||||
{
|
||||
for (size_t j = 0; j < RCT12_EXPENDITURE_TYPE_COUNT; j++)
|
||||
{
|
||||
gExpenditureTable[i][j] = _s6.expenditure_table[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
gNumGuestsInParkLastWeek = _s6.last_guests_in_park;
|
||||
// pad_01357BCA
|
||||
@@ -273,19 +279,20 @@ public:
|
||||
memcpy(gMarketingCampaignDaysLeft, _s6.campaign_weeks_left, sizeof(_s6.campaign_weeks_left));
|
||||
memcpy(gMarketingCampaignRideIndex, _s6.campaign_ride_index, sizeof(_s6.campaign_ride_index));
|
||||
|
||||
memcpy(gCashHistory, _s6.balance_history, sizeof(_s6.balance_history));
|
||||
|
||||
gCurrentExpenditure = _s6.current_expenditure;
|
||||
gCurrentProfit = _s6.current_profit;
|
||||
gWeeklyProfitAverageDividend = _s6.weekly_profit_average_dividend;
|
||||
gWeeklyProfitAverageDivisor = _s6.weekly_profit_average_divisor;
|
||||
// pad_0135833A
|
||||
|
||||
memcpy(gWeeklyProfitHistory, _s6.weekly_profit_history, sizeof(_s6.weekly_profit_history));
|
||||
|
||||
gParkValue = _s6.park_value;
|
||||
|
||||
memcpy(gParkValueHistory, _s6.park_value_history, sizeof(_s6.park_value_history));
|
||||
for (size_t i = 0; i < RCT12_FINANCE_GRAPH_SIZE; i++)
|
||||
{
|
||||
gCashHistory[i] = _s6.balance_history[i];
|
||||
gWeeklyProfitHistory[i] = _s6.weekly_profit_history[i];
|
||||
gParkValueHistory[i] = _s6.park_value_history[i];
|
||||
}
|
||||
|
||||
gScenarioCompletedCompanyValue = _s6.completed_company_value;
|
||||
gTotalAdmissions = _s6.total_admissions;
|
||||
|
||||
@@ -885,8 +885,7 @@ static void scenario_objective_check_guests_and_rating()
|
||||
|
||||
static void scenario_objective_check_monthly_ride_income()
|
||||
{
|
||||
money32 *expenditureLastMonth = &gExpenditureTable[1 * RCT_EXPENDITURE_TYPE_COUNT];
|
||||
money32 lastMonthRideIncome = expenditureLastMonth[RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS];
|
||||
money32 lastMonthRideIncome = gExpenditureTable[1][RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS];
|
||||
if (lastMonthRideIncome >= gScenarioObjectiveCurrency) {
|
||||
scenario_success();
|
||||
}
|
||||
@@ -967,12 +966,12 @@ static void scenario_objective_check_replay_loan_and_park_value()
|
||||
|
||||
static void scenario_objective_check_monthly_food_income()
|
||||
{
|
||||
money32 *expenditureLastMonth = &gExpenditureTable[1 * RCT_EXPENDITURE_TYPE_COUNT];
|
||||
money32 * lastMonthExpenditure = gExpenditureTable[1];
|
||||
sint32 lastMonthProfit =
|
||||
expenditureLastMonth[RCT_EXPENDITURE_TYPE_SHOP_SHOP_SALES] +
|
||||
expenditureLastMonth[RCT_EXPENDITURE_TYPE_SHOP_STOCK] +
|
||||
expenditureLastMonth[RCT_EXPENDITURE_TYPE_FOODDRINK_SALES] +
|
||||
expenditureLastMonth[RCT_EXPENDITURE_TYPE_FOODDRINK_STOCK];
|
||||
lastMonthExpenditure[RCT_EXPENDITURE_TYPE_SHOP_SHOP_SALES] +
|
||||
lastMonthExpenditure[RCT_EXPENDITURE_TYPE_SHOP_STOCK] +
|
||||
lastMonthExpenditure[RCT_EXPENDITURE_TYPE_FOODDRINK_SALES] +
|
||||
lastMonthExpenditure[RCT_EXPENDITURE_TYPE_FOODDRINK_STOCK];
|
||||
|
||||
if (lastMonthProfit >= gScenarioObjectiveCurrency) {
|
||||
scenario_success();
|
||||
|
||||
@@ -142,7 +142,7 @@ typedef struct rct_s6_data {
|
||||
uint16 guests_heading_for_park;
|
||||
|
||||
// Ignored in scenario
|
||||
money32 expenditure_table[224];
|
||||
money32 expenditure_table[RCT12_EXPENDITURE_TABLE_MONTH_COUNT][RCT12_EXPENDITURE_TYPE_COUNT];
|
||||
|
||||
// SC6[8]
|
||||
uint16 last_guests_in_park;
|
||||
@@ -188,7 +188,7 @@ typedef struct rct_s6_data {
|
||||
uint8 campaign_ride_index[22];
|
||||
|
||||
// Ignored in scenario
|
||||
money32 balance_history[128];
|
||||
money32 balance_history[RCT12_FINANCE_GRAPH_SIZE];
|
||||
|
||||
// SC6[11]
|
||||
money32 current_expenditure;
|
||||
@@ -198,13 +198,13 @@ typedef struct rct_s6_data {
|
||||
uint8 pad_0135833A[2];
|
||||
|
||||
// Ignored in scenario
|
||||
money32 weekly_profit_history[128];
|
||||
money32 weekly_profit_history[RCT12_FINANCE_GRAPH_SIZE];
|
||||
|
||||
// SC6[12]
|
||||
money32 park_value;
|
||||
|
||||
// Ignored in scenario
|
||||
money32 park_value_history[128];
|
||||
money32 park_value_history[RCT12_FINANCE_GRAPH_SIZE];
|
||||
|
||||
// SC6[13]
|
||||
money32 completed_company_value;
|
||||
|
||||
Reference in New Issue
Block a user