Save scriptstrings per zone and not per asset since that solves all problems with multiple assets of the same zone referencing the same struct in memory that has scriptstring indices

This commit is contained in:
Jan 2020-10-23 15:54:27 +02:00
parent f8e7a10789
commit eed7164b5b
36 changed files with 387 additions and 447 deletions

View File

@ -71,7 +71,7 @@ namespace IW4
void ObjLoader::LoadImageData(ISearchPath* searchPath, Zone* zone)
{
auto* assetPool = dynamic_cast<GameAssetPoolIW4*>(zone->GetPools());
auto* assetPool = dynamic_cast<GameAssetPoolIW4*>(zone->m_pools.get());
if (assetPool && assetPool->m_image != nullptr)
{

View File

@ -107,7 +107,7 @@ namespace T6
void ObjLoader::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const
{
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone->GetPools());
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get());
const int zoneNameHash = CommonT6::Com_HashKey(zone->m_name.c_str(), 64);
LoadCommonIPaks(searchPath, zone);
@ -197,7 +197,7 @@ namespace T6
void ObjLoader::LoadImageData(ISearchPath* searchPath, Zone* zone)
{
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone->GetPools());
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get());
if (assetPoolT6 && assetPoolT6->m_image != nullptr)
{

View File

@ -26,7 +26,7 @@ bool ZoneDumper::DumpZone(Zone* zone, const std::string& basePath) const
dumper.DumpPool(zone, assetPools->poolName.get(), basePath); \
}
const auto* assetPools = dynamic_cast<GameAssetPoolIW4*>(zone->GetPools());
const auto* assetPools = dynamic_cast<GameAssetPoolIW4*>(zone->m_pools.get());
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset)
// DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap)

View File

@ -1450,7 +1450,7 @@ namespace T6
std::stringstream ss;
bool first = true;
for(auto i = 0u; i < _countof(WeaponFullDef::notetrackSoundMapKeys); i++)
for (auto i = 0u; i < _countof(WeaponFullDef::notetrackSoundMapKeys); i++)
{
const auto& key = m_get_scr_string(keys[i]);
const auto& value = m_get_scr_string(values[i]);
@ -1634,10 +1634,11 @@ void AssetDumperWeapon::DumpAsset(Zone* zone, XAssetInfo<WeaponVariantDef>* asse
InfoStringFromWeaponConverter converter(fullDef, weapon_fields, _countof(weapon_fields), [asset](const scr_string_t scrStr) -> std::string
{
if (scrStr >= asset->m_script_strings.size())
assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size())
return "";
return asset->m_script_strings[scrStr];
return asset->m_zone->m_script_strings[scrStr];
});
const auto infoString = converter.Convert();

View File

@ -29,7 +29,7 @@ bool ZoneDumper::DumpZone(Zone* zone, const std::string& basePath) const
dumper.DumpPool(zone, assetPools->poolName, basePath); \
}
const auto assetPools = dynamic_cast<GameAssetPoolT6*>(zone->GetPools());
const auto assetPools = dynamic_cast<GameAssetPoolT6*>(zone->m_pools.get());
// DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset);
// DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints);

View File

