Explicitly clears the entire ItemLocations array. (#3820)

This commit is contained in:
Christopher Leggett 2024-01-08 09:37:10 -05:00 committed by GitHub
parent 1669393277
commit 63413e8159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -46,6 +46,7 @@ bool GenerateRandomizer(std::set<RandomizerCheck> excludedLocations, std::set<Ra
uint32_t seedHash = boost::hash_32<std::string>{}(ctx->GetSettings()->GetSeedString());
ctx->GetSettings()->SetSeed(seedHash & 0xFFFFFFFF);
ctx->ClearItemLocations();
int ret = Playthrough::Playthrough_Init(ctx->GetSettings()->GetSeed(), excludedLocations, enabledTricks);
if (ret < 0) {
if (ret == -1) { // Failed to generate after 5 tries

View File

@ -226,6 +226,12 @@ std::vector<RandomizerCheck> Context::GetLocations(const std::vector<RandomizerC
return locationsInCategory;
}
void Context::ClearItemLocations() {
for (int i = 0; i < itemLocationTable.size(); i++) {
GetItemLocation(static_cast<RandomizerCheck>(i))->ResetVariables();
}
}
void Context::ItemReset() {
for (const RandomizerCheck il : allLocations) {
GetItemLocation(il)->ResetVariables();

View File

@ -50,6 +50,7 @@ class Context {
Category categoryInclude, Category categoryExclude = Category::cNull);
void AddExcludedOptions();
void LocationReset();
void ClearItemLocations();
void ItemReset();
void HintReset();
void CreateItemOverrides();