cleanup ContentControl

This commit is contained in:
MihailRis
2025-04-02 15:01:24 +03:00
parent f99d909f34
commit 3486cbd4c9
10 changed files with 59 additions and 114 deletions
+5 -5
View File
@@ -15,12 +15,13 @@ namespace fs = std::filesystem;
ContentPack ContentPack::createCore(const EnginePaths& paths) {
return ContentPack {
"core", "Core", ENGINE_VERSION_STRING, "", "", "res:", "res:", {}
"core", "Core", ENGINE_VERSION_STRING, "", "", "res:", {}
};
}
const std::vector<std::string> ContentPack::RESERVED_NAMES = {
"res", "abs", "local", "core", "user", "world", "none", "null"};
"res", "abs", "local", "core", "user", "world", "none", "null"
};
contentpack_error::contentpack_error(
std::string packId, io::path folder, const std::string& message
@@ -70,7 +71,7 @@ static void checkContentPackId(const std::string& id, const io::path& folder) {
}
}
ContentPack ContentPack::read(const std::string& path, const io::path& folder) {
ContentPack ContentPack::read(const io::path& folder) {
auto root = io::read_json(folder / PACKAGE_FILENAME);
ContentPack pack;
root.at("id").get(pack.id);
@@ -90,7 +91,6 @@ ContentPack ContentPack::read(const std::string& path, const io::path& folder) {
root.at("description").get(pack.description);
root.at("source").get(pack.source);
pack.folder = folder;
pack.path = path;
if (auto found = root.at("dependencies")) {
const auto& dependencies = *found;
@@ -133,7 +133,7 @@ void ContentPack::scanFolder(
if (!io::is_directory(packFolder)) continue;
if (!is_pack(packFolder)) continue;
try {
packs.push_back(read(packFolder.string(), packFolder));
packs.push_back(read(packFolder));
} catch (const contentpack_error& err) {
std::cerr << "package.json error at " << err.getFolder().string();
std::cerr << ": " << err.what() << std::endl;