mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge 8105fb64ce
into 47d0996b4f
This commit is contained in:
commit
bd9e2643e3
|
@ -194,7 +194,8 @@ namespace OpenRCT2::Ui::Windows
|
|||
&& !(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(gClearSceneryCost);
|
||||
auto modifiedCost = FinanceGetModifiedCost(gClearSceneryCost,ExpenditureType::Landscaping);
|
||||
ft.Add<money64>(modifiedCost);
|
||||
screenCoords.x = window_clear_scenery_widgets[WIDX_PREVIEW].midX() + windowPos.x;
|
||||
screenCoords.y = window_clear_scenery_widgets[WIDX_PREVIEW].bottom + windowPos.y + 5 + 27;
|
||||
DrawTextBasic(dpi, screenCoords, STR_COST_AMOUNT, ft, { TextAlignment::CENTRE });
|
||||
|
|
|
@ -88,7 +88,8 @@ static Widget window_ride_demolish_widgets[] =
|
|||
: STR_DEMOLISH_RIDE_ID_MONEY;
|
||||
auto ft = Formatter();
|
||||
currentRide->FormatNameTo(ft);
|
||||
ft.Add<money64>(_demolishRideCost);
|
||||
auto modifiedCost = FinanceGetModifiedCost(_demolishRideCost,ExpenditureType::RideConstruction);
|
||||
ft.Add<money64>(modifiedCost);
|
||||
|
||||
ScreenCoordsXY stringCoords(windowPos.x + WW / 2, windowPos.y + (WH / 2) - 3);
|
||||
DrawTextWrapped(dpi, stringCoords, WW - 4, stringId, ft, { TextAlignment::CENTRE });
|
||||
|
|
|
@ -505,7 +505,8 @@ static constexpr uint8_t ConstructionPreviewImages[][4] = {
|
|||
if (!(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(_windowFootpathCost);
|
||||
auto updatedCost = FinanceGetModifiedCost(_windowFootpathCost,ExpenditureType::Landscaping);
|
||||
ft.Add<money64>(updatedCost);
|
||||
DrawTextBasic(dpi, screenCoords, STR_COST_LABEL, ft, { TextAlignment::CENTRE });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,7 +354,8 @@ static Widget window_install_track_widgets[] = {
|
|||
if (td6->cost != 0)
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(td6->cost);
|
||||
auto cost = FinanceGetModifiedCost(td6->cost, ExpenditureType::RideConstruction);
|
||||
ft.Add<money64>(cost);
|
||||
DrawTextBasic(dpi, screenPos, STR_TRACK_LIST_COST_AROUND, ft);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,7 +270,8 @@ static Widget window_land_widgets[] = {
|
|||
if (gLandToolRaiseCost != kMoney64Undefined && gLandToolRaiseCost != 0)
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(gLandToolRaiseCost);
|
||||
auto raiseCost = FinanceGetModifiedCost(gLandToolRaiseCost, ExpenditureType::Landscaping);
|
||||
ft.Add<money64>(raiseCost);
|
||||
DrawTextBasic(dpi, screenCoords, STR_RAISE_COST_AMOUNT, ft, { TextAlignment::CENTRE });
|
||||
}
|
||||
screenCoords.y += 10;
|
||||
|
@ -279,7 +280,8 @@ static Widget window_land_widgets[] = {
|
|||
if (gLandToolLowerCost != kMoney64Undefined && gLandToolLowerCost != 0)
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(gLandToolLowerCost);
|
||||
auto lowerCost = FinanceGetModifiedCost(gLandToolLowerCost, ExpenditureType::Landscaping);
|
||||
ft.Add<money64>(lowerCost);
|
||||
DrawTextBasic(dpi, screenCoords, STR_LOWER_COST_AMOUNT, ft, { TextAlignment::CENTRE });
|
||||
}
|
||||
screenCoords.y += 50;
|
||||
|
@ -304,7 +306,8 @@ static Widget window_land_widgets[] = {
|
|||
if (price != 0)
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(price);
|
||||
auto modifiedPrice = FinanceGetModifiedCost(price, ExpenditureType::Landscaping);
|
||||
ft.Add<money64>(modifiedPrice);
|
||||
DrawTextBasic(dpi, screenCoords, STR_COST_AMOUNT, ft, { TextAlignment::CENTRE });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,7 +232,8 @@ static Widget window_land_rights_widgets[] = {
|
|||
&& !(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(_landRightsCost);
|
||||
auto modifiedCost = FinanceGetModifiedCost(_landRightsCost, ExpenditureType::LandPurchase);
|
||||
ft.Add<money64>(modifiedCost);
|
||||
screenCoords = { window_land_rights_widgets[WIDX_PREVIEW].midX() + windowPos.x,
|
||||
window_land_rights_widgets[WIDX_PREVIEW].bottom + windowPos.y + 32 };
|
||||
DrawTextBasic(dpi, screenCoords, STR_COST_AMOUNT, ft, { TextAlignment::CENTRE });
|
||||
|
|
|
@ -968,7 +968,8 @@ static Widget window_new_ride_widgets[] = {
|
|||
stringId = STR_NEW_RIDE_COST_FROM;
|
||||
|
||||
ft = Formatter();
|
||||
ft.Add<money64>(price);
|
||||
auto modifiedPrice = FinanceGetModifiedCost(price,ExpenditureType::RideConstruction);
|
||||
ft.Add<money64>(modifiedPrice);
|
||||
DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ textWidth, 51 }, stringId, ft, { TextAlignment::RIGHT });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1581,7 +1581,7 @@ static Widget _rideConstructionWidgets[] = {
|
|||
if (_currentTrackPrice != kMoney64Undefined && !(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(_currentTrackPrice);
|
||||
ft.Add<money64>(FinanceGetModifiedCost(_currentTrackPrice,ExpenditureType::RideConstruction));
|
||||
DrawTextBasic(dpi, screenCoords, STR_COST_LABEL, ft, { TextAlignment::CENTRE });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -802,10 +802,11 @@ static Widget WindowSceneryBaseWidgets[] = {
|
|||
}
|
||||
|
||||
auto [name, price] = GetNameAndPrice(selectedSceneryEntry);
|
||||
if (price != kMoney64Undefined && !(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
auto modifiedPrice = FinanceGetModifiedCost(price,ExpenditureType::Landscaping);
|
||||
if (modifiedPrice != kMoney64Undefined && !(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(price);
|
||||
ft.Add<money64>(modifiedPrice);
|
||||
|
||||
// -14
|
||||
DrawTextBasic(
|
||||
|
|
|
@ -935,7 +935,8 @@ static Widget _staffOptionsWidgets[] = {
|
|||
if (!(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(GetStaffWage(staff->AssignedStaffType));
|
||||
auto modifiedCost = FinanceGetModifiedCost(GetStaffWage(staff->AssignedStaffType),ExpenditureType::Wages);
|
||||
ft.Add<money64>(modifiedCost);
|
||||
DrawTextBasic(dpi, screenCoords, STR_STAFF_STAT_WAGES, ft);
|
||||
screenCoords.y += kListRowHeight;
|
||||
}
|
||||
|
|
|
@ -293,7 +293,8 @@ static Widget _staffListWidgets[] = {
|
|||
if (!(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(GetStaffWage(GetSelectedStaffType()));
|
||||
auto modifiedWage = FinanceGetModifiedCost(GetStaffWage(GetSelectedStaffType()),ExpenditureType::Wages);
|
||||
ft.Add<money64>(modifiedWage);
|
||||
DrawTextBasic(dpi, windowPos + ScreenCoordsXY{ width - 155, 32 }, STR_COST_PER_MONTH, ft);
|
||||
}
|
||||
|
||||
|
|
|
@ -667,7 +667,8 @@ static Widget _trackListWidgets[] = {
|
|||
if (_loadedTrackDesign->cost != 0)
|
||||
{
|
||||
ft = Formatter();
|
||||
ft.Add<uint32_t>(_loadedTrackDesign->cost);
|
||||
auto modifiedCost = FinanceGetModifiedCost(_loadedTrackDesign->cost,ExpenditureType::RideConstruction);
|
||||
ft.Add<uint32_t>(modifiedCost);
|
||||
DrawTextBasic(dpi, screenPos, STR_TRACK_LIST_COST_AROUND, ft);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ namespace OpenRCT2
|
|||
uint8_t BankLoanInterestRate;
|
||||
money64 MaxBankLoan;
|
||||
money64 ExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][EnumValue(ExpenditureType::Count)];
|
||||
uint16_t CostMultiplierExpenditureTable[EnumValue(ExpenditureType::Count)];
|
||||
random_engine_t ScenarioRand;
|
||||
TileCoordsXY MapSize;
|
||||
money64 LandPrice;
|
||||
|
|
|
@ -210,12 +210,13 @@ namespace GameActions
|
|||
|
||||
if (result.Error == GameActions::Status::Ok)
|
||||
{
|
||||
if (!FinanceCheckAffordability(result.Cost, action->GetFlags()))
|
||||
auto modifiedCost = FinanceGetModifiedCost(result.Cost, result.Expenditure);
|
||||
if (!FinanceCheckAffordability(modifiedCost, action->GetFlags()))
|
||||
{
|
||||
result.Error = GameActions::Status::InsufficientFunds;
|
||||
result.ErrorTitle = STR_CANT_DO_THIS;
|
||||
result.ErrorMessage = STR_NOT_ENOUGH_CASH_REQUIRES;
|
||||
Formatter(result.ErrorMessageArgs.data()).Add<uint32_t>(result.Cost);
|
||||
Formatter(result.ErrorMessageArgs.data()).Add<uint32_t>(modifiedCost);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -373,10 +374,11 @@ namespace GameActions
|
|||
return result;
|
||||
|
||||
// Update money balance
|
||||
if (result.Error == GameActions::Status::Ok && FinanceCheckMoneyRequired(flags) && result.Cost != 0)
|
||||
auto modifiedCost = FinanceGetModifiedCost(result.Cost, result.Expenditure);
|
||||
if (result.Error == GameActions::Status::Ok && FinanceCheckMoneyRequired(flags) && modifiedCost != 0)
|
||||
{
|
||||
FinancePayment(result.Cost, result.Expenditure);
|
||||
MoneyEffect::Create(result.Cost, result.Position);
|
||||
FinancePayment(modifiedCost, result.Expenditure);
|
||||
MoneyEffect::Create(modifiedCost, result.Position);
|
||||
}
|
||||
|
||||
if (!(actionFlags & GameActions::Flags::ClientOnly) && result.Error == GameActions::Status::Ok)
|
||||
|
@ -391,9 +393,9 @@ namespace GameActions
|
|||
|
||||
NetworkSetPlayerLastAction(playerIndex, action->GetType());
|
||||
NetworkIncrementPlayerNumCommands(playerIndex);
|
||||
if (result.Cost > 0)
|
||||
if (modifiedCost > 0)
|
||||
{
|
||||
NetworkAddPlayerMoneySpent(playerIndex, result.Cost);
|
||||
NetworkAddPlayerMoneySpent(playerIndex, modifiedCost);
|
||||
}
|
||||
|
||||
if (!result.Position.IsNull())
|
||||
|
|
|
@ -1695,7 +1695,10 @@ bool Guest::DecideAndBuyItem(Ride& ride, const ShopItem shopItem, money64 price)
|
|||
}
|
||||
|
||||
if (!(gameState.Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
FinancePayment(shopItemDescriptor.Cost, expenditure);
|
||||
{
|
||||
money64 modifiedCost = FinanceGetModifiedCost(shopItemDescriptor.Cost, expenditure);
|
||||
FinancePayment(modifiedCost, expenditure);
|
||||
}
|
||||
|
||||
// Sets the expenditure type to *_FOODDRINK_SALES or *_SHOP_SALES appropriately.
|
||||
expenditure = static_cast<ExpenditureType>(static_cast<int32_t>(expenditure) - 1);
|
||||
|
@ -2302,16 +2305,18 @@ void Guest::SpendMoney(money64& peep_expend_type, money64 amount, ExpenditureTyp
|
|||
{
|
||||
assert(!(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY));
|
||||
|
||||
CashInPocket = std::max(0.00_GBP, static_cast<money64>(CashInPocket) - amount);
|
||||
CashSpent += amount;
|
||||
auto modifiedCost = FinanceGetModifiedCost(amount, expenditure);
|
||||
|
||||
peep_expend_type += amount;
|
||||
CashInPocket = std::max(0.00_GBP, static_cast<money64>(CashInPocket) - modifiedCost);
|
||||
CashSpent += modifiedCost;
|
||||
|
||||
peep_expend_type += modifiedCost;
|
||||
|
||||
WindowInvalidateByNumber(WindowClass::Peep, Id);
|
||||
|
||||
FinancePayment(-amount, expenditure);
|
||||
FinancePayment(-modifiedCost, expenditure);
|
||||
|
||||
MoneyEffect::CreateAt(amount, GetLocation(), true);
|
||||
MoneyEffect::CreateAt(modifiedCost, GetLocation(), true);
|
||||
|
||||
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Purchase, GetLocation());
|
||||
}
|
||||
|
|
|
@ -91,6 +91,14 @@ void FinancePayment(money64 amount, ExpenditureType type)
|
|||
ContextBroadcastIntent(&intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the cost multiplier with the expenditure modifier applied.
|
||||
*/
|
||||
money64 FinanceGetModifiedCost(money64 cost, ExpenditureType type)
|
||||
{
|
||||
return cost * GetGameState().CostMultiplierExpenditureTable[EnumValue(type)] / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pays the wages of all active staff members in the park.
|
||||
* rct2: 0x006C18A9
|
||||
|
@ -106,7 +114,8 @@ void FinancePayWages()
|
|||
|
||||
for (auto peep : EntityList<Staff>())
|
||||
{
|
||||
FinancePayment(GetStaffWage(peep->AssignedStaffType) / 4, ExpenditureType::Wages);
|
||||
auto modifiedCost = FinanceGetModifiedCost(GetStaffWage(peep->AssignedStaffType), ExpenditureType::Wages);
|
||||
FinancePayment(modifiedCost / 4, ExpenditureType::Wages);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +132,8 @@ void FinancePayResearch()
|
|||
}
|
||||
|
||||
const uint8_t level = gameState.ResearchFundingLevel;
|
||||
FinancePayment(research_cost_table[level] / 4, ExpenditureType::Research);
|
||||
auto modifiedCost = FinanceGetModifiedCost(research_cost_table[level], ExpenditureType::Research);
|
||||
FinancePayment(modifiedCost / 4, ExpenditureType::Research);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,7 +157,8 @@ void FinancePayInterest()
|
|||
? (current_loan / 2400)
|
||||
: (current_loan * 5 * current_interest_rate) >> 14;
|
||||
|
||||
FinancePayment(interest_to_pay, ExpenditureType::Interest);
|
||||
auto modifiedCost = FinanceGetModifiedCost(interest_to_pay, ExpenditureType::Interest);
|
||||
FinancePayment(modifiedCost, ExpenditureType::Interest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,12 +178,12 @@ void FinancePayRideUpkeep()
|
|||
|
||||
if (ride.status != RideStatus::Closed && !(GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY))
|
||||
{
|
||||
auto upkeep = ride.upkeep_cost;
|
||||
if (upkeep != kMoney64Undefined)
|
||||
auto modifiedUpkeep = FinanceGetModifiedCost(ride.upkeep_cost, ExpenditureType::RideRunningCosts);
|
||||
if (modifiedUpkeep != kMoney64Undefined)
|
||||
{
|
||||
ride.total_profit -= upkeep;
|
||||
ride.total_profit -= modifiedUpkeep;
|
||||
ride.window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME;
|
||||
FinancePayment(upkeep, ExpenditureType::RideRunningCosts);
|
||||
FinancePayment(modifiedUpkeep, ExpenditureType::RideRunningCosts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,6 +225,7 @@ void FinanceInit()
|
|||
for (uint32_t i = 0; i < static_cast<int32_t>(ExpenditureType::Count); i++)
|
||||
{
|
||||
gameState.ExpenditureTable[0][i] = 0;
|
||||
gameState.CostMultiplierExpenditureTable[i] = 50;
|
||||
}
|
||||
|
||||
gameState.CurrentExpenditure = 0;
|
||||
|
|
|
@ -57,3 +57,4 @@ money64 FinanceGetMaximumLoan();
|
|||
money64 FinanceGetCurrentCash();
|
||||
|
||||
money64 FinanceGetLastMonthShopProfit();
|
||||
money64 FinanceGetModifiedCost(money64 cost, ExpenditureType type);
|
||||
|
|
Loading…
Reference in New Issue