@ -7,7 +7,7 @@ ContentPrinter::ContentPrinter(Zone* zone)
void ContentPrinter::PrintContent() const
{
const auto* pools = m_zone->GetPools();
const auto* pools = m_zone->m_pools.get();
printf("Zone '%s' (%s)\n", m_zone->m_name.c_str(), m_zone->m_game->GetName().c_str());
puts("Content:");

View File

@ -15,7 +15,7 @@ namespace IW4
{
void WriteContent() const
{
const auto* pools = dynamic_cast<GameAssetPoolIW4*>(m_zone->GetPools());
const auto* pools = dynamic_cast<GameAssetPoolIW4*>(m_zone->m_pools.get());
assert(pools);
if (!pools)

View File

@ -52,7 +52,7 @@ namespace T6
void WriteContent() const
{
const auto* pools = dynamic_cast<GameAssetPoolT6*>(m_zone->GetPools());
const auto* pools = dynamic_cast<GameAssetPoolT6*>(m_zone->m_pools.get());
assert(pools);
if (!pools)
@ -91,7 +91,7 @@ namespace T6
WriteMetaData(META_DATA_KEY_GAME, "t6");
EmptyLine();
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(m_zone->GetPools());
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(m_zone->m_pools.get());
if (assetPoolT6 && !assetPoolT6->m_key_value_pairs->m_asset_lookup.empty())
{

View File

@ -40,12 +40,7 @@ $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)
$\n$
varScriptString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
$if(!member.IsReusable)$
LoadScriptStringArray(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$else$
LoadScriptStringArrayRealloc(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);$\n$
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = varScriptString;
$endif$
%>
@ -75,11 +70,6 @@ if($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(referen
else
{
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
$if(member.IsScriptString)$
varScriptString = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;
LoadScriptStringArrayRealloc(false, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = varScriptString;
$endif$
}$\\$
$endif$
>>
@ -129,7 +119,7 @@ $endif$
%>
LoadPointerArrayMethod_Asset(context, type, structure) ::= <<
$LoaderClassName(structure)$ loader(m_script_string_provider, m_zone, m_stream);
$LoaderClassName(structure)$ loader(m_zone, m_stream);
AddDependency(loader.Load($TypePtrVarName(type)$));
>>

View File

@ -38,7 +38,7 @@ $endif$
>>
LoadSinglePointerAsset(context, structure, member, reference) ::= <<
$LoaderClassName(member.StructureType)$ loader(m_script_string_provider, m_zone, m_stream);
$LoaderClassName(member.StructureType)$ loader(m_zone, m_stream);
AddDependency(loader.Load(&$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$));
>>

View File

@ -12,7 +12,7 @@ import "Loading/PointerArray.stg"
// Loading common
LoaderClassName(asset) ::= "Loader_$asset.Type.Name$"
HeaderConstructor(context) ::= "$LoaderClassName(context.Asset)$(IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream);"
HeaderConstructor(context) ::= "$LoaderClassName(context.Asset)$(Zone* zone, IZoneInputStream* stream);"
HeaderTempPtrLoadMethodDeclaration(structure) ::= "void LoadPtr_$structure.Type.Name$(bool atStreamStart);"
HeaderArrayLoadMethodDeclaration(type) ::= "void LoadArray_$SafeTypeName(type)$(bool atStreamStart, size_t count);"
@ -290,8 +290,8 @@ var$type.Name$Ptr = nullptr;
>>
ConstructorMethod(context) ::= <<
$LoaderClassName(context.Asset)$::$LoaderClassName(context.Asset)$(IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream)
: AssetLoader($context.Asset.AssetEnumEntry.Name$, scriptStringProvider, zone, stream)$\\$
$LoaderClassName(context.Asset)$::$LoaderClassName(context.Asset)$(Zone* zone, IZoneInputStream* stream)
: AssetLoader($context.Asset.AssetEnumEntry.Name$, zone, stream)$\\$
$if(context.HasActions)$, m_actions(zone)$endif$
{
m_asset_info = nullptr;

View File

@ -97,12 +97,12 @@ const std::string GameAssetPoolIW4::ASSET_TYPE_NAMES[]
ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts, m_addon_map_ents
*/
GameAssetPoolIW4::GameAssetPoolIW4(const int priority)
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority)
: ZoneAssetPools(zone),
m_priority(priority)
{
assert(_countof(ASSET_TYPE_NAMES) == ASSET_TYPE_COUNT);
m_priority = priority;
m_phys_preset = nullptr;
m_phys_collmap = nullptr;
m_xanim_parts = nullptr;
@ -258,9 +258,7 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
#undef CASE_INIT_POOL_STATIC
}
XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string name, void* asset,
std::vector<std::string>& scriptStrings,
std::vector<XAssetInfoGeneric*>& dependencies)
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*>& dependencies)
{
XAsset xAsset{};
@ -271,7 +269,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam
case assetType: \
{ \
assert((poolName) != nullptr); \
auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, scriptStrings, dependencies); \
auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, m_zone, dependencies); \
if(assetInfo) \
{ \
m_assets_in_order.push_back(assetInfo); \
@ -394,13 +392,3 @@ const std::string& GameAssetPoolIW4::GetAssetTypeName(const asset_type_t assetTy
return ASSET_TYPE_INVALID;
}
IZoneAssetPools::iterator GameAssetPoolIW4::begin() const
{
return m_assets_in_order.begin();
}
IZoneAssetPools::iterator GameAssetPoolIW4::end() const
{
return m_assets_in_order.end();
}

View File

@ -2,18 +2,20 @@
#include <memory>
#include "Pool/IZoneAssetPools.h"
#include "Pool/ZoneAssetPools.h"
#include "Pool/AssetPool.h"
#include "IW4.h"
class GameAssetPoolIW4 final : public IZoneAssetPools
class GameAssetPoolIW4 final : public ZoneAssetPools
{
int m_priority;
std::vector<XAssetInfoGeneric*> m_assets_in_order;
static const std::string ASSET_TYPE_INVALID;
static const std::string ASSET_TYPE_NAMES[];
protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*>& dependencies) override;
public:
std::unique_ptr<AssetPool<IW4::PhysPreset>> m_phys_preset;
std::unique_ptr<AssetPool<IW4::PhysCollmap>> m_phys_collmap;
@ -51,18 +53,12 @@ public:
std::unique_ptr<AssetPool<IW4::VehicleDef>> m_vehicle;
std::unique_ptr<AssetPool<IW4::AddonMapEnts>> m_addon_map_ents;
explicit GameAssetPoolIW4(int priority);
GameAssetPoolIW4(Zone* zone, int priority);
~GameAssetPoolIW4() override = default;
void InitPoolStatic(asset_type_t type, size_t capacity) override;
void InitPoolDynamic(asset_type_t type) override;
XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset,
std::vector<std::string>& scriptStrings,
std::vector<XAssetInfoGeneric*>& dependencies) override;
XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override;
const std::string& GetAssetTypeName(asset_type_t assetType) const override;
iterator begin() const override;
iterator end() const override;
};

View File

@ -70,12 +70,12 @@ const std::string GameAssetPoolT6::ASSET_TYPE_NAMES[]
"zbarrier"
};
GameAssetPoolT6::GameAssetPoolT6(const int priority)
GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority)
: ZoneAssetPools(zone),
m_priority(priority)
{
assert(_countof(ASSET_TYPE_NAMES) == ASSET_TYPE_COUNT);
m_priority = priority;
m_phys_preset = nullptr;
m_phys_constraints = nullptr;
m_destructible_def = nullptr;
@ -195,57 +195,57 @@ void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capac
break; \
}
switch(type)
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, 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);
default:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -267,57 +267,57 @@ void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type)
break; \
}
switch(type)
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, 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);
default:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -327,7 +327,7 @@ void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type)
#undef CASE_INIT_POOL_STATIC
}
XAssetInfoGeneric* GameAssetPoolT6::AddAsset(asset_type_t type, std::string name, void* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetInfoGeneric*>& dependencies)
XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*>& dependencies)
{
XAsset xAsset{};
@ -338,7 +338,7 @@ XAssetInfoGeneric* GameAssetPoolT6::AddAsset(asset_type_t type, std::string name
case assetType: \
{ \
assert((poolName) != nullptr); \
auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, scriptStrings, dependencies); \
auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, m_zone, dependencies); \
if(assetInfo) \
{ \
m_assets_in_order.push_back(assetInfo); \
@ -346,57 +346,57 @@ XAssetInfoGeneric* GameAssetPoolT6::AddAsset(asset_type_t type, std::string name
return assetInfo; \
}
switch(xAsset.type)
switch (xAsset.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, 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);
default:
assert(false);
@ -420,55 +420,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);
@ -487,13 +487,3 @@ const std::string& GameAssetPoolT6::GetAssetTypeName(const asset_type_t assetTyp
return ASSET_TYPE_INVALID;
}
IZoneAssetPools::iterator GameAssetPoolT6::begin() const
{
return m_assets_in_order.begin();
}
IZoneAssetPools::iterator GameAssetPoolT6::end() const
{
return m_assets_in_order.end();
}

View File

@ -1,17 +1,19 @@
#pragma once
#include "Pool/IZoneAssetPools.h"
#include "Pool/ZoneAssetPools.h"
#include "Pool/AssetPool.h"
#include "T6.h"
class GameAssetPoolT6 final : public IZoneAssetPools
class GameAssetPoolT6 final : public ZoneAssetPools
{
int m_priority;
std::vector<XAssetInfoGeneric*> m_assets_in_order;
static const std::string ASSET_TYPE_INVALID;
static const std::string ASSET_TYPE_NAMES[];
protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*>& dependencies) override;
public:
AssetPool<T6::PhysPreset>* m_phys_preset;
AssetPool<T6::PhysConstraints>* m_phys_constraints;
@ -62,16 +64,12 @@ public:
AssetPool<T6::FootstepFXTableDef>* m_footstep_fx_table;
AssetPool<T6::ZBarrierDef>* m_zbarrier;
explicit GameAssetPoolT6(int priority);
GameAssetPoolT6(Zone* zone, int priority);
~GameAssetPoolT6() override;
void InitPoolStatic(asset_type_t type, size_t capacity) override;
void InitPoolDynamic(asset_type_t type) override;
XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetInfoGeneric*>& dependencies) override;
XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override;
const std::string& GetAssetTypeName(asset_type_t assetType) const override;
iterator begin() const override;
iterator end() const override;
};

