mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Add finance_check_money_required and finance_check_affordability helper functions.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../Game.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../interface/Window.h"
|
||||
#include "../localisation/Date.h"
|
||||
#include "../localisation/Localisation.h"
|
||||
@@ -64,6 +65,39 @@ money32 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][RCT_EXPENDITURE_TYPE_CO
|
||||
|
||||
uint8_t gCommandExpenditureType;
|
||||
|
||||
/**
|
||||
* Checks the condition if the game is required to use money.
|
||||
* @param flags game command flags.
|
||||
*/
|
||||
bool finance_check_money_required(uint32_t flags)
|
||||
{
|
||||
if (gParkFlags & PARK_FLAGS_NO_MONEY)
|
||||
return false;
|
||||
if (gScreenFlags & SCREEN_FLAGS_EDITOR)
|
||||
return false;
|
||||
if (flags & GAME_COMMAND_FLAG_5)
|
||||
return false;
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if enough money is available.
|
||||
* @param cost.
|
||||
* @param flags game command flags.
|
||||
*/
|
||||
bool finance_check_affordability(money32 cost, uint32_t flags)
|
||||
{
|
||||
if (finance_check_money_required(flags) == false)
|
||||
return true;
|
||||
if (cost <= 0)
|
||||
return true;
|
||||
if (cost <= gCash)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pay an amount of money.
|
||||
* rct2: 0x069C674
|
||||
|
||||
@@ -63,6 +63,8 @@ extern money32 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][RCT_EXPENDITURE_
|
||||
|
||||
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);
|
||||
void finance_pay_wages();
|
||||
void finance_pay_research();
|
||||
|
||||
Reference in New Issue
Block a user