diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index 7c64905411..c68dc85938 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -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 diff --git a/src/openrct2/management/Finance.h b/src/openrct2/management/Finance.h index ef131b5f26..2a7191b3d7 100644 --- a/src/openrct2/management/Finance.h +++ b/src/openrct2/management/Finance.h @@ -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();