update component parent environment to the pack environment

This commit is contained in:
MihailRis
2024-07-02 20:01:29 +03:00
parent 3fe66e134d
commit 0082a3444e
4 changed files with 27 additions and 32 deletions
-19
View File
@@ -380,25 +380,6 @@ void ContentLoader::loadBlockMaterial(BlockMaterial& def, const fs::path& file)
root->str("break-sound", def.breakSound);
}
template<class T, void(ContentLoader::*loadfunc)(T&, const std::string&, const std::string&)>
static void load_defs(ContentLoader* cl, dynamic::List* arr, const ContentPack* pack, ContentUnitBuilder<T>& builder, size_t& counter) {
if (arr == nullptr) {
return;
}
for (size_t i = 0; i < arr->size(); i++) {
std::string name = arr->str(i);
auto colon = name.find(':');
std::string full = colon == std::string::npos ? pack->id + ":" + name : name;
if (colon != std::string::npos) name[colon] = '/';
auto& def = builder.create(full);
if (colon != std::string::npos) {
def.scriptName = name.substr(0, colon) + '/' + def.scriptName;
}
cl->*loadfunc(def, full, name);
counter++;
}
}
void ContentLoader::load() {
logger.info() << "loading pack [" << pack->id << "]";