mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-22 12:47:53 -05:00
chore: refactor IW4 asset loaders
This commit is contained in:
@ -2,49 +2,6 @@
|
||||
|
||||
AssetLoadingContext::AssetLoadingContext(Zone& zone, ISearchPath& rawSearchPath, std::vector<Gdt*> gdtFiles)
|
||||
: m_zone(zone),
|
||||
m_raw_search_path(rawSearchPath),
|
||||
m_gdt_files(std::move(gdtFiles))
|
||||
m_raw_search_path(rawSearchPath)
|
||||
{
|
||||
BuildGdtEntryCache();
|
||||
}
|
||||
|
||||
void AssetLoadingContext::BuildGdtEntryCache()
|
||||
{
|
||||
for (const auto* gdt : m_gdt_files)
|
||||
{
|
||||
for (const auto& entry : gdt->m_entries)
|
||||
{
|
||||
auto gdfMapEntry = m_entries_by_gdf_and_by_name.find(entry->m_gdf_name);
|
||||
if (gdfMapEntry == m_entries_by_gdf_and_by_name.end())
|
||||
{
|
||||
std::unordered_map<std::string, GdtEntry*> entryMap;
|
||||
entryMap.emplace(std::make_pair(entry->m_name, entry.get()));
|
||||
m_entries_by_gdf_and_by_name.emplace(std::make_pair(entry->m_gdf_name, std::move(entryMap)));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto entryMapEntry = gdfMapEntry->second.find(entry->m_name);
|
||||
|
||||
if (entryMapEntry == gdfMapEntry->second.end())
|
||||
gdfMapEntry->second.emplace(std::make_pair(entry->m_name, entry.get()));
|
||||
else
|
||||
entryMapEntry->second = entry.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GdtEntry* AssetLoadingContext::GetGdtEntryByGdfAndName(const std::string& gdfName, const std::string& entryName)
|
||||
{
|
||||
const auto foundGdtMap = m_entries_by_gdf_and_by_name.find(gdfName);
|
||||
|
||||
if (foundGdtMap == m_entries_by_gdf_and_by_name.end())
|
||||
return nullptr;
|
||||
|
||||
const auto foundGdtEntry = foundGdtMap->second.find(entryName);
|
||||
|
||||
if (foundGdtEntry == foundGdtMap->second.end())
|
||||
return nullptr;
|
||||
|
||||
return foundGdtEntry->second;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGdtQueryable.h"
|
||||
#include "Gdt/IGdtQueryable.h"
|
||||
#include "IZoneAssetLoaderState.h"
|
||||
#include "Obj/Gdt/Gdt.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
@ -32,15 +32,10 @@ public:
|
||||
return newStatePtr;
|
||||
}
|
||||
|
||||
private:
|
||||
void BuildGdtEntryCache();
|
||||
|
||||
public:
|
||||
Zone& m_zone;
|
||||
ISearchPath& m_raw_search_path;
|
||||
const std::vector<Gdt*> m_gdt_files;
|
||||
std::unordered_map<std::string, asset_type_t> m_ignored_asset_map;
|
||||
|
||||
std::unordered_map<std::string, std::unordered_map<std::string, GdtEntry*>> m_entries_by_gdf_and_by_name;
|
||||
std::unordered_map<std::type_index, std::unique_ptr<IZoneAssetLoaderState>> m_zone_asset_loader_states;
|
||||
};
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Gdt/IGdtQueryable.h"
|
||||
#include "IAssetLoadingManager.h"
|
||||
#include "IGdtQueryable.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
#include "Obj/Gdt/GdtEntry.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class IGdtQueryable
|
||||
{
|
||||
public:
|
||||
IGdtQueryable() = default;
|
||||
virtual ~IGdtQueryable() = default;
|
||||
IGdtQueryable(const IGdtQueryable& other) = default;
|
||||
IGdtQueryable(IGdtQueryable&& other) noexcept = default;
|
||||
IGdtQueryable& operator=(const IGdtQueryable& other) = default;
|
||||
IGdtQueryable& operator=(IGdtQueryable&& other) noexcept = default;
|
||||
|
||||
virtual GdtEntry* GetGdtEntryByGdfAndName(const std::string& gdfName, const std::string& entryName) = 0;
|
||||
};
|
Reference in New Issue
Block a user