Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move gScenarioRand to GameState_t #21280

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/openrct2/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace OpenRCT2
uint16_t ScenarioParkRatingWarningDays;
money64 ScenarioCompletedCompanyValue;
money64 ScenarioCompanyValueRecord;
random_engine_t ScenarioRand;

SCENARIO_CATEGORY ScenarioCategory;
std::string ScenarioName;
Expand Down
4 changes: 3 additions & 1 deletion src/openrct2/core/Random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ namespace Random
return std::numeric_limits<result_type>::max();
}

explicit RotateEngine(result_type seed_value = default_seed)
RotateEngine() = default;

explicit RotateEngine(result_type seed_value)
ZehMatt marked this conversation as resolved.
Show resolved Hide resolved
{
seed(seed_value);
}
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/park/ParkFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,11 @@ namespace OpenRCT2
cs.ReadWrite(s0);
cs.ReadWrite(s1);
Random::RCT2::Seed s{ s0, s1 };
gScenarioRand.seed(s);
gameState.ScenarioRand.seed(s);
}
else
{
auto randState = gScenarioRand.state();
auto randState = gameState.ScenarioRand.state();
cs.Write(randState.s0);
cs.Write(randState.s1);
}
Expand Down
10 changes: 4 additions & 6 deletions src/openrct2/scenario/Scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ bool gFirstTimeSaving = true;
uint16_t gSavedAge;
uint32_t gLastAutoSaveUpdate = 0;

random_engine_t gScenarioRand;

bool gAllowEarlyCompletionInNetworkPlay;

std::string gScenarioFileName;
Expand All @@ -97,7 +95,7 @@ void ScenarioReset(GameState_t& gameState)
{
// Set the scenario pseudo-random seeds
Random::RCT2::Seed s{ 0x1234567F ^ Platform::GetTicks(), 0x789FABCD ^ Platform::GetTicks() };
gScenarioRand.seed(s);
gameState.ScenarioRand.seed(s);

ResearchResetCurrentItem();
ScenerySetDefaultPlacementConfiguration();
Expand Down Expand Up @@ -496,13 +494,13 @@ bool ScenarioCreateDucks()

const random_engine_t::state_type& ScenarioRandState()
{
return gScenarioRand.state();
return GetGameState().ScenarioRand.state();
};

void ScenarioRandSeed(random_engine_t::result_type s0, random_engine_t::result_type s1)
{
Random::RCT2::Seed s{ s0, s1 };
gScenarioRand.seed(s);
GetGameState().ScenarioRand.seed(s);
}

/**
Expand All @@ -513,7 +511,7 @@ void ScenarioRandSeed(random_engine_t::result_type s0, random_engine_t::result_t
*/
random_engine_t::result_type ScenarioRand()
{
return gScenarioRand();
return GetGameState().ScenarioRand();
}

uint32_t ScenarioRandMax(uint32_t max)
Expand Down
2 changes: 0 additions & 2 deletions src/openrct2/scenario/Scenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ static constexpr money64 COMPANY_VALUE_ON_FAILED_OBJECTIVE = 0x8000000000000001;

extern const StringId ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT];

extern random_engine_t gScenarioRand;

extern bool gAllowEarlyCompletionInNetworkPlay;

extern std::string gScenarioSavePath;
Expand Down
Loading