From add5347126aa7e7cbd10cc138b74491725e65700 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 15 Dec 2024 15:20:51 -0700 Subject: [PATCH] Properly check for pre-existing gInjectItemCounts before setting the new separate CVars. (#4692) --- soh/soh/config/ConfigUpdaters.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/soh/soh/config/ConfigUpdaters.cpp b/soh/soh/config/ConfigUpdaters.cpp index e43e98b76..6c18b6fd4 100644 --- a/soh/soh/config/ConfigUpdaters.cpp +++ b/soh/soh/config/ConfigUpdaters.cpp @@ -71,17 +71,17 @@ namespace SOH { void ConfigVersion3Updater::Update(Ship::Config* conf) { conf->EraseBlock("Controllers"); + if (conf->GetNestedJson().contains("CVars") && conf->GetNestedJson()["CVars"].contains("gInjectItemCounts")) { + CVarClear("gInjectItemCounts"); + CVarSetInteger("gEnhancements.InjectItemCounts.GoldSkulltula", 1); + CVarSetInteger("gEnhancements.InjectItemCounts.HeartContainer", 1); + CVarSetInteger("gEnhancements.InjectItemCounts.HeartPiece", 1); + } for (Migration migration : version3Migrations) { if (migration.action == MigrationAction::Rename) { CVarCopy(migration.from.c_str(), migration.to.value().c_str()); } CVarClear(migration.from.c_str()); } - if (conf->Contains("CVars.gEnhancements.InjectItemCounts")) { - CVarClear("gEnhancements.InjectItemCounts"); - CVarSetInteger("gEnhancements.InjectItemCounts.GoldSkulltula", 1); - CVarSetInteger("gEnhancements.InjectItemCounts.HeartContainer", 1); - CVarSetInteger("gEnhancements.InjectItemCounts.HeartPiece", 1); - } } }