mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 15:28:11 -05:00
Import code from previous AssetBuilder version
This commit is contained in:
12
src/ZoneCommon/Game/IGame.h
Normal file
12
src/ZoneCommon/Game/IGame.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "Zone/Zone.h"
|
||||
#include <vector>
|
||||
|
||||
class Zone;
|
||||
|
||||
class IGame
|
||||
{
|
||||
public:
|
||||
virtual void AddZone(Zone* zone) = 0;
|
||||
virtual std::vector<Zone*> GetZones() = 0;
|
||||
};
|
337
src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp
Normal file
337
src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp
Normal file
@ -0,0 +1,337 @@
|
||||
#include "GameAssetPoolT6.h"
|
||||
#include "Pool/AssetPoolStatic.h"
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
#include <cassert>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
GameAssetPoolT6::GameAssetPoolT6(const int priority)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if((poolName) == nullptr && capacity > 0) \
|
||||
{ \
|
||||
(poolName) = new AssetPoolStatic<poolType>(capacity, m_priority); \
|
||||
} \
|
||||
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 GameAssetPoolT6::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); \
|
||||
} \
|
||||
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
|
||||
}
|
||||
|
||||
void* GameAssetPoolT6::AddAsset(asset_type_t type, std::string name, void* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetDependency>& 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); \
|
||||
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, scriptStrings, dependencies)->m_asset; \
|
||||
}
|
||||
|
||||
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
|
||||
}
|
68
src/ZoneCommon/Game/T6/GameAssetPoolT6.h
Normal file
68
src/ZoneCommon/Game/T6/GameAssetPoolT6.h
Normal file
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include "Pool/AssetPool.h"
|
||||
#include "Pool/IZoneAssetPools.h"
|
||||
#include "T6.h"
|
||||
|
||||
class GameAssetPoolT6 final : public IZoneAssetPools
|
||||
{
|
||||
int m_priority;
|
||||
|
||||
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 GameAssetPoolT6(int priority);
|
||||
~GameAssetPoolT6() override;
|
||||
|
||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
||||
void InitPoolDynamic(asset_type_t type) override;
|
||||
|
||||
void* AddAsset(asset_type_t type, std::string name, void* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetDependency>& dependencies) override;
|
||||
};
|
16
src/ZoneCommon/Game/T6/GameT6.cpp
Normal file
16
src/ZoneCommon/Game/T6/GameT6.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "GameT6.h"
|
||||
#include "T6.h"
|
||||
|
||||
using namespace T6;
|
||||
|
||||
GameT6 game_t6;
|
||||
|
||||
void GameT6::AddZone(Zone* zone)
|
||||
{
|
||||
m_zones.push_back(zone);
|
||||
}
|
||||
|
||||
std::vector<Zone*> GameT6::GetZones()
|
||||
{
|
||||
return m_zones;
|
||||
}
|
13
src/ZoneCommon/Game/T6/GameT6.h
Normal file
13
src/ZoneCommon/Game/T6/GameT6.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "Game/IGame.h"
|
||||
|
||||
class GameT6 : public IGame
|
||||
{
|
||||
std::vector<Zone*> m_zones;
|
||||
|
||||
public:
|
||||
void AddZone(Zone* zone) override;
|
||||
std::vector<Zone*> GetZones() override;
|
||||
};
|
||||
|
||||
extern GameT6 game_t6;
|
44
src/ZoneCommon/Game/T6/T6.h
Normal file
44
src/ZoneCommon/Game/T6/T6.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
#include "T6_Assets.h"
|
||||
|
||||
enum XFileBlock
|
||||
{
|
||||
XFILE_BLOCK_TEMP,
|
||||
XFILE_BLOCK_RUNTIME_VIRTUAL,
|
||||
XFILE_BLOCK_RUNTIME_PHYSICAL,
|
||||
XFILE_BLOCK_DELAY_VIRTUAL,
|
||||
XFILE_BLOCK_DELAY_PHYSICAL,
|
||||
XFILE_BLOCK_VIRTUAL,
|
||||
XFILE_BLOCK_PHYSICAL,
|
||||
XFILE_BLOCK_STREAMER_RESERVE,
|
||||
MAX_XFILE_COUNT,
|
||||
};
|
||||
|
||||
struct ScriptStringList
|
||||
{
|
||||
int count;
|
||||
const char **strings;
|
||||
};
|
||||
|
||||
struct XAsset
|
||||
{
|
||||
XAssetType type;
|
||||
XAssetHeader header;
|
||||
};
|
||||
|
||||
|
||||
struct XAssetList
|
||||
{
|
||||
ScriptStringList stringList;
|
||||
int dependCount;
|
||||
const char **depends;
|
||||
int assetCount;
|
||||
XAsset *assets;
|
||||
};
|
||||
|
||||
}
|
5725
src/ZoneCommon/Game/T6/T6_Assets.h
Normal file
5725
src/ZoneCommon/Game/T6/T6_Assets.h
Normal file
File diff suppressed because it is too large
Load Diff
67
src/ZoneCommon/Pool/AssetPool.h
Normal file
67
src/ZoneCommon/Pool/AssetPool.h
Normal file
@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "XAssetInfo.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
template<typename T>
|
||||
class AssetPool
|
||||
{
|
||||
public:
|
||||
std::map<std::string, XAssetInfo<T>*> m_asset_lookup;
|
||||
|
||||
class Iterator
|
||||
{
|
||||
typename std::map<std::string, XAssetInfo<T>*>::iterator m_iterator;
|
||||
|
||||
public:
|
||||
explicit Iterator(typename std::map<std::string, XAssetInfo<T>*>::iterator i)
|
||||
{
|
||||
m_iterator = i;
|
||||
}
|
||||
|
||||
bool operator!=(Iterator rhs)
|
||||
{
|
||||
return m_iterator != rhs.m_iterator;
|
||||
}
|
||||
|
||||
XAssetInfo<T>* operator*()
|
||||
{
|
||||
return m_iterator.operator*().second;
|
||||
}
|
||||
|
||||
void operator++()
|
||||
{
|
||||
++m_iterator;
|
||||
}
|
||||
};
|
||||
|
||||
AssetPool()
|
||||
{
|
||||
m_asset_lookup = std::map<std::string, XAssetInfo<T>*>();
|
||||
}
|
||||
|
||||
virtual ~AssetPool() = default;
|
||||
|
||||
virtual XAssetInfo<T>* AddAsset(std::string name, T* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetDependency>& dependencies) = 0;
|
||||
|
||||
XAssetInfo<T>* GetAsset(const std::string& name)
|
||||
{
|
||||
auto foundAsset = m_asset_lookup.find(name);
|
||||
|
||||
if(foundAsset == m_asset_lookup.end())
|
||||
return nullptr;
|
||||
|
||||
return foundAsset->second;
|
||||
}
|
||||
|
||||
Iterator begin()
|
||||
{
|
||||
return Iterator(m_asset_lookup.begin());
|
||||
}
|
||||
|
||||
Iterator end()
|
||||
{
|
||||
return Iterator(m_asset_lookup.end());
|
||||
}
|
||||
};
|
59
src/ZoneCommon/Pool/AssetPoolDynamic.h
Normal file
59
src/ZoneCommon/Pool/AssetPoolDynamic.h
Normal file
@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "AssetPool.h"
|
||||
#include "GlobalAssetPool.h"
|
||||
#include "XAssetInfo.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
template <typename T>
|
||||
class AssetPoolDynamic final : public AssetPool<T>
|
||||
{
|
||||
using AssetPool<T>::m_asset_lookup;
|
||||
|
||||
std::vector<XAssetInfo<T>*> m_assets;
|
||||
|
||||
public:
|
||||
explicit AssetPoolDynamic(const int priority)
|
||||
{
|
||||
GlobalAssetPool<T>::LinkAssetPool(this, priority);
|
||||
}
|
||||
|
||||
AssetPoolDynamic(AssetPoolDynamic<T>&) = delete;
|
||||
AssetPoolDynamic(AssetPoolDynamic<T>&&) = delete;
|
||||
AssetPoolDynamic<T>& operator =(AssetPoolDynamic<T>&) = delete;
|
||||
AssetPoolDynamic<T>& operator =(AssetPoolDynamic<T>&&) = default;
|
||||
|
||||
~AssetPoolDynamic() override
|
||||
{
|
||||
GlobalAssetPool<T>::UnlinkAssetPool(this);
|
||||
|
||||
for(auto* entry : m_assets)
|
||||
{
|
||||
delete entry->m_asset;
|
||||
delete entry;
|
||||
}
|
||||
|
||||
m_assets.clear();
|
||||
m_asset_lookup.clear();
|
||||
}
|
||||
|
||||
XAssetInfo<T>* AddAsset(std::string name, T* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetDependency>& dependencies) override
|
||||
{
|
||||
auto* newInfo = new XAssetInfo<T>();
|
||||
newInfo->m_name = std::move(name);
|
||||
newInfo->m_script_strings = std::move(scriptStrings);
|
||||
newInfo->m_dependencies = std::move(dependencies);
|
||||
|
||||
T* newAsset = new T();
|
||||
memcpy(newAsset, asset, sizeof(T));
|
||||
newInfo->m_asset = newAsset;
|
||||
|
||||
m_assets.push_back(newInfo);
|
||||
m_asset_lookup[newInfo->m_name] = newInfo;
|
||||
|
||||
GlobalAssetPool<T>::LinkAsset(this, newInfo);
|
||||
|
||||
return newInfo;
|
||||
}
|
||||
};
|
104
src/ZoneCommon/Pool/AssetPoolStatic.h
Normal file
104
src/ZoneCommon/Pool/AssetPoolStatic.h
Normal file
@ -0,0 +1,104 @@
|
||||
#pragma once
|
||||
|
||||
#include "GlobalAssetPool.h"
|
||||
#include "AssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
|
||||
template <typename T>
|
||||
class AssetPoolStatic final : public AssetPool<T>
|
||||
{
|
||||
using AssetPool<T>::m_asset_lookup;
|
||||
|
||||
struct AssetPoolEntry
|
||||
{
|
||||
XAssetInfo<T>* m_info;
|
||||
|
||||
union
|
||||
{
|
||||
T m_entry;
|
||||
AssetPoolEntry* m_next;
|
||||
};
|
||||
};
|
||||
|
||||
AssetPoolEntry* m_free;
|
||||
AssetPoolEntry* m_pool;
|
||||
XAssetInfo<T>* m_info_pool;
|
||||
size_t m_capacity;
|
||||
|
||||
public:
|
||||
AssetPoolStatic(const size_t capacity, const int priority)
|
||||
{
|
||||
m_capacity = capacity;
|
||||
|
||||
if (m_capacity > 0)
|
||||
{
|
||||
m_pool = new AssetPoolEntry[m_capacity];
|
||||
m_info_pool = new XAssetInfo<T>[m_capacity];
|
||||
|
||||
for(size_t i = 0; i < m_capacity - 1; i++)
|
||||
{
|
||||
m_pool[i].m_info = &m_info_pool[i];
|
||||
m_pool[i].m_next = &m_pool[i + 1];
|
||||
}
|
||||
m_pool[m_capacity - 1].m_info = &m_info_pool[m_capacity - 1];
|
||||
m_pool[m_capacity - 1].m_next = nullptr;
|
||||
|
||||
m_free = m_pool;
|
||||
|
||||
GlobalAssetPool<T>::LinkAssetPool(this, priority);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pool = nullptr;
|
||||
m_free = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
AssetPoolStatic(AssetPoolStatic<T>&) = delete;
|
||||
AssetPoolStatic(AssetPoolStatic<T>&&) = delete;
|
||||
AssetPoolStatic<T>& operator =(AssetPoolStatic<T>&) = delete;
|
||||
AssetPoolStatic<T>& operator =(AssetPoolStatic<T>&&) = default;
|
||||
|
||||
~AssetPoolStatic() override
|
||||
{
|
||||
if(m_capacity > 0)
|
||||
{
|
||||
GlobalAssetPool<T>::UnlinkAssetPool(this);
|
||||
}
|
||||
|
||||
delete[] m_pool;
|
||||
m_pool = nullptr;
|
||||
|
||||
delete[] m_info_pool;
|
||||
m_info_pool = nullptr;
|
||||
|
||||
m_free = nullptr;
|
||||
m_capacity = 0;
|
||||
}
|
||||
|
||||
XAssetInfo<T>* AddAsset(std::string name, T* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetDependency>& dependencies) override
|
||||
{
|
||||
if(m_free == nullptr)
|
||||
{
|
||||
throw std::exception("Could not add asset to static asset pool: capacity exhausted.");
|
||||
}
|
||||
|
||||
AssetPoolEntry* poolSlot = m_free;
|
||||
m_free = m_free->m_next;
|
||||
|
||||
memcpy(&poolSlot->m_entry, asset, sizeof(T));
|
||||
|
||||
poolSlot->m_info->m_name = std::move(name);
|
||||
poolSlot->m_info->m_asset = &poolSlot->m_entry;
|
||||
poolSlot->m_info->m_script_strings = std::move(scriptStrings);
|
||||
poolSlot->m_info->m_dependencies = std::move(dependencies);
|
||||
|
||||
m_asset_lookup[poolSlot->m_info->m_name] = poolSlot->m_info;
|
||||
|
||||
GlobalAssetPool<T>::LinkAsset(this, poolSlot->m_info);
|
||||
|
||||
return poolSlot->m_info;
|
||||
}
|
||||
};
|
2
src/ZoneCommon/Pool/GlobalAssetPool.cpp
Normal file
2
src/ZoneCommon/Pool/GlobalAssetPool.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "GlobalAssetPool.h"
|
||||
|
165
src/ZoneCommon/Pool/GlobalAssetPool.h
Normal file
165
src/ZoneCommon/Pool/GlobalAssetPool.h
Normal file
@ -0,0 +1,165 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "AssetPool.h"
|
||||
|
||||
template<typename T>
|
||||
class GlobalAssetPool
|
||||
{
|
||||
struct LinkedAssetPool
|
||||
{
|
||||
AssetPool<T>* m_asset_pool;
|
||||
int m_priority;
|
||||
};
|
||||
|
||||
struct GameAssetPoolEntry
|
||||
{
|
||||
XAssetInfo<T>* m_asset;
|
||||
bool m_duplicate;
|
||||
LinkedAssetPool* m_asset_pool;
|
||||
};
|
||||
|
||||
static std::vector<LinkedAssetPool*> m_linked_asset_pools;
|
||||
static std::map<std::string, GameAssetPoolEntry> m_assets;
|
||||
|
||||
static void SortLinkedAssetPools()
|
||||
{
|
||||
std::sort(m_linked_asset_pools.begin(), m_linked_asset_pools.end(), [](const LinkedAssetPool* a, const LinkedAssetPool* b) -> bool
|
||||
{
|
||||
return a->m_priority < b->m_priority;
|
||||
});
|
||||
}
|
||||
|
||||
static bool ReplaceAssetPoolEntry(GameAssetPoolEntry& assetEntry)
|
||||
{
|
||||
int occurrences = 0;
|
||||
|
||||
for(auto linkedAssetPool : m_linked_asset_pools)
|
||||
{
|
||||
XAssetInfo<T>* foundAsset = linkedAssetPool->m_asset_pool->GetAsset(assetEntry.m_asset->m_name);
|
||||
|
||||
if(foundAsset != nullptr)
|
||||
{
|
||||
if(++occurrences == 1)
|
||||
{
|
||||
assetEntry.m_asset = foundAsset;
|
||||
assetEntry.m_duplicate = false;
|
||||
assetEntry.m_asset_pool = linkedAssetPool;
|
||||
}
|
||||
else
|
||||
{
|
||||
assetEntry.m_duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return occurrences > 0;
|
||||
}
|
||||
|
||||
static void LinkAsset(LinkedAssetPool* link, XAssetInfo<T>* asset)
|
||||
{
|
||||
std::string assetName = std::string(asset->m_name);
|
||||
|
||||
auto existingAsset = m_assets.find(assetName);
|
||||
|
||||
if(existingAsset == m_assets.end())
|
||||
{
|
||||
GameAssetPoolEntry entry{};
|
||||
entry.m_asset = asset;
|
||||
entry.m_asset_pool = link;
|
||||
entry.m_duplicate = false;
|
||||
|
||||
m_assets[assetName] = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& existingEntry = existingAsset->second;
|
||||
|
||||
existingEntry.m_duplicate = true;
|
||||
|
||||
if(existingEntry.m_asset_pool->m_priority < link->m_priority)
|
||||
{
|
||||
existingEntry.m_asset_pool = link;
|
||||
existingEntry.m_asset = asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
static void LinkAssetPool(AssetPool<T>* assetPool, const int priority)
|
||||
{
|
||||
auto* newLink = new LinkedAssetPool();
|
||||
newLink->m_asset_pool = assetPool;
|
||||
newLink->m_priority = priority;
|
||||
|
||||
m_linked_asset_pools.push_back(newLink);
|
||||
SortLinkedAssetPools();
|
||||
|
||||
for(auto asset : *assetPool)
|
||||
{
|
||||
LinkAsset(newLink, asset);
|
||||
}
|
||||
}
|
||||
|
||||
static void LinkAsset(AssetPool<T>* assetPool, XAssetInfo<T>* asset)
|
||||
{
|
||||
LinkedAssetPool* link = nullptr;
|
||||
|
||||
for(auto existingLink : m_linked_asset_pools)
|
||||
{
|
||||
if(existingLink->m_asset_pool == assetPool)
|
||||
{
|
||||
link = existingLink;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(link != nullptr);
|
||||
if(link == nullptr)
|
||||
return;
|
||||
|
||||
LinkAsset(link, asset);
|
||||
}
|
||||
|
||||
static void UnlinkAssetPool(AssetPool<T>* assetPool)
|
||||
{
|
||||
auto iLinkEntry = m_linked_asset_pools.begin();
|
||||
|
||||
for(; iLinkEntry != m_linked_asset_pools.end(); ++iLinkEntry)
|
||||
{
|
||||
LinkedAssetPool* linkEntry = *iLinkEntry;
|
||||
if(linkEntry->m_asset_pool == assetPool)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(iLinkEntry != m_linked_asset_pools.end());
|
||||
if(iLinkEntry == m_linked_asset_pools.end())
|
||||
return;
|
||||
|
||||
m_linked_asset_pools.erase(iLinkEntry);
|
||||
|
||||
for(auto iAssetEntry = m_assets.begin(); iAssetEntry != m_assets.end(); ++iAssetEntry)
|
||||
{
|
||||
auto& assetEntry = *iAssetEntry;
|
||||
|
||||
if(assetEntry.second.m_duplicate && ReplaceAssetPoolEntry(assetEntry.second))
|
||||
continue;
|
||||
|
||||
iAssetEntry = m_assets.erase(iAssetEntry);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::vector<typename GlobalAssetPool<T>::LinkedAssetPool*> GlobalAssetPool<T>::m_linked_asset_pools = std::vector<LinkedAssetPool*>();
|
||||
|
||||
template<typename T>
|
||||
std::map<std::string, typename GlobalAssetPool<T>::GameAssetPoolEntry> GlobalAssetPool<T>::m_assets = std::map<std::string, GameAssetPoolEntry>();
|
14
src/ZoneCommon/Pool/IZoneAssetPools.h
Normal file
14
src/ZoneCommon/Pool/IZoneAssetPools.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "XAssetInfo.h"
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
||||
class IZoneAssetPools
|
||||
{
|
||||
public:
|
||||
virtual ~IZoneAssetPools() = default;
|
||||
|
||||
virtual void* AddAsset(asset_type_t type, std::string name, void* asset, std::vector<std::string>& scriptStrings, std::vector<XAssetDependency>& dependencies) = 0;
|
||||
virtual void InitPoolStatic(asset_type_t type, size_t capacity) = 0;
|
||||
virtual void InitPoolDynamic(asset_type_t type) = 0;
|
||||
};
|
13
src/ZoneCommon/Pool/XAssetInfo.h
Normal file
13
src/ZoneCommon/Pool/XAssetInfo.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "Zone/XAssetDependency.h"
|
||||
|
||||
template<typename T>
|
||||
class XAssetInfo
|
||||
{
|
||||
public:
|
||||
std::string m_name;
|
||||
T* m_asset;
|
||||
std::vector<std::string> m_script_strings;
|
||||
std::vector<XAssetDependency> m_dependencies;
|
||||
};
|
11
src/ZoneCommon/Zone/Stream/IZoneStream.h
Normal file
11
src/ZoneCommon/Zone/Stream/IZoneStream.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "Zone/ZoneTypes.h"
|
||||
|
||||
class IZoneStream
|
||||
{
|
||||
public:
|
||||
virtual ~IZoneStream() = default;
|
||||
|
||||
virtual void PushBlock(block_t block) = 0;
|
||||
virtual block_t PopBlock() = 0;
|
||||
};
|
9
src/ZoneCommon/Zone/XAssetDependency.h
Normal file
9
src/ZoneCommon/Zone/XAssetDependency.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
class XAssetDependency
|
||||
{
|
||||
public:
|
||||
int m_type;
|
||||
std::string m_name;
|
||||
};
|
33
src/ZoneCommon/Zone/XBlock.cpp
Normal file
33
src/ZoneCommon/Zone/XBlock.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "XBlock.h"
|
||||
#include <cassert>
|
||||
|
||||
XBlock::XBlock(const std::string& name, const int index, const Type type)
|
||||
{
|
||||
m_name = name;
|
||||
m_index = index;
|
||||
m_type = type;
|
||||
m_buffer = nullptr;
|
||||
m_buffer_size = 0;
|
||||
}
|
||||
|
||||
XBlock::~XBlock()
|
||||
{
|
||||
delete[] m_buffer;
|
||||
m_buffer = nullptr;
|
||||
}
|
||||
|
||||
void XBlock::Alloc(const size_t blockSize)
|
||||
{
|
||||
delete[] m_buffer;
|
||||
|
||||
if(blockSize > 0)
|
||||
{
|
||||
m_buffer = new uint8_t[blockSize];
|
||||
m_buffer_size = blockSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_buffer = nullptr;
|
||||
m_buffer_size = 0;
|
||||
}
|
||||
}
|
26
src/ZoneCommon/Zone/XBlock.h
Normal file
26
src/ZoneCommon/Zone/XBlock.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
class XBlock
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
BLOCK_TYPE_TEMP,
|
||||
BLOCK_TYPE_RUNTIME,
|
||||
BLOCK_TYPE_DELAY,
|
||||
BLOCK_TYPE_NORMAL
|
||||
};
|
||||
|
||||
std::string m_name;
|
||||
int m_index;
|
||||
Type m_type;
|
||||
|
||||
uint8_t* m_buffer;
|
||||
size_t m_buffer_size;
|
||||
|
||||
XBlock(const std::string& name, int index, Type type);
|
||||
~XBlock();
|
||||
|
||||
void Alloc(size_t blockSize);
|
||||
};
|
14
src/ZoneCommon/Zone/Zone.cpp
Normal file
14
src/ZoneCommon/Zone/Zone.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "Zone.h"
|
||||
|
||||
Zone::Zone(std::string name, const zone_priority_t priority, IZoneAssetPools* pools, IGame* game)
|
||||
{
|
||||
m_name = std::move(name);
|
||||
m_priority = priority;
|
||||
m_pools = pools;
|
||||
m_game = game;
|
||||
}
|
||||
|
||||
IZoneAssetPools* Zone::GetPools() const
|
||||
{
|
||||
return m_pools;
|
||||
}
|
21
src/ZoneCommon/Zone/Zone.h
Normal file
21
src/ZoneCommon/Zone/Zone.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "ZoneTypes.h"
|
||||
#include "Pool/IZoneAssetPools.h"
|
||||
#include "Game/IGame.h"
|
||||
#include <string>
|
||||
|
||||
class IGame;
|
||||
|
||||
class Zone
|
||||
{
|
||||
std::string m_name;
|
||||
zone_priority_t m_priority;
|
||||
IZoneAssetPools* m_pools;
|
||||
|
||||
public:
|
||||
IGame* m_game;
|
||||
|
||||
Zone(std::string name, zone_priority_t priority, IZoneAssetPools* pools, IGame* game);
|
||||
|
||||
IZoneAssetPools* GetPools() const;
|
||||
};
|
24
src/ZoneCommon/Zone/ZoneTypes.h
Normal file
24
src/ZoneCommon/Zone/ZoneTypes.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
struct ZoneHeader
|
||||
{
|
||||
uint8_t m_magic[8];
|
||||
uint32_t m_version;
|
||||
};
|
||||
|
||||
#ifdef _WIN64
|
||||
typedef uint32_t scr_string_t;
|
||||
typedef uint64_t xchunk_size_t;
|
||||
typedef uint64_t xblock_size_t;
|
||||
typedef uint64_t zone_pointer_t;
|
||||
#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;
|
||||
#endif
|
||||
|
||||
typedef int block_t;
|
||||
typedef int asset_type_t;
|
||||
typedef unsigned int zone_priority_t;
|
@ -18,6 +18,31 @@
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Game\IGame.h" />
|
||||
<ClInclude Include="Game\T6\GameAssetPoolT6.h" />
|
||||
<ClInclude Include="Game\T6\GameT6.h" />
|
||||
<ClInclude Include="Game\T6\T6.h" />
|
||||
<ClInclude Include="Game\T6\T6_Assets.h" />
|
||||
<ClInclude Include="Pool\AssetPool.h" />
|
||||
<ClInclude Include="Pool\AssetPoolDynamic.h" />
|
||||
<ClInclude Include="Pool\AssetPoolStatic.h" />
|
||||
<ClInclude Include="Pool\GlobalAssetPool.h" />
|
||||
<ClInclude Include="Pool\IZoneAssetPools.h" />
|
||||
<ClInclude Include="Pool\XAssetInfo.h" />
|
||||
<ClInclude Include="Zone\Stream\IZoneStream.h" />
|
||||
<ClInclude Include="Zone\XAssetDependency.h" />
|
||||
<ClInclude Include="Zone\XBlock.h" />
|
||||
<ClInclude Include="Zone\Zone.h" />
|
||||
<ClInclude Include="Zone\ZoneTypes.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Game\T6\GameAssetPoolT6.cpp" />
|
||||
<ClCompile Include="Game\T6\GameT6.cpp" />
|
||||
<ClCompile Include="Pool\GlobalAssetPool.cpp" />
|
||||
<ClCompile Include="Zone\XBlock.cpp" />
|
||||
<ClCompile Include="Zone\Zone.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{2A92076F-6DFD-4FB1-9E6A-4542B4B049C7}</ProjectGuid>
|
||||
@ -73,54 +98,69 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)_$(Platform)\</OutDir>
|
||||
<OutDir>$(SolutionDir)lib\$(Configuration)_$(Platform)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)_$(Platform)\</OutDir>
|
||||
<OutDir>$(SolutionDir)lib\$(Configuration)_$(Platform)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)_$(Platform)\</OutDir>
|
||||
<OutDir>$(SolutionDir)lib\$(Configuration)_$(Platform)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)\$(Configuration)_$(Platform)\</IntDir>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)_$(Platform)\</OutDir>
|
||||
<OutDir>$(SolutionDir)lib\$(Configuration)_$(Platform)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
<TreatSpecificWarningsAsErrors>4715;%(TreatSpecificWarningsAsErrors)</TreatSpecificWarningsAsErrors>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\$(Configuration)_$(Platform)\</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/ignore:4221</AdditionalOptions>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
<TreatSpecificWarningsAsErrors>4715;%(TreatSpecificWarningsAsErrors)</TreatSpecificWarningsAsErrors>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\$(Configuration)_$(Platform)\</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/ignore:4221</AdditionalOptions>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
@ -128,6 +168,9 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
<TreatSpecificWarningsAsErrors>4715;%(TreatSpecificWarningsAsErrors)</TreatSpecificWarningsAsErrors>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -135,10 +178,15 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\$(Configuration)_$(Platform)\</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/ignore:4221</AdditionalOptions>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
@ -146,6 +194,9 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
<TreatSpecificWarningsAsErrors>4715;%(TreatSpecificWarningsAsErrors)</TreatSpecificWarningsAsErrors>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@ -153,6 +204,12 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalDependencies>
|
||||
</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\$(Configuration)_$(Platform)\</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/ignore:4221</AdditionalOptions>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
Reference in New Issue
Block a user