View File

@ -1,9 +1,13 @@
#pragma once
#include "XAssetInfo.h"
#include <string>
#include <map>
#include "XAssetInfo.h"
#include "zone/Zone.h"
class Zone;
template<typename T>
class AssetPool
{
@ -43,7 +47,7 @@ public:
virtual ~AssetPool() = default;
virtual XAssetInfo<T>* AddAsset(std::string name, T* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetInfoGeneric*>& dependencies) = 0;
virtual XAssetInfo<T>* AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*>& dependencies) = 0;
XAssetInfo<T>* GetAsset(const std::string& name)
{

View File

@ -40,12 +40,12 @@ public:
m_asset_lookup.clear();
}
XAssetInfo<T>* AddAsset(std::string name, T* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetInfoGeneric*>& dependencies) override
XAssetInfo<T>* AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*>& dependencies) override
{
auto* newInfo = new XAssetInfo<T>();
newInfo->m_type = m_type;
newInfo->m_name = std::move(name);
newInfo->m_script_strings = std::move(scriptStrings);
newInfo->m_zone = zone;
newInfo->m_dependencies = std::move(dependencies);
T* newAsset = new T();

View File

@ -81,7 +81,7 @@ public:
m_capacity = 0;
}
XAssetInfo<T>* AddAsset(std::string name, T* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetInfoGeneric*>& dependencies) override
XAssetInfo<T>* AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*>& dependencies) override
{
if(m_free == nullptr)
{
@ -96,7 +96,7 @@ public:
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_script_strings = std::move(scriptStrings);
poolSlot->m_info->m_zone = zone;
poolSlot->m_info->m_dependencies = std::move(dependencies);
m_asset_lookup[poolSlot->m_info->m_name] = poolSlot->m_info;

View File

@ -1,24 +0,0 @@
#pragma once
#include "XAssetInfo.h"
#include "Zone/ZoneTypes.h"
#include <vector>
#include <string>
class IZoneAssetPools
{
public:
using iterator = std::vector<XAssetInfoGeneric*>::const_iterator;
virtual ~IZoneAssetPools() = default;
virtual XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetInfoGeneric*>& dependencies) = 0;
virtual XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const = 0;
virtual const std::string& GetAssetTypeName(asset_type_t assetType) const = 0;
virtual void InitPoolStatic(asset_type_t type, size_t capacity) = 0;
virtual void InitPoolDynamic(asset_type_t type) = 0;
virtual iterator begin() const = 0;
virtual iterator end() const = 0;
};

View File

@ -2,12 +2,16 @@
#include <vector>
#include <string>
#include "Zone/Zone.h"
class Zone;
class XAssetInfoGeneric
{
public:
int m_type = -1;
std::string m_name;
std::vector<std::string> m_script_strings;
Zone* m_zone;
std::vector<XAssetInfoGeneric*> m_dependencies;
void* m_ptr;
};

View File

@ -0,0 +1,27 @@
#include "ZoneAssetPools.h"
ZoneAssetPools::ZoneAssetPools(Zone* zone)
: m_zone(zone)
{
}
XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*>& dependencies)
{
auto* assetInfo = AddAssetToPool(type, std::move(name), asset, dependencies);
if(assetInfo)
{
m_assets_in_order.push_back(assetInfo);
}
return assetInfo;
}
ZoneAssetPools::iterator ZoneAssetPools::begin() const
{
return m_assets_in_order.begin();
}
ZoneAssetPools::iterator ZoneAssetPools::end() const
{
return m_assets_in_order.end();
}

