summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalkierian <malkierian@gmail.com>2025-05-27 13:19:14 -0700
committerGitHub <noreply@github.com>2025-05-27 13:19:14 -0700
commitfa6f45bde53e4df1bf274635f980342ed3d28c59 (patch)
treed93334d8a97108744feae8c4ca5373e0d40af438
parent4e8e6d2313bc0a09a86c0a5d6573a985d33998c8 (diff)
Fix Preset List with no customs available (#5535)
* Surround preset file processing with the fs::exists check rather than returning early. * clang
-rw-r--r--soh/soh/Enhancements/Presets/Presets.cpp23
1 files 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<Ship::ResourceInitData>();
initData->Format = RESOURCE_FORMAT_BINARY;