mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Merge pull request #357 from Laupetin/fix/load-non-reference-assets
fix: load non reference assets
This commit is contained in:
commit
f436cd6caa
@ -65,8 +65,10 @@ std::unique_ptr<XAssetInfoGeneric> GenericAssetRegistration::CreateXAssetInfo()
|
|||||||
AssetCreationContext::AssetCreationContext(Zone& zone, const AssetCreatorCollection* creators, const IgnoredAssetLookup* ignoredAssetLookup)
|
AssetCreationContext::AssetCreationContext(Zone& zone, const AssetCreatorCollection* creators, const IgnoredAssetLookup* ignoredAssetLookup)
|
||||||
: ZoneAssetCreationStateContainer(zone),
|
: ZoneAssetCreationStateContainer(zone),
|
||||||
m_zone(zone),
|
m_zone(zone),
|
||||||
|
m_forced_asset_pools(ZoneAssetPools::CreateForGame(zone.m_game->GetId(), &zone, zone.m_priority)),
|
||||||
m_creators(creators),
|
m_creators(creators),
|
||||||
m_ignored_asset_lookup(ignoredAssetLookup)
|
m_ignored_asset_lookup(ignoredAssetLookup),
|
||||||
|
m_forced_load_depth(0u)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,10 +80,14 @@ XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistratio
|
|||||||
const auto assetType = xAssetInfo->m_type;
|
const auto assetType = xAssetInfo->m_type;
|
||||||
const auto* pAssetName = xAssetInfo->m_name.c_str();
|
const auto* pAssetName = xAssetInfo->m_name.c_str();
|
||||||
|
|
||||||
auto* addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
|
XAssetInfoGeneric* addedAsset;
|
||||||
|
if (m_forced_load_depth > 0)
|
||||||
|
addedAsset = m_forced_asset_pools->AddAsset(std::move(xAssetInfo));
|
||||||
|
else
|
||||||
|
addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
|
||||||
|
|
||||||
if (addedAsset == nullptr)
|
if (addedAsset == nullptr)
|
||||||
std::cerr << std::format("Failed to add asset of type \"{}\" to pool: \"{}\"\n", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName);
|
std::cerr << std::format("Failed to add asset of type \"{}\" to pool: \"{}\"\n", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName);
|
||||||
|
|
||||||
return addedAsset;
|
return addedAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +108,16 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
|||||||
if (alreadyLoadedAsset)
|
if (alreadyLoadedAsset)
|
||||||
return alreadyLoadedAsset;
|
return alreadyLoadedAsset;
|
||||||
|
|
||||||
|
if (m_forced_load_depth > 0)
|
||||||
|
{
|
||||||
|
alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
|
if (alreadyLoadedAsset)
|
||||||
|
return alreadyLoadedAsset;
|
||||||
|
|
||||||
|
// If we are already force loading an asset we should not load its dependencies
|
||||||
|
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
||||||
|
}
|
||||||
|
|
||||||
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
||||||
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
||||||
|
|
||||||
@ -121,9 +137,9 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName)
|
IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(const asset_type_t assetType, const std::string& assetName)
|
||||||
{
|
{
|
||||||
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
const auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
if (alreadyLoadedAsset)
|
if (alreadyLoadedAsset)
|
||||||
return IndirectAssetReference(assetType, assetName);
|
return IndirectAssetReference(assetType, assetName);
|
||||||
|
|
||||||
@ -137,3 +153,44 @@ IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(a
|
|||||||
}
|
}
|
||||||
return IndirectAssetReference(assetType, assetName);
|
return IndirectAssetReference(assetType, assetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XAssetInfoGeneric* AssetCreationContext::ForceLoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName)
|
||||||
|
{
|
||||||
|
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
|
if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference())
|
||||||
|
return alreadyLoadedAsset;
|
||||||
|
alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||||
|
if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference())
|
||||||
|
return alreadyLoadedAsset;
|
||||||
|
|
||||||
|
auto result = AssetCreationResult::NoAction();
|
||||||
|
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
||||||
|
{
|
||||||
|
// Load default asset to zone
|
||||||
|
if (!LoadDefaultAssetDependency(assetType, std::format(",{}", assetName)))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
++m_forced_load_depth;
|
||||||
|
|
||||||
|
result = m_creators->CreateAsset(assetType, assetName, *this);
|
||||||
|
|
||||||
|
assert(m_forced_load_depth > 0);
|
||||||
|
m_forced_load_depth = std::min(m_forced_load_depth - 1u, 0u);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result = m_creators->CreateAsset(assetType, assetName, *this);
|
||||||
|
|
||||||
|
if (result.HasTakenAction())
|
||||||
|
{
|
||||||
|
if (!result.HasFailed())
|
||||||
|
return result.GetAssetInfo();
|
||||||
|
|
||||||
|
std::cerr << std::format("Could not load asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << std::format("Missing asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
@ -65,12 +65,31 @@ public:
|
|||||||
|
|
||||||
IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName);
|
IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Loads an asset dependency like \c LoadDependency but guarantees that the returned asset is not a reference.
|
||||||
|
* If normally a reference would be created, the actual asset is loaded but a reference is added to the zone.
|
||||||
|
* \tparam AssetType The type of the asset
|
||||||
|
* \param assetName The name of the asset
|
||||||
|
* \return XAssetInfo of the asset that is guaranteed to not be a reference or \c nullptr
|
||||||
|
*/
|
||||||
|
template<typename AssetType> XAssetInfo<typename AssetType::Type>* ForceLoadDependency(const std::string& assetName)
|
||||||
|
{
|
||||||
|
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
|
||||||
|
|
||||||
|
return static_cast<XAssetInfo<typename AssetType::Type>*>(ForceLoadDependencyGeneric(AssetType::EnumEntry, assetName));
|
||||||
|
}
|
||||||
|
|
||||||
|
XAssetInfoGeneric* ForceLoadDependencyGeneric(asset_type_t assetType, const std::string& assetName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] XAssetInfoGeneric* LoadDefaultAssetDependency(asset_type_t assetType, const std::string& assetName);
|
[[nodiscard]] XAssetInfoGeneric* LoadDefaultAssetDependency(asset_type_t assetType, const std::string& assetName);
|
||||||
|
|
||||||
Zone& m_zone;
|
Zone& m_zone;
|
||||||
|
std::unique_ptr<ZoneAssetPools> m_forced_asset_pools;
|
||||||
const AssetCreatorCollection* m_creators;
|
const AssetCreatorCollection* m_creators;
|
||||||
const IgnoredAssetLookup* m_ignored_asset_lookup;
|
const IgnoredAssetLookup* m_ignored_asset_lookup;
|
||||||
|
|
||||||
|
unsigned m_forced_load_depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "AssetCreatorCollection.h"
|
#include "AssetCreatorCollection.h"
|
||||||
|
@ -262,7 +262,7 @@ namespace
|
|||||||
|
|
||||||
for (const auto& attachmentName : valueArray)
|
for (const auto& attachmentName : valueArray)
|
||||||
{
|
{
|
||||||
auto* attachmentAssetInfo = m_context.LoadDependency<AssetAttachment>(attachmentName);
|
auto* attachmentAssetInfo = m_context.ForceLoadDependency<AssetAttachment>(attachmentName);
|
||||||
if (attachmentAssetInfo == nullptr)
|
if (attachmentAssetInfo == nullptr)
|
||||||
{
|
{
|
||||||
std::cerr << std::format("Failed to load attachment asset \"{}\"\n", attachmentName);
|
std::cerr << std::format("Failed to load attachment asset \"{}\"\n", attachmentName);
|
||||||
@ -314,7 +314,7 @@ namespace
|
|||||||
|
|
||||||
for (const auto& attachmentUniqueName : valueArray)
|
for (const auto& attachmentUniqueName : valueArray)
|
||||||
{
|
{
|
||||||
auto* attachmentUniqueAssetInfo = m_context.LoadDependency<AssetAttachmentUnique>(attachmentUniqueName);
|
auto* attachmentUniqueAssetInfo = m_context.ForceLoadDependency<AssetAttachmentUnique>(attachmentUniqueName);
|
||||||
if (attachmentUniqueAssetInfo == nullptr)
|
if (attachmentUniqueAssetInfo == nullptr)
|
||||||
{
|
{
|
||||||
std::cerr << std::format("Failed to load attachment unique asset \"{}\"\n", attachmentUniqueName);
|
std::cerr << std::format("Failed to load attachment unique asset \"{}\"\n", attachmentUniqueName);
|
||||||
|
@ -1,123 +1,57 @@
|
|||||||
#include "GameAssetPoolIW3.h"
|
#include "GameAssetPoolIW3.h"
|
||||||
|
|
||||||
#include "Pool/AssetPoolDynamic.h"
|
#include "Pool/AssetPoolDynamic.h"
|
||||||
#include "Pool/AssetPoolStatic.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using namespace IW3;
|
using namespace IW3;
|
||||||
|
|
||||||
const char* GameAssetPoolIW3::ASSET_TYPE_NAMES[]{
|
namespace
|
||||||
|
{
|
||||||
|
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||||
"xmodelpieces", "physpreset", "xanim", "xmodel", "material", "techniqueset", "image", "sound", "soundcurve", "loadedsound",
|
"xmodelpieces", "physpreset", "xanim", "xmodel", "material", "techniqueset", "image", "sound", "soundcurve", "loadedsound",
|
||||||
"clipmap", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", "gfxworld", "lightdef", "uimap", "font",
|
"clipmap", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents", "gfxworld", "lightdef", "uimap", "font",
|
||||||
"menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character",
|
"menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx", "aitype", "mptype", "character",
|
||||||
"xmodelalias", "rawfile", "stringtable",
|
"xmodelalias", "rawfile", "stringtable",
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const int priority)
|
GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const zone_priority_t priority)
|
||||||
: ZoneAssetPools(zone),
|
: ZoneAssetPools(zone),
|
||||||
m_priority(priority)
|
m_priority(priority)
|
||||||
{
|
{
|
||||||
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolIW3::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr && capacity > 0) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
INIT_POOL(m_phys_preset);
|
||||||
{
|
INIT_POOL(m_xanim_parts);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
INIT_POOL(m_xmodel);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
INIT_POOL(m_material);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
INIT_POOL(m_technique_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
INIT_POOL(m_image);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
INIT_POOL(m_sound);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
INIT_POOL(m_sound_curve);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
|
INIT_POOL(m_loaded_sound);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
INIT_POOL(m_clip_map);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
INIT_POOL(m_com_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
INIT_POOL(m_game_world_sp);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
INIT_POOL(m_game_world_mp);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
INIT_POOL(m_map_ents);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
INIT_POOL(m_gfx_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
INIT_POOL(m_gfx_light_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
INIT_POOL(m_font);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
INIT_POOL(m_menu_list);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
INIT_POOL(m_menu_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
INIT_POOL(m_localize);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
INIT_POOL(m_weapon);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
INIT_POOL(m_fx);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
INIT_POOL(m_fx_impact_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
INIT_POOL(m_raw_file);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
INIT_POOL(m_string_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
|
||||||
|
|
||||||
default:
|
#undef INIT_POOL
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_STATIC
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type)
|
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_STATIC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||||
@ -125,7 +59,7 @@ XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr<XAssetInfoGe
|
|||||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
assert((poolName) != nullptr); \
|
assert(poolName); \
|
||||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||||
}
|
}
|
||||||
@ -174,7 +108,7 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, const std
|
|||||||
#define CASE_GET_ASSET(assetType, poolName) \
|
#define CASE_GET_ASSET(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
if ((poolName) != nullptr) \
|
if (poolName) \
|
||||||
return (poolName)->GetAsset(std::move(name)); \
|
return (poolName)->GetAsset(std::move(name)); \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,6 @@
|
|||||||
|
|
||||||
class GameAssetPoolIW3 final : public ZoneAssetPools
|
class GameAssetPoolIW3 final : public ZoneAssetPools
|
||||||
{
|
{
|
||||||
int m_priority;
|
|
||||||
|
|
||||||
static const char* ASSET_TYPE_NAMES[];
|
|
||||||
|
|
||||||
protected:
|
|
||||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<AssetPool<IW3::PhysPreset>> m_phys_preset;
|
std::unique_ptr<AssetPool<IW3::PhysPreset>> m_phys_preset;
|
||||||
std::unique_ptr<AssetPool<IW3::XAnimParts>> m_xanim_parts;
|
std::unique_ptr<AssetPool<IW3::XAnimParts>> m_xanim_parts;
|
||||||
@ -46,17 +39,20 @@ public:
|
|||||||
std::unique_ptr<AssetPool<IW3::RawFile>> m_raw_file;
|
std::unique_ptr<AssetPool<IW3::RawFile>> m_raw_file;
|
||||||
std::unique_ptr<AssetPool<IW3::StringTable>> m_string_table;
|
std::unique_ptr<AssetPool<IW3::StringTable>> m_string_table;
|
||||||
|
|
||||||
GameAssetPoolIW3(Zone* zone, int priority);
|
GameAssetPoolIW3(Zone* zone, zone_priority_t priority);
|
||||||
~GameAssetPoolIW3() override = default;
|
~GameAssetPoolIW3() override = default;
|
||||||
|
|
||||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||||
void InitPoolDynamic(asset_type_t type) override;
|
|
||||||
|
|
||||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
|
||||||
|
|
||||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||||
|
|
||||||
static asset_type_t AssetTypeCount();
|
static asset_type_t AssetTypeCount();
|
||||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
zone_priority_t m_priority;
|
||||||
};
|
};
|
||||||
|
@ -1,144 +1,69 @@
|
|||||||
#include "GameAssetPoolIW4.h"
|
#include "GameAssetPoolIW4.h"
|
||||||
|
|
||||||
#include "Pool/AssetPoolDynamic.h"
|
#include "Pool/AssetPoolDynamic.h"
|
||||||
#include "Pool/AssetPoolStatic.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using namespace IW4;
|
using namespace IW4;
|
||||||
|
|
||||||
const char* GameAssetPoolIW4::ASSET_TYPE_NAMES[]{
|
namespace
|
||||||
"physpreset", "physcollmap", "xanim", "xmodelsurfs", "xmodel", "material", "pixelshader", "vertexshader", "vertexdecl", "techniqueset",
|
{
|
||||||
"image", "sound", "soundcurve", "loadedsound", "clipmap", "clipmap", "comworld", "gameworldsp", "gameworldmp", "mapents",
|
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||||
"fxworld", "gfxworld", "lightdef", "uimap", "font", "menulist", "menu", "localize", "weapon", "snddriverglobals",
|
"physpreset", "physcollmap", "xanim", "xmodelsurfs", "xmodel", "material", "pixelshader", "vertexshader",
|
||||||
"fx", "impactfx", "aitype", "mptype", "character", "xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef",
|
"vertexdecl", "techniqueset", "image", "sound", "soundcurve", "loadedsound", "clipmap", "clipmap",
|
||||||
|
"comworld", "gameworldsp", "gameworldmp", "mapents", "fxworld", "gfxworld", "lightdef", "uimap",
|
||||||
|
"font", "menulist", "menu", "localize", "weapon", "snddriverglobals", "fx", "impactfx",
|
||||||
|
"aitype", "mptype", "character", "xmodelalias", "rawfile", "stringtable", "leaderboard", "structureddatadef",
|
||||||
"tracer", "vehicle", "addonmapents",
|
"tracer", "vehicle", "addonmapents",
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority)
|
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const zone_priority_t priority)
|
||||||
: ZoneAssetPools(zone),
|
: ZoneAssetPools(zone),
|
||||||
m_priority(priority)
|
m_priority(priority)
|
||||||
{
|
{
|
||||||
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr && capacity > 0) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
INIT_POOL(m_phys_preset);
|
||||||
{
|
INIT_POOL(m_phys_collmap);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
INIT_POOL(m_xanim_parts);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
|
INIT_POOL(m_xmodel);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
INIT_POOL(m_material);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
INIT_POOL(m_material_pixel_shader);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
INIT_POOL(m_material_vertex_shader);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
|
INIT_POOL(m_material_vertex_decl);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
|
INIT_POOL(m_technique_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
|
INIT_POOL(m_image);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
INIT_POOL(m_sound);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
INIT_POOL(m_sound_curve);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
|
INIT_POOL(m_loaded_sound);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
INIT_POOL(m_clip_map);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
INIT_POOL(m_com_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
|
INIT_POOL(m_game_world_sp);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
|
INIT_POOL(m_game_world_mp);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
INIT_POOL(m_map_ents);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
INIT_POOL(m_fx_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
INIT_POOL(m_gfx_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
INIT_POOL(m_gfx_light_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
|
INIT_POOL(m_font);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
INIT_POOL(m_menu_list);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
INIT_POOL(m_menu_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
INIT_POOL(m_localize);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
INIT_POOL(m_weapon);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
INIT_POOL(m_fx);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
INIT_POOL(m_fx_impact_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
INIT_POOL(m_raw_file);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
INIT_POOL(m_string_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
INIT_POOL(m_leaderboard);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
INIT_POOL(m_structed_data_def_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
INIT_POOL(m_tracer);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
INIT_POOL(m_vehicle);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
|
INIT_POOL(m_addon_map_ents);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
|
||||||
|
|
||||||
default:
|
#undef INIT_POOL
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_STATIC
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
|
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_DYNAMIC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||||
@ -146,7 +71,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr<XAssetInfoGe
|
|||||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
assert((poolName) != nullptr); \
|
assert(poolName); \
|
||||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||||
}
|
}
|
||||||
@ -205,7 +130,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, const std
|
|||||||
#define CASE_GET_ASSET(assetType, poolName) \
|
#define CASE_GET_ASSET(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
if ((poolName) != nullptr) \
|
if (poolName) \
|
||||||
return (poolName)->GetAsset(name); \
|
return (poolName)->GetAsset(name); \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,11 @@
|
|||||||
#include "Game/IW4/IW4.h"
|
#include "Game/IW4/IW4.h"
|
||||||
#include "Pool/AssetPool.h"
|
#include "Pool/AssetPool.h"
|
||||||
#include "Pool/ZoneAssetPools.h"
|
#include "Pool/ZoneAssetPools.h"
|
||||||
#include "Utils/ClassUtils.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class GameAssetPoolIW4 final : public ZoneAssetPools
|
class GameAssetPoolIW4 final : public ZoneAssetPools
|
||||||
{
|
{
|
||||||
int m_priority;
|
|
||||||
|
|
||||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
|
||||||
static const char* ASSET_TYPE_NAMES[];
|
|
||||||
|
|
||||||
protected:
|
|
||||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<AssetPool<IW4::PhysPreset>> m_phys_preset;
|
std::unique_ptr<AssetPool<IW4::PhysPreset>> m_phys_preset;
|
||||||
std::unique_ptr<AssetPool<IW4::PhysCollmap>> m_phys_collmap;
|
std::unique_ptr<AssetPool<IW4::PhysCollmap>> m_phys_collmap;
|
||||||
@ -54,17 +45,20 @@ public:
|
|||||||
std::unique_ptr<AssetPool<IW4::VehicleDef>> m_vehicle;
|
std::unique_ptr<AssetPool<IW4::VehicleDef>> m_vehicle;
|
||||||
std::unique_ptr<AssetPool<IW4::AddonMapEnts>> m_addon_map_ents;
|
std::unique_ptr<AssetPool<IW4::AddonMapEnts>> m_addon_map_ents;
|
||||||
|
|
||||||
GameAssetPoolIW4(Zone* zone, int priority);
|
GameAssetPoolIW4(Zone* zone, zone_priority_t priority);
|
||||||
~GameAssetPoolIW4() override = default;
|
~GameAssetPoolIW4() override = default;
|
||||||
|
|
||||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||||
void InitPoolDynamic(asset_type_t type) override;
|
|
||||||
|
|
||||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
|
||||||
|
|
||||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||||
|
|
||||||
static asset_type_t AssetTypeCount();
|
static asset_type_t AssetTypeCount();
|
||||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
zone_priority_t m_priority;
|
||||||
};
|
};
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#include "GameAssetPoolIW5.h"
|
#include "GameAssetPoolIW5.h"
|
||||||
|
|
||||||
#include "Pool/AssetPoolDynamic.h"
|
#include "Pool/AssetPoolDynamic.h"
|
||||||
#include "Pool/AssetPoolStatic.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using namespace IW5;
|
using namespace IW5;
|
||||||
|
|
||||||
const char* GameAssetPoolIW5::ASSET_TYPE_NAMES[]{
|
namespace
|
||||||
|
{
|
||||||
|
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||||
"physpreset",
|
"physpreset",
|
||||||
"physcollmap",
|
"physcollmap",
|
||||||
"xanim",
|
"xanim",
|
||||||
@ -56,138 +57,58 @@ const char* GameAssetPoolIW5::ASSET_TYPE_NAMES[]{
|
|||||||
"vehicle",
|
"vehicle",
|
||||||
"addonmapents",
|
"addonmapents",
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const int priority)
|
GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const zone_priority_t priority)
|
||||||
: ZoneAssetPools(zone),
|
: ZoneAssetPools(zone),
|
||||||
m_priority(priority)
|
m_priority(priority)
|
||||||
{
|
{
|
||||||
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr && capacity > 0) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
INIT_POOL(m_phys_preset);
|
||||||
{
|
INIT_POOL(m_phys_collmap);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
INIT_POOL(m_xanim_parts);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
|
INIT_POOL(m_xmodel_surfs);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
INIT_POOL(m_xmodel);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
|
INIT_POOL(m_material);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
INIT_POOL(m_material_pixel_shader);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
INIT_POOL(m_material_vertex_shader);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
|
INIT_POOL(m_material_vertex_decl);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
|
INIT_POOL(m_technique_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
|
INIT_POOL(m_image);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
INIT_POOL(m_sound);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
INIT_POOL(m_sound_curve);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
|
INIT_POOL(m_loaded_sound);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
INIT_POOL(m_clip_map);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
INIT_POOL(m_com_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
INIT_POOL(m_glass_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
INIT_POOL(m_path_data);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
|
INIT_POOL(m_vehicle_track);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data)
|
INIT_POOL(m_map_ents);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
|
INIT_POOL(m_fx_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
INIT_POOL(m_gfx_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
|
INIT_POOL(m_gfx_light_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
INIT_POOL(m_font);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
INIT_POOL(m_menu_list);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
INIT_POOL(m_menu_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
INIT_POOL(m_localize);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
INIT_POOL(m_attachment);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
INIT_POOL(m_weapon);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
|
INIT_POOL(m_fx);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
INIT_POOL(m_fx_impact_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
INIT_POOL(m_surface_fx_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
INIT_POOL(m_raw_file);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
|
INIT_POOL(m_script_file);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
INIT_POOL(m_string_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
|
INIT_POOL(m_leaderboard);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
INIT_POOL(m_structed_data_def_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
INIT_POOL(m_tracer);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
|
INIT_POOL(m_vehicle);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
|
INIT_POOL(m_addon_map_ents);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
|
||||||
|
|
||||||
default:
|
#undef INIT_POOL
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_STATIC
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolIW5::InitPoolDynamic(const asset_type_t type)
|
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PATHDATA, m_path_data)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_DYNAMIC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||||
@ -195,7 +116,7 @@ XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr<XAssetInfoGe
|
|||||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
assert((poolName) != nullptr); \
|
assert(poolName); \
|
||||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||||
}
|
}
|
||||||
@ -258,8 +179,8 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, const std
|
|||||||
#define CASE_GET_ASSET(assetType, poolName) \
|
#define CASE_GET_ASSET(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
if ((poolName) != nullptr) \
|
if (poolName) \
|
||||||
return (poolName)->GetAsset(std::move(name)); \
|
return (poolName)->GetAsset(name); \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,6 @@
|
|||||||
|
|
||||||
class GameAssetPoolIW5 final : public ZoneAssetPools
|
class GameAssetPoolIW5 final : public ZoneAssetPools
|
||||||
{
|
{
|
||||||
int m_priority;
|
|
||||||
|
|
||||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
|
||||||
static const char* ASSET_TYPE_NAMES[];
|
|
||||||
|
|
||||||
protected:
|
|
||||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<AssetPool<IW5::PhysPreset>> m_phys_preset;
|
std::unique_ptr<AssetPool<IW5::PhysPreset>> m_phys_preset;
|
||||||
std::unique_ptr<AssetPool<IW5::PhysCollmap>> m_phys_collmap;
|
std::unique_ptr<AssetPool<IW5::PhysCollmap>> m_phys_collmap;
|
||||||
@ -58,17 +50,20 @@ public:
|
|||||||
std::unique_ptr<AssetPool<IW5::VehicleDef>> m_vehicle;
|
std::unique_ptr<AssetPool<IW5::VehicleDef>> m_vehicle;
|
||||||
std::unique_ptr<AssetPool<IW5::AddonMapEnts>> m_addon_map_ents;
|
std::unique_ptr<AssetPool<IW5::AddonMapEnts>> m_addon_map_ents;
|
||||||
|
|
||||||
GameAssetPoolIW5(Zone* zone, int priority);
|
GameAssetPoolIW5(Zone* zone, zone_priority_t priority);
|
||||||
~GameAssetPoolIW5() override = default;
|
~GameAssetPoolIW5() override = default;
|
||||||
|
|
||||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||||
void InitPoolDynamic(asset_type_t type) override;
|
|
||||||
|
|
||||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
|
||||||
|
|
||||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||||
|
|
||||||
static asset_type_t AssetTypeCount();
|
static asset_type_t AssetTypeCount();
|
||||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
zone_priority_t m_priority;
|
||||||
};
|
};
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#include "GameAssetPoolT5.h"
|
#include "GameAssetPoolT5.h"
|
||||||
|
|
||||||
#include "Pool/AssetPoolDynamic.h"
|
#include "Pool/AssetPoolDynamic.h"
|
||||||
#include "Pool/AssetPoolStatic.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using namespace T5;
|
using namespace T5;
|
||||||
|
|
||||||
const char* GameAssetPoolT5::ASSET_TYPE_NAMES[]{
|
namespace
|
||||||
|
{
|
||||||
|
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||||
"xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material",
|
"xmodelpieces", "physpreset", "physconstraints", "destructibledef", "xanim", "xmodel", "material",
|
||||||
"techniqueset", "image", "soundbank", "soundpatch", "clipmap", "clipmap", "comworld",
|
"techniqueset", "image", "soundbank", "soundpatch", "clipmap", "clipmap", "comworld",
|
||||||
"gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font",
|
"gameworldsp", "gameworldmp", "mapents", "gfxworld", "gfxlightdef", "uimap", "font",
|
||||||
@ -17,124 +18,50 @@ const char* GameAssetPoolT5::ASSET_TYPE_NAMES[]{
|
|||||||
"xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses",
|
"xmodelalias", "rawfile", "stringtable", "packindex", "xglobals", "ddl", "glasses",
|
||||||
"emblemset",
|
"emblemset",
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const int priority)
|
GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const zone_priority_t priority)
|
||||||
: ZoneAssetPools(zone),
|
: ZoneAssetPools(zone),
|
||||||
m_priority(priority)
|
m_priority(priority)
|
||||||
{
|
{
|
||||||
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr && capacity > 0) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
INIT_POOL(m_phys_preset);
|
||||||
{
|
INIT_POOL(m_phys_constraints);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
INIT_POOL(m_destructible_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
|
INIT_POOL(m_xanim_parts);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
|
INIT_POOL(m_xmodel);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
INIT_POOL(m_material);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
INIT_POOL(m_technique_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
INIT_POOL(m_image);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
INIT_POOL(m_sound_bank);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
INIT_POOL(m_sound_patch);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank)
|
INIT_POOL(m_clip_map);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
|
INIT_POOL(m_com_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
INIT_POOL(m_game_world_sp);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
INIT_POOL(m_game_world_mp);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
INIT_POOL(m_map_ents);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
INIT_POOL(m_gfx_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
INIT_POOL(m_gfx_light_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
INIT_POOL(m_font);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
INIT_POOL(m_menu_list);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
INIT_POOL(m_menu_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
INIT_POOL(m_localize);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
INIT_POOL(m_weapon);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
INIT_POOL(m_snd_driver_globals);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
INIT_POOL(m_fx);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
INIT_POOL(m_fx_impact_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
|
INIT_POOL(m_raw_file);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
INIT_POOL(m_string_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
INIT_POOL(m_pack_index);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
INIT_POOL(m_xglobals);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
INIT_POOL(m_ddl);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PACK_INDEX, m_pack_index)
|
INIT_POOL(m_glasses);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals)
|
INIT_POOL(m_emblem_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
|
|
||||||
|
|
||||||
default:
|
#undef INIT_POOL
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_STATIC
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolT5::InitPoolDynamic(const asset_type_t type)
|
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PACK_INDEX, m_pack_index)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_DYNAMIC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||||
@ -142,7 +69,7 @@ XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr<XAssetInfoGen
|
|||||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
assert((poolName) != nullptr); \
|
assert(poolName); \
|
||||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||||
}
|
}
|
||||||
@ -198,8 +125,8 @@ XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, const std:
|
|||||||
#define CASE_GET_ASSET(assetType, poolName) \
|
#define CASE_GET_ASSET(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
if ((poolName) != nullptr) \
|
if (poolName) \
|
||||||
return (poolName)->GetAsset(std::move(name)); \
|
return (poolName)->GetAsset(name); \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,6 @@
|
|||||||
|
|
||||||
class GameAssetPoolT5 final : public ZoneAssetPools
|
class GameAssetPoolT5 final : public ZoneAssetPools
|
||||||
{
|
{
|
||||||
int m_priority;
|
|
||||||
|
|
||||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
|
||||||
static const char* ASSET_TYPE_NAMES[];
|
|
||||||
|
|
||||||
protected:
|
|
||||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<AssetPool<T5::PhysPreset>> m_phys_preset;
|
std::unique_ptr<AssetPool<T5::PhysPreset>> m_phys_preset;
|
||||||
std::unique_ptr<AssetPool<T5::PhysConstraints>> m_phys_constraints;
|
std::unique_ptr<AssetPool<T5::PhysConstraints>> m_phys_constraints;
|
||||||
@ -50,17 +42,20 @@ public:
|
|||||||
std::unique_ptr<AssetPool<T5::Glasses>> m_glasses;
|
std::unique_ptr<AssetPool<T5::Glasses>> m_glasses;
|
||||||
std::unique_ptr<AssetPool<T5::EmblemSet>> m_emblem_set;
|
std::unique_ptr<AssetPool<T5::EmblemSet>> m_emblem_set;
|
||||||
|
|
||||||
GameAssetPoolT5(Zone* zone, int priority);
|
GameAssetPoolT5(Zone* zone, zone_priority_t priority);
|
||||||
~GameAssetPoolT5() override = default;
|
~GameAssetPoolT5() override = default;
|
||||||
|
|
||||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||||
void InitPoolDynamic(asset_type_t type) override;
|
|
||||||
|
|
||||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
|
||||||
|
|
||||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||||
|
|
||||||
static asset_type_t AssetTypeCount();
|
static asset_type_t AssetTypeCount();
|
||||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
zone_priority_t m_priority;
|
||||||
};
|
};
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#include "GameAssetPoolT6.h"
|
#include "GameAssetPoolT6.h"
|
||||||
|
|
||||||
#include "Pool/AssetPoolDynamic.h"
|
#include "Pool/AssetPoolDynamic.h"
|
||||||
#include "Pool/AssetPoolStatic.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using namespace T6;
|
using namespace T6;
|
||||||
|
|
||||||
const char* GameAssetPoolT6::ASSET_TYPE_NAMES[]{
|
namespace
|
||||||
|
{
|
||||||
|
constexpr const char* ASSET_TYPE_NAMES[]{
|
||||||
"xmodelpieces",
|
"xmodelpieces",
|
||||||
"physpreset",
|
"physpreset",
|
||||||
"physconstraints",
|
"physconstraints",
|
||||||
@ -70,156 +71,66 @@ const char* GameAssetPoolT6::ASSET_TYPE_NAMES[]{
|
|||||||
"footstepfxtable",
|
"footstepfxtable",
|
||||||
"zbarrier",
|
"zbarrier",
|
||||||
};
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority)
|
GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const zone_priority_t priority)
|
||||||
: ZoneAssetPools(zone),
|
: ZoneAssetPools(zone),
|
||||||
m_priority(priority)
|
m_priority(priority)
|
||||||
{
|
{
|
||||||
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capacity)
|
#define INIT_POOL(poolName) (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority)
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr && capacity > 0) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
INIT_POOL(m_phys_preset);
|
||||||
{
|
INIT_POOL(m_phys_constraints);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
INIT_POOL(m_destructible_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
|
INIT_POOL(m_xanim_parts);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
|
INIT_POOL(m_xmodel);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
INIT_POOL(m_material);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
|
INIT_POOL(m_technique_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
|
INIT_POOL(m_image);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
INIT_POOL(m_sound_bank);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
|
INIT_POOL(m_sound_patch);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank)
|
INIT_POOL(m_clip_map);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
|
INIT_POOL(m_com_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
INIT_POOL(m_game_world_sp);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
INIT_POOL(m_game_world_mp);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
|
INIT_POOL(m_map_ents);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
INIT_POOL(m_gfx_world);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
INIT_POOL(m_gfx_light_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
INIT_POOL(m_font);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
INIT_POOL(m_font_icon);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
INIT_POOL(m_menu_list);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
|
INIT_POOL(m_menu_def);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon)
|
INIT_POOL(m_localize);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
|
INIT_POOL(m_weapon);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
|
INIT_POOL(m_attachment);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
INIT_POOL(m_attachment_unique);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
|
INIT_POOL(m_camo);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
|
INIT_POOL(m_snd_driver_globals);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
|
INIT_POOL(m_fx);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo)
|
INIT_POOL(m_fx_impact_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
|
INIT_POOL(m_raw_file);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
|
INIT_POOL(m_string_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
INIT_POOL(m_leaderboard);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
INIT_POOL(m_xglobals);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
INIT_POOL(m_ddl);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
INIT_POOL(m_glasses);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals)
|
INIT_POOL(m_emblem_set);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl)
|
INIT_POOL(m_script);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses)
|
INIT_POOL(m_key_value_pairs);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
|
INIT_POOL(m_vehicle);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script)
|
INIT_POOL(m_memory_block);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
|
INIT_POOL(m_addon_map_ents);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle)
|
INIT_POOL(m_tracer);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
|
INIT_POOL(m_skinned_verts);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
INIT_POOL(m_qdb);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
|
INIT_POOL(m_slug);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
|
INIT_POOL(m_footstep_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb)
|
INIT_POOL(m_footstep_fx_table);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug)
|
INIT_POOL(m_zbarrier);
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
|
|
||||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier)
|
|
||||||
|
|
||||||
default:
|
#undef INIT_POOL
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_STATIC
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type)
|
|
||||||
{
|
|
||||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
|
|
||||||
case assetType: \
|
|
||||||
{ \
|
|
||||||
if ((poolName) == nullptr) \
|
|
||||||
{ \
|
|
||||||
(poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
|
|
||||||
} \
|
|
||||||
break; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
|
|
||||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier)
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef CASE_INIT_POOL_DYNAMIC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
|
||||||
@ -227,7 +138,7 @@ XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr<XAssetInfoGen
|
|||||||
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
#define CASE_ADD_TO_POOL(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
assert((poolName) != nullptr); \
|
assert(poolName); \
|
||||||
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
|
||||||
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
|
||||||
}
|
}
|
||||||
@ -299,7 +210,7 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, const std:
|
|||||||
#define CASE_GET_ASSET(assetType, poolName) \
|
#define CASE_GET_ASSET(assetType, poolName) \
|
||||||
case assetType: \
|
case assetType: \
|
||||||
{ \
|
{ \
|
||||||
if ((poolName) != nullptr) \
|
if (poolName) \
|
||||||
return (poolName)->GetAsset(name); \
|
return (poolName)->GetAsset(name); \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,6 @@
|
|||||||
|
|
||||||
class GameAssetPoolT6 final : public ZoneAssetPools
|
class GameAssetPoolT6 final : public ZoneAssetPools
|
||||||
{
|
{
|
||||||
int m_priority;
|
|
||||||
|
|
||||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
|
||||||
static const char* ASSET_TYPE_NAMES[];
|
|
||||||
|
|
||||||
protected:
|
|
||||||
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<AssetPool<T6::PhysPreset>> m_phys_preset;
|
std::unique_ptr<AssetPool<T6::PhysPreset>> m_phys_preset;
|
||||||
std::unique_ptr<AssetPool<T6::PhysConstraints>> m_phys_constraints;
|
std::unique_ptr<AssetPool<T6::PhysConstraints>> m_phys_constraints;
|
||||||
@ -66,17 +58,20 @@ public:
|
|||||||
std::unique_ptr<AssetPool<T6::FootstepFXTableDef>> m_footstep_fx_table;
|
std::unique_ptr<AssetPool<T6::FootstepFXTableDef>> m_footstep_fx_table;
|
||||||
std::unique_ptr<AssetPool<T6::ZBarrierDef>> m_zbarrier;
|
std::unique_ptr<AssetPool<T6::ZBarrierDef>> m_zbarrier;
|
||||||
|
|
||||||
GameAssetPoolT6(Zone* zone, int priority);
|
GameAssetPoolT6(Zone* zone, zone_priority_t priority);
|
||||||
~GameAssetPoolT6() override = default;
|
~GameAssetPoolT6() override = default;
|
||||||
|
|
||||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
[[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
||||||
void InitPoolDynamic(asset_type_t type) override;
|
|
||||||
|
|
||||||
_NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, const std::string& name) const override;
|
|
||||||
|
|
||||||
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
static std::optional<const char*> AssetTypeNameByType(asset_type_t assetType);
|
||||||
_NODISCARD std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
[[nodiscard]] std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const override;
|
||||||
|
|
||||||
static asset_type_t AssetTypeCount();
|
static asset_type_t AssetTypeCount();
|
||||||
_NODISCARD asset_type_t GetAssetTypeCount() const override;
|
[[nodiscard]] asset_type_t GetAssetTypeCount() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
zone_priority_t m_priority;
|
||||||
};
|
};
|
||||||
|
@ -4,20 +4,18 @@
|
|||||||
#include "GlobalAssetPool.h"
|
#include "GlobalAssetPool.h"
|
||||||
#include "XAssetInfo.h"
|
#include "XAssetInfo.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <vector>
|
||||||
|
|
||||||
template<typename T> class AssetPoolDynamic final : public AssetPool<T>
|
template<typename T> class AssetPoolDynamic final : public AssetPool<T>
|
||||||
{
|
{
|
||||||
using AssetPool<T>::m_asset_lookup;
|
using AssetPool<T>::m_asset_lookup;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<XAssetInfo<T>>> m_assets;
|
std::vector<std::unique_ptr<XAssetInfo<T>>> m_assets;
|
||||||
asset_type_t m_type;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AssetPoolDynamic(const int priority, const asset_type_t type)
|
explicit AssetPoolDynamic(const zone_priority_t priority)
|
||||||
{
|
{
|
||||||
GlobalAssetPool<T>::LinkAssetPool(this, priority);
|
GlobalAssetPool<T>::LinkAssetPool(this, priority);
|
||||||
m_type = type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetPoolDynamic(AssetPoolDynamic<T>&) = delete;
|
AssetPoolDynamic(AssetPoolDynamic<T>&) = delete;
|
||||||
|
@ -1,104 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "AssetPool.h"
|
|
||||||
#include "GlobalAssetPool.h"
|
|
||||||
#include "XAssetInfo.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
template<typename T> class AssetPoolStatic final : public AssetPool<T>
|
|
||||||
{
|
|
||||||
using AssetPool<T>::m_asset_lookup;
|
|
||||||
|
|
||||||
struct AssetPoolEntry
|
|
||||||
{
|
|
||||||
XAssetInfo<T>* m_info;
|
|
||||||
|
|
||||||
union
|
|
||||||
{
|
|
||||||
T m_entry;
|
|
||||||
AssetPoolEntry* m_next;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
AssetPoolEntry* m_free;
|
|
||||||
AssetPoolEntry* m_pool;
|
|
||||||
XAssetInfo<T>* m_info_pool;
|
|
||||||
size_t m_capacity;
|
|
||||||
asset_type_t m_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AssetPoolStatic(const size_t capacity, const int priority, const asset_type_t type)
|
|
||||||
{
|
|
||||||
m_capacity = capacity;
|
|
||||||
m_type = type;
|
|
||||||
|
|
||||||
if (m_capacity > 0)
|
|
||||||
{
|
|
||||||
m_pool = new AssetPoolEntry[m_capacity];
|
|
||||||
m_info_pool = new XAssetInfo<T>[m_capacity];
|
|
||||||
|
|
||||||
for (size_t i = 0; i < m_capacity - 1; i++)
|
|
||||||
{
|
|
||||||
m_pool[i].m_info = &m_info_pool[i];
|
|
||||||
m_pool[i].m_next = &m_pool[i + 1];
|
|
||||||
}
|
|
||||||
m_pool[m_capacity - 1].m_info = &m_info_pool[m_capacity - 1];
|
|
||||||
m_pool[m_capacity - 1].m_next = nullptr;
|
|
||||||
|
|
||||||
m_free = m_pool;
|
|
||||||
|
|
||||||
GlobalAssetPool<T>::LinkAssetPool(this, priority);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pool = nullptr;
|
|
||||||
m_free = nullptr;
|
|
||||||
m_info_pool = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AssetPoolStatic(AssetPoolStatic<T>&) = delete;
|
|
||||||
AssetPoolStatic(AssetPoolStatic<T>&&) = delete;
|
|
||||||
AssetPoolStatic<T>& operator=(AssetPoolStatic<T>&) = delete;
|
|
||||||
AssetPoolStatic<T>& operator=(AssetPoolStatic<T>&&) = default;
|
|
||||||
|
|
||||||
~AssetPoolStatic() override
|
|
||||||
{
|
|
||||||
if (m_capacity > 0)
|
|
||||||
GlobalAssetPool<T>::UnlinkAssetPool(this);
|
|
||||||
|
|
||||||
delete[] m_pool;
|
|
||||||
m_pool = nullptr;
|
|
||||||
|
|
||||||
delete[] m_info_pool;
|
|
||||||
m_info_pool = nullptr;
|
|
||||||
|
|
||||||
m_free = nullptr;
|
|
||||||
m_capacity = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) override
|
|
||||||
{
|
|
||||||
if (m_free == nullptr)
|
|
||||||
throw std::runtime_error("Could not add asset to static asset pool: capacity exhausted.");
|
|
||||||
|
|
||||||
const auto normalizedName = XAssetInfo<T>::NormalizeAssetName(xAssetInfo->m_name);
|
|
||||||
|
|
||||||
AssetPoolEntry* poolSlot = m_free;
|
|
||||||
m_free = m_free->m_next;
|
|
||||||
|
|
||||||
const T* pAsset = xAssetInfo->Asset();
|
|
||||||
xAssetInfo->m_ptr = static_cast<void*>(&poolSlot->m_entry);
|
|
||||||
memcpy(&poolSlot->m_entry, pAsset, sizeof(T));
|
|
||||||
|
|
||||||
*poolSlot->m_info = std::move(*xAssetInfo);
|
|
||||||
|
|
||||||
m_asset_lookup[normalizedName] = poolSlot->m_info;
|
|
||||||
|
|
||||||
GlobalAssetPool<T>::LinkAsset(this, normalizedName, poolSlot->m_info);
|
|
||||||
|
|
||||||
return poolSlot->m_info;
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "AssetPool.h"
|
#include "AssetPool.h"
|
||||||
|
#include "Zone/ZoneTypes.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@ -14,7 +15,7 @@ template<typename T> class GlobalAssetPool
|
|||||||
struct LinkedAssetPool
|
struct LinkedAssetPool
|
||||||
{
|
{
|
||||||
AssetPool<T>* m_asset_pool;
|
AssetPool<T>* m_asset_pool;
|
||||||
int m_priority;
|
zone_priority_t m_priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GameAssetPoolEntry
|
struct GameAssetPoolEntry
|
||||||
@ -92,7 +93,7 @@ template<typename T> class GlobalAssetPool
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void LinkAssetPool(AssetPool<T>* assetPool, const int priority)
|
static void LinkAssetPool(AssetPool<T>* assetPool, const zone_priority_t priority)
|
||||||
{
|
{
|
||||||
auto newLink = std::make_unique<LinkedAssetPool>();
|
auto newLink = std::make_unique<LinkedAssetPool>();
|
||||||
newLink->m_asset_pool = assetPool;
|
newLink->m_asset_pool = assetPool;
|
||||||
|
@ -93,6 +93,11 @@ XAssetInfoGeneric::XAssetInfoGeneric(const asset_type_t type,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool XAssetInfoGeneric::IsReference() const
|
||||||
|
{
|
||||||
|
return !m_name.empty() && m_name[0] == ',';
|
||||||
|
}
|
||||||
|
|
||||||
std::string XAssetInfoGeneric::NormalizeAssetName(std::string input)
|
std::string XAssetInfoGeneric::NormalizeAssetName(std::string input)
|
||||||
{
|
{
|
||||||
utils::MakeStringLowerCase(input);
|
utils::MakeStringLowerCase(input);
|
||||||
|
@ -54,6 +54,8 @@ public:
|
|||||||
XAssetInfoGeneric& operator=(const XAssetInfoGeneric& other) = default;
|
XAssetInfoGeneric& operator=(const XAssetInfoGeneric& other) = default;
|
||||||
XAssetInfoGeneric& operator=(XAssetInfoGeneric&& other) noexcept = default;
|
XAssetInfoGeneric& operator=(XAssetInfoGeneric&& other) noexcept = default;
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsReference() const;
|
||||||
|
|
||||||
static std::string NormalizeAssetName(std::string input);
|
static std::string NormalizeAssetName(std::string input);
|
||||||
|
|
||||||
asset_type_t m_type;
|
asset_type_t m_type;
|
||||||
|
@ -16,12 +16,6 @@ class XAssetInfoGeneric;
|
|||||||
|
|
||||||
class ZoneAssetPools
|
class ZoneAssetPools
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
Zone* m_zone;
|
|
||||||
std::vector<XAssetInfoGeneric*> m_assets_in_order;
|
|
||||||
|
|
||||||
virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) = 0;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using iterator = std::vector<XAssetInfoGeneric*>::const_iterator;
|
using iterator = std::vector<XAssetInfoGeneric*>::const_iterator;
|
||||||
|
|
||||||
@ -45,13 +39,16 @@ public:
|
|||||||
_NODISCARD virtual asset_type_t GetAssetTypeCount() const = 0;
|
_NODISCARD virtual asset_type_t GetAssetTypeCount() const = 0;
|
||||||
_NODISCARD virtual std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const = 0;
|
_NODISCARD virtual std::optional<const char*> GetAssetTypeName(asset_type_t assetType) const = 0;
|
||||||
|
|
||||||
virtual void InitPoolStatic(asset_type_t type, size_t capacity) = 0;
|
|
||||||
virtual void InitPoolDynamic(asset_type_t type) = 0;
|
|
||||||
|
|
||||||
_NODISCARD size_t GetTotalAssetCount() const;
|
_NODISCARD size_t GetTotalAssetCount() const;
|
||||||
|
|
||||||
_NODISCARD iterator begin() const;
|
_NODISCARD iterator begin() const;
|
||||||
_NODISCARD iterator end() const;
|
_NODISCARD iterator end() const;
|
||||||
|
|
||||||
static std::unique_ptr<ZoneAssetPools> CreateForGame(GameId game, Zone* zone, zone_priority_t priority);
|
static std::unique_ptr<ZoneAssetPools> CreateForGame(GameId game, Zone* zone, zone_priority_t priority);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) = 0;
|
||||||
|
|
||||||
|
Zone* m_zone;
|
||||||
|
std::vector<XAssetInfoGeneric*> m_assets_in_order;
|
||||||
};
|
};
|
||||||
|
@ -9,9 +9,6 @@ Zone::Zone(std::string name, const zone_priority_t priority, IGame* game)
|
|||||||
m_game(game),
|
m_game(game),
|
||||||
m_pools(ZoneAssetPools::CreateForGame(game->GetId(), this, priority))
|
m_pools(ZoneAssetPools::CreateForGame(game->GetId(), this, priority))
|
||||||
{
|
{
|
||||||
const auto assetTypeCount = m_pools->GetAssetTypeCount();
|
|
||||||
for (auto i = 0; i < assetTypeCount; i++)
|
|
||||||
m_pools->InitPoolDynamic(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Zone::~Zone()
|
Zone::~Zone()
|
||||||
|
@ -126,11 +126,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
m_stream->Load<XAsset>(varXAsset, count);
|
m_stream->Load<XAsset>(varXAsset, count);
|
||||||
|
|
||||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
{
|
|
||||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
|
@ -146,11 +146,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
m_stream->Load<XAsset>(varXAsset, count);
|
m_stream->Load<XAsset>(varXAsset, count);
|
||||||
|
|
||||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
{
|
|
||||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
|
@ -155,11 +155,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
m_stream->Load<XAsset>(varXAsset, count);
|
m_stream->Load<XAsset>(varXAsset, count);
|
||||||
|
|
||||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
{
|
|
||||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
|
@ -139,11 +139,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
m_stream->Load<XAsset>(varXAsset, count);
|
m_stream->Load<XAsset>(varXAsset, count);
|
||||||
|
|
||||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
{
|
|
||||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
|
@ -168,11 +168,6 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
|
|||||||
if (atStreamStart)
|
if (atStreamStart)
|
||||||
m_stream->Load<XAsset>(varXAsset, count);
|
m_stream->Load<XAsset>(varXAsset, count);
|
||||||
|
|
||||||
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
|
|
||||||
{
|
|
||||||
m_zone->m_pools->InitPoolDynamic(assetType);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t index = 0; index < count; index++)
|
for (size_t index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
LoadXAsset(false);
|
LoadXAsset(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user