View File

@ -0,0 +1,35 @@
#pragma once
#include "XAssetInfo.h"
#include "Zone/ZoneTypes.h"
#include "Zone/Zone.h"
#include <vector>
#include <string>
class Zone;
class XAssetInfoGeneric;
class ZoneAssetPools
{
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) = 0;
public:
using iterator = std::vector<XAssetInfoGeneric*>::const_iterator;
explicit ZoneAssetPools(Zone* zone);
virtual ~ZoneAssetPools() = default;
XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*>& dependencies);
virtual XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const = 0;
virtual const std::string& GetAssetTypeName(asset_type_t assetType) const = 0;
virtual void InitPoolStatic(asset_type_t type, size_t capacity) = 0;
virtual void InitPoolDynamic(asset_type_t type) = 0;
iterator begin() const;
iterator end() const;
};

View File

@ -1,28 +1,21 @@
#include "Zone.h"
Zone::Zone(std::string name, const zone_priority_t priority, IZoneAssetPools* pools, IGame* game)
Zone::Zone(std::string name, const zone_priority_t priority, IGame* game)
: m_memory(std::make_unique<ZoneMemory>()),
m_registered(false),
m_name(std::move(name)),
m_priority(priority),
m_language(GameLanguage::LANGUAGE_NONE),
m_game(game)
{
m_name = std::move(name);
m_priority = priority;
m_pools = pools;
m_game = game;
m_language = GameLanguage::LANGUAGE_NONE;
m_memory = new ZoneMemory();
m_registered = false;
}
Zone::~Zone()
{
if(m_registered)
if (m_registered)
{
m_game->RemoveZone(this);
}
delete m_pools;
m_pools = nullptr;
delete m_memory;
m_memory = nullptr;
}
void Zone::Register()
@ -34,12 +27,7 @@ void Zone::Register()
}
}
IZoneAssetPools* Zone::GetPools() const
{
return m_pools;
}
ZoneMemory* Zone::GetMemory() const
{
return m_memory;
return m_memory.get();
}

