chore: refactor pool allocation and add indirect references

This commit is contained in:
Jan 2024-02-06 23:03:40 +01:00
parent 1e5475e5ce
commit ac0d8a83a0
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
24 changed files with 1001 additions and 1083 deletions

View File

@ -102,7 +102,7 @@ void ZoneCreator::HandleMetadata(Zone* zone, const ZoneCreationContext& context)
for (auto i = 0u; i < kvpList.size(); i++)
kvps->keyValuePairs[i] = kvpList[i];
zone->m_pools->AddAsset(ASSET_TYPE_KEYVALUEPAIRS, zone->m_name, kvps, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>());
zone->m_pools->AddAsset(std::make_unique<XAssetInfo<KeyValuePairs>>(ASSET_TYPE_KEYVALUEPAIRS, zone->m_name, kvps));
}
}

View File

@ -19,17 +19,15 @@ AssetLoadingContext* AssetLoadingManager::GetAssetLoadingContext() const
return &m_context;
}
XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone)
XAssetInfoGeneric* AssetLoadingManager::AddAssetInternal(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
m_last_dependency_loaded = m_context.m_zone->m_pools->AddAsset(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), zone);
const auto assetType = xAssetInfo->m_type;
const auto* pAssetName = xAssetInfo->m_name.c_str();
m_last_dependency_loaded = m_context.m_zone->m_pools->AddAsset(std::move(xAssetInfo));
if (m_last_dependency_loaded == nullptr)
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: \"" << pAssetName << "\"\n";
return m_last_dependency_loaded;
}
@ -39,11 +37,13 @@ XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings)
{
m_last_dependency_loaded = m_context.m_zone->m_pools->AddAsset(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings));
if (m_last_dependency_loaded == nullptr)
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\""
<< std::endl;
return m_last_dependency_loaded;
return AddAsset(std::make_unique<XAssetInfoGeneric>(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings)));
}
XAssetInfoGeneric* AssetLoadingManager::AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
xAssetInfo->m_zone = m_context.m_zone;
return AddAssetInternal(std::move(xAssetInfo));
}
XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t assetType, const std::string& assetName, IAssetLoader* loader)
@ -64,20 +64,13 @@ XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t
auto* existingAsset = loader->LoadFromGlobalAssetPools(assetName);
if (existingAsset)
{
std::vector<XAssetInfoGeneric*> dependencies;
AddAsset(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::vector<XAssetInfoGeneric*>(),
std::vector<scr_string_t>(),
existingAsset->m_zone);
AddAssetInternal(std::make_unique<XAssetInfoGeneric>(*existingAsset));
auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr;
return lastDependency;
}
std::cout << "Failed to create empty asset \"" << assetName << "\" for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\""
<< std::endl;
std::cout << "Failed to create empty asset \"" << assetName << "\" for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"\n";
return nullptr;
}
@ -119,12 +112,14 @@ XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t a
for (const auto scrString : existingAsset->m_used_script_strings)
m_context.m_zone->m_script_strings.AddOrGetScriptString(existingAsset->m_zone->m_script_strings.CValue(scrString));
AddAsset(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::move(dependencies),
existingAsset->m_used_script_strings,
existingAsset->m_zone);
AddAssetInternal(std::make_unique<XAssetInfoGeneric>(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::move(dependencies),
existingAsset->m_used_script_strings,
existingAsset->m_indirect_asset_references,
existingAsset->m_zone));
auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr;
return lastDependency;

View File

@ -14,12 +14,7 @@ class AssetLoadingManager final : public IAssetLoadingManager
XAssetInfoGeneric* LoadIgnoredDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
XAssetInfoGeneric* LoadAssetDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone);
XAssetInfoGeneric* AddAssetInternal(std::unique_ptr<XAssetInfoGeneric> xAssetInfo);
public:
AssetLoadingManager(const std::map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context);
@ -33,5 +28,6 @@ public:
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) override;
XAssetInfoGeneric* AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override;
};

View File

