From bf9f6bbe7915d6e952ec4ec436b55328ae225a53 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 28 Nov 2024 13:41:59 +0300 Subject: [PATCH] make 'structures.toml' combined --- src/content/loading/GeneratorLoader.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/content/loading/GeneratorLoader.cpp b/src/content/loading/GeneratorLoader.cpp index 8aef7f7b..f9f06d80 100644 --- a/src/content/loading/GeneratorLoader.cpp +++ b/src/content/loading/GeneratorLoader.cpp @@ -132,14 +132,14 @@ static VoxelStructureMeta load_structure_meta( } static std::vector> load_structures( - const fs::path& structuresFile + const dv::value& map, const fs::path& filesFolder, const ResPaths& paths ) { - auto structuresDir = structuresFile.parent_path() / fs::path("fragments"); - auto map = files::read_object(structuresFile); + auto structuresDir = filesFolder / fs::path("fragments"); std::vector> structures; for (auto& [name, config] : map.asObject()) { auto structFile = structuresDir / fs::u8path(name + ".vox"); + structFile = paths.find(structFile.u8string()); logger.debug() << "loading voxel fragment " << structFile.u8string(); if (!fs::exists(structFile)) { throw std::runtime_error("structure file does not exist (" + @@ -159,8 +159,13 @@ static std::vector> load_structures( return structures; } -static void load_structures(GeneratorDef& def, const fs::path& structuresFile) { - auto rawStructures = load_structures(structuresFile); +static void load_structures( + GeneratorDef& def, + const dv::value& map, + const fs::path& filesFolder, + const ResPaths& paths +) { + auto rawStructures = load_structures(map, filesFolder, paths); def.structures.resize(rawStructures.size()); for (int i = 0; i < rawStructures.size(); i++) { @@ -231,10 +236,9 @@ void ContentLoader::loadGenerator( auto folder = generatorsDir / fs::u8path(name + ".files"); auto scriptFile = folder / fs::u8path("script.lua"); - auto structuresFile = folder / STRUCTURES_FILE; - if (fs::exists(structuresFile)) { - load_structures(def, structuresFile); - } + auto structuresFile = GENERATORS_DIR / fs::u8path(name + ".files") / STRUCTURES_FILE; + auto structuresMap = paths.readCombinedObject(structuresFile.u8string()); + load_structures(def, structuresMap, structuresFile.parent_path(), paths); auto biomesFile = GENERATORS_DIR / fs::u8path(name + ".files") / BIOMES_FILE; auto biomesMap = paths.readCombinedObject(biomesFile.u8string());