mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-31 03:50:37 -07:00
Fix Preset List with no customs available (#5535)
* Surround preset file processing with the fs::exists check rather than returning early. * clang
This commit is contained in:
parent
4e8e6d2313
commit
fa6f45bde5
1 changed files with 11 additions and 12 deletions
|
@ -193,23 +193,22 @@ void ParsePreset(nlohmann::json& json, std::string name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadPresets() {
|
void LoadPresets() {
|
||||||
if (!fs::exists(presetFolder)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!presets.empty()) {
|
if (!presets.empty()) {
|
||||||
presets.clear();
|
presets.clear();
|
||||||
}
|
}
|
||||||
for (auto const& preset : fs::directory_iterator(presetFolder)) {
|
if (fs::exists(presetFolder)) {
|
||||||
std::ifstream ifs(preset.path());
|
for (auto const& preset : fs::directory_iterator(presetFolder)) {
|
||||||
|
std::ifstream ifs(preset.path());
|
||||||
|
|
||||||
auto json = nlohmann::json::parse(ifs);
|
auto json = nlohmann::json::parse(ifs);
|
||||||
if (!json.contains("presetName")) {
|
if (!json.contains("presetName")) {
|
||||||
spdlog::error(fmt::format("Attempted to load file {} as a preset, but was not a preset file.",
|
spdlog::error(fmt::format("Attempted to load file {} as a preset, but was not a preset file.",
|
||||||
preset.path().filename().string()));
|
preset.path().filename().string()));
|
||||||
} else {
|
} else {
|
||||||
ParsePreset(json, preset.path().filename().stem().string());
|
ParsePreset(json, preset.path().filename().stem().string());
|
||||||
|
}
|
||||||
|
ifs.close();
|
||||||
}
|
}
|
||||||
ifs.close();
|
|
||||||
}
|
}
|
||||||
auto initData = std::make_shared<Ship::ResourceInitData>();
|
auto initData = std::make_shared<Ship::ResourceInitData>();
|
||||||
initData->Format = RESOURCE_FORMAT_BINARY;
|
initData->Format = RESOURCE_FORMAT_BINARY;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue