Fix #18151: Recalculate park and company value when loading a save (#27065)

This commit is contained in:
Sjoerd de Bruin authored and GitHub committed 2026-09-22 21:29:38 +02:00
1 parent 5858550eb1
commit 66b81c502b
5 files changed
+15 -4

No files matched your search

+1
View File
@@ -10,6 +10,7 @@
- Fix: [#12516] Sprites past 65,536 pixels are drawn in the wrong place by the software renderer, most visibly in long scenario lists.
- Fix: [#15423] Crash when a guest or handyman uses a bin whose path addition object is not loaded.
- Fix: [#17409] When reading system settings, non-US dollar currencies are not recognised correctly.
- Fix: [#18151] Park value and company value are out of date after loading a save.
- Fix: [#19754, #27109] Some rides in RCT1 saves have a wrong number of cars per train.
- Fix: [#20882] When setting rides with preservation status in the Scenario Editor, some rides are not shown.
- Fix: [#21320] RCT1 allows more cars per train on some rides than OpenRCT2.
+5
View File
@@ -79,6 +79,7 @@
#include "ui/WindowManager.h"
#include "world/MapAnimation.h"
#include "world/MapSelection.h"
#include "world/Park.h"
#include <chrono>
#include <cmath>
@@ -810,6 +811,10 @@ namespace OpenRCT2
}
#endif
GameLoadInit(); // NB: calls `setActiveScene`
// Park::Update only recalculates these every ~13 seconds, so a save can hold a value that
// predates this park being loaded. Scenarios get the same treatment from ScenarioReset.
Park::updateValuations(gameState.park, gameState);
#ifndef DISABLE_NETWORK
if (_network.GetMode() == Network::Mode::server)
{
+1 -2
View File
@@ -87,8 +87,7 @@ void ScenarioReset(GameState_t& gameState)
auto& park = gameState.park;
park.rating = Park::CalculateParkRating(park, gameState);
park.value = Park::CalculateParkValue(park, gameState);
park.companyValue = Park::CalculateCompanyValue(park);
Park::updateValuations(park, gameState);
park.historicalProfit = gameState.scenarioOptions.initialCash - park.bankLoan;
park.cash = gameState.scenarioOptions.initialCash;
+7 -2
View File
@@ -311,6 +311,12 @@ namespace OpenRCT2::Park
gameState.scenarioOptions.details = String::toStd(LanguageGetString(STR_NO_DETAILS_YET));
}
void updateValuations(ParkData& park, const GameState_t& gameState)
{
park.value = CalculateParkValue(park, gameState);
park.companyValue = CalculateCompanyValue(park);
}
void Update(ParkData& park, GameState_t& gameState)
{
PROFILED_FUNCTION();
@@ -328,8 +334,7 @@ namespace OpenRCT2::Park
if (currentTicks % 512 == 0)
{
park.rating = CalculateParkRating(park, gameState);
park.value = CalculateParkValue(park, gameState);
park.companyValue = CalculateCompanyValue(park);
updateValuations(park, gameState);
park.totalRideValueForMoney = calculateTotalRideValueForMoney(park, gameState);
park.suggestedGuestMaximum = calculateSuggestedMaxGuests(park, gameState);
park.guestGenerationProbability = calculateGuestGenerationProbability(park);
+1
View File
@@ -30,6 +30,7 @@ namespace OpenRCT2::Park
int32_t CalculateParkRating(const ParkData& park, const GameState_t& gameState);
money64 CalculateParkValue(const ParkData& park, const GameState_t& gameState);
money64 CalculateCompanyValue(const ParkData& park);
void updateValuations(ParkData& park, const GameState_t& gameState);
Guest* GenerateGuest();