View File

@ -1,19 +1,22 @@
#pragma once
#include <memory>
#include "ZoneTypes.h"
#include "Pool/IZoneAssetPools.h"
#include "Pool/ZoneAssetPools.h"
#include "Game/IGame.h"
#include "Game/GameLanguage.h"
#include "Zone/XBlock.h"
#include "ZoneMemory.h"
#include <string>
#include <vector>
class IGame;
class ZoneAssetPools;
class Zone
{
IZoneAssetPools* m_pools;
std::vector<XBlock*> m_blocks;
ZoneMemory* m_memory;
std::unique_ptr<ZoneMemory> m_memory;
bool m_registered;
@ -22,12 +25,13 @@ public:
zone_priority_t m_priority;
GameLanguage m_language;
IGame* m_game;
std::vector<std::string> m_script_strings;
std::unique_ptr<ZoneAssetPools> m_pools;
Zone(std::string name, zone_priority_t priority, IZoneAssetPools* pools, IGame* game);
Zone(std::string name, zone_priority_t priority, IGame* game);
~Zone();
void Register();
IZoneAssetPools* GetPools() const;
ZoneMemory* GetMemory() const;
};

View File

@ -12,11 +12,15 @@ typedef uint32_t scr_string_t;
typedef uint64_t xchunk_size_t;
typedef uint64_t xblock_size_t;
typedef uint64_t zone_pointer_t;
constexpr uint16_t SCR_STRING_MAX = UINT32_MAX;
#elif _WIN32
typedef uint16_t scr_string_t;
typedef uint32_t xchunk_size_t;
typedef uint32_t xblock_size_t;
typedef uint32_t zone_pointer_t;
constexpr uint16_t SCR_STRING_MAX = UINT16_MAX;
#endif
typedef int block_t;