@ -23,6 +23,7 @@ public:
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) = 0;
virtual XAssetInfoGeneric* AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) = 0;
XAssetInfoGeneric* AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset)
{

View File

@ -15,87 +15,53 @@ const char* GameAssetPoolIW3::ASSET_TYPE_NAMES[]{
"xmodelalias", "rawfile", "stringtable",
};
/*
Asset Pool Table
Useful for macro generation via regex-replace for example
#assetType, #typeName, #unionEntry, #poolName
ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset, m_phys_preset
ASSET_TYPE_XANIMPARTS, XAnimParts, parts, m_xanim_parts
ASSET_TYPE_XMODEL, XModel, model, m_xmodel
ASSET_TYPE_MATERIAL, Material, material, m_material
ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet, m_technique_set
ASSET_TYPE_IMAGE, GfxImage, image, m_image
ASSET_TYPE_SOUND, snd_alias_list_t, sound, m_sound
ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve, m_sound_curve
ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd, m_loaded_sound
ASSET_TYPE_CLIPMAP, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_COMWORLD, ComWorld, comWorld, m_com_world
ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp, m_game_world_sp
ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp, m_game_world_mp
ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts, m_map_ents
ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld, m_gfx_world
ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef, m_gfx_light_def
ASSET_TYPE_FONT, Font_s, font, m_font
ASSET_TYPE_MENULIST, MenuList, menuList, m_menu_list
ASSET_TYPE_MENU, menuDef_t, menu, m_menu_def
ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize, m_localize
ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon, m_weapon
ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals, m_snd_driver_globals
ASSET_TYPE_FX, FxEffectDef, fx, m_fx
ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx, m_fx_impact_table
ASSET_TYPE_RAWFILE, RawFile, rawfile, m_raw_file
ASSET_TYPE_STRINGTABLE, StringTable, stringTable, m_string_table
*/
GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const int priority)
: ZoneAssetPools(zone),
m_priority(priority)
{
static_assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == 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 CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr && capacity > 0) \
{ \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \
break; \
}
switch (type)
{
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
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:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -107,44 +73,44 @@ void GameAssetPoolIW3::InitPoolStatic(const asset_type_t type, const size_t capa
void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr) \
{ \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \
(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, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
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);
@ -154,49 +120,44 @@ void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type)
#undef CASE_INIT_POOL_STATIC
}
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
#define CASE_ADD_TO_POOL(assetType, poolName) \
case assetType: \
{ \
assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
}
switch (xAsset.type)
switch (static_cast<XAssetType>(xAssetInfo->m_type))
{
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset);
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
default:
assert(false);
@ -220,32 +181,32 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, std::stri
switch (type)
{
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset);
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts);
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel);
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve);
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp);
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp);
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents);
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world);
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table);
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file);
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table);
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
default:
assert(false);
@ -257,9 +218,9 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, std::stri
#undef CASE_GET_ASSET
}
const char* GameAssetPoolIW3::AssetTypeNameByType(asset_type_t assetType)
const char* GameAssetPoolIW3::AssetTypeNameByType(const asset_type_t assetType)
{
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value))
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID;

View File

@ -14,12 +14,7 @@ class GameAssetPoolIW3 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[];
protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
public:
std::unique_ptr<AssetPool<IW3::PhysPreset>> m_phys_preset;

View File

@ -16,107 +16,63 @@ const char* GameAssetPoolIW4::ASSET_TYPE_NAMES[]{
"tracer", "vehicle", "addonmapents",
};
/*
Asset Pool Table
Useful for macro generation via regex-replace for example
#assetType, #typeName, #unionEntry, #poolName
ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset, m_phys_preset
ASSET_TYPE_PHYSCOLLMAP, PhysCollmap, physCollmap, m_phys_collmap
ASSET_TYPE_XANIMPARTS, XAnimParts, parts, m_xanim_parts
ASSET_TYPE_XMODEL, XModel, model, m_xmodel
ASSET_TYPE_MATERIAL, Material, material, m_material
ASSET_TYPE_PIXELSHADER, MaterialPixelShader, pixelShader, m_material_pixel_shader
ASSET_TYPE_VERTEXSHADER, MaterialVertexShader, vertexShader, m_material_vertex_shader
ASSET_TYPE_VERTEXDECL, MaterialVertexDeclaration, vertexDecl, m_material_vertex_decl
ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet, m_technique_set
ASSET_TYPE_IMAGE, GfxImage, image, m_image
ASSET_TYPE_SOUND, snd_alias_list_t, sound, m_sound
ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve, m_sound_curve
ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd, m_loaded_sound
ASSET_TYPE_CLIPMAP_SP, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_CLIPMAP_MP, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_COMWORLD, ComWorld, comWorld, m_com_world
ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp, m_game_world_sp
ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp, m_game_world_mp
ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts, m_map_ents
ASSET_TYPE_FXWORLD, FxWorld, fxWorld, m_fx_world
ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld, m_gfx_world
ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef, m_gfx_light_def
ASSET_TYPE_FONT, Font_s, font, m_font
ASSET_TYPE_MENULIST, MenuList, menuList, m_menu_list
ASSET_TYPE_MENU, menuDef_t, menu, m_menu_def
ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize, m_localize
ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon, m_weapon
ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals, m_snd_driver_globals
ASSET_TYPE_FX, FxEffectDef, fx, m_fx
ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx, m_fx_impact_table
ASSET_TYPE_RAWFILE, RawFile, rawfile, m_raw_file
ASSET_TYPE_STRINGTABLE, StringTable, stringTable, m_string_table
ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef, m_leaderboard
ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet, m_structed_data_def_set
ASSET_TYPE_TRACER, TracerDef, tracerDef, m_tracer
ASSET_TYPE_VEHICLE, VehicleDef, vehDef, m_vehicle
ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts, m_addon_map_ents
*/
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority)
: ZoneAssetPools(zone),
m_priority(priority)
{
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT);
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
}
void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capacity)
{
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr && capacity > 0) \
{ \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \
break; \
}
switch (type)
{
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
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)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
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:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -128,116 +84,111 @@ void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capa
void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr) \
{ \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \
(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, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
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_STATIC
#undef CASE_INIT_POOL_DYNAMIC
}
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
#define CASE_ADD_TO_POOL(assetType, poolName) \
case assetType: \
{ \
assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
}
switch (xAsset.type)
switch (static_cast<XAssetType>(xAssetInfo->m_type))
{
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, physCollmap);
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, pixelShader);
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, vertexShader);
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, vertexDecl);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world, fxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef);
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, structuredDataDefSet);
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef);
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle, vehDef);
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(false);
@ -261,42 +212,42 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
switch (type)
{
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset);
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap);
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts);
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel);
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader);
CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader);
CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve);
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp);
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp);
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents);
CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world);
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world);
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table);
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file);
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table);
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard);
CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set);
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer);
CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle);
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents);
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer)
CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(false);
@ -308,9 +259,9 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
#undef CASE_GET_ASSET
}
const char* GameAssetPoolIW4::AssetTypeNameByType(asset_type_t assetType)
const char* GameAssetPoolIW4::AssetTypeNameByType(const asset_type_t assetType)
{
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value))
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID;

