Skip to content

Commit

Permalink
Get size of WeeklyProfitHistory in compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
Broxzier committed Jan 25, 2024
1 parent 99e1746 commit 1f8b795
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/openrct2/world/Park.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,13 +773,14 @@ void Park::UpdateHistories()
{
currentWeeklyProfit /= gameState.WeeklyProfitAverageDivisor;
}
HistoryPushRecord<money64, FINANCE_GRAPH_SIZE>(gameState.WeeklyProfitHistory, currentWeeklyProfit);
constexpr auto profitHistorySize = std::extent_v<decltype(GameState_t::WeeklyProfitHistory)>;
HistoryPushRecord<money64, profitHistorySize>(gameState.WeeklyProfitHistory, currentWeeklyProfit);
gameState.WeeklyProfitAverageDividend = 0;
gameState.WeeklyProfitAverageDivisor = 0;

// Update park value history
HistoryPushRecord<money64, std::extent_v<decltype(GameState_t::ParkValueHistory)>>(
gameState.ParkValueHistory, gameState.ParkValue);
constexpr auto parkValueHistorySize = std::extent_v<decltype(GameState_t::WeeklyProfitHistory)>;
HistoryPushRecord<money64, parkValueHistorySize>(gameState.ParkValueHistory, gameState.ParkValue);

// Invalidate relevant windows
auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT);
Expand Down

0 comments on commit 1f8b795

Please sign in to comment.