View File

@ -50,6 +50,8 @@ ContentLoader::ContentLoader()
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
{
assert(m_zone->m_script_strings.empty());
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
if (atStreamStart)
@ -67,16 +69,18 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
{
if (varScriptStringList->strings[i])
{
m_script_strings.emplace_back(varScriptStringList->strings[i]);
m_zone->m_script_strings.emplace_back(varScriptStringList->strings[i]);
}
else
{
m_script_strings.emplace_back("");
m_zone->m_script_strings.emplace_back("");
}
}
}
m_stream->PopBlock();
assert(m_zone->m_script_strings.size() <= SCR_STRING_MAX + 1);
}
void ContentLoader::LoadXAsset(const bool atStreamStart)
@ -84,7 +88,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart)
#define LOAD_ASSET(type_index, typeName, headerEntry) \
case type_index: \
{ \
Loader_##typeName loader(this, m_zone, m_stream); \
Loader_##typeName loader(m_zone, m_stream); \
loader.Load(&varXAsset->header.headerEntry); \
break; \
}
@ -155,7 +159,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
{
m_zone->GetPools()->InitPoolDynamic(assetType);
m_zone->m_pools->InitPoolDynamic(assetType);
}
for (size_t index = 0; index < count; index++)
@ -189,15 +193,3 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream)
m_stream->PopBlock();
}
std::string& ContentLoader::GetZoneScriptString(const scr_string_t scrString)
{
assert(scrString >= 0 && scrString < m_script_strings.size());
if (scrString >= m_script_strings.size())
{
return m_script_strings[0];
}
return m_script_strings[scrString];
}

View File

@ -2,13 +2,11 @@
#include "Loading/ContentLoaderBase.h"
#include "Loading/IContentLoadingEntryPoint.h"
#include "Game/IW4/IW4.h"
#include "Loading/IZoneScriptStringProvider.h"
namespace IW4
{
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint, public IZoneScriptStringProvider
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
{
std::vector<std::string> m_script_strings;
XAsset* varXAsset;
ScriptStringList* varScriptStringList;
@ -21,6 +19,5 @@ namespace IW4
ContentLoader();
void Load(Zone* zone, IZoneInputStream* stream) override;
std::string& GetZoneScriptString(scr_string_t scrString) override;
};
}

View File

@ -204,7 +204,8 @@ public:
return nullptr;
// Create new zone
auto* zone = new Zone(fileName, 0, new GameAssetPoolIW4(0), &g_GameIW4);
auto* zone = new Zone(fileName, 0, &g_GameIW4);
zone->m_pools = std::make_unique<GameAssetPoolIW4>(zone, 0);
zone->m_language = GetZoneLanguage(fileName);
// File is supported. Now setup all required steps for loading this file.

View File

