From b8b8e4c267aec5da3986d83d39e5c1750f7d963d Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 11 Oct 2020 12:22:20 +0200 Subject: [PATCH] Implement loading of the remaining iw4 assets which are the map assets --- src/ZoneCode.lua | 10 +- src/ZoneCode/Game/IW4/IW4_Commands.txt | 266 +++++- src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp | 50 +- src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h | 10 +- src/ZoneCommon/Game/IW4/IW4_Assets.h | 851 +++++++++++++++++- src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp | 20 +- 6 files changed, 1142 insertions(+), 65 deletions(-) diff --git a/src/ZoneCode.lua b/src/ZoneCode.lua index 750f499c..e3c2b199 100644 --- a/src/ZoneCode.lua +++ b/src/ZoneCode.lua @@ -16,12 +16,12 @@ ZoneCode.Assets = { "SndCurve", "LoadedSound", "clipMap_t", - -- "ComWorld", - -- "GameWorldSp", - -- "GameWorldMp", + "ComWorld", + "GameWorldSp", + "GameWorldMp", "MapEnts", - -- "FxWorld", - -- "GfxWorld", + "FxWorld", + "GfxWorld", "GfxLightDef", "Font_s", "MenuList", diff --git a/src/ZoneCode/Game/IW4/IW4_Commands.txt b/src/ZoneCode/Game/IW4/IW4_Commands.txt index 0003c457..62e2d3e0 100644 --- a/src/ZoneCode/Game/IW4/IW4_Commands.txt +++ b/src/ZoneCode/Game/IW4/IW4_Commands.txt @@ -16,12 +16,12 @@ 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 ComWorld ASSET_TYPE_COMWORLD; -// asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP; -// asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP; +asset ComWorld ASSET_TYPE_COMWORLD; +asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP; +asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP; asset MapEnts ASSET_TYPE_MAP_ENTS; -// asset FxWorld ASSET_TYPE_FXWORLD; -// asset GfxWorld ASSET_TYPE_GFXWORLD; +asset FxWorld ASSET_TYPE_FXWORLD; +asset GfxWorld ASSET_TYPE_GFXWORLD; asset GfxLightDef ASSET_TYPE_LIGHT_DEF; asset Font_s ASSET_TYPE_FONT; asset MenuList ASSET_TYPE_MENULIST; @@ -443,6 +443,11 @@ reorder: leafs leafbrushes leafbrushNodes; +reorder: + ... + brushContents + smodelNodes + mapEnts; // ClipMaterial set string ClipMaterial::name; @@ -465,6 +470,91 @@ use cbrush_t; set reusable sides; set reusable baseAdjacentSide; +// ========================================= +// ComWorld +// ========================================= +use ComWorld; +set string name; +set name name; +set count primaryLights primaryLightCount; + +// ComPrimaryLight +set string ComPrimaryLight::defName; + +// ========================================= +// GameWorldSp +// ========================================= +use GameWorldSp; +set string name; +set name name; + +// PathData +use PathData; +set count nodes nodeCount; +set block basenodes XFILE_BLOCK_RUNTIME; +set count basenodes nodeCount; +set count chainNodeForNode nodeCount; +set count nodeForChainNode nodeCount; +set count pathVis visBytes; +set count nodeTree nodeTreeCount; + +// pathnode_t +set condition pathnode_t::transient never; + +// pathnode_constant_t +use pathnode_constant_t; +set scriptstring targetname; +set scriptstring script_linkName; +set scriptstring script_noteworthy; +set scriptstring target; +set scriptstring animscript; +set count Links totalLinkCount; + +// pathnode_dynamic_t +set condition pathnode_dynamic_t::pOwner never; + +// pathnode_tree_t +use pathnode_tree_t; +set condition u::child axis >= 0; +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; + +// ========================================= +// GameWorldMp +// ========================================= +use GameWorldMp; +set string name; +set name name; + // ========================================= // MapEnts // ========================================= @@ -483,6 +573,172 @@ set count slabs slabCount; // Stage set string Stage::name; +// ========================================= +// FxWorld +// ========================================= +use FxWorld; +set string name; +set name name; + +// FxGlassSystem +use FxGlassSystem; +set count defs defCount; +set block piecePlaces XFILE_BLOCK_RUNTIME; +set count piecePlaces pieceLimit; +set block pieceStates XFILE_BLOCK_RUNTIME; +set count pieceStates pieceLimit; +set block pieceDynamics XFILE_BLOCK_RUNTIME; +set count pieceDynamics pieceLimit; +set block geoData XFILE_BLOCK_RUNTIME; +set count geoData geoDataLimit; +set block isInUse XFILE_BLOCK_RUNTIME; +set count isInUse pieceWordCount; +set block cellBits XFILE_BLOCK_RUNTIME; +set count cellBits pieceWordCount * cellCount; +set block visData XFILE_BLOCK_RUNTIME; +set count visData (pieceLimit + 15) / 16 * 16; +set block linkOrg XFILE_BLOCK_RUNTIME; +set count linkOrg pieceLimit; +set block halfThickness XFILE_BLOCK_RUNTIME; +set count halfThickness (pieceLimit + 3) / 4 * 4; +set count lightingHandles initPieceCount; +set count initPieceStates initPieceCount; +set count initGeoData initGeoDataCount; + +// FxGlassDef +reorder FxGlassDef: + physPreset + material + materialShattered; + +// ========================================= +// GfxWorld +// ========================================= +use GfxWorld; +set string name; +set name name; +set string baseName; +set count skies skyCount; +set count aabbTreeCounts dpvsPlanes::cellCount; +set count aabbTrees dpvsPlanes::cellCount; +set count cells dpvsPlanes::cellCount; +set count models modelCount; +set count materialMemory materialMemoryCount; +set block cellCasterBits XFILE_BLOCK_RUNTIME; +set count cellCasterBits dpvsPlanes::cellCount * ((dpvsPlanes::cellCount + 31) / 32); +set block cellHasSunLitSurfsBits XFILE_BLOCK_RUNTIME; +set count cellHasSunLitSurfsBits (dpvsPlanes::cellCount + 31) / 32; +set block sceneDynModel XFILE_BLOCK_RUNTIME; +set count sceneDynModel dpvsDyn::dynEntClientCount[0]; +set block sceneDynBrush XFILE_BLOCK_RUNTIME; +set count sceneDynBrush dpvsDyn::dynEntClientCount[1]; +set block primaryLightEntityShadowVis XFILE_BLOCK_RUNTIME; +set count primaryLightEntityShadowVis (primaryLightCount - lastSunPrimaryLightIndex - 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 block nonSunPrimaryLightForModelDynEnt XFILE_BLOCK_RUNTIME; +set count nonSunPrimaryLightForModelDynEnt dpvsDyn::dynEntClientCount[0]; +set count shadowGeom primaryLightCount; +set count lightRegion primaryLightCount; +set count heroOnlyLights heroOnlyLightCount; + +// GfxSky +set count GfxSky::skyStartSurfs skySurfCount; + +// GfxWorldDpvsPlanes +use GfxWorldDpvsPlanes; +set reusable planes; +set count planes GfxWorld::planeCount; +set count nodes GfxWorld::nodeCount; +set block sceneEntCellBits XFILE_BLOCK_RUNTIME; +set count sceneEntCellBits cellCount * 0x200; + +// GfxCellTree +// Extremly dirty hack caused by IW doing an extremly dirty hack in their code as well. +// No idea why they decided to separate the count from the pointer that uses the count. +// Thank you Treyarch for doing better in your games at least. +set count GfxCellTree::aabbTree GfxWorld::aabbTreeCounts[GfxCellTree - GfxWorld::aabbTrees]; + +// GfxAabbTree +use GfxAabbTree; +set reusable smodelIndexes; +set count smodelIndexes smodelIndexCount; + +// GfxCell +use GfxCell; +set count portals portalCount; +set count reflectionProbes reflectionProbeCount; + +// GfxPortal +use GfxPortal; +set condition writable never; +set count vertices vertexCount; + +// GfxWorldDraw +use GfxWorldDraw; +set count reflectionProbes reflectionProbeCount; +set count reflectionProbeOrigins reflectionProbeCount; +set block reflectionProbeTextures XFILE_BLOCK_RUNTIME; +set count reflectionProbeTextures reflectionProbeCount; +set count lightmaps lightmapCount; +set block lightmapPrimaryTextures XFILE_BLOCK_RUNTIME; +set count lightmapPrimaryTextures lightmapCount; +set block lightmapSecondaryTextures XFILE_BLOCK_RUNTIME; +set count lightmapSecondaryTextures lightmapCount; +set count vd::vertices vertexCount; +set condition vd::worldVb never; +set count vld::data vertexLayerDataSize; +set condition vld::layerVb never; +set count indices indexCount; + +// GfxLightGrid +use GfxLightGrid; +set count rowDataStart maxs[rowAxis] - mins[rowAxis] + 1; +set count rawRowData rawRowDataSize; +set count entries entryCount; +set count colors colorCount; + +// GfxShadowGeometry +use GfxShadowGeometry; +set count sortedSurfIndex surfaceCount; +set count smodelIndex smodelCount; + +// GfxLightRegion +set count GfxLightRegion::hulls hullCount; + +// GfxLightRegionHull +set count GfxLightRegionHull::axis axisCount; + +// GfxWorldDpvsStatic +use GfxWorldDpvsStatic; +set block smodelVisData XFILE_BLOCK_RUNTIME; +set count smodelVisData smodelCount; +set block surfaceVisData XFILE_BLOCK_RUNTIME; +set count surfaceVisData staticSurfaceCount; +set count sortedSurfIndex staticSurfaceCount + staticSurfaceCountNoDecal; +set count smodelInsts smodelCount; +set count surfaces GfxWorld::surfaceCount; +set count surfacesBounds GfxWorld::surfaceCount; +set count smodelDrawInsts smodelCount; +set block surfaceMaterials XFILE_BLOCK_RUNTIME; +set count surfaceMaterials GfxWorld::surfaceCount; +set block surfaceCastsSunShadow XFILE_BLOCK_RUNTIME; +set count surfaceCastsSunShadow surfaceVisDataCount; + +// GfxWorldDpvsDynamic +use GfxWorldDpvsDynamic; +set block dynEntCellBits XFILE_BLOCK_RUNTIME; +set count dynEntCellBits[0] dynEntClientWordCount[0] * GfxWorld::dpvsPlanes::cellCount; +set count dynEntCellBits[1] dynEntClientWordCount[1] * GfxWorld::dpvsPlanes::cellCount; +set block dynEntVisData XFILE_BLOCK_RUNTIME; +set count dynEntVisData[0][0] 32 * dynEntClientWordCount[0]; +set count dynEntVisData[1][0] 32 * dynEntClientWordCount[1]; +set count dynEntVisData[0][1] 32 * dynEntClientWordCount[0]; +set count dynEntVisData[1][1] 32 * dynEntClientWordCount[1]; +set count dynEntVisData[0][2] 32 * dynEntClientWordCount[0]; +set count dynEntVisData[1][2] 32 * dynEntClientWordCount[1]; + // ========================================= // LocalizeEntry // ========================================= diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp index 295c6970..4b12db59 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp @@ -117,12 +117,12 @@ GameAssetPoolIW4::GameAssetPoolIW4(const int priority) 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_com_world = nullptr; + m_game_world_sp = nullptr; + m_game_world_mp = nullptr; m_map_ents = nullptr; - // m_fx_world = nullptr; - // m_gfx_world = nullptr; + m_fx_world = nullptr; + m_gfx_world = nullptr; m_gfx_light_def = nullptr; m_font = nullptr; m_menu_list = nullptr; @@ -169,12 +169,12 @@ void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capa CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, 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_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_FXWORLD, m_fx_world, FxWorld); - // CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); + CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld); + 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); @@ -228,12 +228,12 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type) CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, 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_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_FXWORLD, m_fx_world, FxWorld); - // CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld); + 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); @@ -296,12 +296,12 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, 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_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_FXWORLD, m_fx_world, fxWorld); - // CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld); + CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world, fxWorld); + 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); @@ -355,12 +355,12 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, 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_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_FXWORLD, m_fx_world); - // CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world); + CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world); + 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); diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h index cad44396..18c286ce 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h @@ -29,12 +29,12 @@ public: std::unique_ptr> m_sound_curve; std::unique_ptr> m_loaded_sound; std::unique_ptr> m_clip_map; - // std::unique_ptr> m_com_world; - // std::unique_ptr> m_game_world_sp; - // std::unique_ptr> m_game_world_mp; + std::unique_ptr> m_com_world; + std::unique_ptr> m_game_world_sp; + std::unique_ptr> m_game_world_mp; std::unique_ptr> m_map_ents; - // std::unique_ptr> m_fx_world; - // std::unique_ptr> m_gfx_world; + std::unique_ptr> m_fx_world; + std::unique_ptr> m_gfx_world; std::unique_ptr> m_gfx_light_def; std::unique_ptr> m_font; std::unique_ptr> m_menu_list; diff --git a/src/ZoneCommon/Game/IW4/IW4_Assets.h b/src/ZoneCommon/Game/IW4/IW4_Assets.h index c87d212f..760d45f7 100644 --- a/src/ZoneCommon/Game/IW4/IW4_Assets.h +++ b/src/ZoneCommon/Game/IW4/IW4_Assets.h @@ -88,12 +88,12 @@ namespace IW4 struct SndCurve; struct LoadedSound; struct clipMap_t; - // struct ComWorld; - // struct GameWorldSp; - // struct GameWorldMp; + struct ComWorld; + struct GameWorldSp; + struct GameWorldMp; struct MapEnts; - // struct FxWorld; - // struct GfxWorld; + struct FxWorld; + struct GfxWorld; struct GfxLightDef; struct Font_s; struct MenuList; @@ -128,12 +128,12 @@ namespace IW4 SndCurve* sndCurve; LoadedSound* loadSnd; clipMap_t* clipMap; - // ComWorld* comWorld; - // GameWorldSp* gameWorldSp; - // GameWorldMp* gameWorldMp; + ComWorld* comWorld; + GameWorldSp* gameWorldSp; + GameWorldMp* gameWorldMp; MapEnts* mapEnts; - // FxWorld* fxWorld; - // GfxWorld* gfxWorld; + FxWorld* fxWorld; + GfxWorld* gfxWorld; GfxLightDef* lightDef; Font_s* font; MenuList* menuList; @@ -153,7 +153,12 @@ namespace IW4 void* data; }; + typedef __declspec(align(16)) char raw_byte16; + typedef __declspec(align(16)) float raw_float16; + typedef unsigned int raw_uint; + typedef __declspec(align(128)) unsigned int raw_uint128; typedef char cbrushedge_t; + typedef unsigned short r_index_t; typedef float vec2_t[2]; typedef float vec3_t[3]; @@ -520,9 +525,9 @@ namespace IW4 struct XModel { const char* name; - char numBones; - char numRootBones; - char numsurfs; + unsigned char numBones; + unsigned char numRootBones; + unsigned char numsurfs; char lodRampType; float scale; unsigned int noScalePartBits[6]; @@ -535,8 +540,8 @@ namespace IW4 Material** materialHandles; XModelLodInfo lodInfo[4]; char maxLoadedLod; - char numLods; - char collLod; + unsigned char numLods; + unsigned char collLod; char flags; XModelCollSurf_s* collSurfs; int numCollSurfs; @@ -2113,6 +2118,822 @@ namespace IW4 char padding[48]; }; + struct ComPrimaryLight + { + char type; + char canUseShadowMap; + char exponent; + char unused; + float color[3]; + float dir[3]; + float origin[3]; + float radius; + float cosHalfFovOuter; + float cosHalfFovInner; + float cosHalfFovExpanded; + float rotationLimit; + float translationLimit; + const char* defName; + }; + + struct ComWorld + { + const char* name; + int isInUse; + unsigned int primaryLightCount; + ComPrimaryLight* primaryLights; + }; + + struct pathnode_t; + + enum nodeType + { + NODE_ERROR = 0x0, + NODE_PATHNODE = 0x1, + NODE_COVER_STAND = 0x2, + NODE_COVER_CROUCH = 0x3, + NODE_COVER_CROUCH_WINDOW = 0x4, + NODE_COVER_PRONE = 0x5, + NODE_COVER_RIGHT = 0x6, + NODE_COVER_LEFT = 0x7, + NODE_AMBUSH = 0x8, + NODE_EXPOSED = 0x9, + NODE_CONCEALMENT_STAND = 0xA, + NODE_CONCEALMENT_CROUCH = 0xB, + NODE_CONCEALMENT_PRONE = 0xC, + NODE_DOOR = 0xD, + NODE_DOOR_INTERIOR = 0xE, + NODE_SCRIPTED = 0xF, + NODE_NEGOTIATION_BEGIN = 0x10, + NODE_NEGOTIATION_END = 0x11, + NODE_TURRET = 0x12, + NODE_GUARD = 0x13, + NODE_NUMTYPES = 0x14, + NODE_DONTLINK = 0x14, + }; + + struct pathlink_s + { + float fDist; + unsigned __int16 nodeNum; + char disconnectCount; + char negotiationLink; + char flags; + char ubBadPlaceCount[3]; + }; + + enum PathNodeErrorCode + { + PNERR_NONE = 0x0, + PNERR_INSOLID = 0x1, + PNERR_FLOATING = 0x2, + PNERR_NOLINK = 0x3, + PNERR_DUPLICATE = 0x4, + PNERR_NOSTANCE = 0x5, + PNERR_INVALIDDOOR = 0x6, + PNERR_NOANGLES = 0x7, + PNERR_BADPLACEMENT = 0x8, + + NUM_PATH_NODE_ERRORS + }; + + struct pathnode_constant_t + { + nodeType type; + unsigned __int16 spawnflags; + unsigned __int16 targetname; + unsigned __int16 script_linkName; + unsigned __int16 script_noteworthy; + unsigned __int16 target; + unsigned __int16 animscript; + int animscriptfunc; + float vOrigin[3]; + float fAngle; + float forward[2]; + float fRadius; + union + { + float minUseDistSq; + PathNodeErrorCode error; + }; + __int16 wOverlapNode[2]; + unsigned __int16 totalLinkCount; + pathlink_s* Links; + }; + + struct pathnode_dynamic_t + { + void* pOwner; + int iFreeTime; + int iValidTime[3]; + int dangerousNodeTime[3]; + int inPlayerLOSTime; + __int16 wLinkCount; + __int16 wOverlapCount; + __int16 turretEntNumber; + char userCount; + bool hasBadPlaceLink; + }; + + struct pathnode_transient_t + { + int iSearchFrame; + pathnode_t* pNextOpen; + pathnode_t* pPrevOpen; + pathnode_t* pParent; + float fCost; + float fHeuristic; + union + { + float nodeCost; + int linkIndex; + }; + }; + + struct pathnode_t + { + pathnode_constant_t constant; + pathnode_dynamic_t dynamic; + pathnode_transient_t transient; + }; + + struct __declspec(align(16)) pathbasenode_t + { + float vOrigin[3]; + unsigned int type; + }; + + struct pathnode_tree_nodes_t + { + int nodeCount; + unsigned __int16* nodes; + }; + + struct pathnode_tree_t; + + union pathnode_tree_info_t + { + pathnode_tree_t* child[2]; + pathnode_tree_nodes_t s; + }; + + struct pathnode_tree_t + { + int axis; + float dist; + pathnode_tree_info_t u; + }; + + struct PathData + { + unsigned int nodeCount; + pathnode_t* nodes; + pathbasenode_t* basenodes; + unsigned int chainNodeCount; + unsigned __int16* chainNodeForNode; + unsigned __int16* nodeForChainNode; + int visBytes; + char* pathVis; + int nodeTreeCount; + pathnode_tree_t* nodeTree; + }; + + struct VehicleTrackObstacle + { + float origin[2]; + float radius; + }; + + struct VehicleTrackSector + { + float startEdgeDir[2]; + float startEdgeDist; + float leftEdgeDir[2]; + float leftEdgeDist; + float rightEdgeDir[2]; + float rightEdgeDist; + float sectorLength; + float sectorWidth; + float totalPriorLength; + float totalFollowingLength; + VehicleTrackObstacle* obstacles; + unsigned int obstacleCount; + }; + + struct VehicleTrackSegment + { + const char* targetName; + VehicleTrackSector* sectors; + unsigned int sectorCount; + VehicleTrackSegment** nextBranches; + unsigned int nextBranchesCount; + VehicleTrackSegment** prevBranches; + unsigned int prevBranchesCount; + float endEdgeDir[2]; + float endEdgeDist; + float totalLength; + }; + + struct VehicleTrack + { + VehicleTrackSegment* segments; + unsigned int segmentCount; + }; + + struct G_GlassPiece + { + unsigned __int16 damageTaken; + unsigned __int16 collapseTime; + int lastStateChangeTime; + char impactDir; + char impactPos[2]; + }; + + struct G_GlassName + { + char* nameStr; + unsigned __int16 name; + unsigned __int16 pieceCount; + unsigned __int16* pieceIndices; + }; + + struct G_GlassData + { + G_GlassPiece* glassPieces; + unsigned int pieceCount; + unsigned __int16 damageToWeaken; + unsigned __int16 damageToDestroy; + unsigned int glassNameCount; + G_GlassName* glassNames; + char pad[108]; + }; + + struct GameWorldSp + { + const char* name; + PathData path; + VehicleTrack vehicleTrack; + G_GlassData* g_glassData; + }; + + struct GameWorldMp + { + const char* name; + G_GlassData* g_glassData; + }; + + struct FxGlassDef + { + float halfThickness; + float texVecs[2][2]; + GfxColor color; + Material* material; + Material* materialShattered; + PhysPreset* physPreset; + }; + + struct FxSpatialFrame + { + float quat[4]; + float origin[3]; + }; + + union FxGlassPiecePlace + { + union + { + FxSpatialFrame frame; + float radius; + }; + unsigned int nextFree; + }; + + struct FxGlassPieceState + { + float texCoordOrigin[2]; + unsigned int supportMask; + unsigned __int16 initIndex; + unsigned __int16 geoDataStart; + char defIndex; + char pad[5]; + char vertCount; + char holeDataCount; + char crackDataCount; + char fanDataCount; + unsigned __int16 flags; + float areaX2; + }; + + struct FxGlassPieceDynamics + { + int fallTime; + int physObjId; + int physJointId; + float vel[3]; + float avel[3]; + }; + + struct FxGlassVertex + { + __int16 x; + __int16 y; + }; + + struct FxGlassHoleHeader + { + unsigned __int16 uniqueVertCount; + char touchVert; + char pad[1]; + }; + + struct FxGlassCrackHeader + { + unsigned __int16 uniqueVertCount; + char beginVertIndex; + char endVertIndex; + }; + + union __declspec(align(4)) FxGlassGeometryData + { + FxGlassVertex vert; + FxGlassHoleHeader hole; + FxGlassCrackHeader crack; + char asBytes[4]; + __int16 anonymous[2]; + }; + + struct FxGlassInitPieceState + { + FxSpatialFrame frame; + float radius; + float texCoordOrigin[2]; + unsigned int supportMask; + float areaX2; + char defIndex; + char vertCount; + char fanDataCount; + char pad[1]; + }; + + struct FxGlassSystem + { + int time; + int prevTime; + unsigned int defCount; + unsigned int pieceLimit; + unsigned int pieceWordCount; + unsigned int initPieceCount; + unsigned int cellCount; + unsigned int activePieceCount; + unsigned int firstFreePiece; + unsigned int geoDataLimit; + unsigned int geoDataCount; + unsigned int initGeoDataCount; + FxGlassDef* defs; + FxGlassPiecePlace* piecePlaces; + FxGlassPieceState* pieceStates; + FxGlassPieceDynamics* pieceDynamics; + FxGlassGeometryData* geoData; + raw_uint* isInUse; + raw_uint* cellBits; + raw_byte16* visData; + vec3_t* linkOrg; + raw_float16* halfThickness; + unsigned __int16* lightingHandles; + FxGlassInitPieceState* initPieceStates; + FxGlassGeometryData* initGeoData; + bool needToCompactData; + char initCount; + float effectChanceAccum; + int lastPieceDeletionTime; + }; + + struct FxWorld + { + const char* name; + FxGlassSystem glassSys; + }; + + struct GfxSky + { + int skySurfCount; + int* skyStartSurfs; + GfxImage* skyImage; + char skySamplerState; + }; + + struct GfxWorldDpvsPlanes + { + int cellCount; + cplane_s* planes; + unsigned __int16* nodes; + raw_uint* sceneEntCellBits; + }; + + struct GfxCellTreeCount + { + int aabbTreeCount; + }; + + typedef unsigned short StaticModelIndex; + + struct GfxAabbTree + { + Bounds bounds; + unsigned __int16 childCount; + unsigned __int16 surfaceCount; + unsigned __int16 startSurfIndex; + unsigned __int16 surfaceCountNoDecal; + unsigned __int16 startSurfIndexNoDecal; + unsigned __int16 smodelIndexCount; + StaticModelIndex* smodelIndexes; + int childrenOffset; + }; + + struct GfxCellTree + { + GfxAabbTree* aabbTree; + }; + + struct GfxPortal; + + struct GfxPortalWritable + { + bool isQueued; + bool isAncestor; + char recursionDepth; + char hullPointCount; + float(*hullPoints)[2]; + GfxPortal* queuedParent; + }; + + struct DpvsPlane + { + float coeffs[4]; + }; + + struct GfxPortal + { + GfxPortalWritable writable; + DpvsPlane plane; + vec3_t* vertices; + unsigned __int16 cellIndex; + char vertexCount; + float hullAxis[2][3]; + }; + + struct GfxCell + { + Bounds bounds; + int portalCount; + GfxPortal* portals; + char reflectionProbeCount; + char* reflectionProbes; + }; + + struct GfxReflectionProbe + { + float origin[3]; + }; + + struct GfxLightmapArray + { + GfxImage* primary; + GfxImage* secondary; + }; + + struct GfxWorldVertex + { + float xyz[3]; + float binormalSign; + GfxColor color; + float texCoord[2]; + float lmapCoord[2]; + PackedUnitVec normal; + PackedUnitVec tangent; + }; + + struct GfxWorldVertexData + { + GfxWorldVertex* vertices; + void/*IDirect3DVertexBuffer9*/* worldVb; + }; + + struct GfxWorldVertexLayerData + { + char* data; + void/*IDirect3DVertexBuffer9*/* layerVb; + }; + + struct GfxWorldDraw + { + unsigned int reflectionProbeCount; + GfxImage** reflectionProbes; + GfxReflectionProbe* reflectionProbeOrigins; + GfxTexture* reflectionProbeTextures; + int lightmapCount; + GfxLightmapArray* lightmaps; + GfxTexture* lightmapPrimaryTextures; + GfxTexture* lightmapSecondaryTextures; + GfxImage* lightmapOverridePrimary; + GfxImage* lightmapOverrideSecondary; + unsigned int vertexCount; + GfxWorldVertexData vd; + unsigned int vertexLayerDataSize; + GfxWorldVertexLayerData vld; + unsigned int indexCount; + r_index_t* indices; + }; + + struct __declspec(align(4)) GfxLightGridEntry + { + unsigned __int16 colorsIndex; + char primaryLightIndex; + char needsTrace; + }; + + struct __declspec(align(4)) GfxLightGridColors + { + char rgb[56][3]; + }; + + struct GfxLightGrid + { + bool hasLightRegions; + unsigned int lastSunPrimaryLightIndex; + unsigned __int16 mins[3]; + unsigned __int16 maxs[3]; + unsigned int rowAxis; + unsigned int colAxis; + unsigned __int16* rowDataStart; + unsigned int rawRowDataSize; + char* rawRowData; + unsigned int entryCount; + GfxLightGridEntry* entries; + unsigned int colorCount; + GfxLightGridColors* colors; + }; + + struct GfxBrushModelWritable + { + Bounds bounds; + }; + + struct __declspec(align(4)) GfxBrushModel + { + GfxBrushModelWritable writable; + Bounds bounds; + float radius; + unsigned __int16 surfaceCount; + unsigned __int16 startSurfIndex; + unsigned __int16 surfaceCountNoDecal; + }; + + struct MaterialMemory + { + Material* material; + int memory; + }; + + struct sunflare_t + { + bool hasValidData; + Material* spriteMaterial; + Material* flareMaterial; + float spriteSize; + float flareMinSize; + float flareMinDot; + float flareMaxSize; + float flareMaxDot; + float flareMaxAlpha; + int flareFadeInTime; + int flareFadeOutTime; + float blindMinDot; + float blindMaxDot; + float blindMaxDarken; + int blindFadeInTime; + int blindFadeOutTime; + float glareMinDot; + float glareMaxDot; + float glareMaxLighten; + int glareFadeInTime; + int glareFadeOutTime; + float sunFxPosition[3]; + }; + + struct XModelDrawInfo + { + char hasGfxEntIndex; + char lod; + unsigned __int16 surfId; + }; + + struct GfxSceneDynModel + { + XModelDrawInfo info; + unsigned __int16 dynEntId; + }; + + struct BModelDrawInfo + { + unsigned __int16 surfId; + }; + + struct __declspec(align(4)) GfxSceneDynBrush + { + BModelDrawInfo info; + unsigned __int16 dynEntId; + }; + + struct GfxShadowGeometry + { + unsigned __int16 surfaceCount; + unsigned __int16 smodelCount; + unsigned __int16* sortedSurfIndex; + unsigned __int16* smodelIndex; + }; + + struct GfxLightRegionAxis + { + float dir[3]; + float midPoint; + float halfSize; + }; + + struct GfxLightRegionHull + { + float kdopMidPoint[9]; + float kdopHalfSize[9]; + unsigned int axisCount; + GfxLightRegionAxis* axis; + }; + + struct GfxLightRegion + { + unsigned int hullCount; + GfxLightRegionHull* hulls; + }; + + struct GfxPackedPlacement + { + float origin[3]; + float axis[3][3]; + float scale; + }; + + struct GfxStaticModelDrawInst + { + GfxPackedPlacement placement; + XModel* model; + unsigned __int16 cullDist; + unsigned __int16 lightingHandle; + char reflectionProbeIndex; + char primaryLightIndex; + char flags; + char firstMtlSkinIndex; + GfxColor groundLighting; + unsigned __int16 cacheId[4]; + }; + + struct GfxStaticModelInst + { + Bounds bounds; + float lightingOrigin[3]; + }; + + struct srfTriangles_t + { + unsigned int vertexLayerData; + unsigned int firstVertex; + unsigned __int16 vertexCount; + unsigned __int16 triCount; + unsigned int baseIndex; + }; + + struct GfxSurfaceLightingAndFlagsFields + { + char lightmapIndex; + char reflectionProbeIndex; + char primaryLightIndex; + char flags; + }; + + union GfxSurfaceLightingAndFlags + { + GfxSurfaceLightingAndFlagsFields fields; + unsigned int packed; + }; + + struct GfxSurface + { + srfTriangles_t tris; + Material* material; + GfxSurfaceLightingAndFlags laf; + }; + + struct GfxSurfaceBounds + { + Bounds bounds; + }; + + struct GfxWorldDpvsStatic + { + unsigned int smodelCount; + unsigned int staticSurfaceCount; + unsigned int staticSurfaceCountNoDecal; + unsigned int litOpaqueSurfsBegin; + unsigned int litOpaqueSurfsEnd; + unsigned int litTransSurfsBegin; + unsigned int litTransSurfsEnd; + unsigned int shadowCasterSurfsBegin; + unsigned int shadowCasterSurfsEnd; + unsigned int emissiveSurfsBegin; + unsigned int emissiveSurfsEnd; + unsigned int smodelVisDataCount; + unsigned int surfaceVisDataCount; + char* smodelVisData[3]; + char* surfaceVisData[3]; + unsigned __int16* sortedSurfIndex; + GfxStaticModelInst* smodelInsts; + GfxSurface* surfaces; + GfxSurfaceBounds* surfacesBounds; + GfxStaticModelDrawInst* smodelDrawInsts; + GfxDrawSurf* surfaceMaterials; + raw_uint128* surfaceCastsSunShadow; + volatile int usageCount; + }; + + struct GfxWorldDpvsDynamic + { + unsigned int dynEntClientWordCount[2]; + unsigned int dynEntClientCount[2]; + raw_uint* dynEntCellBits[2]; + raw_byte16* dynEntVisData[2][3]; + }; + + struct GfxHeroOnlyLight + { + char type; + char unused[3]; + float color[3]; + float dir[3]; + float origin[3]; + float radius; + float cosHalfFovOuter; + float cosHalfFovInner; + int exponent; + }; + + typedef __declspec(align(128)) GfxCellTree GfxCellTree128; + typedef __declspec(align(4)) GfxSceneDynModel GfxSceneDynModel4; + + struct GfxWorld + { + const char* name; + const char* baseName; + int planeCount; + int nodeCount; + unsigned int surfaceCount; + int skyCount; + GfxSky* skies; + unsigned int lastSunPrimaryLightIndex; + unsigned int primaryLightCount; + unsigned int sortKeyLitDecal; + unsigned int sortKeyEffectDecal; + unsigned int sortKeyEffectAuto; + unsigned int sortKeyDistortion; + GfxWorldDpvsPlanes dpvsPlanes; + int/*GfxCellTreeCount*/* aabbTreeCounts; + GfxCellTree128* aabbTrees; + GfxCell* cells; + GfxWorldDraw draw; + GfxLightGrid lightGrid; + int modelCount; + GfxBrushModel* models; + Bounds bounds; + unsigned int checksum; + int materialMemoryCount; + MaterialMemory* materialMemory; + sunflare_t sun; + float outdoorLookupMatrix[4][4]; + GfxImage* outdoorImage; + raw_uint* cellCasterBits; + raw_uint* cellHasSunLitSurfsBits; + GfxSceneDynModel4* sceneDynModel; + GfxSceneDynBrush* sceneDynBrush; + raw_uint* primaryLightEntityShadowVis; + raw_uint* primaryLightDynEntShadowVis[2]; + char* nonSunPrimaryLightForModelDynEnt; + GfxShadowGeometry* shadowGeom; + GfxLightRegion* lightRegion; + GfxWorldDpvsStatic dpvs; + GfxWorldDpvsDynamic dpvsDyn; + unsigned int mapVtxChecksum; + unsigned int heroOnlyLightCount; + GfxHeroOnlyLight* heroOnlyLights; + char fogTypesAllowed; + }; + enum ImpactType { IMPACT_TYPE_NONE = 0x0, diff --git a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp index 6ae517ff..282727f3 100644 --- a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp @@ -6,16 +6,16 @@ #include "Game/IW4/XAssets/addonmapents/addonmapents_load_db.h" #include "Game/IW4/XAssets/clipmap_t/clipmap_t_load_db.h" -//#include "Game/IW4/XAssets/comworld/comworld_load_db.h" +#include "Game/IW4/XAssets/comworld/comworld_load_db.h" #include "Game/IW4/XAssets/font_s/font_s_load_db.h" #include "Game/IW4/XAssets/fxeffectdef/fxeffectdef_load_db.h" #include "Game/IW4/XAssets/fximpacttable/fximpacttable_load_db.h" -//#include "Game/IW4/XAssets/fxworld/fxworld_load_db.h" -//#include "Game/IW4/XAssets/gameworldmp/gameworldmp_load_db.h" -//#include "Game/IW4/XAssets/gameworldsp/gameworldsp_load_db.h" +#include "Game/IW4/XAssets/fxworld/fxworld_load_db.h" +#include "Game/IW4/XAssets/gameworldmp/gameworldmp_load_db.h" +#include "Game/IW4/XAssets/gameworldsp/gameworldsp_load_db.h" #include "Game/IW4/XAssets/gfximage/gfximage_load_db.h" #include "Game/IW4/XAssets/gfxlightdef/gfxlightdef_load_db.h" -//#include "Game/IW4/XAssets/gfxworld/gfxworld_load_db.h" +#include "Game/IW4/XAssets/gfxworld/gfxworld_load_db.h" #include "Game/IW4/XAssets/leaderboarddef/leaderboarddef_load_db.h" #include "Game/IW4/XAssets/loadedsound/loadedsound_load_db.h" #include "Game/IW4/XAssets/localizeentry/localizeentry_load_db.h" @@ -117,12 +117,12 @@ void ContentLoaderIW4::LoadXAsset(const bool atStreamStart) LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd); LOAD_ASSET(ASSET_TYPE_CLIPMAP_SP, clipMap_t, clipMap); LOAD_ASSET(ASSET_TYPE_CLIPMAP_MP, clipMap_t, clipMap); - // LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld); - // LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp); - // LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp); + LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld); + LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp); + LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp); LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts); - // LOAD_ASSET(ASSET_TYPE_FXWORLD, FxWorld, fxWorld); - // LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld); + LOAD_ASSET(ASSET_TYPE_FXWORLD, FxWorld, fxWorld); + LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld); LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef); LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font); LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList);