mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 05:43:42 -07:00
Prevent empty randomizer blocks from triggering the rando version flow. (#5689)
Clear SpoilerLog CVar when unsupported spoiler log is discovered on load.
This commit is contained in:
parent
5066fbf82c
commit
35ad68578e
2 changed files with 12 additions and 0 deletions
|
@ -406,6 +406,8 @@ bool Randomizer::SpoilerFileExists(const char* spoilerFileName) {
|
||||||
"The spoiler file located at\n" + std::string(spoilerFileName) +
|
"The spoiler file located at\n" + std::string(spoilerFileName) +
|
||||||
"\nwas made by a version that doesn't match the currently running version.\n" +
|
"\nwas made by a version that doesn't match the currently running version.\n" +
|
||||||
"Loading for this file has been cancelled.");
|
"Loading for this file has been cancelled.");
|
||||||
|
CVarClear(CVAR_GENERAL("SpoilerLog"));
|
||||||
|
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update cache
|
// Update cache
|
||||||
|
|
|
@ -1111,6 +1111,7 @@ void SaveManager::LoadFile(int fileNum) {
|
||||||
std::ifstream input(fileName);
|
std::ifstream input(fileName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
bool deleteRando = false;
|
||||||
saveBlock = nlohmann::json::object();
|
saveBlock = nlohmann::json::object();
|
||||||
input >> saveBlock;
|
input >> saveBlock;
|
||||||
if (!saveBlock.contains("version")) {
|
if (!saveBlock.contains("version")) {
|
||||||
|
@ -1122,6 +1123,10 @@ void SaveManager::LoadFile(int fileNum) {
|
||||||
for (auto& block : saveBlock["sections"].items()) {
|
for (auto& block : saveBlock["sections"].items()) {
|
||||||
std::string sectionName = block.key();
|
std::string sectionName = block.key();
|
||||||
if (sectionName == "randomizer") {
|
if (sectionName == "randomizer") {
|
||||||
|
if (block.value()["data"].empty()) {
|
||||||
|
deleteRando = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
bool hasStats = saveBlock["sections"].contains("sohStats");
|
bool hasStats = saveBlock["sections"].contains("sohStats");
|
||||||
if (block.value()["data"].contains("aat0") || !hasStats) { // Rachael rando data
|
if (block.value()["data"].contains("aat0") || !hasStats) { // Rachael rando data
|
||||||
SohGui::RegisterPopup(
|
SohGui::RegisterPopup(
|
||||||
|
@ -1201,6 +1206,11 @@ void SaveManager::LoadFile(int fileNum) {
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (deleteRando) {
|
||||||
|
saveBlock["sections"].erase(saveBlock["sections"].find("randomizer"));
|
||||||
|
SaveFile(fileNum);
|
||||||
|
deleteRando = false;
|
||||||
|
}
|
||||||
InitMeta(fileNum);
|
InitMeta(fileNum);
|
||||||
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnLoadFile>(fileNum);
|
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnLoadFile>(fileNum);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue