diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index c8011dc63d..5ea9f38e75 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -332,17 +332,16 @@ void update_palette_effects() * * @param cost (ebp) */ -static int32_t game_check_affordability(int32_t cost) +static int32_t game_check_affordability(int32_t cost, uint32_t flags) { - if (cost <= 0) - return cost; + // Only checked for game commands. if (gUnk141F568 & 0xF0) return cost; - if (cost <= gCash) + + if (finance_check_affordability(cost, flags)) return cost; set_format_arg(0, uint32_t, cost); - gGameCommandErrorText = STR_NOT_ENOUGH_CASH_REQUIRES; return MONEY32_UNDEFINED; } @@ -447,7 +446,7 @@ int32_t game_do_command_p( // Check funds int32_t insufficientFunds = 0; if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_2) && !(flags & GAME_COMMAND_FLAG_5) && cost != 0) - insufficientFunds = game_check_affordability(cost); + insufficientFunds = game_check_affordability(cost, flags); if (insufficientFunds != MONEY32_UNDEFINED) { @@ -531,8 +530,8 @@ int32_t game_do_command_p( if (gGameCommandNestLevel != 0) return cost; - // - if (!(flags & 0x20)) + // Check if money is required. + if (finance_check_money_required(flags)) { // Update money balance finance_payment(cost, gCommandExpenditureType); diff --git a/src/openrct2/actions/FootpathRemoveAction.hpp b/src/openrct2/actions/FootpathRemoveAction.hpp index 8e7335bf53..94dfef978c 100644 --- a/src/openrct2/actions/FootpathRemoveAction.hpp +++ b/src/openrct2/actions/FootpathRemoveAction.hpp @@ -138,16 +138,6 @@ private: money32 GetRefundPrice(TileElement * footpathElement) const { money32 cost = -MONEY(10, 00); - - bool isNotOwnedByPark = (GetFlags() & GAME_COMMAND_FLAG_5); - bool moneyDisabled = (gParkFlags & PARK_FLAGS_NO_MONEY); - bool isGhost = (footpathElement == nullptr) || (footpathElement->IsGhost()); - - if (isNotOwnedByPark || moneyDisabled || isGhost) - { - cost = 0; - } - return cost; } }; diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index 54d6c2e04c..b8b78af009 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -154,7 +154,7 @@ namespace GameActions if (result->Error == GA_ERROR::OK) { - if (finance_check_affordability(result->Cost, action->GetFlags())) + if (finance_check_affordability(result->Cost, action->GetFlags()) == false) { result->Error = GA_ERROR::INSUFFICIENT_FUNDS; result->ErrorMessage = STR_NOT_ENOUGH_CASH_REQUIRES; @@ -298,7 +298,7 @@ namespace GameActions gCommandPosition.z = result->Position.z; // Update money balance - if (finance_check_money_required(flags) && result->Cost != 0) + if (result->Error == GA_ERROR::OK && finance_check_money_required(flags) && result->Cost != 0) { finance_payment(result->Cost, result->ExpenditureType); money_effect_create(result->Cost); diff --git a/src/openrct2/actions/LandSetHeightAction.hpp b/src/openrct2/actions/LandSetHeightAction.hpp index 52d9900947..5161d4f588 100644 --- a/src/openrct2/actions/LandSetHeightAction.hpp +++ b/src/openrct2/actions/LandSetHeightAction.hpp @@ -134,11 +134,7 @@ public: } } auto res = std::make_unique(); - res->Cost = 0; - if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !(gParkFlags & PARK_FLAGS_NO_MONEY)) - { - res->Cost = sceneryRemovalCost + GetSurfaceHeightChangeCost(surfaceElement); - } + res->Cost = sceneryRemovalCost + GetSurfaceHeightChangeCost(surfaceElement); res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; return res; } diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index c68dc85938..d2c8421a24 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -91,11 +91,9 @@ 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; + if (cost > gCash) + return false; + return true; } /**