Read IW4 signed headers

This commit is contained in:
Jan
2020-09-06 14:39:19 +02:00
parent 3a69b3b0b0
commit 060e5678b5
40 changed files with 1767 additions and 24 deletions

View File

View File

View File

@ -0,0 +1,484 @@
#include "GameAssetPoolIW4.h"
#include "Pool/AssetPoolStatic.h"
#include "Pool/AssetPoolDynamic.h"
#include <cassert>
using namespace IW4;
const std::string GameAssetPoolIW4::ASSET_TYPE_INVALID = "invalid_asset";
const std::string GameAssetPoolIW4::ASSET_TYPE_NAMES[]
{
"physpreset",
"physcollmap",
"xanim",
"xmodelsurfs",
"xmodel",
"material",
"pixelshader",
"vertexshader",
"vertexdecl",
"techniqueset",
"image",
"sound",
"soundcurve",
"loadedsound",
"clipmap",
"clipmap",
"comworld",
"gameworldsp",
"gameworldmp",
"mapents",
"fxworld",
"gfxworld",
"lightdef",
"uimap",
"font",
"menulist",
"menu",
"localize",
"weapon",
"snddriverglobals",
"fx",
"impactfx",
"aitype",
"mptype",
"character",
"xmodelalias",
"rawfile",
"stringtable",
"leaderboard",
"structureddatadef",
"tracer",
"vehicle",
"addonmapents"
};
GameAssetPoolIW4::GameAssetPoolIW4(const int priority)
{
assert(_countof(ASSET_TYPE_NAMES) == ASSET_TYPE_COUNT);
m_priority = priority;
/*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;*/
}
GameAssetPoolIW4::~GameAssetPoolIW4()
{
#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 GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capacity)
{
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
case assetType: \
{ \
if((poolName) == nullptr && capacity > 0) \
{ \
(poolName) = new AssetPoolStatic<poolType>(capacity, m_priority, (assetType)); \
} \
break; \
}
switch (type)
{
/*CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints);
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals);
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses, Glasses);
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree);
CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb, Qdb);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug, Slug);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef);*/
default:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
break;
}
#undef CASE_INIT_POOL_STATIC
}
void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
case assetType: \
{ \
if((poolName) == nullptr) \
{ \
(poolName) = new AssetPoolDynamic<poolType>(m_priority, (assetType)); \
} \
break; \
}
switch (type)
{
/*CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses, Glasses);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb, Qdb);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug, Slug);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef);*/
default:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
break;
}
#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)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
case assetType: \
{ \
assert((poolName) != nullptr); \
auto* assetInfo = (poolName)->AddAsset(std::move(name), xAsset.header.headerName, scriptStrings, dependencies); \
if(assetInfo) \
{ \
m_assets_in_order.push_back(assetInfo); \
} \
return assetInfo; \
}
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);*/
default:
assert(false);
break;
}
return nullptr;
#undef CASE_ADD_TO_POOL
}
XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::string name) const
{
#define CASE_GET_ASSET(assetType, poolName) \
case assetType: \
{ \
if((poolName) != nullptr) \
return (poolName)->GetAsset(std::move(name)); \
break; \
}
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);*/
default:
assert(false);
break;
}
return nullptr;
#undef CASE_GET_ASSET
}
const std::string& GameAssetPoolIW4::GetAssetTypeName(const asset_type_t assetType) const
{
if (assetType >= 0 && assetType < static_cast<int>(_countof(ASSET_TYPE_NAMES)))
return ASSET_TYPE_NAMES[assetType];
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

@ -0,0 +1,77 @@
#pragma once
#include "Pool/IZoneAssetPools.h"
#include "Pool/AssetPool.h"
#include "IW4.h"
class GameAssetPoolIW4 final : public IZoneAssetPools
{
int m_priority;
std::vector<XAssetInfoGeneric*> m_assets_in_order;
static const std::string ASSET_TYPE_INVALID;
static const std::string ASSET_TYPE_NAMES[];
public:
/*AssetPool<T6::PhysPreset>* m_phys_preset;
AssetPool<T6::PhysConstraints>* m_phys_constraints;
AssetPool<T6::DestructibleDef>* m_destructible_def;
AssetPool<T6::XAnimParts>* m_xanim_parts;
AssetPool<T6::XModel>* m_xmodel;
AssetPool<T6::Material>* m_material;
AssetPool<T6::MaterialTechniqueSet>* m_technique_set;
AssetPool<T6::GfxImage>* m_image;
AssetPool<T6::SndBank>* m_sound_bank;
AssetPool<T6::SndPatch>* m_sound_patch;
AssetPool<T6::clipMap_t>* m_clip_map;
AssetPool<T6::ComWorld>* m_com_world;
AssetPool<T6::GameWorldSp>* m_game_world_sp;
AssetPool<T6::GameWorldMp>* m_game_world_mp;
AssetPool<T6::MapEnts>* m_map_ents;
AssetPool<T6::GfxWorld>* m_gfx_world;
AssetPool<T6::GfxLightDef>* m_gfx_light_def;
AssetPool<T6::Font_s>* m_font;
AssetPool<T6::FontIcon>* m_font_icon;
AssetPool<T6::MenuList>* m_menu_list;
AssetPool<T6::menuDef_t>* m_menu_def;
AssetPool<T6::LocalizeEntry>* m_localize;
AssetPool<T6::WeaponVariantDef>* m_weapon;
AssetPool<T6::WeaponAttachment>* m_attachment;
AssetPool<T6::WeaponAttachmentUnique>* m_attachment_unique;
AssetPool<T6::WeaponCamo>* m_camo;
AssetPool<T6::SndDriverGlobals>* m_snd_driver_globals;
AssetPool<T6::FxEffectDef>* m_fx;
AssetPool<T6::FxImpactTable>* m_fx_impact_table;
AssetPool<T6::RawFile>* m_raw_file;
AssetPool<T6::StringTable>* m_string_table;
AssetPool<T6::LeaderboardDef>* m_leaderboard;
AssetPool<T6::XGlobals>* m_xglobals;
AssetPool<T6::ddlRoot_t>* m_ddl;
AssetPool<T6::Glasses>* m_glasses;
AssetPool<T6::EmblemSet>* m_emblem_set;
AssetPool<T6::ScriptParseTree>* m_script;
AssetPool<T6::KeyValuePairs>* m_key_value_pairs;
AssetPool<T6::VehicleDef>* m_vehicle;
AssetPool<T6::MemoryBlock>* m_memory_block;
AssetPool<T6::AddonMapEnts>* m_addon_map_ents;
AssetPool<T6::TracerDef>* m_tracer;
AssetPool<T6::SkinnedVertsDef>* m_skinned_verts;
AssetPool<T6::Qdb>* m_qdb;
AssetPool<T6::Slug>* m_slug;
AssetPool<T6::FootstepTableDef>* m_footstep_table;
AssetPool<T6::FootstepFXTableDef>* m_footstep_fx_table;
AssetPool<T6::ZBarrierDef>* m_zbarrier;*/
explicit GameAssetPoolIW4(int priority);
~GameAssetPoolIW4() 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

@ -0,0 +1,37 @@
#include "GameIW4.h"
#include "IW4.h"
using namespace IW4;
GameIW4 g_GameIW4;
const std::string GameIW4::NAME = "IW4";
const std::string& GameIW4::GetName()
{
return NAME;
}
void GameIW4::AddZone(Zone* zone)
{
m_zones.push_back(zone);
}
void GameIW4::RemoveZone(Zone* zone)
{
const auto foundEntry = std::find(m_zones.begin(), m_zones.end(), zone);
if (foundEntry != m_zones.end())
m_zones.erase(foundEntry);
}
std::vector<Zone*> GameIW4::GetZones()
{
return m_zones;
}
std::vector<GameLanguagePrefix> GameIW4::GetLanguagePrefixes()
{
std::vector<GameLanguagePrefix> prefixes;
return prefixes;
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "Game/IGame.h"
class GameIW4 : public IGame
{
static const std::string NAME;
std::vector<Zone*> m_zones;
public:
const std::string& GetName() override;
void AddZone(Zone* zone) override;
void RemoveZone(Zone* zone) override;
std::vector<Zone*> GetZones() override;
std::vector<GameLanguagePrefix> GetLanguagePrefixes() override;
};
extern GameIW4 g_GameIW4;

View File

@ -0,0 +1,54 @@
#pragma once
#include <d3d11.h>
#include "Image/Texture.h"
#include "IW4_Assets.h"
namespace IW4
{
struct DB_AuthHash
{
char bytes[32];
};
struct DB_AuthSignature
{
char bytes[256];
};
struct DB_AuthSubHeader
{
char fastfileName[32];
unsigned int reserved;
DB_AuthHash masterBlockHashes[244];
};
struct DB_AuthHeader
{
char magic[8]; // + 0
unsigned int reserved; // + 8
DB_AuthHash subheaderHash; // + 12
DB_AuthSignature signedSubheaderHash; // + 44
DB_AuthSubHeader subheader; // + 300
};
struct ScriptStringList
{
int count;
const char** strings;
};
struct XAsset
{
XAssetType type;
XAssetHeader header;
};
struct XAssetList
{
ScriptStringList stringList;
int assetCount;
XAsset* assets;
};
}

View File

@ -0,0 +1,114 @@
#pragma once
namespace IW4
{
enum XAssetType
{
ASSET_TYPE_PHYSPRESET = 0x0,
ASSET_TYPE_PHYSCOLLMAP = 0x1,
ASSET_TYPE_XANIMPARTS = 0x2,
ASSET_TYPE_XMODEL_SURFS = 0x3,
ASSET_TYPE_XMODEL = 0x4,
ASSET_TYPE_MATERIAL = 0x5,
ASSET_TYPE_PIXELSHADER = 0x6,
ASSET_TYPE_VERTEXSHADER = 0x7,
ASSET_TYPE_VERTEXDECL = 0x8,
ASSET_TYPE_TECHNIQUE_SET = 0x9,
ASSET_TYPE_IMAGE = 0xA,
ASSET_TYPE_SOUND = 0xB,
ASSET_TYPE_SOUND_CURVE = 0xC,
ASSET_TYPE_LOADED_SOUND = 0xD,
ASSET_TYPE_CLIPMAP_SP = 0xE,
ASSET_TYPE_CLIPMAP_MP = 0xF,
ASSET_TYPE_COMWORLD = 0x10,
ASSET_TYPE_GAMEWORLD_SP = 0x11,
ASSET_TYPE_GAMEWORLD_MP = 0x12,
ASSET_TYPE_MAP_ENTS = 0x13,
ASSET_TYPE_FXWORLD = 0x14,
ASSET_TYPE_GFXWORLD = 0x15,
ASSET_TYPE_LIGHT_DEF = 0x16,
ASSET_TYPE_UI_MAP = 0x17,
ASSET_TYPE_FONT = 0x18,
ASSET_TYPE_MENULIST = 0x19,
ASSET_TYPE_MENU = 0x1A,
ASSET_TYPE_LOCALIZE_ENTRY = 0x1B,
ASSET_TYPE_WEAPON = 0x1C,
ASSET_TYPE_SNDDRIVER_GLOBALS = 0x1D,
ASSET_TYPE_FX = 0x1E,
ASSET_TYPE_IMPACT_FX = 0x1F,
ASSET_TYPE_AITYPE = 0x20,
ASSET_TYPE_MPTYPE = 0x21,
ASSET_TYPE_CHARACTER = 0x22,
ASSET_TYPE_XMODELALIAS = 0x23,
ASSET_TYPE_RAWFILE = 0x24,
ASSET_TYPE_STRINGTABLE = 0x25,
ASSET_TYPE_LEADERBOARD = 0x26,
ASSET_TYPE_STRUCTURED_DATA_DEF = 0x27,
ASSET_TYPE_TRACER = 0x28,
ASSET_TYPE_VEHICLE = 0x29,
ASSET_TYPE_ADDON_MAP_ENTS = 0x2A,
ASSET_TYPE_COUNT,
ASSET_TYPE_STRING = ASSET_TYPE_COUNT,
ASSET_TYPE_ASSETLIST = 0x2C,
ASSET_TYPE_FULLCOUNT
};
enum XFileBlock
{
XFILE_BLOCK_TEMP,
XFILE_BLOCK_PHYSICAL,
XFILE_BLOCK_RUNTIME,
XFILE_BLOCK_VIRTUAL,
XFILE_BLOCK_LARGE,
XFILE_BLOCK_CALLBACK,
XFILE_BLOCK_VERTEX,
XFILE_BLOCK_INDEX,
MAX_XFILE_COUNT,
};
union XAssetHeader
{
/*PhysPreset* physPreset;
PhysCollmap* physCollmap;
XAnimParts* parts;
XModelSurfs* modelSurfs;
XModel* model;
Material* material;
MaterialPixelShader* pixelShader;
MaterialVertexShader* vertexShader;
MaterialVertexDeclaration* vertexDecl;
MaterialTechniqueSet* techniqueSet;
GfxImage* image;
snd_alias_list_t* sound;
SndCurve* sndCurve;
LoadedSound* loadSnd;
clipMap_t* clipMap;
ComWorld* comWorld;
GameWorldSp* gameWorldSp;
GameWorldMp* gameWorldMp;
MapEnts* mapEnts;
FxWorld* fxWorld;
GfxWorld* gfxWorld;
GfxLightDef* lightDef;
Font_s* font;
MenuList* menuList;
menuDef_t* menu;
LocalizeEntry* localize;
WeaponCompleteDef* weapon;
SndDriverGlobals* sndDriverGlobals;
FxEffectDef* fx;
FxImpactTable* impactFx;
RawFile* rawfile;
StringTable* stringTable;
LeaderboardDef* leaderboardDef;
StructuredDataDefSet* structuredDataDefSet;
TracerDef* tracerDef;
VehicleDef* vehDef;
AddonMapEnts* addonMapEnts;*/
void* data;
};
}