@ -63,6 +63,8 @@ ContentLoader::ContentLoader()
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
{
assert(m_zone->m_script_strings.empty());
m_stream->PushBlock(XFILE_BLOCK_VIRTUAL);
if (atStreamStart)
@ -80,16 +82,18 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
{
if (varScriptStringList->strings[i])
{
m_script_strings.emplace_back(varScriptStringList->strings[i]);
m_zone->m_script_strings.emplace_back(varScriptStringList->strings[i]);
}
else
{
m_script_strings.emplace_back("");
m_zone->m_script_strings.emplace_back("");
}
}
}
m_stream->PopBlock();
assert(m_zone->m_script_strings.size() <= SCR_STRING_MAX + 1);
}
void ContentLoader::LoadXAsset(const bool atStreamStart)
@ -97,7 +101,7 @@ void ContentLoader::LoadXAsset(const bool atStreamStart)
#define LOAD_ASSET(type_index, typeName, headerEntry) \
case type_index: \
{ \
Loader_##typeName loader(this, m_zone, m_stream); \
Loader_##typeName loader(m_zone, m_stream); \
loader.Load(&varXAsset->header.headerEntry); \
break; \
}
@ -177,7 +181,7 @@ void ContentLoader::LoadXAssetArray(const bool atStreamStart, const size_t count
for (asset_type_t assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
{
m_zone->GetPools()->InitPoolDynamic(assetType);
m_zone->m_pools->InitPoolDynamic(assetType);
}
for (size_t index = 0; index < count; index++)
@ -220,15 +224,3 @@ void ContentLoader::Load(Zone* zone, IZoneInputStream* stream)
m_stream->PopBlock();
}
std::string& ContentLoader::GetZoneScriptString(const scr_string_t scrString)
{
assert(scrString >= 0 && scrString < m_script_strings.size());
if (scrString >= m_script_strings.size())
{
return m_script_strings[0];
}
return m_script_strings[scrString];
}

View File

@ -2,13 +2,11 @@
#include "Loading/ContentLoaderBase.h"
#include "Loading/IContentLoadingEntryPoint.h"
#include "Game/T6/T6.h"
#include "Loading/IZoneScriptStringProvider.h"
namespace T6
{
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint, public IZoneScriptStringProvider
class ContentLoader final : public ContentLoaderBase, public IContentLoadingEntryPoint
{
std::vector<std::string> m_script_strings;
XAsset* varXAsset;
ScriptStringList* varScriptStringList;
@ -21,6 +19,5 @@ namespace T6
ContentLoader();
void Load(Zone* zone, IZoneInputStream* stream) override;
std::string& GetZoneScriptString(scr_string_t scrString) override;
};
}

View File

@ -238,7 +238,8 @@ public:
return nullptr;
// Create new zone
auto* zone = new Zone(fileName, 0, new GameAssetPoolT6(0), &g_GameT6);
auto* zone = new Zone(fileName, 0, &g_GameT6);
zone->m_pools = std::make_unique<GameAssetPoolT6>(zone, 0);
zone->m_language = GetZoneLanguage(fileName);
// File is supported. Now setup all required steps for loading this file.

View File

@ -1,10 +1,12 @@
#include "AssetLoader.h"
#include <cassert>
AssetLoader::AssetLoader(const asset_type_t assetType, IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream)
AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStream* stream)
: ContentLoaderBase(zone, stream),
m_asset_type(assetType),
varScriptString(nullptr)
{
m_asset_type = assetType;
m_script_string_provider = scriptStringProvider;
m_zone = zone;
m_stream = stream;
varScriptString = nullptr;
@ -16,7 +18,7 @@ void AssetLoader::AddDependency(XAssetInfoGeneric* assetInfo)
return;
const auto existingEntry = std::find(m_dependencies.begin(), m_dependencies.end(), assetInfo);
if(existingEntry != m_dependencies.end())
if (existingEntry != m_dependencies.end())
{
return;
}
@ -26,31 +28,12 @@ void AssetLoader::AddDependency(XAssetInfoGeneric* assetInfo)
scr_string_t AssetLoader::UseScriptString(const scr_string_t scrString)
{
std::string& scrStringValue = m_script_string_provider->GetZoneScriptString(scrString);
assert(scrString < m_zone->m_script_strings.size());
scr_string_t scriptStringIndex = 0;
for(auto& existingScriptString : m_used_script_strings)
{
if(existingScriptString == scrStringValue)
{
return scriptStringIndex;
}
if (scrString >= m_zone->m_script_strings.size())
return 0u;
scriptStringIndex++;
}
scriptStringIndex = static_cast<scr_string_t>(m_used_script_strings.size());
// If an asset uses script strings make sure that script string 0 is always empty
if(scriptStringIndex == 0 && !scrStringValue.empty())
{
m_used_script_strings.emplace_back("");
scriptStringIndex++;
}
m_used_script_strings.push_back(scrStringValue);
return scriptStringIndex;
return scrString;
}
void AssetLoader::LoadScriptStringArray(const bool atStreamStart, const size_t count)
@ -68,31 +51,12 @@ void AssetLoader::LoadScriptStringArray(const bool atStreamStart, const size_t c
}
}
void AssetLoader::LoadScriptStringArrayRealloc(const bool atStreamStart, const size_t count)
{
assert(varScriptString != nullptr);
if (atStreamStart)
m_stream->Load<scr_string_t>(varScriptString, count);
auto* scriptStringsNew = static_cast<scr_string_t*>(m_zone->GetMemory()->Alloc(sizeof scr_string_t * count));
memcpy_s(scriptStringsNew, sizeof scr_string_t * count, varScriptString, sizeof scr_string_t * count);
varScriptString = scriptStringsNew;
auto* ptr = varScriptString;
for (size_t index = 0; index < count; index++)
{
*ptr = UseScriptString(*ptr);
ptr++;
}
}
XAssetInfoGeneric* AssetLoader::LinkAsset(std::string name, void* asset)
{
return m_zone->GetPools()->AddAsset(m_asset_type, std::move(name), asset, m_used_script_strings, m_dependencies);;
return m_zone->m_pools->AddAsset(m_asset_type, std::move(name), asset, m_dependencies);
}
XAssetInfoGeneric* AssetLoader::GetAssetInfo(std::string name) const
{
return m_zone->GetPools()->GetAsset(m_asset_type, std::move(name));
return m_zone->m_pools->GetAsset(m_asset_type, std::move(name));
}

