Отладка получения ресурсов

This commit is contained in:
2025-09-02 13:03:39 +06:00
parent 05570b0844
commit 4eef3ca211
10 changed files with 149 additions and 65 deletions

View File

@@ -105,6 +105,7 @@ private:
// Связь домены -> {ключ -> идентификатор}
std::unordered_map<std::string, std::unordered_map<std::string, ResourceId>> KeyToId[(int) EnumAssets::MAX_ENUM];
std::unordered_map<Hash_t, std::tuple<EnumAssets, ResourceId>> HashToId;
std::tuple<ResourceId, std::optional<DataEntry>&> nextId(EnumAssets type);
@@ -132,6 +133,28 @@ private:
return std::nullopt;
}
std::optional<std::tuple<Resource, const std::string&, const std::string&, EnumAssets, ResourceId>> getResource(const Hash_t& hash) {
auto iter = HashToId.find(hash);
if(iter == HashToId.end())
return std::nullopt;
auto [type, id] = iter->second;
std::optional<std::tuple<Resource, const std::string&, const std::string&>> res = getResource(type, id);
if(!res) {
HashToId.erase(iter);
return std::nullopt;
}
if(std::get<Resource>(*res).hash() == hash) {
auto& [resource, domain, key] = *res;
return std::tuple<Resource, const std::string&, const std::string&, EnumAssets, ResourceId>{resource, domain, key, type, id};
}
HashToId.erase(iter);
return std::nullopt;
}
const std::optional<std::vector<AssetsModel>>& getResourceNodestate(ResourceId id) {
assert(id < Table_NodeState.size()*TableEntry<DataEntry>::ChunkSize);
return Table_NodeState[id / TableEntry<DataEntry>::ChunkSize]
@@ -224,6 +247,11 @@ public:
return LocalObj.lock()->getResource(type, id);
}
// Выдаёт ресурс по хешу
std::optional<std::tuple<Resource, const std::string&, const std::string&, EnumAssets, ResourceId>> getResource(const Hash_t& hash) {
return LocalObj.lock()->getResource(hash);
}
// Выдаёт зависимости к ресурсам профиля ноды
std::tuple<AssetsNodestate, std::vector<AssetsModel>, std::vector<AssetsTexture>>
getNodeDependency(const std::string& domain, const std::string& key)