From fa6f45bde53e4df1bf274635f980342ed3d28c59 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Tue, 27 May 2025 13:19:14 -0700 Subject: [PATCH] Fix Preset List with no customs available (#5535) * Surround preset file processing with the fs::exists check rather than returning early. * clang --- soh/soh/Enhancements/Presets/Presets.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/soh/soh/Enhancements/Presets/Presets.cpp b/soh/soh/Enhancements/Presets/Presets.cpp index b5c364251..d50b45360 100644 --- a/soh/soh/Enhancements/Presets/Presets.cpp +++ b/soh/soh/Enhancements/Presets/Presets.cpp @@ -193,23 +193,22 @@ void ParsePreset(nlohmann::json& json, std::string name) { } void LoadPresets() { - if (!fs::exists(presetFolder)) { - return; - } if (!presets.empty()) { presets.clear(); } - for (auto const& preset : fs::directory_iterator(presetFolder)) { - std::ifstream ifs(preset.path()); + if (fs::exists(presetFolder)) { + for (auto const& preset : fs::directory_iterator(presetFolder)) { + std::ifstream ifs(preset.path()); - auto json = nlohmann::json::parse(ifs); - if (!json.contains("presetName")) { - spdlog::error(fmt::format("Attempted to load file {} as a preset, but was not a preset file.", - preset.path().filename().string())); - } else { - ParsePreset(json, preset.path().filename().stem().string()); + auto json = nlohmann::json::parse(ifs); + if (!json.contains("presetName")) { + spdlog::error(fmt::format("Attempted to load file {} as a preset, but was not a preset file.", + preset.path().filename().string())); + } else { + ParsePreset(json, preset.path().filename().stem().string()); + } + ifs.close(); } - ifs.close(); } auto initData = std::make_shared(); initData->Format = RESOURCE_FORMAT_BINARY;