View File

@ -1,28 +1,22 @@
#pragma once
#include "Pool/XAssetInfo.h"
#include "ContentLoaderBase.h"
#include "IZoneScriptStringProvider.h"
class AssetLoader : public ContentLoaderBase
{
asset_type_t m_asset_type;
std::vector<std::string> m_used_script_strings;
std::vector<XAssetInfoGeneric*> m_dependencies;
protected:
IZoneScriptStringProvider* m_script_string_provider;
scr_string_t* varScriptString;
AssetLoader(asset_type_t assetType, IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream);
AssetLoader(asset_type_t assetType, Zone* zone, IZoneInputStream* stream);
void AddDependency(XAssetInfoGeneric* assetInfo);
scr_string_t UseScriptString(scr_string_t scrString);
void LoadScriptStringArray(bool atStreamStart, size_t count);
void LoadScriptStringArrayRealloc(bool atStreamStart, size_t count);
XAssetInfoGeneric* LinkAsset(std::string name, void* asset);

View File

@ -5,11 +5,17 @@ const void* ContentLoaderBase::PTR_FOLLOWING = reinterpret_cast<void*>(-1);
const void* ContentLoaderBase::PTR_INSERT = reinterpret_cast<void*>(-2);
ContentLoaderBase::ContentLoaderBase()
: varXString(nullptr),
m_zone(nullptr),
m_stream(nullptr)
{
varXString = nullptr;
}
m_zone = nullptr;
m_stream = nullptr;
ContentLoaderBase::ContentLoaderBase(Zone* zone, IZoneInputStream* stream)
: varXString(nullptr),
m_zone(zone),
m_stream(stream)
{
}
void ContentLoaderBase::LoadXString(const bool atStreamStart) const
@ -19,9 +25,9 @@ void ContentLoaderBase::LoadXString(const bool atStreamStart) const
if (atStreamStart)
m_stream->Load<const char*>(varXString);
if(*varXString != nullptr)
if (*varXString != nullptr)
{
if(*varXString == PTR_FOLLOWING)
if (*varXString == PTR_FOLLOWING)
{
*varXString = m_stream->Alloc<const char>(alignof(const char));
m_stream->LoadNullTerminated(const_cast<char*>(*varXString));
@ -37,12 +43,12 @@ void ContentLoaderBase::LoadXStringArray(const bool atStreamStart, const size_t
{
assert(varXString != nullptr);
if(atStreamStart)
if (atStreamStart)
m_stream->Load<const char*>(varXString, count);
for(size_t index = 0; index < count; index++)
for (size_t index = 0; index < count; index++)
{
LoadXString(false);
varXString++;
}
}
}

View File

@ -15,6 +15,7 @@ protected:
IZoneInputStream* m_stream;
ContentLoaderBase();
ContentLoaderBase(Zone* zone, IZoneInputStream* stream);
void LoadXString(bool atStreamStart) const;
void LoadXStringArray(bool atStreamStart, size_t count);

View File

@ -1,10 +0,0 @@
#pragma once
#include "Zone/ZoneTypes.h"
#include <string>
class IZoneScriptStringProvider
{
public:
virtual std::string& GetZoneScriptString(scr_string_t scrString) = 0;
};