1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

add global macro for a few ride variables and expenditure table

This commit is contained in:
Ted John
2016-05-09 22:11:56 +01:00
parent 3c3a37073d
commit 5162bc5a0e
11 changed files with 44 additions and 56 deletions

View File

@@ -288,7 +288,6 @@
#define RCT2_ADDRESS_PARK_ENTRANCE_FEE 0x013573E8
#define RCT2_ADDRESS_GUESTS_IN_PARK 0x01357844
#define RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK 0x01357846
#define RCT2_ADDRESS_MONTHLY_RIDE_INCOME 0x01357894
#define RCT2_ADDRESS_CURRENT_PARK_RATING 0x01357CB0
#define RCT2_ADDRESS_PARK_RATING_HISTORY 0x01357CB2
#define RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY 0x01357CD2

View File

@@ -46,6 +46,7 @@ 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);
money32 *gExpenditureTable = RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32);
uint8 gCommandExpenditureType;
@@ -62,7 +63,7 @@ void finance_payment(money32 amount, rct_expenditure_type type)
//overflow check
gCashEncrypted = ENCRYPT_MONEY(new_money);
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount;
gExpenditureTable[type] -= amount;
if (dword_988E60[type] & 1)
gCurrentExpenditure -= amount; // Cumulative amount of money spent this day
@@ -165,7 +166,7 @@ void finance_init() {
// It only initializes the first month
for (uint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++) {
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = 0;
gExpenditureTable[i] = 0;
}
gCurrentExpenditure = 0;
@@ -327,32 +328,32 @@ void game_command_set_current_loan(int* eax, int* ebx, int* ecx, int* edx, int*
}
/**
* 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() {
* 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 (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++) {
sum += RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i];
sum += gExpenditureTable[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];
gExpenditureTable[i] = gExpenditureTable[i - RCT_EXPENDITURE_TYPE_COUNT];
}
// Zero the beggining of the table, which is the new month
// Zero the beginning 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;
gExpenditureTable[i] = 0;
}
// Invalidate the expenditure table window
window_invalidate_by_number(0x1C, 0);
window_invalidate_by_class(WC_FINANCES);
}
/**

View File

@@ -55,6 +55,7 @@ extern const money32 research_cost_table[4];
extern money32 *gCashHistory;
extern money32 *gWeeklyProfitHistory;
extern money32 *gParkValueHistory;
extern money32 *gExpenditureTable;
extern uint8 gCommandExpenditureType;

View File

@@ -696,7 +696,7 @@ void S4Importer::ImportFinance()
for (int i = 0; i < 14 * 16; i++)
{
RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i] = _s4.expenditure[i];
gExpenditureTable[i] = _s4.expenditure[i];
}
gCurrentExpenditure = _s4.total_expenditure;

View File

@@ -281,13 +281,7 @@ void S6Exporter::Export()
_s6.guests_in_park = gNumGuestsInPark;
_s6.guests_heading_for_park = gNumGuestsHeadingForPark;
memcpy(_s6.expenditure_table, RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32), sizeof(_s6.expenditure_table));
memcpy(_s6.dword_01357880, RCT2_ADDRESS(0x01357880, uint32), sizeof(_s6.dword_01357880));
_s6.monthly_ride_income = RCT2_GLOBAL(RCT2_ADDRESS_MONTHLY_RIDE_INCOME, money32);
_s6.dword_01357898 = RCT2_GLOBAL(0x01357898, money32);
_s6.dword_0135789C = RCT2_GLOBAL(0x0135789C, money32);
_s6.dword_013578A0 = RCT2_GLOBAL(0x013578A0, money32);
memcpy(_s6.dword_013578A4, RCT2_ADDRESS(0x013578A4, money32), sizeof(_s6.dword_013578A4));
memcpy(_s6.expenditure_table, gExpenditureTable, sizeof(_s6.expenditure_table));
_s6.last_guests_in_park = RCT2_GLOBAL(RCT2_ADDRESS_LAST_GUESTS_IN_PARK, uint16);
// pad_01357BCA
@@ -388,8 +382,8 @@ void S6Exporter::Export()
memcpy(_s6.saved_expansion_pack_names, RCT2_ADDRESS(0x0135946C, uint8), sizeof(_s6.saved_expansion_pack_names));
memcpy(_s6.banners, gBanners, sizeof(_s6.banners));
memcpy(_s6.custom_strings, gUserStrings, sizeof(_s6.custom_strings));
_s6.game_ticks_1 = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32);
memcpy(_s6.rides, RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride*), sizeof(_s6.rides));
_s6.game_ticks_1 = gCurrentTicks;
memcpy(_s6.rides, gRideList, sizeof(_s6.rides));
_s6.saved_age = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_AGE, uint16);
_s6.saved_view_x = gSavedViewX;
_s6.saved_view_y = gSavedViewY;

View File

@@ -213,13 +213,7 @@ void S6Importer::Import()
gNumGuestsInPark = _s6.guests_in_park;
gNumGuestsHeadingForPark = _s6.guests_heading_for_park;
memcpy(RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32), _s6.expenditure_table, sizeof(_s6.expenditure_table));
memcpy(RCT2_ADDRESS(0x01357880, uint32), _s6.dword_01357880, sizeof(_s6.dword_01357880));
RCT2_GLOBAL(RCT2_ADDRESS_MONTHLY_RIDE_INCOME, money32) = _s6.monthly_ride_income;
RCT2_GLOBAL(0x01357898, money32) = _s6.dword_01357898;
RCT2_GLOBAL(0x0135789C, money32) = _s6.dword_0135789C;
RCT2_GLOBAL(0x013578A0, money32) = _s6.dword_013578A0;
memcpy(RCT2_ADDRESS(0x013578A4, money32), _s6.dword_013578A4, sizeof(_s6.dword_013578A4));
memcpy(gExpenditureTable, _s6.expenditure_table, sizeof(_s6.expenditure_table));
RCT2_GLOBAL(RCT2_ADDRESS_LAST_GUESTS_IN_PARK, uint16) = _s6.last_guests_in_park;
// pad_01357BCA
@@ -320,8 +314,8 @@ void S6Importer::Import()
memcpy(RCT2_ADDRESS(0x0135946C, uint8), _s6.saved_expansion_pack_names, sizeof(_s6.saved_expansion_pack_names));
memcpy(gBanners, _s6.banners, sizeof(_s6.banners));
memcpy(gUserStrings, _s6.custom_strings, sizeof(_s6.custom_strings));
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) = _s6.game_ticks_1;
memcpy(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride*), _s6.rides, sizeof(_s6.rides));
gCurrentTicks = _s6.game_ticks_1;
memcpy(gRideList, _s6.rides, sizeof(_s6.rides));
RCT2_GLOBAL(RCT2_ADDRESS_SAVED_AGE, uint16) = _s6.saved_age;
gSavedViewX = _s6.saved_view_x;
gSavedViewY = _s6.saved_view_y;

View File

@@ -890,6 +890,8 @@ rct_ride_measurement *get_ride_measurement(int index);
extern const uint8 gRideClassifications[255];
extern rct_ride *gRideList;
extern money32 _currentTrackPrice;
extern uint16 _numCurrentPossibleRideConfigurations;

View File

@@ -924,10 +924,11 @@ static void scenario_objective_check_guests_and_rating()
static void scenario_objective_check_monthly_ride_income()
{
money32 objectiveMonthlyRideIncome = gScenarioObjectiveCurrency;
money32 monthlyRideIncome = RCT2_GLOBAL(RCT2_ADDRESS_MONTHLY_RIDE_INCOME, money32);
if (monthlyRideIncome >= objectiveMonthlyRideIncome)
money32 *expenditureLastMonth = &gExpenditureTable[1 * RCT_EXPENDITURE_TYPE_COUNT];
money32 lastMonthRideIncome = expenditureLastMonth[RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS];
if (lastMonthRideIncome >= gScenarioObjectiveCurrency) {
scenario_success();
}
}
/**
@@ -996,15 +997,16 @@ static void scenario_objective_check_replay_loan_and_park_value()
static void scenario_objective_check_monthly_food_income()
{
money32 objectiveMonthlyIncome = gScenarioObjectiveCurrency;
sint32 monthlyIncome =
RCT2_GLOBAL(0x013578A4, money32) +
RCT2_GLOBAL(0x013578A0, money32) +
RCT2_GLOBAL(0x0135789C, money32) +
RCT2_GLOBAL(0x01357898, money32);
money32 *expenditureLastMonth = &gExpenditureTable[1 * RCT_EXPENDITURE_TYPE_COUNT];
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];
if (monthlyIncome >= objectiveMonthlyIncome)
if (lastMonthProfit >= gScenarioObjectiveCurrency) {
scenario_success();
}
}
/**

View File

@@ -19,6 +19,7 @@
#include "common.h"
#include "management/award.h"
#include "management/finance.h"
#include "management/news_item.h"
#include "management/research.h"
#include "ride/ride.h"
@@ -165,13 +166,7 @@ typedef struct {
uint16 guests_heading_for_park;
// Ignored in scenario
money32 expenditure_table[14];
uint32 dword_01357880[5];
uint32 monthly_ride_income;
uint32 dword_01357898;
uint32 dword_0135789C;
uint32 dword_013578A0;
uint32 dword_013578A4[201];
money32 expenditure_table[224];
// SC6[8]
uint16 last_guests_in_park;

View File

@@ -692,7 +692,7 @@ static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi)
// Month expenditures
money32 profit = 0;
money32 *expenditures = &RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[i * 14];
money32 *expenditures = &gExpenditureTable[i * RCT_EXPENDITURE_TYPE_COUNT];
for (j = 0; j < 14; j++) {
money32 expenditure = expenditures[j];
if (expenditure != 0) {

View File

@@ -728,7 +728,7 @@ void window_guest_viewport_init(rct_window* w){
|| peep->state == PEEP_STATE_ENTERING_RIDE
|| (peep->state == PEEP_STATE_LEAVING_RIDE && peep->x == SPRITE_LOCATION_NULL)){
rct_ride* ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]);
rct_ride *ride = get_ride(peep->current_ride);
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK){
rct_vehicle* train = GET_VEHICLE(ride->vehicles[peep->current_train]);
int car = peep->current_car;
@@ -742,7 +742,7 @@ void window_guest_viewport_init(rct_window* w){
}
}
if (peep->x == SPRITE_LOCATION_NULL && final_check){
rct_ride* ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]);
rct_ride *ride = get_ride(peep->current_ride);
int x = (ride->overall_view & 0xFF) * 32 + 16;
int y = (ride->overall_view >> 8) * 32 + 16;
int height = map_element_height(x, y);