View File

@ -15,12 +15,7 @@ class GameAssetPoolIW4 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[];
protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
public:
std::unique_ptr<AssetPool<IW4::PhysPreset>> m_phys_preset;

View File

@ -57,114 +57,67 @@ const char* GameAssetPoolIW5::ASSET_TYPE_NAMES[]{
"addonmapents",
};
/*
Asset Pool Table
Useful for macro generation via regex-replace for example
#assetType, #typeName, #unionEntry, #poolName
ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset, m_phys_preset
ASSET_TYPE_PHYSCOLLMAP, PhysCollmap, physCollmap, m_phys_collmap
ASSET_TYPE_XANIMPARTS, XAnimParts, parts, m_xanim_parts
ASSET_TYPE_XMODEL_SURFS, XModelSurfs, modelSurfs, m_xmodel_surfs
ASSET_TYPE_XMODEL, XModel, model, m_xmodel
ASSET_TYPE_MATERIAL, Material, material, m_material
ASSET_TYPE_PIXELSHADER, MaterialPixelShader, pixelShader, m_material_pixel_shader
ASSET_TYPE_VERTEXSHADER, MaterialVertexShader, vertexShader, m_material_vertex_shader
ASSET_TYPE_VERTEXDECL, MaterialVertexDeclaration, vertexDecl, m_material_vertex_decl
ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet, m_technique_set
ASSET_TYPE_IMAGE, GfxImage, image, m_image
ASSET_TYPE_SOUND, snd_alias_list_t, sound, m_sound
ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve, m_sound_curve
ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd, m_loaded_sound
ASSET_TYPE_CLIPMAP, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_COMWORLD, ComWorld, comWorld, m_com_world
ASSET_TYPE_GLASSWORLD, GlassWorld, glassWorld, m_glass_world
ASSET_TYPE_PATHDATA, PathData, pathData, m_path_data
ASSET_TYPE_VEHICLE_TRACK, VehicleTrack, vehicleTrack, m_vehicle_track
ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts, m_map_ents
ASSET_TYPE_FXWORLD, FxWorld, fxWorld, m_fx_world
ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld, m_gfx_world
ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef, m_gfx_light_def
ASSET_TYPE_FONT, Font_s, font, m_font
ASSET_TYPE_MENULIST, MenuList, menuList, m_menu_list
ASSET_TYPE_MENU, menuDef_t, menu, m_menu_def
ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize, m_localize
ASSET_TYPE_ATTACHMENT, WeaponAttachment, attachment, m_attachment
ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon, m_weapon
ASSET_TYPE_FX, FxEffectDef, fx, m_fx
ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx, m_fx_impact_table
ASSET_TYPE_SURFACE_FX, SurfaceFxTable, surfaceFx, m_surface_fx_table
ASSET_TYPE_RAWFILE, RawFile, rawfile, m_raw_file
ASSET_TYPE_SCRIPTFILE, ScriptFile, scriptfile, m_script_file
ASSET_TYPE_STRINGTABLE, StringTable, stringTable, m_string_table
ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef, m_leaderboard
ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet, m_structed_data_def_set
ASSET_TYPE_TRACER, TracerDef, tracerDef, m_tracer
ASSET_TYPE_VEHICLE, VehicleDef, vehDef, m_vehicle
ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts, m_addon_map_ents
*/
GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const int priority)
: ZoneAssetPools(zone),
m_priority(priority)
{
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT);
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
}
void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capacity)
{
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr && capacity > 0) \
{ \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \
break; \
}
switch (type)
{
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, XModelSurfs);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world, GlassWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data, PathData);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, VehicleTrack);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, SurfaceFxTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file, ScriptFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
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:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -176,124 +129,119 @@ void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capa
void GameAssetPoolIW5::InitPoolDynamic(const asset_type_t type)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr) \
{ \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \
(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, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, XModelSurfs);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSWORLD, m_glass_world, GlassWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PATHDATA, m_path_data, PathData);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, VehicleTrack);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, SurfaceFxTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTFILE, m_script_file, ScriptFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
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_STATIC
#undef CASE_INIT_POOL_DYNAMIC
}
XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
#define CASE_ADD_TO_POOL(assetType, poolName) \
case assetType: \
{ \
assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
}
switch (xAsset.type)
switch (static_cast<XAssetType>(xAssetInfo->m_type))
{
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, physCollmap);
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, modelSurfs);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, pixelShader);
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, vertexShader);
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, vertexDecl);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSWORLD, m_glass_world, glassWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_PATHDATA, m_path_data, pathData);
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, vehicleTrack);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world, fxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment, attachment);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
CASE_ADD_TO_POOL(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, surfaceFx);
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTFILE, m_script_file, scriptfile);
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef);
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, structuredDataDefSet);
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef);
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle, vehDef);
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_ADD_TO_POOL(ASSET_TYPE_PATHDATA, m_path_data)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(false);
@ -317,46 +265,46 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, std::stri
switch (type)
{
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset);
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap);
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts);
CASE_GET_ASSET(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs);
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel);
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader);
CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader);
CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve);
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);
CASE_GET_ASSET(ASSET_TYPE_GLASSWORLD, m_glass_world);
CASE_GET_ASSET(ASSET_TYPE_PATHDATA, m_path_data);
CASE_GET_ASSET(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track);
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents);
CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world);
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world);
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment);
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table);
CASE_GET_ASSET(ASSET_TYPE_SURFACE_FX, m_surface_fx_table);
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file);
CASE_GET_ASSET(ASSET_TYPE_SCRIPTFILE, m_script_file);
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table);
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard);
CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set);
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer);
CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle);
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents);
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_GET_ASSET(ASSET_TYPE_PATHDATA, m_path_data)
CASE_GET_ASSET(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer)
CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(false);
@ -368,9 +316,9 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, std::stri
#undef CASE_GET_ASSET
}
const char* GameAssetPoolIW5::AssetTypeNameByType(asset_type_t assetType)
const char* GameAssetPoolIW5::AssetTypeNameByType(const asset_type_t assetType)
{
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value))
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID;

