mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-26 00:04:43 +01:00
Refactor out gCommandExpenditureType
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "localisation/Localisation.h"
|
||||
#include "management/NewsItem.h"
|
||||
#include "network/network.h"
|
||||
#include "peep/Staff.h"
|
||||
#include "platform/Platform2.h"
|
||||
#include "scenario/Scenario.h"
|
||||
#include "title/TitleScreen.h"
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
std::array<uint8_t, 32> ErrorMessageArgs;
|
||||
CoordsXYZ Position = { LOCATION_NULL, LOCATION_NULL, LOCATION_NULL };
|
||||
money32 Cost = 0;
|
||||
uint16_t ExpenditureType = 0;
|
||||
rct_expenditure_type ExpenditureType = RCT_EXPENDITURE_TYPE_COUNT;
|
||||
|
||||
GameActionResult() = default;
|
||||
GameActionResult(GA_ERROR error, rct_string_id message);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "../localisation/Localisation.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "../management/Finance.h"
|
||||
#include "../peep/Staff.h"
|
||||
#include "../ride/Ride.h"
|
||||
#include "../scenario/Scenario.h"
|
||||
#include "../ui/UiContext.h"
|
||||
|
||||
@@ -24,18 +24,6 @@
|
||||
#include "../world/Park.h"
|
||||
#include "../world/Sprite.h"
|
||||
|
||||
/**
|
||||
* Monthly staff wages
|
||||
*
|
||||
* rct2: 0x00992A00
|
||||
*/
|
||||
const money32 wage_table[STAFF_TYPE_COUNT] = {
|
||||
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[RESEARCH_FUNDING_COUNT] = {
|
||||
MONEY(0, 00), // No funding
|
||||
@@ -63,8 +51,6 @@ money32 gWeeklyProfitHistory[FINANCE_GRAPH_SIZE];
|
||||
money32 gParkValueHistory[FINANCE_GRAPH_SIZE];
|
||||
money32 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][RCT_EXPENDITURE_TYPE_COUNT];
|
||||
|
||||
uint8_t gCommandExpenditureType;
|
||||
|
||||
/**
|
||||
* Checks the condition if the game is required to use money.
|
||||
* @param flags game command flags.
|
||||
@@ -130,7 +116,7 @@ void finance_pay_wages()
|
||||
|
||||
FOR_ALL_STAFF (spriteIndex, peep)
|
||||
{
|
||||
finance_payment(wage_table[peep->staff_type] / 4, RCT_EXPENDITURE_TYPE_WAGES);
|
||||
finance_payment(gStaffWageTable[peep->staff_type] / 4, RCT_EXPENDITURE_TYPE_WAGES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +254,7 @@ void finance_update_daily_profit()
|
||||
|
||||
FOR_ALL_STAFF (sprite_index, peep)
|
||||
{
|
||||
current_profit -= wage_table[peep->staff_type];
|
||||
current_profit -= gStaffWageTable[peep->staff_type];
|
||||
}
|
||||
|
||||
// Research costs
|
||||
|
||||
@@ -10,14 +10,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
#include "../peep/Staff.h"
|
||||
#include "Research.h"
|
||||
|
||||
using rct_expenditure_type = int32_t;
|
||||
|
||||
enum
|
||||
enum rct_expenditure_type : int32_t
|
||||
{
|
||||
RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION,
|
||||
RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION = 0,
|
||||
RCT_EXPENDITURE_TYPE_RIDE_RUNNING_COSTS,
|
||||
RCT_EXPENDITURE_TYPE_LAND_PURCHASE,
|
||||
RCT_EXPENDITURE_TYPE_LANDSCAPING,
|
||||
@@ -37,7 +34,6 @@ enum
|
||||
#define EXPENDITURE_TABLE_MONTH_COUNT 16
|
||||
#define FINANCE_GRAPH_SIZE 128
|
||||
|
||||
extern const money32 wage_table[STAFF_TYPE_COUNT];
|
||||
extern const money32 research_cost_table[RESEARCH_FUNDING_COUNT];
|
||||
|
||||
extern money32 gInitialCash;
|
||||
@@ -61,8 +57,6 @@ extern money32 gWeeklyProfitHistory[FINANCE_GRAPH_SIZE];
|
||||
extern money32 gParkValueHistory[FINANCE_GRAPH_SIZE];
|
||||
extern money32 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][RCT_EXPENDITURE_TYPE_COUNT];
|
||||
|
||||
extern uint8_t gCommandExpenditureType;
|
||||
|
||||
bool finance_check_money_required(uint32_t flags);
|
||||
bool finance_check_affordability(money32 cost, uint32_t flags);
|
||||
void finance_payment(money32 amount, rct_expenditure_type type);
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "../world/Sprite.h"
|
||||
#include "../world/Surface.h"
|
||||
#include "Peep.h"
|
||||
#include "Staff.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
@@ -1707,25 +1708,25 @@ loc_69B221:
|
||||
no_of_souvenirs++;
|
||||
|
||||
money16* expend_type = &paid_on_souvenirs;
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_SHOP_STOCK;
|
||||
rct_expenditure_type expenditure = RCT_EXPENDITURE_TYPE_SHOP_STOCK;
|
||||
|
||||
if (shop_item_is_food(shopItem))
|
||||
{
|
||||
expend_type = &paid_on_food;
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_FOODDRINK_STOCK;
|
||||
expenditure = RCT_EXPENDITURE_TYPE_FOODDRINK_STOCK;
|
||||
}
|
||||
|
||||
if (shop_item_is_drink(shopItem))
|
||||
{
|
||||
expend_type = &paid_on_drink;
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_FOODDRINK_STOCK;
|
||||
expenditure = RCT_EXPENDITURE_TYPE_FOODDRINK_STOCK;
|
||||
}
|
||||
|
||||
if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
|
||||
finance_payment(ShopItems[shopItem].Cost, gCommandExpenditureType);
|
||||
finance_payment(ShopItems[shopItem].Cost, expenditure);
|
||||
|
||||
// Sets the expenditure type to *_FOODDRINK_SALES or *_SHOP_SALES appropriately.
|
||||
gCommandExpenditureType--;
|
||||
expenditure = static_cast<rct_expenditure_type>(static_cast<int32_t>(expenditure) - 1);
|
||||
if (hasVoucher)
|
||||
{
|
||||
item_standard_flags &= ~PEEP_ITEM_VOUCHER;
|
||||
@@ -1733,7 +1734,7 @@ loc_69B221:
|
||||
}
|
||||
else if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
SpendMoney(*expend_type, price);
|
||||
SpendMoney(*expend_type, price, expenditure);
|
||||
}
|
||||
ride->total_profit += (price - ShopItems[shopItem].Cost);
|
||||
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME;
|
||||
@@ -2329,10 +2330,10 @@ bool Guest::ShouldGoToShop(Ride* ride, bool peepAtShop)
|
||||
}
|
||||
|
||||
// Used when no logging to an expend type required
|
||||
void Guest::SpendMoney(money32 amount)
|
||||
void Guest::SpendMoney(money32 amount, rct_expenditure_type expenditure)
|
||||
{
|
||||
money16 unused;
|
||||
SpendMoney(unused, amount);
|
||||
SpendMoney(unused, amount, expenditure);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2340,7 +2341,7 @@ void Guest::SpendMoney(money32 amount)
|
||||
* rct2: 0x0069926C
|
||||
* Expend type was previously an offset saved in 0x00F1AEC0
|
||||
*/
|
||||
void Guest::SpendMoney(money16& peep_expend_type, money32 amount)
|
||||
void Guest::SpendMoney(money16& peep_expend_type, money32 amount, rct_expenditure_type expenditure)
|
||||
{
|
||||
assert(!(gParkFlags & PARK_FLAGS_NO_MONEY));
|
||||
|
||||
@@ -2351,7 +2352,7 @@ void Guest::SpendMoney(money16& peep_expend_type, money32 amount)
|
||||
|
||||
window_invalidate_by_number(WC_PEEP, sprite_index);
|
||||
|
||||
finance_payment(-amount, gCommandExpenditureType);
|
||||
finance_payment(-amount, expenditure);
|
||||
|
||||
if (gConfigGeneral.show_guest_purchases && !(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
|
||||
{
|
||||
@@ -3872,8 +3873,7 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride* ride)
|
||||
{
|
||||
ride->total_profit += ridePrice;
|
||||
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME;
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS;
|
||||
SpendMoney(paid_on_rides, ridePrice);
|
||||
SpendMoney(paid_on_rides, ridePrice, RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "../world/Entrance.h"
|
||||
#include "../world/Footpath.h"
|
||||
#include "Peep.h"
|
||||
#include "Staff.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
@@ -2623,8 +2623,7 @@ static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileEl
|
||||
}
|
||||
|
||||
gTotalIncomeFromAdmissions += entranceFee;
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_PARK_ENTRANCE_TICKETS;
|
||||
guest->SpendMoney(peep->paid_to_enter, entranceFee);
|
||||
guest->SpendMoney(peep->paid_to_enter, entranceFee, RCT_EXPENDITURE_TYPE_PARK_ENTRANCE_TICKETS);
|
||||
peep->peep_flags |= PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY;
|
||||
}
|
||||
|
||||
@@ -2961,11 +2960,10 @@ static bool peep_interact_with_shop(Peep* peep, int16_t x, int16_t y, TileElemen
|
||||
{
|
||||
ride->total_profit += cost;
|
||||
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME;
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS;
|
||||
// TODO: Refactor? SpendMoney previously accepted nullptr to not track money, passing a temporary variable as a
|
||||
// workaround
|
||||
money16 money = 0;
|
||||
guest->SpendMoney(money, cost);
|
||||
guest->SpendMoney(money, cost, RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS);
|
||||
}
|
||||
peep->destination_x = (x & 0xFFE0) + 16;
|
||||
peep->destination_y = (y & 0xFFE0) + 16;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "../common.h"
|
||||
#include "../core/Optional.hpp"
|
||||
#include "../management/Finance.h"
|
||||
#include "../rct12/RCT12.h"
|
||||
#include "../ride/Ride.h"
|
||||
#include "../ride/RideTypes.h"
|
||||
@@ -762,8 +763,8 @@ public:
|
||||
bool ShouldFindBench();
|
||||
bool UpdateWalkingFindBench();
|
||||
bool UpdateWalkingFindBin();
|
||||
void SpendMoney(money16& peep_expend_type, money32 amount);
|
||||
void SpendMoney(money32 amount);
|
||||
void SpendMoney(money16& peep_expend_type, money32 amount, rct_expenditure_type type);
|
||||
void SpendMoney(money32 amount, rct_expenditure_type type);
|
||||
void SetHasRidden(const Ride* ride);
|
||||
bool HasRidden(const Ride* ride) const;
|
||||
void SetHasRiddenRideType(int32_t rideType);
|
||||
|
||||
Reference in New Issue
Block a user