mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Finish iw3 zone code generation
This commit is contained in:
parent
adae75a7a6
commit
6b72ac080f
@ -414,7 +414,7 @@ namespace IW3
|
||||
char pad[2];
|
||||
};
|
||||
|
||||
struct __declspec(align(2)) cbrushside_t
|
||||
struct cbrushside_t
|
||||
{
|
||||
cplane_s* plane;
|
||||
unsigned int materialNum;
|
||||
@ -462,6 +462,7 @@ namespace IW3
|
||||
|
||||
struct XModelStreamInfo
|
||||
{
|
||||
char pad;
|
||||
};
|
||||
|
||||
struct XModel
|
||||
@ -614,6 +615,22 @@ namespace IW3
|
||||
unsigned int nameHash;
|
||||
};
|
||||
|
||||
enum MaterialShaderArgumentType
|
||||
{
|
||||
MTL_ARG_MATERIAL_VERTEX_CONST = 0x0,
|
||||
MTL_ARG_LITERAL_VERTEX_CONST = 0x1,
|
||||
MTL_ARG_MATERIAL_PIXEL_SAMPLER = 0x2,
|
||||
MTL_ARG_CODE_PRIM_BEGIN = 0x3,
|
||||
MTL_ARG_CODE_VERTEX_CONST = 0x3,
|
||||
MTL_ARG_CODE_PIXEL_SAMPLER = 0x4,
|
||||
MTL_ARG_CODE_PIXEL_CONST = 0x5,
|
||||
MTL_ARG_CODE_PRIM_END = 0x6,
|
||||
MTL_ARG_MATERIAL_PIXEL_CONST = 0x6,
|
||||
MTL_ARG_LITERAL_PIXEL_CONST = 0x7,
|
||||
|
||||
MLT_ARG_COUNT
|
||||
};
|
||||
|
||||
struct MaterialShaderArgument
|
||||
{
|
||||
uint16_t type;
|
||||
@ -731,10 +748,10 @@ namespace IW3
|
||||
|
||||
union GfxTexture
|
||||
{
|
||||
void/*IDirect3DBaseTexture9*/* basemap;
|
||||
void/*IDirect3DTexture9*/* map;
|
||||
void/*IDirect3DVolumeTexture9*/* volmap;
|
||||
void/*IDirect3DCubeTexture9*/* cubemap;
|
||||
//void/*IDirect3DBaseTexture9*/* basemap;
|
||||
//void/*IDirect3DTexture9*/* map;
|
||||
//void/*IDirect3DVolumeTexture9*/* volmap;
|
||||
//void/*IDirect3DCubeTexture9*/* cubemap;
|
||||
Texture* texture;
|
||||
GfxImageLoadDef* loadDef;
|
||||
};
|
||||
@ -1657,7 +1674,7 @@ namespace IW3
|
||||
|
||||
struct GfxWorldStreamInfo
|
||||
{
|
||||
|
||||
char pad;
|
||||
};
|
||||
|
||||
struct GfxWorld
|
||||
@ -1790,7 +1807,7 @@ namespace IW3
|
||||
{
|
||||
int intVal;
|
||||
float floatVal;
|
||||
const char* string;
|
||||
const char* stringVal;
|
||||
};
|
||||
|
||||
enum expDataType
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ObjLoaderIW3.h"
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||
#include "Game/IW3/GameIW3.h"
|
||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||
#include "ObjContainer/IPak/IPak.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "AssetLoaders/AssetLoaderRawFile.h"
|
||||
@ -49,7 +49,7 @@ ObjLoader::ObjLoader()
|
||||
|
||||
bool ObjLoader::SupportsZone(Zone* zone) const
|
||||
{
|
||||
return zone->m_game == &g_GameIW4;
|
||||
return zone->m_game == &g_GameIW3;
|
||||
}
|
||||
|
||||
bool ObjLoader::IsMpZone(Zone* zone)
|
||||
@ -109,7 +109,7 @@ void ObjLoader::LoadImageFromIwi(GfxImage* image, ISearchPath* searchPath, Zone*
|
||||
|
||||
void ObjLoader::LoadImageData(ISearchPath* searchPath, Zone* zone)
|
||||
{
|
||||
auto* assetPool = dynamic_cast<GameAssetPoolIW4*>(zone->m_pools.get());
|
||||
auto* assetPool = dynamic_cast<GameAssetPoolIW3*>(zone->m_pools.get());
|
||||
|
||||
if (assetPool && assetPool->m_image != nullptr)
|
||||
{
|
||||
|
@ -0,0 +1 @@
|
||||
# This file exists for automatically generating zone loading code.
|
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// Entry point for IW3 code generation
|
||||
|
||||
#include "../Common.h"
|
||||
#include "../../../Common/Game/IW3/IW3_Assets.h"
|
||||
|
||||
// EOF
|
@ -12,7 +12,7 @@ asset GfxImage ASSET_TYPE_IMAGE;
|
||||
asset snd_alias_list_t ASSET_TYPE_SOUND;
|
||||
asset SndCurve ASSET_TYPE_SOUND_CURVE;
|
||||
asset LoadedSound ASSET_TYPE_LOADED_SOUND;
|
||||
asset clipMap_t ASSET_TYPE_CLIPMAP_MP;
|
||||
asset clipMap_t ASSET_TYPE_CLIPMAP_PVS;
|
||||
asset ComWorld ASSET_TYPE_COMWORLD;
|
||||
asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP;
|
||||
asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP;
|
||||
|
@ -36,11 +36,6 @@ use FxEffectDefRef;
|
||||
set condition handle never;
|
||||
set string name;
|
||||
|
||||
// FxElemExtendedDefPtr
|
||||
use FxElemExtendedDefPtr;
|
||||
set condition trailDef FxElemDef::elemType == FX_ELEM_TYPE_TRAIL;
|
||||
set condition sparkFountainDef FxElemDef::elemType == FX_ELEM_TYPE_SPARK_FOUNTAIN;
|
||||
|
||||
// FxTrailDef
|
||||
use FxTrailDef;
|
||||
set count verts vertCount;
|
||||
|
@ -37,30 +37,3 @@ set reusable u::child;
|
||||
|
||||
// pathnode_tree_nodes_t
|
||||
set count pathnode_tree_nodes_t::nodes nodeCount;
|
||||
|
||||
// VehicleTrack
|
||||
use VehicleTrack;
|
||||
set reusable segments;
|
||||
set count segments segmentCount;
|
||||
|
||||
// VehicleTrackSegment
|
||||
use VehicleTrackSegment;
|
||||
set string targetName;
|
||||
set count sectors sectorCount;
|
||||
set reusable nextBranches;
|
||||
set count nextBranches nextBranchesCount;
|
||||
set reusable prevBranches;
|
||||
set count prevBranches prevBranchesCount;
|
||||
|
||||
// VehicleTrackSector
|
||||
set count VehicleTrackSector::obstacles obstacleCount;
|
||||
|
||||
// G_GlassData
|
||||
use G_GlassData;
|
||||
set count glassPieces pieceCount;
|
||||
set count glassNames glassNameCount;
|
||||
|
||||
// G_GlassName
|
||||
use G_GlassName;
|
||||
set string nameStr;
|
||||
set count pieceIndices pieceCount;
|
@ -28,8 +28,8 @@ set count sceneDynBrush dpvsDyn::dynEntClientCount[1];
|
||||
set block primaryLightEntityShadowVis XFILE_BLOCK_RUNTIME;
|
||||
set count primaryLightEntityShadowVis (primaryLightCount - sunPrimaryLightIndex - 1) * 0x2000;
|
||||
set block primaryLightDynEntShadowVis XFILE_BLOCK_RUNTIME;
|
||||
set count primaryLightDynEntShadowVis[0] dpvsDyn::dynEntClientCount[0] * (primaryLightCount - lastSunPrimaryLightIndex - 1);
|
||||
set count primaryLightDynEntShadowVis[1] dpvsDyn::dynEntClientCount[1] * (primaryLightCount - lastSunPrimaryLightIndex - 1);
|
||||
set count primaryLightDynEntShadowVis[0] dpvsDyn::dynEntClientCount[0] * (primaryLightCount - sunPrimaryLightIndex - 1);
|
||||
set count primaryLightDynEntShadowVis[1] dpvsDyn::dynEntClientCount[1] * (primaryLightCount - sunPrimaryLightIndex - 1);
|
||||
set block nonSunPrimaryLightForModelDynEnt XFILE_BLOCK_RUNTIME;
|
||||
set count nonSunPrimaryLightForModelDynEnt dpvsDyn::dynEntClientCount[0];
|
||||
set count shadowGeom primaryLightCount;
|
||||
@ -74,10 +74,14 @@ set count entries entryCount;
|
||||
set count colors colorCount;
|
||||
|
||||
// GfxWorldVertexData
|
||||
set count GfxWorldVertexData::vertices GfxWorld::vertexCount;
|
||||
use GfxWorldVertexData;
|
||||
set count vertices GfxWorld::vertexCount;
|
||||
set condition worldVb never;
|
||||
|
||||
// GfxWorldVertexLayerData
|
||||
set count GfxWorldVertexLayerData::data GfxWorld::vertexLayerDataSize;
|
||||
use GfxWorldVertexLayerData;
|
||||
set count data GfxWorld::vertexLayerDataSize;
|
||||
set condition layerVb never;
|
||||
|
||||
// GfxShadowGeometry
|
||||
use GfxShadowGeometry;
|
||||
@ -101,8 +105,7 @@ set count lodData 2 * smodelVisDataCount;
|
||||
set count sortedSurfIndex staticSurfaceCount + staticSurfaceCountNoDecal;
|
||||
set count smodelInsts smodelCount;
|
||||
set count surfaces GfxWorld::surfaceCount;
|
||||
set count cullGroups cullGroupCount;
|
||||
set count surfacesBounds GfxWorld::surfaceCount;
|
||||
set count cullGroups GfxWorld::cullGroupCount;
|
||||
set count smodelDrawInsts smodelCount;
|
||||
set block surfaceMaterials XFILE_BLOCK_RUNTIME;
|
||||
set count surfaceMaterials staticSurfaceCount;
|
||||
|
@ -34,9 +34,6 @@ set count GfxPixelShaderLoadDef::program programSize;
|
||||
// MaterialPixelShaderProgram
|
||||
set condition MaterialPixelShaderProgram::ps never;
|
||||
|
||||
// MaterialVertexDeclaration
|
||||
set string MaterialVertexDeclaration::name;
|
||||
|
||||
// MaterialVertexStreamRouting
|
||||
set condition MaterialVertexStreamRouting::decl never;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// =========================================
|
||||
// WeaponCompleteDef
|
||||
// WeaponDef
|
||||
// =========================================
|
||||
use WeaponDef;
|
||||
set string szInternalName;
|
||||
@ -23,22 +23,23 @@ set reusable accuracyGraphKnots0;
|
||||
set reusable accuracyGraphKnots1;
|
||||
set reusable originalAccuracyGraphKnots0;
|
||||
set reusable originalAccuracyGraphKnots1;
|
||||
set count accuracyGraphKnots0 WeaponCompleteDef::accuracyGraphKnotCount[0];
|
||||
set count accuracyGraphKnots1 WeaponCompleteDef::accuracyGraphKnotCount[1];
|
||||
set count originalAccuracyGraphKnots0 WeaponCompleteDef::accuracyGraphKnotCount[0]; // yeah it uses accuracyGraphKnotCount
|
||||
set count originalAccuracyGraphKnots1 WeaponCompleteDef::accuracyGraphKnotCount[1];
|
||||
set count accuracyGraphKnots0 accuracyGraphKnotCount[0];
|
||||
set count accuracyGraphKnots1 accuracyGraphKnotCount[1];
|
||||
set count originalAccuracyGraphKnots0 accuracyGraphKnotCount[0]; // yeah it uses accuracyGraphKnotCount
|
||||
set count originalAccuracyGraphKnots1 accuracyGraphKnotCount[1];
|
||||
set string szUseHintString;
|
||||
set string dropHintString;
|
||||
set string szScript;
|
||||
set string fireRumble;
|
||||
set string meleeImpactRumble;
|
||||
|
||||
reorder:
|
||||
...
|
||||
accuracyGraphName0
|
||||
accuracyGraphKnots0
|
||||
originalAccuracyGraphKnots0
|
||||
accuracyGraphName1
|
||||
accuracyGraphKnots1;
|
||||
accuracyGraphKnots1
|
||||
originalAccuracyGraphKnots1;
|
||||
|
||||
// SndAliasCustom
|
||||
|
@ -32,12 +32,6 @@ set count geoms count;
|
||||
// PhysGeomInfo
|
||||
use PhysGeomInfo;
|
||||
|
||||
// XModelSurfs
|
||||
use XModelSurfs;
|
||||
set block XFILE_BLOCK_VIRTUAL;
|
||||
set string name;
|
||||
set count surfs XModelLodInfo::numsurfs; // No this is not a mistake. This is how the game does it.
|
||||
|
||||
// XSurface
|
||||
use XSurface;
|
||||
set reusable verts0;
|
||||
|
@ -23,7 +23,7 @@ set count partitions partitionCount;
|
||||
set count aabbTrees aabbTreeCount;
|
||||
set count cmodels numSubModels;
|
||||
set count brushes numBrushes;
|
||||
set visibility numClusters * clusterBytes;
|
||||
set count visibility numClusters * clusterBytes;
|
||||
set reusable box_brush;
|
||||
set count dynEntDefList[0] dynEntCount[0];
|
||||
set count dynEntDefList[1] dynEntCount[1];
|
||||
|
@ -34,7 +34,7 @@ use Operand;
|
||||
set condition internals::intVal dataType == VAL_INT;
|
||||
set condition internals::floatVal dataType == VAL_FLOAT;
|
||||
set condition internals::stringVal dataType == VAL_STRING;
|
||||
set string internal::stringVal;
|
||||
set string internals::stringVal;
|
||||
|
||||
// itemDef_s
|
||||
use itemDef_s;
|
||||
@ -70,8 +70,6 @@ set condition editField itemDef_s::type == 0
|
||||
|| itemDef_s::type == 23;
|
||||
set condition multi itemDef_s::type == 12;
|
||||
set condition enumDvarName itemDef_s::type == 13;
|
||||
set condition ticker itemDef_s::type == 20;
|
||||
set condition scroll itemDef_s::type == 21;
|
||||
|
||||
// listBoxDef_s
|
||||
set string listBoxDef_s::doubleClick;
|
||||
|
@ -6,6 +6,9 @@ public:
|
||||
template<typename T>
|
||||
static T Align(T number, T alignmentValue)
|
||||
{
|
||||
if (alignmentValue == 0)
|
||||
return number;
|
||||
|
||||
return (number + (alignmentValue - 1)) / alignmentValue * alignmentValue;
|
||||
}
|
||||
};
|
@ -0,0 +1,332 @@
|
||||
#include "GameAssetPoolIW3.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Pool/AssetPoolStatic.h"
|
||||
#include "Pool/AssetPoolDynamic.h"
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
const char* GameAssetPoolIW3::ASSET_TYPE_NAMES[]
|
||||
{
|
||||
"physpreset",
|
||||
"xanim",
|
||||
"xmodelsurfs",
|
||||
"xmodel",
|
||||
"material",
|
||||
"pixelshader",
|
||||
"vertexshader",
|
||||
"vertexdecl",
|
||||
"techniqueset",
|
||||
"image",
|
||||
"sound",
|
||||
"soundcurve",
|
||||
"loadedsound",
|
||||
"clipmap",
|
||||
"clipmap",
|
||||
"comworld",
|
||||
"gameworldsp",
|
||||
"gameworldmp",
|
||||
"mapents",
|
||||
"gfxworld",
|
||||
"lightdef",
|
||||
"uimap",
|
||||
"font",
|
||||
"menulist",
|
||||
"menu",
|
||||
"localize",
|
||||
"weapon",
|
||||
"snddriverglobals",
|
||||
"fx",
|
||||
"impactfx",
|
||||
"aitype",
|
||||
"mptype",
|
||||
"character",
|
||||
"xmodelalias",
|
||||
"rawfile",
|
||||
"stringtable"
|
||||
};
|
||||
|
||||
/*
|
||||
Asset Pool Table
|
||||
Useful for macro generation via regex-replace for example
|
||||
|
||||
#assetType, #typeName, #unionEntry, #poolName
|
||||
ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset, m_phys_preset
|
||||
ASSET_TYPE_XANIMPARTS, XAnimParts, parts, m_xanim_parts
|
||||
ASSET_TYPE_XMODEL, XModel, model, m_xmodel
|
||||
ASSET_TYPE_MATERIAL, Material, material, m_material
|
||||
ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet, m_technique_set
|
||||
ASSET_TYPE_IMAGE, GfxImage, image, m_image
|
||||
ASSET_TYPE_SOUND, snd_alias_list_t, sound, m_sound
|
||||
ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve, m_sound_curve
|
||||
ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd, m_loaded_sound
|
||||
ASSET_TYPE_CLIPMAP, clipMap_t, clipMap, m_clip_map
|
||||
ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap, m_clip_map
|
||||
ASSET_TYPE_COMWORLD, ComWorld, comWorld, m_com_world
|
||||
ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp, m_game_world_sp
|
||||
ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp, m_game_world_mp
|
||||
ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts, m_map_ents
|
||||
ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld, m_gfx_world
|
||||
ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef, m_gfx_light_def
|
||||
ASSET_TYPE_FONT, Font_s, font, m_font
|
||||
ASSET_TYPE_MENULIST, MenuList, menuList, m_menu_list
|
||||
ASSET_TYPE_MENU, menuDef_t, menu, m_menu_def
|
||||
ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize, m_localize
|
||||
ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon, m_weapon
|
||||
ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals, m_snd_driver_globals
|
||||
ASSET_TYPE_FX, FxEffectDef, fx, m_fx
|
||||
ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx, m_fx_impact_table
|
||||
ASSET_TYPE_RAWFILE, RawFile, rawfile, m_raw_file
|
||||
ASSET_TYPE_STRINGTABLE, StringTable, stringTable, m_string_table
|
||||
*/
|
||||
|
||||
GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const int priority)
|
||||
: ZoneAssetPools(zone),
|
||||
m_priority(priority)
|
||||
{
|
||||
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::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)
|
||||
{
|
||||
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if((poolName) == nullptr && capacity > 0) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<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_XANIMPARTS, m_xanim_parts, XAnimParts);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponDef);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
|
||||
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_STATIC
|
||||
}
|
||||
|
||||
void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type)
|
||||
{
|
||||
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
|
||||
case assetType: \
|
||||
{ \
|
||||
if((poolName) == nullptr) \
|
||||
{ \
|
||||
(poolName) = std::make_unique<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_XANIMPARTS, m_xanim_parts, XAnimParts);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponDef);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
|
||||
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
|
||||
|
||||
default:
|
||||
assert(type >= 0 && type < ASSET_TYPE_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef CASE_INIT_POOL_STATIC
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
|
||||
{
|
||||
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, zone, std::move(dependencies), std::move(usedScriptStrings)); \
|
||||
}
|
||||
|
||||
switch (xAsset.type)
|
||||
{
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
|
||||
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
#undef CASE_ADD_TO_POOL
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* GameAssetPoolIW3::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_XANIMPARTS, m_xanim_parts);
|
||||
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel);
|
||||
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
|
||||
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
|
||||
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
|
||||
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
|
||||
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve);
|
||||
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound);
|
||||
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map);
|
||||
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map);
|
||||
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);
|
||||
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp);
|
||||
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp);
|
||||
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents);
|
||||
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world);
|
||||
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);
|
||||
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font);
|
||||
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
|
||||
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
|
||||
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
|
||||
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
|
||||
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
|
||||
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table);
|
||||
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file);
|
||||
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table);
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
#undef CASE_GET_ASSET
|
||||
}
|
||||
|
||||
const char* GameAssetPoolIW3::AssetTypeNameByType(asset_type_t assetType)
|
||||
{
|
||||
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value))
|
||||
return ASSET_TYPE_NAMES[assetType];
|
||||
|
||||
return ASSET_TYPE_INVALID;
|
||||
}
|
||||
|
||||
const char* GameAssetPoolIW3::GetAssetTypeName(const asset_type_t assetType) const
|
||||
{
|
||||
return AssetTypeNameByType(assetType);
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Pool/ZoneAssetPools.h"
|
||||
#include "Pool/AssetPool.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
|
||||
class GameAssetPoolIW3 final : public ZoneAssetPools
|
||||
{
|
||||
int m_priority;
|
||||
|
||||
static constexpr const char* ASSET_TYPE_INVALID = "invalid_asset_type";
|
||||
static const char* ASSET_TYPE_NAMES[];
|
||||
|
||||
protected:
|
||||
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone) override;
|
||||
|
||||
public:
|
||||
std::unique_ptr<AssetPool<IW3::PhysPreset>> m_phys_preset;
|
||||
std::unique_ptr<AssetPool<IW3::XAnimParts>> m_xanim_parts;
|
||||
std::unique_ptr<AssetPool<IW3::XModel>> m_xmodel;
|
||||
std::unique_ptr<AssetPool<IW3::Material>> m_material;
|
||||
std::unique_ptr<AssetPool<IW3::MaterialPixelShader>> m_material_pixel_shader;
|
||||
std::unique_ptr<AssetPool<IW3::MaterialVertexShader>> m_material_vertex_shader;
|
||||
std::unique_ptr<AssetPool<IW3::MaterialVertexDeclaration>> m_material_vertex_decl;
|
||||
std::unique_ptr<AssetPool<IW3::MaterialTechniqueSet>> m_technique_set;
|
||||
std::unique_ptr<AssetPool<IW3::GfxImage>> m_image;
|
||||
std::unique_ptr<AssetPool<IW3::snd_alias_list_t>> m_sound;
|
||||
std::unique_ptr<AssetPool<IW3::SndCurve>> m_sound_curve;
|
||||
std::unique_ptr<AssetPool<IW3::LoadedSound>> m_loaded_sound;
|
||||
std::unique_ptr<AssetPool<IW3::clipMap_t>> m_clip_map;
|
||||
std::unique_ptr<AssetPool<IW3::ComWorld>> m_com_world;
|
||||
std::unique_ptr<AssetPool<IW3::GameWorldSp>> m_game_world_sp;
|
||||
std::unique_ptr<AssetPool<IW3::GameWorldMp>> m_game_world_mp;
|
||||
std::unique_ptr<AssetPool<IW3::MapEnts>> m_map_ents;
|
||||
std::unique_ptr<AssetPool<IW3::GfxWorld>> m_gfx_world;
|
||||
std::unique_ptr<AssetPool<IW3::GfxLightDef>> m_gfx_light_def;
|
||||
std::unique_ptr<AssetPool<IW3::Font_s>> m_font;
|
||||
std::unique_ptr<AssetPool<IW3::MenuList>> m_menu_list;
|
||||
std::unique_ptr<AssetPool<IW3::menuDef_t>> m_menu_def;
|
||||
std::unique_ptr<AssetPool<IW3::LocalizeEntry>> m_localize;
|
||||
std::unique_ptr<AssetPool<IW3::WeaponDef>> m_weapon;
|
||||
std::unique_ptr<AssetPool<IW3::FxEffectDef>> m_fx;
|
||||
std::unique_ptr<AssetPool<IW3::FxImpactTable>> m_fx_impact_table;
|
||||
std::unique_ptr<AssetPool<IW3::RawFile>> m_raw_file;
|
||||
std::unique_ptr<AssetPool<IW3::StringTable>> m_string_table;
|
||||
|
||||
GameAssetPoolIW3(Zone* zone, int priority);
|
||||
~GameAssetPoolIW3() override = default;
|
||||
|
||||
void InitPoolStatic(asset_type_t type, size_t capacity) override;
|
||||
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;
|
||||
};
|
@ -0,0 +1,31 @@
|
||||
#include "gfximage_actions.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
Actions_GfxImage::Actions_GfxImage(Zone* zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
|
||||
void Actions_GfxImage::OnImageLoaded(GfxImage* image) const
|
||||
{
|
||||
image->cardMemory.platform[0] = 0;
|
||||
}
|
||||
|
||||
void Actions_GfxImage::LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const
|
||||
{
|
||||
if (loadDef->resourceSize > 0)
|
||||
{
|
||||
const size_t loadDefSize = offsetof(IW3::GfxImageLoadDef, data) + loadDef->resourceSize;
|
||||
|
||||
image->texture.loadDef = static_cast<GfxImageLoadDef*>(m_zone->GetMemory()->Alloc(loadDefSize));
|
||||
memcpy(image->texture.loadDef, loadDef, loadDefSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
image->texture.loadDef = nullptr;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
|
||||
namespace IW3
|
||||
{
|
||||
class Actions_GfxImage final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_GfxImage(Zone* zone);
|
||||
|
||||
void OnImageLoaded(GfxImage* image) const;
|
||||
void LoadImageData(GfxImageLoadDef* loadDef, GfxImage* image) const;
|
||||
};
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#include "loadedsound_actions.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW3;
|
||||
|
||||
Actions_LoadedSound::Actions_LoadedSound(Zone* zone)
|
||||
: AssetLoadingActions(zone)
|
||||
{
|
||||
}
|
||||
|
||||
void Actions_LoadedSound::SetSoundData(MssSound* sound) const
|
||||
{
|
||||
if (sound->info.data_len > 0)
|
||||
{
|
||||
char* tempData = sound->data;
|
||||
sound->data = static_cast<char*>(m_zone->GetMemory()->Alloc(sound->info.data_len));
|
||||
memcpy(sound->data, tempData, sound->info.data_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
sound->data = nullptr;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loading/AssetLoadingActions.h"
|
||||
#include "Game/IW3/IW3.h"
|
||||
|
||||
namespace IW3
|
||||
{
|
||||
class Actions_LoadedSound final : public AssetLoadingActions
|
||||
{
|
||||
public:
|
||||
explicit Actions_LoadedSound(Zone* zone);
|
||||
|
||||
void SetSoundData(MssSound* sound) const;
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user