View File

@ -14,12 +14,7 @@ class GameAssetPoolIW5 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[];
protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
public:
std::unique_ptr<AssetPool<IW5::PhysPreset>> m_phys_preset;

View File

@ -22,56 +22,56 @@ GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const int priority)
: ZoneAssetPools(zone),
m_priority(priority)
{
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT);
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
}
void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capacity)
{
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr && capacity > 0) \
{ \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \
break; \
}
switch (type)
{
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints);
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PACK_INDEX, m_pack_index, PackIndex);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals);
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses, Glasses);
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
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)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PACK_INDEX, m_pack_index)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals)
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:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -83,110 +83,105 @@ void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capac
void GameAssetPoolT5::InitPoolDynamic(const asset_type_t type)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr) \
{ \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \
(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, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PACK_INDEX, m_pack_index, PackIndex);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses, Glasses);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet);
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_STATIC
#undef CASE_INIT_POOL_DYNAMIC
}
XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
#define CASE_ADD_TO_POOL(assetType, poolName) \
case assetType: \
{ \
assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
}
switch (xAsset.type)
switch (static_cast<XAssetType>(xAssetInfo->m_type))
{
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, physConstraints);
CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, destructibleDef);
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch, soundPatch);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, sndDriverGlobals);
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
CASE_ADD_TO_POOL(ASSET_TYPE_PACK_INDEX, m_pack_index, packIndex);
CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals, xGlobals);
CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl, ddlRoot);
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses, glasses);
CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set, emblemSet);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_PACK_INDEX, m_pack_index)
CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl)
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses)
CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set)
default:
assert(false);
@ -210,39 +205,39 @@ XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, std::strin
switch (type)
{
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset);
CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints);
CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def);
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts);
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel);
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank);
CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp);
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp);
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents);
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world);
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals);
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table);
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file);
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table);
CASE_GET_ASSET(ASSET_TYPE_PACK_INDEX, m_pack_index);
CASE_GET_ASSET(ASSET_TYPE_XGLOBALS, m_xglobals);
CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl);
CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses);
CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set);
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank)
CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_GET_ASSET(ASSET_TYPE_PACK_INDEX, m_pack_index)
CASE_GET_ASSET(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl)
CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses)
CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set)
default:
assert(false);
@ -254,9 +249,9 @@ XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, std::strin
#undef CASE_GET_ASSET
}
const char* GameAssetPoolT5::AssetTypeNameByType(asset_type_t assetType)
const char* GameAssetPoolT5::AssetTypeNameByType(const asset_type_t assetType)
{
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value))
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID;

