[Bugfix] Prevent crash in audio editor when shuffling over old CVar format (#3337)

* Add a `CVarClear` inside the check for a sequence's lock to get rid of old data.

* Rework all replacement and lock `CVarSetInteger` calls to call a function which checks for previous format with `CVarGet` to know if it needs clearing before setting either the lock or the sequence

* Swapped everything over to a migrator where it loops through the `sequenceMap` and just clears everything from there in "gAudioEditor.ReplacedSequences"
This commit is contained in:
Malkierian 2023-11-05 00:57:59 -07:00 committed by GitHub
parent e60761eb61
commit 39a7437fc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 6 deletions

View File

@ -831,6 +831,7 @@ extern "C" void InitOTR() {
std::shared_ptr<LUS::Config> conf = OTRGlobals::Instance->context->GetConfig();
conf->RegisterConfigVersionUpdater(std::make_shared<LUS::ConfigVersion1Updater>());
conf->RegisterConfigVersionUpdater(std::make_shared<LUS::ConfigVersion2Updater>());
conf->RunVersionUpdates();
}

View File

@ -1,7 +1,9 @@
#include "ConfigUpdaters.h"
#include "soh/Enhancements/audio/AudioCollection.h"
namespace LUS {
ConfigVersion1Updater::ConfigVersion1Updater() : ConfigVersionUpdater(1) {}
ConfigVersion2Updater::ConfigVersion2Updater() : ConfigVersionUpdater(2) {}
void ConfigVersion1Updater::Update(Config* conf) {
if (conf->GetInt("Window.Width", 640) == 640) {
@ -60,4 +62,10 @@ namespace LUS {
}
CVarClear("gSeededRandomizedEnemies");
}
}
void ConfigVersion2Updater::Update(Config* conf) {
for (auto seq : AudioCollection::Instance->GetAllSequences()) {
CVarClear(std::string("gAudioEditor.ReplacedSequences." + seq.second.sfxKey).c_str());
}
}
}

View File

@ -1,9 +1,15 @@
#include "libultraship/libultraship.h"
namespace LUS {
class ConfigVersion1Updater : public ConfigVersionUpdater {
public:
ConfigVersion1Updater();
void Update(Config* conf);
};
class ConfigVersion1Updater : public ConfigVersionUpdater {
public:
ConfigVersion1Updater();
void Update(Config* conf);
};
class ConfigVersion2Updater : public ConfigVersionUpdater {
public:
ConfigVersion2Updater();
void Update(Config* conf);
};
}