1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Update checks for when money is required.

This commit is contained in:
Matt
2019-02-10 23:24:40 +01:00
parent 21e4c52853
commit a6c6d6ddc3
5 changed files with 13 additions and 30 deletions

View File

@@ -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);

View File

@@ -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;
}
};

View File

@@ -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);

View File

@@ -134,11 +134,7 @@ public:
}
}
auto res = std::make_unique<GameActionResult>();
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;
}

View File

@@ -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;
}
/**