View File

@ -14,12 +14,7 @@ class GameAssetPoolT5 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[];
protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
public:
std::unique_ptr<AssetPool<T5::PhysPreset>> m_phys_preset;

View File

@ -75,72 +75,72 @@ GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority)
: ZoneAssetPools(zone),
m_priority(priority)
{
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT);
assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
}
void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capacity)
{
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr && capacity > 0) \
{ \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \
(poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \
break; \
}
switch (type)
{
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints);
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals);
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses, Glasses);
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree);
CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb, Qdb);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug, Slug);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
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)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals)
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)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script)
CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug)
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:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -152,142 +152,137 @@ void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capac
void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \
{ \
if ((poolName) == nullptr) \
{ \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \
(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, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses, Glasses);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb, Qdb);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug, Slug);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef);
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_STATIC
#undef CASE_INIT_POOL_DYNAMIC
}
XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
#define CASE_ADD_TO_POOL(assetType, poolName) \
case assetType: \
{ \
assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \
return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
}
switch (xAsset.type)
switch (static_cast<XAssetType>(xAssetInfo->m_type))
{
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, physConstraints);
CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, destructibleDef);
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch, soundPatch);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
CASE_ADD_TO_POOL(ASSET_TYPE_FONTICON, m_font_icon, fontIcon);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment, attachment);
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, attachmentUnique);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON_CAMO, m_camo, weaponCamo);
CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, sndDriverGlobals);
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef);
CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals, xGlobals);
CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl, ddlRoot);
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses, glasses);
CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set, emblemSet);
CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTPARSETREE, m_script, scriptParseTree);
CASE_ADD_TO_POOL(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, keyValuePairs);
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLEDEF, m_vehicle, vehicleDef);
CASE_ADD_TO_POOL(ASSET_TYPE_MEMORYBLOCK, m_memory_block, memoryBlock);
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef);
CASE_ADD_TO_POOL(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, skinnedVertsDef);
CASE_ADD_TO_POOL(ASSET_TYPE_QDB, m_qdb, qdb);
CASE_ADD_TO_POOL(ASSET_TYPE_SLUG, m_slug, slug);
CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, footstepTableDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, footstepFXTableDef);
CASE_ADD_TO_POOL(ASSET_TYPE_ZBARRIER, m_zbarrier, zbarrierDef);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_FONTICON, m_font_icon)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON_CAMO, m_camo)
CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl)
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses)
CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set)
CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTPARSETREE, m_script)
CASE_ADD_TO_POOL(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLEDEF, m_vehicle)
CASE_ADD_TO_POOL(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer)
CASE_ADD_TO_POOL(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
CASE_ADD_TO_POOL(ASSET_TYPE_QDB, m_qdb)
CASE_ADD_TO_POOL(ASSET_TYPE_SLUG, m_slug)
CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
CASE_ADD_TO_POOL(ASSET_TYPE_ZBARRIER, m_zbarrier)
default:
assert(false);
@ -311,55 +306,55 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, std::strin
switch (type)
{
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset);
CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints);
CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def);
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts);
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel);
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank);
CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp);
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp);
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents);
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world);
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font);
CASE_GET_ASSET(ASSET_TYPE_FONTICON, m_font_icon);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment);
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique);
CASE_GET_ASSET(ASSET_TYPE_WEAPON_CAMO, m_camo);
CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals);
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table);
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file);
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table);
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard);
CASE_GET_ASSET(ASSET_TYPE_XGLOBALS, m_xglobals);
CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl);
CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses);
CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set);
CASE_GET_ASSET(ASSET_TYPE_SCRIPTPARSETREE, m_script);
CASE_GET_ASSET(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs);
CASE_GET_ASSET(ASSET_TYPE_VEHICLEDEF, m_vehicle);
CASE_GET_ASSET(ASSET_TYPE_MEMORYBLOCK, m_memory_block);
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents);
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer);
CASE_GET_ASSET(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts);
CASE_GET_ASSET(ASSET_TYPE_QDB, m_qdb);
CASE_GET_ASSET(ASSET_TYPE_SLUG, m_slug);
CASE_GET_ASSET(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table);
CASE_GET_ASSET(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table);
CASE_GET_ASSET(ASSET_TYPE_ZBARRIER, m_zbarrier);
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank)
CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_FONTICON, m_font_icon)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
CASE_GET_ASSET(ASSET_TYPE_WEAPON_CAMO, m_camo)
CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_GET_ASSET(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl)
CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses)
CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set)
CASE_GET_ASSET(ASSET_TYPE_SCRIPTPARSETREE, m_script)
CASE_GET_ASSET(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
CASE_GET_ASSET(ASSET_TYPE_VEHICLEDEF, m_vehicle)
CASE_GET_ASSET(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer)
CASE_GET_ASSET(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
CASE_GET_ASSET(ASSET_TYPE_QDB, m_qdb)
CASE_GET_ASSET(ASSET_TYPE_SLUG, m_slug)
CASE_GET_ASSET(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
CASE_GET_ASSET(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
CASE_GET_ASSET(ASSET_TYPE_ZBARRIER, m_zbarrier)
default:
assert(false);
@ -371,9 +366,9 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, std::strin
#undef CASE_GET_ASSET
}
const char* GameAssetPoolT6::AssetTypeNameByType(asset_type_t assetType)
const char* GameAssetPoolT6::AssetTypeNameByType(const asset_type_t assetType)
{
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value))
if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID;

View File

@ -14,12 +14,7 @@ class GameAssetPoolT6 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[];
protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
public:
std::unique_ptr<AssetPool<T6::PhysPreset>> m_phys_preset;

View File

@ -11,6 +11,8 @@ class Zone;
template<typename T> class AssetPool
{
public:
using type = T;
std::map<std::string, XAssetInfo<T>*> m_asset_lookup;
class Iterator
@ -46,8 +48,7 @@ public:
virtual ~AssetPool() = default;
virtual XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) = 0;
virtual XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) = 0;
XAssetInfo<T>* GetAsset(const std::string& name)
{

View File

@ -10,7 +10,7 @@ template<typename T> class AssetPoolDynamic final : public AssetPool<T>
{
using AssetPool<T>::m_asset_lookup;
std::vector<XAssetInfo<T>*> m_assets;
std::vector<std::unique_ptr<XAssetInfo<T>>> m_assets;
asset_type_t m_type;
public:
@ -29,35 +29,27 @@ public:
{
GlobalAssetPool<T>::UnlinkAssetPool(this);
for (auto* entry : m_assets)
for (auto& entry : m_assets)
{
delete entry->Asset();
delete entry;
}
m_assets.clear();
m_asset_lookup.clear();
}
XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) override
{
auto* newInfo = new XAssetInfo<T>();
newInfo->m_type = m_type;
newInfo->m_name = std::move(name);
newInfo->m_zone = zone;
newInfo->m_dependencies = std::move(dependencies);
newInfo->m_used_script_strings = std::move(usedScriptStrings);
T* newAsset = new T();
memcpy(newAsset, asset, sizeof(T));
newInfo->m_ptr = newAsset;
memcpy(newAsset, xAssetInfo->Asset(), sizeof(T));
xAssetInfo->m_ptr = newAsset;
m_assets.push_back(newInfo);
m_asset_lookup[newInfo->m_name] = newInfo;
auto* pAssetInfo = xAssetInfo.get();
m_asset_lookup[xAssetInfo->m_name] = pAssetInfo;
m_assets.emplace_back(std::move(xAssetInfo));
GlobalAssetPool<T>::LinkAsset(this, newInfo);
GlobalAssetPool<T>::LinkAsset(this, pAssetInfo);
return newInfo;
return pAssetInfo;
}
};

View File

@ -67,9 +67,7 @@ public:
~AssetPoolStatic() override
{
if (m_capacity > 0)
{
GlobalAssetPool<T>::UnlinkAssetPool(this);
}
delete[] m_pool;
m_pool = nullptr;
@ -81,25 +79,19 @@ public:
m_capacity = 0;
}
XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
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.");
}
AssetPoolEntry* poolSlot = m_free;
m_free = m_free->m_next;
memcpy(&poolSlot->m_entry, asset, sizeof(T));
const T* pAsset = xAssetInfo->Asset();
xAssetInfo->m_ptr = static_cast<void*>(&poolSlot->m_entry);
memcpy(&poolSlot->m_entry, pAsset, sizeof(T));
poolSlot->m_info->m_type = m_type;
poolSlot->m_info->m_name = std::move(name);
poolSlot->m_info->m_ptr = &poolSlot->m_entry;
poolSlot->m_info->m_zone = zone;
poolSlot->m_info->m_dependencies = std::move(dependencies);
poolSlot->m_info->m_used_script_strings = std::move(usedScriptStrings);
*poolSlot->m_info = std::move(*xAssetInfo);
m_asset_lookup[poolSlot->m_info->m_name] = poolSlot->m_info;

