From 868bd070d0a7f75fdff80571f0fef2f58977d1d3 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 11 Oct 2021 18:47:53 +0200 Subject: [PATCH] Include and exclude asset type dumping configured by command line args --- src/ObjWriting/Game/IW3/ZoneDumperIW3.cpp | 57 ++++----- src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp | 77 ++++++------ src/ObjWriting/Game/IW5/ZoneDumperIW5.cpp | 85 ++++++------- src/ObjWriting/Game/T5/ZoneDumperT5.cpp | 71 +++++------ src/ObjWriting/Game/T6/ZoneDumperT6.cpp | 103 ++++++++-------- src/ObjWriting/ObjWriting.cpp | 12 +- src/ObjWriting/ObjWriting.h | 6 + src/Unlinker/Unlinker.cpp | 18 +++ src/Unlinker/UnlinkerArgs.cpp | 61 +++++++++- src/Unlinker/UnlinkerArgs.h | 12 ++ src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp | 39 ++---- src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h | 4 + src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp | 46 ++----- src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h | 9 +- src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp | 51 ++------ src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h | 8 +- src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp | 88 ++------------ src/ZoneCommon/Game/T5/GameAssetPoolT5.h | 76 ++++++------ src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp | 120 ++----------------- src/ZoneCommon/Game/T6/GameAssetPoolT6.h | 108 +++++++++-------- src/ZoneCommon/Pool/ZoneAssetPools.h | 1 + 21 files changed, 476 insertions(+), 576 deletions(-) diff --git a/src/ObjWriting/Game/IW3/ZoneDumperIW3.cpp b/src/ObjWriting/Game/IW3/ZoneDumperIW3.cpp index d5356d44..86ce234b 100644 --- a/src/ObjWriting/Game/IW3/ZoneDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/ZoneDumperIW3.cpp @@ -1,5 +1,6 @@ #include "ZoneDumperIW3.h" +#include "ObjWriting.h" #include "Game/IW3/GameIW3.h" #include "Game/IW3/GameAssetPoolIW3.h" @@ -21,8 +22,8 @@ bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ZoneDumper::DumpZone(AssetDumpingContext& context) const { -#define DUMP_ASSET_POOL(dumperType, poolName) \ - if(assetPools->poolName) \ +#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ + if(assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ { \ dumperType dumper; \ dumper.DumpPool(context, assetPools->poolName.get()); \ @@ -30,32 +31,32 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const const auto* assetPools = dynamic_cast(context.m_zone->m_pools.get()); - // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset) - // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel) - // DUMP_ASSET_POOL(AssetDumperMaterial, m_material) - // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image) - // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound) - // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve) - DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound) - // DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map) - // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world) - // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp) - // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp) - DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents) - // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world) - // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def) - // DUMP_ASSET_POOL(AssetDumperFont_s, m_font) - // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list) - // DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize) - // DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon) - // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals) - // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx) - // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table) + // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) + // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) + DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + // DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) + // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) + DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + // DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP) + // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) + // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) + // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP) + DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) + // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) + // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) + // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) + // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) + // DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + // DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) + // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) + // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) + // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) + DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) return true; diff --git a/src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp b/src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp index 42326cd8..cedb0d2b 100644 --- a/src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/ZoneDumperIW4.cpp @@ -1,5 +1,6 @@ #include "ZoneDumperIW4.h" +#include "ObjWriting.h" #include "Game/IW4/GameIW4.h" #include "Game/IW4/GameAssetPoolIW4.h" @@ -24,8 +25,8 @@ bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ZoneDumper::DumpZone(AssetDumpingContext& context) const { -#define DUMP_ASSET_POOL(dumperType, poolName) \ - if(assetPools->poolName) \ +#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ + if(assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ { \ dumperType dumper; \ dumper.DumpPool(context, assetPools->poolName.get()); \ @@ -33,42 +34,42 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const const auto* assetPools = dynamic_cast(context.m_zone->m_pools.get()); - // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset) - // DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap) - // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel) - // DUMP_ASSET_POOL(AssetDumperMaterial, m_material) - // DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader) - // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader) - // DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl) - // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image) - // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound) - // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve) - DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound) - // DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map) - // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world) - // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp) - // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp) - // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents) - // DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world) - // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world) - // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def) - // DUMP_ASSET_POOL(AssetDumperFont_s, m_font) - DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list) - DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize) - DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon) - // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals) - // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx) - // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table) - // DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard) - // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set) - // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer) - DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle) - DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents) + // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) + // DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) + // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) + DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + // DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + // DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) + // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) + // DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL) + // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) + // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) + DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + // DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP_MP) + // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) + // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) + // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP) + // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) + // DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world, ASSET_TYPE_FXWORLD) + // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) + // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) + // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) + DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) + DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) + // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) + // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) + // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) + DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + // DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD) + // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) + // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER) + DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLE) + DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) return true; diff --git a/src/ObjWriting/Game/IW5/ZoneDumperIW5.cpp b/src/ObjWriting/Game/IW5/ZoneDumperIW5.cpp index 8dcac040..5b9f22e2 100644 --- a/src/ObjWriting/Game/IW5/ZoneDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/ZoneDumperIW5.cpp @@ -1,5 +1,6 @@ #include "ZoneDumperIW5.h" +#include "ObjWriting.h" #include "Game/IW5/GameIW5.h" #include "Game/IW5/GameAssetPoolIW5.h" @@ -20,54 +21,54 @@ bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ZoneDumper::DumpZone(AssetDumpingContext& context) const { -#define DUMP_ASSET_POOL(dumperType, poolName) \ - if(assetPools->poolName) \ +#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ + if(assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ { \ dumperType dumper; \ dumper.DumpPool(context, assetPools->poolName.get()); \ } const auto* assetPools = dynamic_cast(context.m_zone->m_pools.get()); - // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset) - // DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap) - // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts) - // DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel) - // DUMP_ASSET_POOL(AssetDumperMaterial, m_material) - // DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader) - // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader) - // DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl) - // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image) - // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound) - // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve) - DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound) - // DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map) - // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world) - // DUMP_ASSET_POOL(AssetDumperGlassWorld, m_glass_world) - // DUMP_ASSET_POOL(AssetDumperPathData, m_path_data) - // DUMP_ASSET_POOL(AssetDumperVehicleTrack, m_vehicle_track) - // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents) - // DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world) - // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world) - // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def) - // DUMP_ASSET_POOL(AssetDumperFont_s, m_font) - // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list) - // DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize) - // DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment) - // DUMP_ASSET_POOL(AssetDumperWeaponCompleteDef, m_weapon) - // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx) - // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table) - // DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file) - // DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table) - // DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard) - // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set) - // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer) - // DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle) - DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents) + // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) + // DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) + // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) + // DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs, ASSET_TYPE_XMODEL_SURFS) + DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + // DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + // DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) + // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) + // DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL) + // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) + // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) + DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + // DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP) + // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) + // DUMP_ASSET_POOL(AssetDumperGlassWorld, m_glass_world, ASSET_TYPE_GLASSWORLD) + // DUMP_ASSET_POOL(AssetDumperPathData, m_path_data, ASSET_TYPE_PATHDATA) + // DUMP_ASSET_POOL(AssetDumperVehicleTrack, m_vehicle_track, ASSET_TYPE_VEHICLE_TRACK) + // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) + // DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world, ASSET_TYPE_FXWORLD) + // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) + // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) + // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) + // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) + // DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + // DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT) + // DUMP_ASSET_POOL(AssetDumperWeaponCompleteDef, m_weapon, ASSET_TYPE_WEAPON) + // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) + // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) + // DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX) + DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + // DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file, ASSET_TYPE_SCRIPTFILE) + DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + // DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD) + // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) + // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER) + // DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle, ASSET_TYPE_VEHICLE) + DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) return true; diff --git a/src/ObjWriting/Game/T5/ZoneDumperT5.cpp b/src/ObjWriting/Game/T5/ZoneDumperT5.cpp index b78b0165..3d8fd3c5 100644 --- a/src/ObjWriting/Game/T5/ZoneDumperT5.cpp +++ b/src/ObjWriting/Game/T5/ZoneDumperT5.cpp @@ -1,5 +1,6 @@ #include "ZoneDumperT5.h" +#include "ObjWriting.h" #include "Game/T5/GameT5.h" #include "Game/T5/GameAssetPoolT5.h" @@ -22,47 +23,47 @@ bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ZoneDumper::DumpZone(AssetDumpingContext& context) const { -#define DUMP_ASSET_POOL(dumperType, poolName) \ - if(assetPools->poolName) \ +#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ + if(assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ { \ dumperType dumper; \ - dumper.DumpPool(context, assetPools->poolName); \ + dumper.DumpPool(context, assetPools->poolName.get()); \ } const auto* assetPools = dynamic_cast(context.m_zone->m_pools.get()); - // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset) - // DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints) - // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def) - // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel) - // DUMP_ASSET_POOL(AssetDumperMaterial, m_material) - // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image) - // DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank) - // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch) - // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map) - // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world) - // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp) - // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp) - // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents) - // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world) - // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def) - // DUMP_ASSET_POOL(AssetDumperFont, m_font) - // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list) - // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize) - // DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon) - // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals) - // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx) - // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table) - // DUMP_ASSET_POOL(AssetDumperPackIndex, m_pack_index) - // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals) - // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl) - // DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses) - // DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set) + // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) + // DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) + // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) + // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) + DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + // DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + // DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) + // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH) + // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP) + // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) + // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) + // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP) + // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) + // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) + // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) + // DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT) + // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) + // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + // DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) + // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) + // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) + // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) + DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + // DUMP_ASSET_POOL(AssetDumperPackIndex, m_pack_index, ASSET_TYPE_PACK_INDEX) + // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) + // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL) + // DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses, ASSET_TYPE_GLASSES) + // DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set, ASSET_TYPE_EMBLEMSET) return true; diff --git a/src/ObjWriting/Game/T6/ZoneDumperT6.cpp b/src/ObjWriting/Game/T6/ZoneDumperT6.cpp index 98d451e4..4a7349b5 100644 --- a/src/ObjWriting/Game/T6/ZoneDumperT6.cpp +++ b/src/ObjWriting/Game/T6/ZoneDumperT6.cpp @@ -1,5 +1,6 @@ #include "ZoneDumperT6.h" +#include "ObjWriting.h" #include "Game/T6/GameT6.h" #include "Game/T6/GameAssetPoolT6.h" @@ -31,63 +32,63 @@ bool ZoneDumper::CanHandleZone(AssetDumpingContext& context) const bool ZoneDumper::DumpZone(AssetDumpingContext& context) const { -#define DUMP_ASSET_POOL(dumperType, poolName) \ - if(assetPools->poolName) \ +#define DUMP_ASSET_POOL(dumperType, poolName, assetType) \ + if(assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ { \ dumperType dumper; \ - dumper.DumpPool(context, assetPools->poolName); \ + dumper.DumpPool(context, assetPools->poolName.get()); \ } const auto* assetPools = dynamic_cast(context.m_zone->m_pools.get()); - DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset); - DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints); - // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def); - // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts); - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel); - // DUMP_ASSET_POOL(AssetDumperMaterial, m_material); - // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set); - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image); - DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank); - // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch); - // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map); - // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world); - // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp); - // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp); - // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents); - // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world); - // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def); - // DUMP_ASSET_POOL(AssetDumperFont, m_font); - DUMP_ASSET_POOL(AssetDumperFontIcon, m_font_icon); - // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list); - // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def); - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize); - DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon); - DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment); - DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique); - // DUMP_ASSET_POOL(AssetDumperWeaponCamo, m_camo); - // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals); - // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx); - // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table); - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file); - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table); - // DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard); - // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals); - // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl); - // DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses); - // DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set); - DUMP_ASSET_POOL(AssetDumperScriptParseTree, m_script); - // DUMP_ASSET_POOL(AssetDumperKeyValuePairs, m_key_value_pairs); - DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle); - // DUMP_ASSET_POOL(AssetDumperMemoryBlock, m_memory_block); - // DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents); - DUMP_ASSET_POOL(AssetDumperTracer, m_tracer); - // DUMP_ASSET_POOL(AssetDumperSkinnedVertsDef, m_skinned_verts); - DUMP_ASSET_POOL(AssetDumperQdb, m_qdb); - DUMP_ASSET_POOL(AssetDumperSlug, m_slug); - // DUMP_ASSET_POOL(AssetDumperFootstepTableDef, m_footstep_table); - // DUMP_ASSET_POOL(AssetDumperFootstepFXTableDef, m_footstep_fx_table); - DUMP_ASSET_POOL(AssetDumperZBarrier, m_zbarrier); + DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) + DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) + // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) + // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) + DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + // DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) + // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH) + // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP) + // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) + // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) + // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP) + // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) + // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) + // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) + // DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT) + DUMP_ASSET_POOL(AssetDumperFontIcon, m_font_icon, ASSET_TYPE_FONTICON) + // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) + // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) + DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT) + DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE) + // DUMP_ASSET_POOL(AssetDumperWeaponCamo, m_camo, ASSET_TYPE_WEAPON_CAMO) + // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) + // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) + // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) + DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + // DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD) + // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) + // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL) + // DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses, ASSET_TYPE_GLASSES) + // DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set, ASSET_TYPE_EMBLEMSET) + DUMP_ASSET_POOL(AssetDumperScriptParseTree, m_script, ASSET_TYPE_SCRIPTPARSETREE) + // DUMP_ASSET_POOL(AssetDumperKeyValuePairs, m_key_value_pairs, ASSET_TYPE_KEYVALUEPAIRS) + DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLEDEF) + // DUMP_ASSET_POOL(AssetDumperMemoryBlock, m_memory_block, ASSET_TYPE_MEMORYBLOCK) + // DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) + DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER) + // DUMP_ASSET_POOL(AssetDumperSkinnedVertsDef, m_skinned_verts, ASSET_TYPE_SKINNEDVERTS) + DUMP_ASSET_POOL(AssetDumperQdb, m_qdb, ASSET_TYPE_QDB) + DUMP_ASSET_POOL(AssetDumperSlug, m_slug, ASSET_TYPE_SLUG) + // DUMP_ASSET_POOL(AssetDumperFootstepTableDef, m_footstep_table, ASSET_TYPE_FOOTSTEP_TABLE) + // DUMP_ASSET_POOL(AssetDumperFootstepFXTableDef, m_footstep_fx_table, ASSET_TYPE_FOOTSTEPFX_TABLE) + DUMP_ASSET_POOL(AssetDumperZBarrier, m_zbarrier, ASSET_TYPE_ZBARRIER) return true; diff --git a/src/ObjWriting/ObjWriting.cpp b/src/ObjWriting/ObjWriting.cpp index c39edc4e..90dda09a 100644 --- a/src/ObjWriting/ObjWriting.cpp +++ b/src/ObjWriting/ObjWriting.cpp @@ -34,4 +34,14 @@ bool ObjWriting::DumpZone(AssetDumpingContext& context) } return false; -} \ No newline at end of file +} + +bool ObjWriting::ShouldHandleAssetType(const asset_type_t assetType) +{ + if (assetType < 0) + return false; + if (static_cast(assetType) >= Configuration.AssetTypesToHandleBitfield.size()) + return true; + + return Configuration.AssetTypesToHandleBitfield[assetType]; +} diff --git a/src/ObjWriting/ObjWriting.h b/src/ObjWriting/ObjWriting.h index 63c2e19d..7bf918f2 100644 --- a/src/ObjWriting/ObjWriting.h +++ b/src/ObjWriting/ObjWriting.h @@ -1,6 +1,9 @@ #pragma once +#include + #include "Dumping/AssetDumpingContext.h" +#include "Zone/ZoneTypes.h" class ObjWriting { @@ -21,10 +24,13 @@ public: }; bool Verbose = false; + std::vector AssetTypesToHandleBitfield; + ImageOutputFormat_e ImageOutputFormat = ImageOutputFormat_e::DDS; ModelOutputFormat_e ModelOutputFormat = ModelOutputFormat_e::XMODEL_EXPORT; } Configuration; static bool DumpZone(AssetDumpingContext& context); + static bool ShouldHandleAssetType(asset_type_t assetType); }; diff --git a/src/Unlinker/Unlinker.cpp b/src/Unlinker/Unlinker.cpp index ec9c9d6a..45e38f9a 100644 --- a/src/Unlinker/Unlinker.cpp +++ b/src/Unlinker/Unlinker.cpp @@ -210,6 +210,23 @@ class Unlinker::Impl return true; } + void UpdateAssetIncludesAndExcludes(const AssetDumpingContext& context) const + { + const auto assetTypeCount = context.m_zone->m_pools->GetAssetTypeCount(); + + ObjWriting::Configuration.AssetTypesToHandleBitfield = std::vector(assetTypeCount); + + for(auto i = 0; i < assetTypeCount; i++) + { + const auto assetTypeName = std::string(context.m_zone->m_pools->GetAssetTypeName(i)); + + if (m_args.m_specified_asset_types.find(assetTypeName) != m_args.m_specified_asset_types.end()) + ObjWriting::Configuration.AssetTypesToHandleBitfield[i] = m_args.m_asset_type_handling == UnlinkerArgs::AssetTypeHandling::INCLUDE; + else + ObjWriting::Configuration.AssetTypesToHandleBitfield[i] = m_args.m_asset_type_handling == UnlinkerArgs::AssetTypeHandling::EXCLUDE; + } + } + /** * \brief Performs the tasks specified by the command line arguments on the specified zone. * \param zone The zone to handle. @@ -249,6 +266,7 @@ class Unlinker::Impl context.m_gdt = std::move(gdt); } + UpdateAssetIncludesAndExcludes(context); ObjWriting::DumpZone(context); if (m_args.m_use_gdt) diff --git a/src/Unlinker/UnlinkerArgs.cpp b/src/Unlinker/UnlinkerArgs.cpp index ed8e65b6..5cfacf96 100644 --- a/src/Unlinker/UnlinkerArgs.cpp +++ b/src/Unlinker/UnlinkerArgs.cpp @@ -79,6 +79,22 @@ const CommandLineOption* const OPTION_GDT = .WithDescription("Dumps assets in a GDT whenever possible.") .Build(); +const CommandLineOption* const OPTION_EXCLUDE_ASSETS = + CommandLineOption::Builder::Create() + .WithLongName("exclude-assets") + .WithDescription("Specify all asset types that should be excluded.") + .WithParameter("assetTypeList") + .Reusable() + .Build(); + +const CommandLineOption* const OPTION_INCLUDE_ASSETS = + CommandLineOption::Builder::Create() + .WithLongName("include-assets") + .WithDescription("Specify all asset types that should be included.") + .WithParameter("assetTypeList") + .Reusable() + .Build(); + const CommandLineOption* const COMMAND_LINE_OPTIONS[] { OPTION_HELP, @@ -90,7 +106,9 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[] OPTION_SEARCH_PATH, OPTION_IMAGE_FORMAT, OPTION_MODEL_FORMAT, - OPTION_GDT + OPTION_GDT, + OPTION_EXCLUDE_ASSETS, + OPTION_INCLUDE_ASSETS }; UnlinkerArgs::UnlinkerArgs() @@ -98,6 +116,7 @@ UnlinkerArgs::UnlinkerArgs() m_zone_pattern(R"(\?zone\?)"), m_task(ProcessingTask::DUMP), m_minimal_zone_def(false), + m_asset_type_handling(AssetTypeHandling::EXCLUDE), m_use_gdt(false), m_verbose(false) { @@ -171,6 +190,25 @@ bool UnlinkerArgs::SetModelDumpingMode() return false; } +void UnlinkerArgs::ParseCommaSeparatedAssetTypeString(const std::string& input) +{ + auto currentPos = 0u; + size_t endPos; + + std::string lowerInput(input); + for (auto& c : lowerInput) + c = static_cast(tolower(c)); + + while (currentPos < lowerInput.size() && (endPos = lowerInput.find_first_of(',', currentPos)) != std::string::npos) + { + m_specified_asset_types.emplace(lowerInput, currentPos, endPos - currentPos); + currentPos = endPos + 1; + } + + if (currentPos < lowerInput.size()) + m_specified_asset_types.emplace(lowerInput, currentPos, lowerInput.size() - currentPos); +} + bool UnlinkerArgs::ParseArgs(const int argc, const char** argv) { if (!m_argument_parser.ParseArguments(argc - 1, &argv[1])) @@ -246,6 +284,27 @@ bool UnlinkerArgs::ParseArgs(const int argc, const char** argv) // --gdt m_use_gdt = m_argument_parser.IsOptionSpecified(OPTION_GDT); + // --exclude-assets + // --include-assets + if (m_argument_parser.IsOptionSpecified(OPTION_EXCLUDE_ASSETS) && m_argument_parser.IsOptionSpecified(OPTION_INCLUDE_ASSETS)) + { + std::cout << "You can only asset types to either exclude or include, not both\n"; + return false; + } + + if (m_argument_parser.IsOptionSpecified(OPTION_EXCLUDE_ASSETS)) + { + m_asset_type_handling = AssetTypeHandling::EXCLUDE; + for (const auto& exclude : m_argument_parser.GetParametersForOption(OPTION_EXCLUDE_ASSETS)) + ParseCommaSeparatedAssetTypeString(exclude); + } + else if (m_argument_parser.IsOptionSpecified(OPTION_INCLUDE_ASSETS)) + { + m_asset_type_handling = AssetTypeHandling::INCLUDE; + for (const auto& include : m_argument_parser.GetParametersForOption(OPTION_INCLUDE_ASSETS)) + ParseCommaSeparatedAssetTypeString(include); + } + return true; } diff --git a/src/Unlinker/UnlinkerArgs.h b/src/Unlinker/UnlinkerArgs.h index 1716821e..973fa8dd 100644 --- a/src/Unlinker/UnlinkerArgs.h +++ b/src/Unlinker/UnlinkerArgs.h @@ -2,6 +2,7 @@ #include #include #include +#include #include "Utils/Arguments/ArgumentParser.h" #include "Zone/Zone.h" @@ -24,6 +25,8 @@ private: bool SetImageDumpingMode(); bool SetModelDumpingMode(); + void ParseCommaSeparatedAssetTypeString(const std::string& input); + public: enum class ProcessingTask { @@ -31,6 +34,12 @@ public: LIST }; + enum class AssetTypeHandling + { + EXCLUDE, + INCLUDE + }; + std::vector m_zones_to_load; std::vector m_zones_to_unlink; std::set m_user_search_paths; @@ -39,6 +48,9 @@ public: std::string m_output_folder; bool m_minimal_zone_def; + std::set m_specified_asset_types; + AssetTypeHandling m_asset_type_handling; + bool m_use_gdt; bool m_verbose; diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp index b4c8196e..e203030c 100644 --- a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp +++ b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp @@ -84,35 +84,6 @@ GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const int priority) m_priority(priority) { static_assert(std::extent::value == ASSET_TYPE_COUNT); - - m_phys_preset = nullptr; - m_xanim_parts = nullptr; - m_xmodel = nullptr; - m_material = nullptr; - m_material_pixel_shader = nullptr; - m_material_vertex_shader = nullptr; - m_material_vertex_decl = nullptr; - m_technique_set = nullptr; - m_image = nullptr; - m_sound = nullptr; - m_sound_curve = nullptr; - m_loaded_sound = nullptr; - m_clip_map = nullptr; - m_com_world = nullptr; - m_game_world_sp = nullptr; - m_game_world_mp = nullptr; - m_map_ents = nullptr; - m_gfx_world = nullptr; - m_gfx_light_def = nullptr; - m_font = nullptr; - m_menu_list = nullptr; - m_menu_def = nullptr; - m_localize = nullptr; - m_weapon = nullptr; - m_fx = nullptr; - m_fx_impact_table = nullptr; - m_raw_file = nullptr; - m_string_table = nullptr; } void GameAssetPoolIW3::InitPoolStatic(const asset_type_t type, const size_t capacity) @@ -327,3 +298,13 @@ const char* GameAssetPoolIW3::GetAssetTypeName(const asset_type_t assetType) con { return AssetTypeNameByType(assetType); } + +asset_type_t GameAssetPoolIW3::AssetTypeCount() +{ + return ASSET_TYPE_COUNT; +} + +asset_type_t GameAssetPoolIW3::GetAssetTypeCount() const +{ + return AssetTypeCount(); +} diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h index 0beb9dea..71bcc282 100644 --- a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h +++ b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h @@ -53,6 +53,10 @@ public: void InitPoolDynamic(asset_type_t type) override; _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + static const char* AssetTypeNameByType(asset_type_t assetType); _NODISCARD const char* GetAssetTypeName(asset_type_t assetType) const override; + + static asset_type_t AssetTypeCount(); + _NODISCARD asset_type_t GetAssetTypeCount() const override; }; diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp index facc5a9b..d6cf8a86 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp @@ -104,42 +104,6 @@ GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority) m_priority(priority) { assert(std::extent::value == ASSET_TYPE_COUNT); - - m_phys_preset = nullptr; - m_phys_collmap = nullptr; - m_xanim_parts = nullptr; - m_xmodel = nullptr; - m_material = nullptr; - m_material_pixel_shader = nullptr; - m_material_vertex_shader = nullptr; - m_material_vertex_decl = nullptr; - m_technique_set = nullptr; - m_image = nullptr; - m_sound = nullptr; - m_sound_curve = nullptr; - m_loaded_sound = nullptr; - m_clip_map = nullptr; - m_com_world = nullptr; - m_game_world_sp = nullptr; - m_game_world_mp = nullptr; - m_map_ents = nullptr; - m_fx_world = nullptr; - m_gfx_world = nullptr; - m_gfx_light_def = nullptr; - m_font = nullptr; - m_menu_list = nullptr; - m_menu_def = nullptr; - m_localize = nullptr; - m_weapon = nullptr; - m_fx = nullptr; - m_fx_impact_table = nullptr; - m_raw_file = nullptr; - m_string_table = nullptr; - m_leaderboard = nullptr; - m_structed_data_def_set = nullptr; - m_tracer = nullptr; - m_vehicle = nullptr; - m_addon_map_ents = nullptr; } void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capacity) @@ -394,3 +358,13 @@ const char* GameAssetPoolIW4::GetAssetTypeName(const asset_type_t assetType) con { return AssetTypeNameByType(assetType); } + +asset_type_t GameAssetPoolIW4::AssetTypeCount() +{ + return ASSET_TYPE_COUNT; +} + +asset_type_t GameAssetPoolIW4::GetAssetTypeCount() const +{ + return AssetTypeCount(); +} diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h index 2c2b0100..1cf60a47 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h @@ -2,6 +2,7 @@ #include +#include "Utils/ClassUtils.h" #include "Pool/ZoneAssetPools.h" #include "Pool/AssetPool.h" #include "Game/IW4/IW4.h" @@ -59,7 +60,11 @@ public: void InitPoolStatic(asset_type_t type, size_t capacity) override; void InitPoolDynamic(asset_type_t type) override; - XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + static const char* AssetTypeNameByType(asset_type_t assetType); - const char* GetAssetTypeName(asset_type_t assetType) const override; + _NODISCARD const char* GetAssetTypeName(asset_type_t assetType) const override; + + static asset_type_t AssetTypeCount(); + _NODISCARD asset_type_t GetAssetTypeCount() const override; }; diff --git a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp index 06c8d42f..0c176165 100644 --- a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp +++ b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp @@ -110,47 +110,6 @@ GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const int priority) m_priority(priority) { assert(std::extent::value == ASSET_TYPE_COUNT); - - m_phys_preset = nullptr; - m_phys_collmap = nullptr; - m_xanim_parts = nullptr; - m_xmodel_surfs = nullptr; - m_xmodel = nullptr; - m_material = nullptr; - m_material_pixel_shader = nullptr; - m_material_vertex_shader = nullptr; - m_material_vertex_decl = nullptr; - m_technique_set = nullptr; - m_image = nullptr; - m_sound = nullptr; - m_sound_curve = nullptr; - m_loaded_sound = nullptr; - m_clip_map = nullptr; - m_com_world = nullptr; - m_glass_world = nullptr; - m_path_data = nullptr; - m_vehicle_track = nullptr; - m_map_ents = nullptr; - m_fx_world = nullptr; - m_gfx_world = nullptr; - m_gfx_light_def = nullptr; - m_font = nullptr; - m_menu_list = nullptr; - m_menu_def = nullptr; - m_localize = nullptr; - m_attachment = nullptr; - m_weapon = nullptr; - m_fx = nullptr; - m_fx_impact_table = nullptr; - m_surface_fx_table = nullptr; - m_raw_file = nullptr; - m_script_file = nullptr; - m_string_table = nullptr; - m_leaderboard = nullptr; - m_structed_data_def_set = nullptr; - m_tracer = nullptr; - m_vehicle = nullptr; - m_addon_map_ents = nullptr; } void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capacity) @@ -421,3 +380,13 @@ const char* GameAssetPoolIW5::GetAssetTypeName(const asset_type_t assetType) con { return AssetTypeNameByType(assetType); } + +asset_type_t GameAssetPoolIW5::AssetTypeCount() +{ + return ASSET_TYPE_COUNT; +} + +asset_type_t GameAssetPoolIW5::GetAssetTypeCount() const +{ + return AssetTypeCount(); +} diff --git a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h index 6f76e806..a9d03a7a 100644 --- a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h +++ b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h @@ -64,7 +64,11 @@ public: void InitPoolStatic(asset_type_t type, size_t capacity) override; void InitPoolDynamic(asset_type_t type) override; - XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + static const char* AssetTypeNameByType(asset_type_t assetType); - const char* GetAssetTypeName(asset_type_t assetType) const override; + _NODISCARD const char* GetAssetTypeName(asset_type_t assetType) const override; + + static asset_type_t AssetTypeCount(); + _NODISCARD asset_type_t GetAssetTypeCount() const override; }; diff --git a/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp b/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp index 764c3730..b46e8d3c 100644 --- a/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp +++ b/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp @@ -60,80 +60,6 @@ GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const int priority) m_priority(priority) { assert(std::extent::value == ASSET_TYPE_COUNT); - - m_phys_preset = nullptr; - m_phys_constraints = nullptr; - m_destructible_def = nullptr; - m_xanim_parts = nullptr; - m_xmodel = nullptr; - m_material = nullptr; - m_technique_set = nullptr; - m_image = nullptr; - m_sound_bank = nullptr; - m_sound_patch = nullptr; - m_clip_map = nullptr; - m_com_world = nullptr; - m_game_world_sp = nullptr; - m_game_world_mp = nullptr; - m_map_ents = nullptr; - m_gfx_world = nullptr; - m_gfx_light_def = nullptr; - m_font = nullptr; - m_menu_list = nullptr; - m_menu_def = nullptr; - m_localize = nullptr; - m_weapon = nullptr; - m_snd_driver_globals = nullptr; - m_fx = nullptr; - m_fx_impact_table = nullptr; - m_raw_file = nullptr; - m_string_table = nullptr; - m_pack_index = nullptr; - m_xglobals = nullptr; - m_ddl = nullptr; - m_glasses = nullptr; - m_emblem_set = nullptr; -} - -GameAssetPoolT5::~GameAssetPoolT5() -{ -#define DELETE_POOL(poolName) \ - delete (poolName); (poolName) = nullptr; - - DELETE_POOL(m_phys_preset); - DELETE_POOL(m_phys_constraints); - DELETE_POOL(m_destructible_def); - DELETE_POOL(m_xanim_parts); - DELETE_POOL(m_xmodel); - DELETE_POOL(m_material); - DELETE_POOL(m_technique_set); - DELETE_POOL(m_image); - DELETE_POOL(m_sound_bank); - DELETE_POOL(m_sound_patch); - DELETE_POOL(m_clip_map); - DELETE_POOL(m_com_world); - DELETE_POOL(m_game_world_sp); - DELETE_POOL(m_game_world_mp); - DELETE_POOL(m_map_ents); - DELETE_POOL(m_gfx_world); - DELETE_POOL(m_gfx_light_def); - DELETE_POOL(m_font); - DELETE_POOL(m_menu_list); - DELETE_POOL(m_menu_def); - DELETE_POOL(m_localize); - DELETE_POOL(m_weapon); - DELETE_POOL(m_snd_driver_globals); - DELETE_POOL(m_fx); - DELETE_POOL(m_fx_impact_table); - DELETE_POOL(m_raw_file); - DELETE_POOL(m_string_table); - DELETE_POOL(m_pack_index); - DELETE_POOL(m_xglobals); - DELETE_POOL(m_ddl); - DELETE_POOL(m_glasses); - DELETE_POOL(m_emblem_set); - -#undef DELETE_POOL } void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capacity) @@ -143,7 +69,7 @@ void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capac { \ if((poolName) == nullptr && capacity > 0) \ { \ - (poolName) = new AssetPoolStatic(capacity, m_priority, (assetType)); \ + (poolName) = std::make_unique>(capacity, m_priority, (assetType)); \ } \ break; \ } @@ -199,7 +125,7 @@ void GameAssetPoolT5::InitPoolDynamic(const asset_type_t type) { \ if((poolName) == nullptr) \ { \ - (poolName) = new AssetPoolDynamic(m_priority, (assetType)); \ + (poolName) = std::make_unique>(m_priority, (assetType)); \ } \ break; \ } @@ -377,3 +303,13 @@ const char* GameAssetPoolT5::GetAssetTypeName(const asset_type_t assetType) cons { return AssetTypeNameByType(assetType); } + +asset_type_t GameAssetPoolT5::AssetTypeCount() +{ + return ASSET_TYPE_COUNT; +} + +asset_type_t GameAssetPoolT5::GetAssetTypeCount() const +{ + return AssetTypeCount(); +} diff --git a/src/ZoneCommon/Game/T5/GameAssetPoolT5.h b/src/ZoneCommon/Game/T5/GameAssetPoolT5.h index 1180213e..e1aba0d1 100644 --- a/src/ZoneCommon/Game/T5/GameAssetPoolT5.h +++ b/src/ZoneCommon/Game/T5/GameAssetPoolT5.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "Pool/ZoneAssetPools.h" #include "Pool/AssetPool.h" #include "Game/T5/T5.h" @@ -15,46 +17,50 @@ protected: XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector dependencies, std::vector usedScriptStrings, Zone* zone) override; public: - AssetPool* m_phys_preset; - AssetPool* m_phys_constraints; - AssetPool* m_destructible_def; - AssetPool* m_xanim_parts; - AssetPool* m_xmodel; - AssetPool* m_material; - AssetPool* m_technique_set; - AssetPool* m_image; - AssetPool* m_sound_bank; - AssetPool* m_sound_patch; - AssetPool* m_clip_map; - AssetPool* m_com_world; - AssetPool* m_game_world_sp; - AssetPool* m_game_world_mp; - AssetPool* m_map_ents; - AssetPool* m_gfx_world; - AssetPool* m_gfx_light_def; - AssetPool* m_font; - AssetPool* m_menu_list; - AssetPool* m_menu_def; - AssetPool* m_localize; - AssetPool* m_weapon; - AssetPool* m_snd_driver_globals; - AssetPool* m_fx; - AssetPool* m_fx_impact_table; - AssetPool* m_raw_file; - AssetPool* m_string_table; - AssetPool* m_pack_index; - AssetPool* m_xglobals; - AssetPool* m_ddl; - AssetPool* m_glasses; - AssetPool* m_emblem_set; + std::unique_ptr> m_phys_preset; + std::unique_ptr> m_phys_constraints; + std::unique_ptr> m_destructible_def; + std::unique_ptr> m_xanim_parts; + std::unique_ptr> m_xmodel; + std::unique_ptr> m_material; + std::unique_ptr> m_technique_set; + std::unique_ptr> m_image; + std::unique_ptr> m_sound_bank; + std::unique_ptr> m_sound_patch; + std::unique_ptr> m_clip_map; + std::unique_ptr> m_com_world; + std::unique_ptr> m_game_world_sp; + std::unique_ptr> m_game_world_mp; + std::unique_ptr> m_map_ents; + std::unique_ptr> m_gfx_world; + std::unique_ptr> m_gfx_light_def; + std::unique_ptr> m_font; + std::unique_ptr> m_menu_list; + std::unique_ptr> m_menu_def; + std::unique_ptr> m_localize; + std::unique_ptr> m_weapon; + std::unique_ptr> m_snd_driver_globals; + std::unique_ptr> m_fx; + std::unique_ptr> m_fx_impact_table; + std::unique_ptr> m_raw_file; + std::unique_ptr> m_string_table; + std::unique_ptr> m_pack_index; + std::unique_ptr> m_xglobals; + std::unique_ptr> m_ddl; + std::unique_ptr> m_glasses; + std::unique_ptr> m_emblem_set; GameAssetPoolT5(Zone* zone, int priority); - ~GameAssetPoolT5() override; + ~GameAssetPoolT5() override = default; void InitPoolStatic(asset_type_t type, size_t capacity) override; void InitPoolDynamic(asset_type_t type) override; - XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + static const char* AssetTypeNameByType(asset_type_t assetType); - const char* GetAssetTypeName(asset_type_t assetType) const override; + _NODISCARD const char* GetAssetTypeName(asset_type_t assetType) const override; + + static asset_type_t AssetTypeCount(); + _NODISCARD asset_type_t GetAssetTypeCount() const override; }; diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp index 7263b133..b667df7e 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp @@ -77,112 +77,6 @@ GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority) m_priority(priority) { assert(std::extent::value == ASSET_TYPE_COUNT); - - m_phys_preset = nullptr; - m_phys_constraints = nullptr; - m_destructible_def = nullptr; - m_xanim_parts = nullptr; - m_xmodel = nullptr; - m_material = nullptr; - m_technique_set = nullptr; - m_image = nullptr; - m_sound_bank = nullptr; - m_sound_patch = nullptr; - m_clip_map = nullptr; - m_com_world = nullptr; - m_game_world_sp = nullptr; - m_game_world_mp = nullptr; - m_map_ents = nullptr; - m_gfx_world = nullptr; - m_gfx_light_def = nullptr; - m_font = nullptr; - m_font_icon = nullptr; - m_menu_list = nullptr; - m_menu_def = nullptr; - m_localize = nullptr; - m_weapon = nullptr; - m_attachment = nullptr; - m_attachment_unique = nullptr; - m_camo = nullptr; - m_snd_driver_globals = nullptr; - m_fx = nullptr; - m_fx_impact_table = nullptr; - m_raw_file = nullptr; - m_string_table = nullptr; - m_leaderboard = nullptr; - m_xglobals = nullptr; - m_ddl = nullptr; - m_glasses = nullptr; - m_emblem_set = nullptr; - m_script = nullptr; - m_key_value_pairs = nullptr; - m_vehicle = nullptr; - m_memory_block = nullptr; - m_addon_map_ents = nullptr; - m_tracer = nullptr; - m_skinned_verts = nullptr; - m_qdb = nullptr; - m_slug = nullptr; - m_footstep_table = nullptr; - m_footstep_fx_table = nullptr; - m_zbarrier = nullptr; -} - -GameAssetPoolT6::~GameAssetPoolT6() -{ -#define DELETE_POOL(poolName) \ - delete (poolName); (poolName) = nullptr; - - DELETE_POOL(m_phys_preset); - DELETE_POOL(m_phys_constraints); - DELETE_POOL(m_destructible_def); - DELETE_POOL(m_xanim_parts); - DELETE_POOL(m_xmodel); - DELETE_POOL(m_material); - DELETE_POOL(m_technique_set); - DELETE_POOL(m_image); - DELETE_POOL(m_sound_bank); - DELETE_POOL(m_sound_patch); - DELETE_POOL(m_clip_map); - DELETE_POOL(m_com_world); - DELETE_POOL(m_game_world_sp); - DELETE_POOL(m_game_world_mp); - DELETE_POOL(m_map_ents); - DELETE_POOL(m_gfx_world); - DELETE_POOL(m_gfx_light_def); - DELETE_POOL(m_font); - DELETE_POOL(m_font_icon); - DELETE_POOL(m_menu_list); - DELETE_POOL(m_menu_def); - DELETE_POOL(m_localize); - DELETE_POOL(m_weapon); - DELETE_POOL(m_attachment); - DELETE_POOL(m_attachment_unique); - DELETE_POOL(m_camo); - DELETE_POOL(m_snd_driver_globals); - DELETE_POOL(m_fx); - DELETE_POOL(m_fx_impact_table); - DELETE_POOL(m_raw_file); - DELETE_POOL(m_string_table); - DELETE_POOL(m_leaderboard); - DELETE_POOL(m_xglobals); - DELETE_POOL(m_ddl); - DELETE_POOL(m_glasses); - DELETE_POOL(m_emblem_set); - DELETE_POOL(m_script); - DELETE_POOL(m_key_value_pairs); - DELETE_POOL(m_vehicle); - DELETE_POOL(m_memory_block); - DELETE_POOL(m_addon_map_ents); - DELETE_POOL(m_tracer); - DELETE_POOL(m_skinned_verts); - DELETE_POOL(m_qdb); - DELETE_POOL(m_slug); - DELETE_POOL(m_footstep_table); - DELETE_POOL(m_footstep_fx_table); - DELETE_POOL(m_zbarrier); - -#undef DELETE_POOL } void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capacity) @@ -192,7 +86,7 @@ void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capac { \ if((poolName) == nullptr && capacity > 0) \ { \ - (poolName) = new AssetPoolStatic(capacity, m_priority, (assetType)); \ + (poolName) = std::make_unique>(capacity, m_priority, (assetType)); \ } \ break; \ } @@ -264,7 +158,7 @@ void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type) { \ if((poolName) == nullptr) \ { \ - (poolName) = new AssetPoolDynamic(m_priority, (assetType)); \ + (poolName) = std::make_unique>(m_priority, (assetType)); \ } \ break; \ } @@ -490,3 +384,13 @@ const char* GameAssetPoolT6::GetAssetTypeName(const asset_type_t assetType) cons { return AssetTypeNameByType(assetType); } + +asset_type_t GameAssetPoolT6::AssetTypeCount() +{ + return ASSET_TYPE_COUNT; +} + +asset_type_t GameAssetPoolT6::GetAssetTypeCount() const +{ + return AssetTypeCount(); +} diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h index a0de091f..1daddca6 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "Pool/ZoneAssetPools.h" #include "Pool/AssetPool.h" #include "Game/T6/T6.h" @@ -15,62 +17,66 @@ protected: XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector dependencies, std::vector usedScriptStrings, Zone* zone) override; public: - AssetPool* m_phys_preset; - AssetPool* m_phys_constraints; - AssetPool* m_destructible_def; - AssetPool* m_xanim_parts; - AssetPool* m_xmodel; - AssetPool* m_material; - AssetPool* m_technique_set; - AssetPool* m_image; - AssetPool* m_sound_bank; - AssetPool* m_sound_patch; - AssetPool* m_clip_map; - AssetPool* m_com_world; - AssetPool* m_game_world_sp; - AssetPool* m_game_world_mp; - AssetPool* m_map_ents; - AssetPool* m_gfx_world; - AssetPool* m_gfx_light_def; - AssetPool* m_font; - AssetPool* m_font_icon; - AssetPool* m_menu_list; - AssetPool* m_menu_def; - AssetPool* m_localize; - AssetPool* m_weapon; - AssetPool* m_attachment; - AssetPool* m_attachment_unique; - AssetPool* m_camo; - AssetPool* m_snd_driver_globals; - AssetPool* m_fx; - AssetPool* m_fx_impact_table; - AssetPool* m_raw_file; - AssetPool* m_string_table; - AssetPool* m_leaderboard; - AssetPool* m_xglobals; - AssetPool* m_ddl; - AssetPool* m_glasses; - AssetPool* m_emblem_set; - AssetPool* m_script; - AssetPool* m_key_value_pairs; - AssetPool* m_vehicle; - AssetPool* m_memory_block; - AssetPool* m_addon_map_ents; - AssetPool* m_tracer; - AssetPool* m_skinned_verts; - AssetPool* m_qdb; - AssetPool* m_slug; - AssetPool* m_footstep_table; - AssetPool* m_footstep_fx_table; - AssetPool* m_zbarrier; + std::unique_ptr> m_phys_preset; + std::unique_ptr> m_phys_constraints; + std::unique_ptr> m_destructible_def; + std::unique_ptr> m_xanim_parts; + std::unique_ptr> m_xmodel; + std::unique_ptr> m_material; + std::unique_ptr> m_technique_set; + std::unique_ptr> m_image; + std::unique_ptr> m_sound_bank; + std::unique_ptr> m_sound_patch; + std::unique_ptr> m_clip_map; + std::unique_ptr> m_com_world; + std::unique_ptr> m_game_world_sp; + std::unique_ptr> m_game_world_mp; + std::unique_ptr> m_map_ents; + std::unique_ptr> m_gfx_world; + std::unique_ptr> m_gfx_light_def; + std::unique_ptr> m_font; + std::unique_ptr> m_font_icon; + std::unique_ptr> m_menu_list; + std::unique_ptr> m_menu_def; + std::unique_ptr> m_localize; + std::unique_ptr> m_weapon; + std::unique_ptr> m_attachment; + std::unique_ptr> m_attachment_unique; + std::unique_ptr> m_camo; + std::unique_ptr> m_snd_driver_globals; + std::unique_ptr> m_fx; + std::unique_ptr> m_fx_impact_table; + std::unique_ptr> m_raw_file; + std::unique_ptr> m_string_table; + std::unique_ptr> m_leaderboard; + std::unique_ptr> m_xglobals; + std::unique_ptr> m_ddl; + std::unique_ptr> m_glasses; + std::unique_ptr> m_emblem_set; + std::unique_ptr> m_script; + std::unique_ptr> m_key_value_pairs; + std::unique_ptr> m_vehicle; + std::unique_ptr> m_memory_block; + std::unique_ptr> m_addon_map_ents; + std::unique_ptr> m_tracer; + std::unique_ptr> m_skinned_verts; + std::unique_ptr> m_qdb; + std::unique_ptr> m_slug; + std::unique_ptr> m_footstep_table; + std::unique_ptr> m_footstep_fx_table; + std::unique_ptr> m_zbarrier; GameAssetPoolT6(Zone* zone, int priority); - ~GameAssetPoolT6() override; + ~GameAssetPoolT6() override = default; void InitPoolStatic(asset_type_t type, size_t capacity) override; void InitPoolDynamic(asset_type_t type) override; - XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + _NODISCARD XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const override; + static const char* AssetTypeNameByType(asset_type_t assetType); - const char* GetAssetTypeName(asset_type_t assetType) const override; + _NODISCARD const char* GetAssetTypeName(asset_type_t assetType) const override; + + static asset_type_t AssetTypeCount(); + _NODISCARD asset_type_t GetAssetTypeCount() const override; }; diff --git a/src/ZoneCommon/Pool/ZoneAssetPools.h b/src/ZoneCommon/Pool/ZoneAssetPools.h index 777f1a8b..d2c7efc4 100644 --- a/src/ZoneCommon/Pool/ZoneAssetPools.h +++ b/src/ZoneCommon/Pool/ZoneAssetPools.h @@ -33,6 +33,7 @@ public: XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector dependencies, std::vector usedScriptStrings); XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector dependencies, std::vector usedScriptStrings, Zone* zone); _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; virtual void InitPoolStatic(asset_type_t type, size_t capacity) = 0;