mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
Make empty linking asset if asset is ignored
This commit is contained in:
parent
d65f906ecb
commit
94230cefb0
@ -22,6 +22,33 @@ void ZoneCreator::AddAssetTypeName(asset_type_t assetType, std::string name)
|
|||||||
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
|
||||||
|
{
|
||||||
|
std::vector<Gdt*> gdtList;
|
||||||
|
gdtList.reserve(context.m_gdt_files.size());
|
||||||
|
for (const auto& gdt : context.m_gdt_files)
|
||||||
|
gdtList.push_back(gdt.get());
|
||||||
|
|
||||||
|
return gdtList;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZoneCreator::CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
|
||||||
|
{
|
||||||
|
for (const auto& ignoreEntry : context.m_ignored_assets)
|
||||||
|
{
|
||||||
|
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
|
||||||
|
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
||||||
|
{
|
||||||
|
std::cout << "Unknown asset type \"" << ignoreEntry.m_type << "\" for ignore \"" << ignoreEntry.m_name << "\"" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ignoredAssetMap[ignoreEntry.m_name] = foundAssetTypeEntry->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
|
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
|
||||||
{
|
{
|
||||||
zone->m_pools = std::make_unique<GameAssetPoolT6>(zone, zone->m_priority);
|
zone->m_pools = std::make_unique<GameAssetPoolT6>(zone, zone->m_priority);
|
||||||
@ -40,17 +67,20 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
|
|||||||
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameT6);
|
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameT6);
|
||||||
CreateZoneAssetPools(zone.get());
|
CreateZoneAssetPools(zone.get());
|
||||||
|
|
||||||
std::vector<Gdt*> gdtList;
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
gdtList.reserve(context.m_gdt_files.size());
|
{
|
||||||
for (const auto& gdt : context.m_gdt_files)
|
if(!assetEntry.m_is_reference)
|
||||||
gdtList.push_back(gdt.get());
|
continue;
|
||||||
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, std::move(gdtList));
|
|
||||||
|
context.m_ignored_assets.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
|
||||||
|
if (!CreateIgnoredAssetMap(context, assetLoadingContext->m_ignored_asset_map))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
for (const auto& assetEntry : context.m_definition->m_assets)
|
for (const auto& assetEntry : context.m_definition->m_assets)
|
||||||
{
|
{
|
||||||
if (assetEntry.m_is_reference)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const auto foundAssetTypeEntry = m_asset_types_by_name.find(assetEntry.m_asset_type);
|
const auto foundAssetTypeEntry = m_asset_types_by_name.find(assetEntry.m_asset_type);
|
||||||
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
if (foundAssetTypeEntry == m_asset_types_by_name.end())
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,8 @@ namespace T6
|
|||||||
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
std::unordered_map<std::string, asset_type_t> m_asset_types_by_name;
|
||||||
|
|
||||||
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
void AddAssetTypeName(asset_type_t assetType, std::string name);
|
||||||
|
static std::vector<Gdt*> CreateGdtList(ZoneCreationContext& context);
|
||||||
|
bool CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const;
|
||||||
void CreateZoneAssetPools(Zone* zone) const;
|
void CreateZoneAssetPools(Zone* zone) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -332,39 +332,28 @@ class Linker::Impl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProcessZoneDefinitionIgnores(const std::string& zoneName, ZoneDefinition& zoneDefinition, ISearchPath* sourceSearchPath) const
|
bool ProcessZoneDefinitionIgnores(const std::string& zoneName, ZoneCreationContext& context, ISearchPath* sourceSearchPath) const
|
||||||
{
|
{
|
||||||
if (zoneDefinition.m_ignores.empty())
|
if (context.m_definition->m_ignores.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
std::map<std::string, std::reference_wrapper<ZoneDefinitionEntry>> zoneDefinitionAssetsByName;
|
std::map<std::string, std::reference_wrapper<ZoneDefinitionEntry>> zoneDefinitionAssetsByName;
|
||||||
for (auto& entry : zoneDefinition.m_assets)
|
for (auto& entry : context.m_definition->m_assets)
|
||||||
{
|
{
|
||||||
zoneDefinitionAssetsByName.try_emplace(entry.m_asset_name, entry);
|
zoneDefinitionAssetsByName.try_emplace(entry.m_asset_name, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const auto& ignore : zoneDefinition.m_ignores)
|
for (const auto& ignore : context.m_definition->m_ignores)
|
||||||
{
|
{
|
||||||
if (ignore == zoneName)
|
if (ignore == zoneName)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::vector<AssetListEntry> assetList;
|
std::vector<AssetListEntry> assetList;
|
||||||
if(!ReadAssetList(ignore, assetList, sourceSearchPath))
|
if (!ReadAssetList(ignore, context.m_ignored_assets, sourceSearchPath))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read asset listing for ignoring assets of zone \"" << ignore << "\"." << std::endl;
|
std::cout << "Failed to read asset listing for ignoring assets of zone \"" << ignore << "\"." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const auto& assetListEntry : assetList)
|
|
||||||
{
|
|
||||||
const auto foundAsset = zoneDefinitionAssetsByName.find(assetListEntry.m_name);
|
|
||||||
|
|
||||||
if(foundAsset != zoneDefinitionAssetsByName.end()
|
|
||||||
&& foundAsset->second.get().m_asset_type == assetListEntry.m_type)
|
|
||||||
{
|
|
||||||
foundAsset->second.get().m_is_reference = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -425,9 +414,12 @@ class Linker::Impl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Zone> CreateZoneForDefinition(const std::string& zoneName, ZoneDefinition& zoneDefinition, ISearchPath* assetSearchPath, ISearchPath* gdtSearchPath) const
|
std::unique_ptr<Zone> CreateZoneForDefinition(const std::string& zoneName, ZoneDefinition& zoneDefinition, ISearchPath* assetSearchPath, ISearchPath* gdtSearchPath,
|
||||||
|
ISearchPath* sourceSearchPath) const
|
||||||
{
|
{
|
||||||
auto context = std::make_unique<ZoneCreationContext>(zoneName, assetSearchPath, &zoneDefinition);
|
auto context = std::make_unique<ZoneCreationContext>(zoneName, assetSearchPath, &zoneDefinition);
|
||||||
|
if (!ProcessZoneDefinitionIgnores(zoneName, *context, sourceSearchPath))
|
||||||
|
return nullptr;
|
||||||
if (!GetGameNameFromZoneDefinition(context->m_game_name, zoneName, zoneDefinition))
|
if (!GetGameNameFromZoneDefinition(context->m_game_name, zoneName, zoneDefinition))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (!LoadGdtFilesFromZoneDefinition(context->m_gdt_files, zoneName, zoneDefinition, gdtSearchPath))
|
if (!LoadGdtFilesFromZoneDefinition(context->m_gdt_files, zoneName, zoneDefinition, gdtSearchPath))
|
||||||
@ -465,13 +457,10 @@ class Linker::Impl
|
|||||||
auto sourceSearchPaths = GetSourceSearchPathsForZone(zoneName);
|
auto sourceSearchPaths = GetSourceSearchPathsForZone(zoneName);
|
||||||
|
|
||||||
const auto zoneDefinition = ReadZoneDefinition(zoneName, &sourceSearchPaths);
|
const auto zoneDefinition = ReadZoneDefinition(zoneName, &sourceSearchPaths);
|
||||||
if (!zoneDefinition
|
if (!zoneDefinition)
|
||||||
|| !ProcessZoneDefinitionIgnores(zoneName, *zoneDefinition, &sourceSearchPaths))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
const auto zone = CreateZoneForDefinition(zoneName, *zoneDefinition, &assetSearchPaths, &gdtSearchPaths);
|
const auto zone = CreateZoneForDefinition(zoneName, *zoneDefinition, &assetSearchPaths, &gdtSearchPaths, &sourceSearchPaths);
|
||||||
auto result = zone != nullptr;
|
auto result = zone != nullptr;
|
||||||
if (zone)
|
if (zone)
|
||||||
result = WriteZoneToFile(zone.get());
|
result = WriteZoneToFile(zone.get());
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "SearchPath/ISearchPath.h"
|
#include "SearchPath/ISearchPath.h"
|
||||||
#include "Obj/Gdt/Gdt.h"
|
#include "Obj/Gdt/Gdt.h"
|
||||||
|
#include "Zone/AssetList/AssetList.h"
|
||||||
#include "Zone/Definition/ZoneDefinition.h"
|
#include "Zone/Definition/ZoneDefinition.h"
|
||||||
|
|
||||||
class ZoneCreationContext
|
class ZoneCreationContext
|
||||||
@ -15,6 +17,7 @@ public:
|
|||||||
ISearchPath* m_asset_search_path;
|
ISearchPath* m_asset_search_path;
|
||||||
ZoneDefinition* m_definition;
|
ZoneDefinition* m_definition;
|
||||||
std::vector<std::unique_ptr<Gdt>> m_gdt_files;
|
std::vector<std::unique_ptr<Gdt>> m_gdt_files;
|
||||||
|
std::vector<AssetListEntry> m_ignored_assets;
|
||||||
|
|
||||||
ZoneCreationContext();
|
ZoneCreationContext();
|
||||||
ZoneCreationContext(std::string zoneName, ISearchPath* assetSearchPath, ZoneDefinition* definition);
|
ZoneCreationContext(std::string zoneName, ISearchPath* assetSearchPath, ZoneDefinition* definition);
|
||||||
|
@ -17,6 +17,7 @@ public:
|
|||||||
Zone* const m_zone;
|
Zone* const m_zone;
|
||||||
ISearchPath* const m_raw_search_path;
|
ISearchPath* const m_raw_search_path;
|
||||||
const std::vector<Gdt*> m_gdt_files;
|
const std::vector<Gdt*> m_gdt_files;
|
||||||
|
std::unordered_map<std::string, asset_type_t> m_ignored_asset_map;
|
||||||
|
|
||||||
AssetLoadingContext(Zone* zone, ISearchPath* rawSearchPath, std::vector<Gdt*> gdtFiles);
|
AssetLoadingContext(Zone* zone, ISearchPath* rawSearchPath, std::vector<Gdt*> gdtFiles);
|
||||||
GdtEntry* GetGdtEntryByGdfAndName(const std::string& gdfName, const std::string& entryName) override;
|
GdtEntry* GetGdtEntryByGdfAndName(const std::string& gdfName, const std::string& entryName) override;
|
||||||
|
@ -20,30 +20,53 @@ void AssetLoadingManager::AddAsset(const asset_type_t assetType, const std::stri
|
|||||||
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\"" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
XAssetInfoGeneric* AssetLoadingManager::LoadDependency(const asset_type_t assetType, const std::string& assetName)
|
XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t assetType, const std::string& assetName, IAssetLoader* loader)
|
||||||
{
|
{
|
||||||
auto* existingAsset = m_context.m_zone->m_pools->GetAsset(assetType, assetName);
|
auto* alreadyLoadedAsset = m_context.m_zone->m_pools->GetAsset(assetType, assetName);
|
||||||
|
if (alreadyLoadedAsset)
|
||||||
|
return alreadyLoadedAsset;
|
||||||
|
|
||||||
|
auto* linkAsset = loader->CreateEmptyAsset(assetName, m_context.m_zone->GetMemory());
|
||||||
|
if (linkAsset)
|
||||||
|
{
|
||||||
|
std::vector<XAssetInfoGeneric*> dependencies;
|
||||||
|
AddAsset(assetType, assetName, linkAsset, dependencies);
|
||||||
|
auto* lastDependency = m_last_dependency_loaded;
|
||||||
|
m_last_dependency_loaded = nullptr;
|
||||||
|
return lastDependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* existingAsset = loader->LoadFromGlobalAssetPools(assetName);
|
||||||
if (existingAsset)
|
if (existingAsset)
|
||||||
return existingAsset;
|
|
||||||
|
|
||||||
const auto loader = m_asset_loaders_by_type.find(assetType);
|
|
||||||
if (loader != m_asset_loaders_by_type.end())
|
|
||||||
{
|
{
|
||||||
if (loader->second->CanLoadFromGdt() && loader->second->LoadFromGdt(assetName, &m_context, m_context.m_zone->GetMemory(), this))
|
std::vector<XAssetInfoGeneric*> dependencies;
|
||||||
|
AddAsset(existingAsset->m_type, existingAsset->m_name, existingAsset->m_ptr, dependencies);
|
||||||
|
auto* lastDependency = m_last_dependency_loaded;
|
||||||
|
m_last_dependency_loaded = nullptr;
|
||||||
|
return lastDependency;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Failed to create empty asset for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"" << std::endl;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t assetType, const std::string& assetName, IAssetLoader* loader)
|
||||||
|
{
|
||||||
|
if (loader->CanLoadFromGdt() && loader->LoadFromGdt(assetName, &m_context, m_context.m_zone->GetMemory(), this))
|
||||||
{
|
{
|
||||||
auto* lastDependency = m_last_dependency_loaded;
|
auto* lastDependency = m_last_dependency_loaded;
|
||||||
m_last_dependency_loaded = nullptr;
|
m_last_dependency_loaded = nullptr;
|
||||||
return lastDependency;
|
return lastDependency;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loader->second->CanLoadFromRaw() && loader->second->LoadFromRaw(assetName, m_context.m_raw_search_path, m_context.m_zone->GetMemory(), this))
|
if (loader->CanLoadFromRaw() && loader->LoadFromRaw(assetName, m_context.m_raw_search_path, m_context.m_zone->GetMemory(), this))
|
||||||
{
|
{
|
||||||
auto* lastDependency = m_last_dependency_loaded;
|
auto* lastDependency = m_last_dependency_loaded;
|
||||||
m_last_dependency_loaded = nullptr;
|
m_last_dependency_loaded = nullptr;
|
||||||
return lastDependency;
|
return lastDependency;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* existingAsset = loader->second->LoadFromGlobalAssetPools(assetName);
|
auto* existingAsset = loader->LoadFromGlobalAssetPools(assetName);
|
||||||
if (existingAsset)
|
if (existingAsset)
|
||||||
{
|
{
|
||||||
std::vector<XAssetInfoGeneric*> dependencies;
|
std::vector<XAssetInfoGeneric*> dependencies;
|
||||||
@ -63,11 +86,29 @@ XAssetInfoGeneric* AssetLoadingManager::LoadDependency(const asset_type_t assetT
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Failed to load asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\": \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to load asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\": \"" << assetName << "\"" << std::endl;
|
||||||
}
|
return nullptr;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
std::cout << "Failed to find loader for asset type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"" << std::endl;
|
XAssetInfoGeneric* AssetLoadingManager::LoadDependency(const asset_type_t assetType, const std::string& assetName)
|
||||||
}
|
{
|
||||||
|
auto* alreadyLoadedAsset = m_context.m_zone->m_pools->GetAsset(assetType, assetName);
|
||||||
|
if (alreadyLoadedAsset)
|
||||||
|
return alreadyLoadedAsset;
|
||||||
|
|
||||||
|
const auto loader = m_asset_loaders_by_type.find(assetType);
|
||||||
|
if (loader != m_asset_loaders_by_type.end())
|
||||||
|
{
|
||||||
|
const auto ignoreEntry = m_context.m_ignored_asset_map.find(assetName);
|
||||||
|
if(ignoreEntry != m_context.m_ignored_asset_map.end() && ignoreEntry->second == assetType)
|
||||||
|
{
|
||||||
|
const auto linkAssetName = ',' + assetName;
|
||||||
|
|
||||||
|
return LoadIgnoredDependency(assetType, linkAssetName, loader->second.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
return LoadAssetDependency(assetType, assetName, loader->second.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Failed to find loader for asset type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"" << std::endl;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@ class AssetLoadingManager final : public IAssetLoadingManager
|
|||||||
AssetLoadingContext& m_context;
|
AssetLoadingContext& m_context;
|
||||||
XAssetInfoGeneric* m_last_dependency_loaded;
|
XAssetInfoGeneric* m_last_dependency_loaded;
|
||||||
|
|
||||||
|
XAssetInfoGeneric* LoadIgnoredDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
|
||||||
|
XAssetInfoGeneric* LoadAssetDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AssetLoadingManager(const std::unordered_map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context);
|
AssetLoadingManager(const std::unordered_map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context);
|
||||||
|
|
||||||
|
@ -20,6 +20,12 @@ public:
|
|||||||
_NODISCARD virtual asset_type_t GetHandlingAssetType() const = 0;
|
_NODISCARD virtual asset_type_t GetHandlingAssetType() const = 0;
|
||||||
_NODISCARD virtual XAssetInfoGeneric* LoadFromGlobalAssetPools(const std::string& assetName) const = 0;
|
_NODISCARD virtual XAssetInfoGeneric* LoadFromGlobalAssetPools(const std::string& assetName) const = 0;
|
||||||
|
|
||||||
|
_NODISCARD virtual void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||||
|
{
|
||||||
|
// TODO: Make this pure virtual
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
_NODISCARD virtual bool CanLoadFromGdt() const
|
_NODISCARD virtual bool CanLoadFromGdt() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
#include "AssetLoaderRawFile.h"
|
#include "AssetLoaderRawFile.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "Game/IW4/IW4.h"
|
#include "Game/IW4/IW4.h"
|
||||||
#include "Pool/GlobalAssetPool.h"
|
#include "Pool/GlobalAssetPool.h"
|
||||||
|
|
||||||
using namespace IW4;
|
using namespace IW4;
|
||||||
|
|
||||||
|
void* AssetLoaderRawFile::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||||
|
{
|
||||||
|
auto* rawFile = memory->Create<RawFile>();
|
||||||
|
memset(rawFile, 0, sizeof(RawFile));
|
||||||
|
rawFile->name = memory->Dup(assetName.c_str());
|
||||||
|
return rawFile;
|
||||||
|
}
|
||||||
|
|
||||||
bool AssetLoaderRawFile::CanLoadFromRaw() const
|
bool AssetLoaderRawFile::CanLoadFromRaw() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,6 +9,7 @@ namespace IW4
|
|||||||
class AssetLoaderRawFile final : public BasicAssetLoader<ASSET_TYPE_RAWFILE, RawFile>
|
class AssetLoaderRawFile final : public BasicAssetLoader<ASSET_TYPE_RAWFILE, RawFile>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||||
_NODISCARD bool CanLoadFromRaw() const override;
|
_NODISCARD bool CanLoadFromRaw() const override;
|
||||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager) const override;
|
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager) const override;
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
#include "AssetLoaderRawFile.h"
|
#include "AssetLoaderRawFile.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "Game/T6/T6.h"
|
#include "Game/T6/T6.h"
|
||||||
#include "Pool/GlobalAssetPool.h"
|
#include "Pool/GlobalAssetPool.h"
|
||||||
|
|
||||||
using namespace T6;
|
using namespace T6;
|
||||||
|
|
||||||
|
void* AssetLoaderRawFile::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||||
|
{
|
||||||
|
auto* rawFile = memory->Create<RawFile>();
|
||||||
|
memset(rawFile, 0, sizeof(RawFile));
|
||||||
|
rawFile->name = memory->Dup(assetName.c_str());
|
||||||
|
return rawFile;
|
||||||
|
}
|
||||||
|
|
||||||
bool AssetLoaderRawFile::CanLoadFromRaw() const
|
bool AssetLoaderRawFile::CanLoadFromRaw() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,6 +9,7 @@ namespace T6
|
|||||||
class AssetLoaderRawFile final : public BasicAssetLoader<ASSET_TYPE_RAWFILE, RawFile>
|
class AssetLoaderRawFile final : public BasicAssetLoader<ASSET_TYPE_RAWFILE, RawFile>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||||
_NODISCARD bool CanLoadFromRaw() const override;
|
_NODISCARD bool CanLoadFromRaw() const override;
|
||||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager) const override;
|
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager) const override;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user