View File

@ -0,0 +1,55 @@
#include "XAssetInfo.h"
IndirectAssetReference::IndirectAssetReference()
: m_type(-1)
{
}
IndirectAssetReference::IndirectAssetReference(const asset_type_t type, std::string name)
: m_type(type),
m_name(std::move(name))
{
}
XAssetInfoGeneric::XAssetInfoGeneric()
: m_type(-1),
m_ptr(nullptr),
m_zone(nullptr)
{
}
XAssetInfoGeneric::XAssetInfoGeneric(const asset_type_t type, std::string name, void* ptr)
: m_type(type),
m_name(std::move(name)),
m_ptr(ptr),
m_zone(nullptr)
{
}
XAssetInfoGeneric::XAssetInfoGeneric(
const asset_type_t type, std::string name, void* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
: m_type(type),
m_name(std::move(name)),
m_ptr(ptr),
m_dependencies(std::move(dependencies)),
m_used_script_strings(std::move(usedScriptStrings)),
m_zone(nullptr)
{
}
XAssetInfoGeneric::XAssetInfoGeneric(const asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences,
Zone* zone)
: m_type(type),
m_name(std::move(name)),
m_ptr(ptr),
m_dependencies(std::move(dependencies)),
m_used_script_strings(std::move(usedScriptStrings)),
m_indirect_asset_references(std::move(indirectAssetReferences)),
m_zone(zone)
{
}

View File

@ -7,20 +7,82 @@
class Zone;
// An indirect asset reference is a reference that is not done per pointer but by mentioning the asset
// in a string or requiring the asset to exist in some other way
class IndirectAssetReference
{
public:
asset_type_t m_type;
std::string m_name;
IndirectAssetReference();
IndirectAssetReference(asset_type_t type, std::string name);
};
class XAssetInfoGeneric
{
public:
asset_type_t m_type = -1;
asset_type_t m_type;
std::string m_name;
Zone* m_zone;
void* m_ptr;
std::vector<XAssetInfoGeneric*> m_dependencies;
std::vector<scr_string_t> m_used_script_strings;
void* m_ptr;
std::vector<IndirectAssetReference> m_indirect_asset_references;
Zone* m_zone;
XAssetInfoGeneric();
XAssetInfoGeneric(asset_type_t type, std::string name, void* ptr);
XAssetInfoGeneric(
asset_type_t type, std::string name, void* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings);
XAssetInfoGeneric(asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences,
Zone* zone);
~XAssetInfoGeneric() = default;
XAssetInfoGeneric(const XAssetInfoGeneric& other) = default;
XAssetInfoGeneric(XAssetInfoGeneric&& other) noexcept = default;
XAssetInfoGeneric& operator=(const XAssetInfoGeneric& other) = default;
XAssetInfoGeneric& operator=(XAssetInfoGeneric&& other) noexcept = default;
};
template<typename T> class XAssetInfo : public XAssetInfoGeneric
{
public:
XAssetInfo() = default;
XAssetInfo(const asset_type_t type, std::string name, T* ptr)
: XAssetInfoGeneric(type, std::move(name), static_cast<void*>(ptr))
{
}
XAssetInfo(const asset_type_t type, std::string name, T* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
: XAssetInfoGeneric(type, std::move(name), static_cast<void*>(ptr), std::move(dependencies), std::move(usedScriptStrings))
{
}
XAssetInfo(const asset_type_t type,
std::string name,
T* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences,
Zone* zone)
: XAssetInfoGeneric(
type, std::move(name), static_cast<void*>(ptr), std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), zone)
{
}
~XAssetInfo() = default;
XAssetInfo(const XAssetInfo& other) = default;
XAssetInfo(XAssetInfo&& other) noexcept = default;
XAssetInfo& operator=(const XAssetInfo& other) = default;
XAssetInfo& operator=(XAssetInfo&& other) noexcept = default;
T* Asset()
{
return static_cast<T*>(m_ptr);

View File

@ -5,24 +5,22 @@ ZoneAssetPools::ZoneAssetPools(Zone* zone)
{
}
XAssetInfoGeneric* ZoneAssetPools::AddAsset(
const asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
{
return AddAsset(type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), m_zone);
}
XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone)
std::vector<IndirectAssetReference> indirectAssetReferences)
{
auto* assetInfo = AddAssetToPool(type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), zone);
return AddAsset(std::make_unique<XAssetInfoGeneric>(
type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), m_zone));
}
XAssetInfoGeneric* ZoneAssetPools::AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
auto* assetInfo = AddAssetToPool(std::move(xAssetInfo));
if (assetInfo)
{
m_assets_in_order.push_back(assetInfo);
}
return assetInfo;
}

View File

@ -5,10 +5,12 @@
#include "Zone/ZoneTypes.h"
#include <cstddef>
#include <memory>
#include <string>
#include <vector>
class Zone;
class IndirectAssetReference;
class XAssetInfoGeneric;
class ZoneAssetPools
@ -17,12 +19,7 @@ protected:
Zone* m_zone;
std::vector<XAssetInfoGeneric*> m_assets_in_order;
virtual XAssetInfoGeneric* AddAssetToPool(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) = 0;
virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) = 0;
public:
using iterator = std::vector<XAssetInfoGeneric*>::const_iterator;
@ -34,14 +31,13 @@ public:
ZoneAssetPools& operator=(const ZoneAssetPools& other) = delete;
ZoneAssetPools& operator=(ZoneAssetPools&& other) noexcept = default;
XAssetInfoGeneric*
AddAsset(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings);
XAssetInfoGeneric* AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo);
XAssetInfoGeneric* AddAsset(asset_type_t type,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone);
std::vector<IndirectAssetReference> indirectAssetReferences);
_NODISCARD virtual XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const = 0;
_NODISCARD virtual asset_type_t GetAssetTypeCount() const = 0;
_NODISCARD virtual const char* GetAssetTypeName(asset_type_t assetType) const = 0;
@ -51,6 +47,6 @@ public:
_NODISCARD size_t GetTotalAssetCount() const;
iterator begin() const;
iterator end() const;
_NODISCARD iterator begin() const;
_NODISCARD iterator end() const;
};

View File

@ -13,7 +13,9 @@ AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStr
XAssetInfoGeneric*
AssetLoader::LinkAsset(std::string name, void* asset, std::vector<scr_string_t> scriptStrings, std::vector<XAssetInfoGeneric*> dependencies) const
{
return m_zone->m_pools->AddAsset(m_asset_type, std::move(name), asset, std::move(dependencies), std::move(scriptStrings));
// TODO: Add indirect asset references here
return m_zone->m_pools->AddAsset(
m_asset_type, std::move(name), asset, std::move(dependencies), std::move(scriptStrings), std::vector<IndirectAssetReference>());
}
XAssetInfoGeneric* AssetLoader::GetAssetInfo(std::string name) const

View File

@ -12,18 +12,21 @@ AssetLoadingContext* MockAssetLoadingManager::GetAssetLoadingContext() const
return m_context.get();
}
XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
const auto assetInfoPtr = xAssetInfo.get();
m_added_assets.emplace(std::make_pair(xAssetInfo->m_name, std::move(xAssetInfo)));
return assetInfoPtr;
}
XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(const asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings)
{
XAssetInfoGeneric assetInfoObj{assetType, assetName, m_zone, std::move(dependencies), std::move(usedScriptStrings), asset};
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj));
const auto assetInfoPtr = assetInfo.get();
m_added_assets.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
return assetInfoPtr;
return AddAsset(std::make_unique<XAssetInfoGeneric>(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings)));
}
XAssetInfoGeneric* MockAssetLoadingManager::LoadDependency(const asset_type_t assetType, const std::string& assetName)
@ -43,9 +46,8 @@ XAssetInfoGeneric* MockAssetLoadingManager::LoadDependency(const asset_type_t as
void MockAssetLoadingManager::MockAddAvailableDependency(const asset_type_t assetType, std::string assetName, void* asset)
{
XAssetInfoGeneric assetInfoObj{assetType, std::move(assetName), m_zone, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>(), asset};
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj));
m_available_dependencies.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
auto assetInfo = std::make_unique<XAssetInfoGeneric>(assetType, std::move(assetName), asset);
m_available_dependencies.emplace(assetInfo->m_name, std::move(assetInfo));
}
XAssetInfoGeneric* MockAssetLoadingManager::MockGetAddedAsset(const std::string& assetName)

View File

@ -17,6 +17,7 @@ public:
MockAssetLoadingManager(Zone* zone, ISearchPath* searchPath);
_NODISCARD AssetLoadingContext* GetAssetLoadingContext() const override;
XAssetInfoGeneric* AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,