diff --git a/src/Common/Game/IW3/CommonIW3.cpp b/src/Common/Game/IW3/CommonIW3.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/Common/Game/IW3/CommonIW3.h b/src/Common/Game/IW3/CommonIW3.h new file mode 100644 index 00000000..e7e310b5 --- /dev/null +++ b/src/Common/Game/IW3/CommonIW3.h @@ -0,0 +1,5 @@ +#pragma once + +namespace IW3 +{ +} \ No newline at end of file diff --git a/src/Common/Game/IW3/GameIW3.cpp b/src/Common/Game/IW3/GameIW3.cpp new file mode 100644 index 00000000..c9b69fe5 --- /dev/null +++ b/src/Common/Game/IW3/GameIW3.cpp @@ -0,0 +1,43 @@ +#include "GameIW3.h" + +#include + +#include "IW3.h" + +using namespace IW3; + +GameIW3 g_GameIW3; + +std::string GameIW3::GetFullName() +{ + return "Call Of Duty 4: Modern Warfare"; +} + +std::string GameIW3::GetShortName() +{ + return "IW3"; +} + +void GameIW3::AddZone(Zone* zone) +{ + m_zones.push_back(zone); +} + +void GameIW3::RemoveZone(Zone* zone) +{ + const auto foundEntry = std::find(m_zones.begin(), m_zones.end(), zone); + + if (foundEntry != m_zones.end()) + m_zones.erase(foundEntry); +} + +std::vector GameIW3::GetZones() +{ + return m_zones; +} + +std::vector GameIW3::GetLanguagePrefixes() +{ + std::vector prefixes; + return prefixes; +} diff --git a/src/Common/Game/IW3/GameIW3.h b/src/Common/Game/IW3/GameIW3.h new file mode 100644 index 00000000..ec06f8c7 --- /dev/null +++ b/src/Common/Game/IW3/GameIW3.h @@ -0,0 +1,17 @@ +#pragma once +#include "Game/IGame.h" + +class GameIW3 : public IGame +{ + std::vector m_zones; + +public: + std::string GetFullName() override; + std::string GetShortName() override; + void AddZone(Zone* zone) override; + void RemoveZone(Zone* zone) override; + std::vector GetZones() override; + std::vector GetLanguagePrefixes() override; +}; + +extern GameIW3 g_GameIW3; \ No newline at end of file diff --git a/src/Common/Game/IW3/IW3.h b/src/Common/Game/IW3/IW3.h new file mode 100644 index 00000000..25ca8d08 --- /dev/null +++ b/src/Common/Game/IW3/IW3.h @@ -0,0 +1,82 @@ +#pragma once + +//#include +#include "Image/Texture.h" + +#include "IW3_Assets.h" + +namespace IW3 +{ + struct ScriptStringList + { + int count; + const char** strings; + }; + + struct XAsset + { + XAssetType type; + XAssetHeader header; + }; + + struct XAssetList + { + ScriptStringList stringList; + int assetCount; + XAsset* assets; + }; + + struct cspField_t + { + const char* szName; + int iOffset; + int iFieldType; + }; + + enum csParseFieldType_t + { + CSPFT_STRING = 0, + CSPFT_STRING_MAX_STRING_CHARS, + CSPFT_STRING_MAX_QPATH, + CSPFT_STRING_MAX_OSPATH, + CSPFT_INT, + CSPFT_QBOOLEAN, + CSPFT_FLOAT, + CSPFT_MILLISECONDS, + CSPFT_FX, + CSPFT_XMODEL, + CSPFT_MATERIAL, + CSPFT_SOUND, + + CSPFT_NUM_BASE_FIELD_TYPES + }; + + enum weapFieldType_t + { + WFT_WEAPONTYPE = CSPFT_NUM_BASE_FIELD_TYPES, + WFT_WEAPONCLASS, + WFT_OVERLAYRETICLE, + WFT_PENETRATE_TYPE, + WFT_IMPACT_TYPE, + WFT_STANCE, + WFT_PROJ_EXPLOSION, + WFT_OFFHAND_CLASS, + WFT_ANIMTYPE, + WFT_ACTIVE_RETICLE_TYPE, + WFT_GUIDED_MISSILE_TYPE, + WFT_BOUNCE_SOUND, + WFT_STICKINESS, + WFT_OVERLAYINTERFACE, + WFT_INVENTORYTYPE, + WFT_FIRETYPE, + WFT_AMMOCOUNTER_CLIPTYPE, + WFT_ICONRATIO_HUD, + WFT_ICONRATIO_AMMOCOUNTER, + WFT_ICONRATIO_KILL, + WFT_ICONRATIO_DPAD, + WFT_HIDETAGS, + WFT_NOTETRACKSOUNDMAP, + + WFT_NUM_FIELD_TYPES + }; +} \ No newline at end of file diff --git a/src/Common/Game/IW3/IW3_Assets.h b/src/Common/Game/IW3/IW3_Assets.h new file mode 100644 index 00000000..31c6ba28 --- /dev/null +++ b/src/Common/Game/IW3/IW3_Assets.h @@ -0,0 +1,2651 @@ +#pragma once + +#ifndef __IW3_ASSETS_H +#define __IW3_ASSETS_H + +#include "../../Utils/TypeAlignment.h" + +#ifndef __zonecodegenerator +namespace IW3 +{ +#endif + enum XAssetType + { + ASSET_TYPE_XMODELPIECES = 0x0, + ASSET_TYPE_PHYSPRESET = 0x1, + ASSET_TYPE_XANIMPARTS = 0x2, + ASSET_TYPE_XMODEL = 0x3, + ASSET_TYPE_MATERIAL = 0x4, + ASSET_TYPE_TECHNIQUE_SET = 0x5, + ASSET_TYPE_IMAGE = 0x6, + ASSET_TYPE_SOUND = 0x7, + ASSET_TYPE_SOUND_CURVE = 0x8, + ASSET_TYPE_LOADED_SOUND = 0x9, + ASSET_TYPE_CLIPMAP = 0xA, + ASSET_TYPE_CLIPMAP_PVS = 0xB, + ASSET_TYPE_COMWORLD = 0xC, + ASSET_TYPE_GAMEWORLD_SP = 0xD, + ASSET_TYPE_GAMEWORLD_MP = 0xE, + ASSET_TYPE_MAP_ENTS = 0xF, + ASSET_TYPE_GFXWORLD = 0x10, + ASSET_TYPE_LIGHT_DEF = 0x11, + ASSET_TYPE_UI_MAP = 0x12, + ASSET_TYPE_FONT = 0x13, + ASSET_TYPE_MENULIST = 0x14, + ASSET_TYPE_MENU = 0x15, + ASSET_TYPE_LOCALIZE_ENTRY = 0x16, + ASSET_TYPE_WEAPON = 0x17, + ASSET_TYPE_SNDDRIVER_GLOBALS = 0x18, + ASSET_TYPE_FX = 0x19, + ASSET_TYPE_IMPACT_FX = 0x1A, + ASSET_TYPE_AITYPE = 0x1B, + ASSET_TYPE_MPTYPE = 0x1C, + ASSET_TYPE_CHARACTER = 0x1D, + ASSET_TYPE_XMODELALIAS = 0x1E, + ASSET_TYPE_RAWFILE = 0x1F, + ASSET_TYPE_STRINGTABLE = 0x20, + ASSET_TYPE_COUNT, + + ASSET_TYPE_STRING = ASSET_TYPE_COUNT, + ASSET_TYPE_ASSETLIST, + + ASSET_TYPE_FULLCOUNT + }; + + enum XFileBlock + { + XFILE_BLOCK_TEMP, + XFILE_BLOCK_RUNTIME_BEGIN, + XFILE_BLOCK_RUNTIME = XFILE_BLOCK_RUNTIME_BEGIN, + XFILE_BLOCK_LARGE_RUNTIME, + XFILE_BLOCK_PHYSICAL_RUNTIME, + XFILE_BLOCK_RUNTIME_END, + XFILE_BLOCK_VIRTUAL = XFILE_BLOCK_RUNTIME_END, + XFILE_BLOCK_LARGE, + XFILE_BLOCK_PHYSICAL, + XFILE_BLOCK_VERTEX, + XFILE_BLOCK_INDEX, + + MAX_XFILE_COUNT + }; + + struct XModelPieces; + struct PhysPreset; + struct XAnimParts; + struct XModel; + struct Material; + struct MaterialPixelShader; + struct MaterialVertexShader; + struct MaterialTechniqueSet; + struct GfxImage; + struct snd_alias_list_t; + struct SndCurve; + struct LoadedSound; + struct clipMap_t; + struct ComWorld; + struct GameWorldSp; + struct GameWorldMp; + struct MapEnts; + struct GfxWorld; + struct GfxLightDef; + struct Font_s; + struct MenuList; + struct menuDef_t; + struct LocalizeEntry; + struct WeaponDef; + struct SndDriverGlobals; + struct FxEffectDef; + struct FxImpactTable; + struct RawFile; + struct StringTable; + + union XAssetHeader + { + // XModelPieces *xmodelPieces; // NOT AN ASSET + PhysPreset *physPreset; + XAnimParts *parts; + XModel *model; + Material *material; + MaterialPixelShader *pixelShader; + MaterialVertexShader *vertexShader; + MaterialTechniqueSet *techniqueSet; + GfxImage *image; + snd_alias_list_t *sound; + SndCurve *sndCurve; + LoadedSound *loadSnd; + clipMap_t *clipMap; + ComWorld *comWorld; + GameWorldSp *gameWorldSp; + GameWorldMp *gameWorldMp; + MapEnts *mapEnts; + GfxWorld *gfxWorld; + GfxLightDef *lightDef; + Font_s *font; + MenuList *menuList; + menuDef_t *menu; + LocalizeEntry *localize; + WeaponDef *weapon; + SndDriverGlobals *sndDriverGlobals; + FxEffectDef *fx; + FxImpactTable *impactFx; + RawFile *rawfile; + StringTable *stringTable; + void *data; + }; + + typedef char cbrushedge_t; + typedef float vec2_t[2]; + typedef float vec3_t[3]; + + struct PhysPreset + { + const char *name; + int type; + float mass; + float bounce; + float friction; + float bulletForceScale; + float explosiveForceScale; + const char *sndAliasPrefix; + float piecesSpreadFraction; + float piecesUpwardVelocity; + bool tempDefaultToCylinder; + }; + + union XAnimIndices + { + char* _1; + uint16_t* _2; + void* data; + }; + + struct XAnimNotifyInfo + { + uint16_t name; + float time; + }; + + union XAnimDynamicIndices + { + char _1[1]; + uint16_t _2[1]; + }; + + typedef unsigned char ByteVec[3]; + typedef tdef_align(4) unsigned short UShortVec[3]; + + union XAnimDynamicFrames + { + ByteVec* _1; + UShortVec* _2; + }; + + struct __declspec(align(4)) XAnimPartTransFrames + { + float mins[3]; + float size[3]; + XAnimDynamicFrames frames; + XAnimDynamicIndices indices; + }; + + union XAnimPartTransData + { + XAnimPartTransFrames frames; + vec3_t frame0; + }; + + struct XAnimPartTrans + { + uint16_t size; + char smallTrans; + XAnimPartTransData u; + }; + + typedef tdef_align(4) short XQuat[2]; + + struct __declspec(align(4)) XAnimDeltaPartQuatDataFrames + { + XQuat *frames; + XAnimDynamicIndices indices; + }; + + union XAnimDeltaPartQuatData + { + XAnimDeltaPartQuatDataFrames frames; + int16_t frame0[2]; + }; + + struct XAnimDeltaPartQuat + { + uint16_t size; + XAnimDeltaPartQuatData u; + }; + + struct XAnimDeltaPart + { + XAnimPartTrans* trans; + XAnimDeltaPartQuat* quat; + }; + + struct XAnimParts + { + const char* name; + uint16_t dataByteCount; + uint16_t dataShortCount; + uint16_t dataIntCount; + uint16_t randomDataByteCount; + uint16_t randomDataIntCount; + uint16_t numframes; + bool bLoop; + bool bDelta; + char boneCount[10]; + char notifyCount; + char assetType; + bool isDefault; + unsigned int randomDataShortCount; + unsigned int indexCount; + float framerate; + float frequency; + uint16_t* names; + char* dataByte; + int16_t* dataShort; + int* dataInt; + int16_t* randomDataShort; + char* randomDataByte; + int* randomDataInt; + XAnimIndices indices; + XAnimNotifyInfo* notify; + XAnimDeltaPart* deltaPart; + }; + + struct DObjAnimMat + { + float quat[4]; + float trans[3]; + float transWeight; + }; + + struct XSurfaceCollisionAabb + { + uint16_t mins[3]; + uint16_t maxs[3]; + }; + + struct XSurfaceCollisionNode + { + XSurfaceCollisionAabb aabb; + uint16_t childBeginIndex; + uint16_t childCount; + }; + + struct XSurfaceCollisionLeaf + { + uint16_t triangleBeginIndex; + }; + + struct XSurfaceCollisionTree + { + float trans[3]; + float scale[3]; + unsigned int nodeCount; + XSurfaceCollisionNode* nodes; + unsigned int leafCount; + XSurfaceCollisionLeaf* leafs; + }; + + struct XRigidVertList + { + uint16_t boneOffset; + uint16_t vertCount; + uint16_t triOffset; + uint16_t triCount; + XSurfaceCollisionTree* collisionTree; + }; + + union GfxColor + { + unsigned int packed; + char array[4]; + }; + + union PackedTexCoords + { + unsigned int packed; + }; + + union PackedUnitVec + { + unsigned int packed; + char array[4]; + }; + + struct GfxPackedVertex + { + float xyz[3]; + float binormalSign; + GfxColor color; + PackedTexCoords texCoord; + PackedUnitVec normal; + PackedUnitVec tangent; + }; + + struct XSurfaceVertexInfo + { + int16_t vertCount[4]; + uint16_t* vertsBlend; + }; + + typedef tdef_align(16) uint16_t r_index16_t; + + struct XSurface + { + char tileMode; + bool deformed; + uint16_t vertCount; + uint16_t triCount; + char zoneHandle; + uint16_t baseTriIndex; + uint16_t baseVertIndex; + r_index16_t(*triIndices)[3]; + XSurfaceVertexInfo vertInfo; + GfxPackedVertex* verts0; + unsigned int vertListCount; + XRigidVertList* vertList; + int partBits[4]; + }; + + struct XModelLodInfo + { + float dist; + uint16_t numsurfs; + uint16_t surfIndex; + int partBits[4]; + char lod; + char smcIndexPlusOne; + char smcAllocBits; + char unused; + }; + + struct XModelCollTri_s + { + float plane[4]; + float svec[4]; + float tvec[4]; + }; + + struct XModelCollSurf_s + { + XModelCollTri_s* collTris; + int numCollTris; + float mins[3]; + float maxs[3]; + int boneIdx; + int contents; + int surfFlags; + }; + + struct XBoneInfo + { + float bounds[2][3]; + float offset[3]; + float radiusSquared; + }; + + struct cplane_s + { + float normal[3]; + float dist; + char type; + char signbits; + char pad[2]; + }; + + struct __declspec(align(2)) cbrushside_t + { + cplane_s* plane; + unsigned int materialNum; + int16_t firstAdjacentSideOffset; + char edgeCount; + }; + + struct BrushWrapper + { + float mins[3]; + int contents; + float maxs[3]; + unsigned int numsides; + cbrushside_t* sides; + int16_t axialMaterialNum[2][3]; + char* baseAdjacentSide; + int16_t firstAdjacentSideOffsets[2][3]; + char edgeCount[2][3]; + int totalEdgeCount; + cplane_s* planes; + }; + + struct PhysGeomInfo + { + BrushWrapper* brush; + int type; + float orientation[3][3]; + float offset[3]; + float halfLengths[3]; + }; + + struct PhysMass + { + float centerOfMass[3]; + float momentsOfInertia[3]; + float productsOfInertia[3]; + }; + + struct PhysGeomList + { + unsigned int count; + PhysGeomInfo* geoms; + PhysMass mass; + }; + + struct XModelStreamInfo + { + }; + + struct XModel + { + const char* name; + char numBones; + char numRootBones; + char numsurfs; + char lodRampType; + uint16_t* boneNames; + char* parentList; + int16_t(*quats)[4]; + float(*trans)[4]; + char* partClassification; + DObjAnimMat* baseMat; + XSurface* surfs; + Material** materialHandles; + XModelLodInfo lodInfo[4]; + XModelCollSurf_s* collSurfs; + int numCollSurfs; + int contents; + XBoneInfo* boneInfo; + float radius; + float mins[3]; + float maxs[3]; + int16_t numLods; + int16_t collLod; + XModelStreamInfo streamInfo; + int memUsage; + char flags; + bool bad; + PhysPreset* physPreset; + PhysGeomList* physGeoms; + }; + + struct GfxStateBits + { + unsigned int loadBits[2]; + }; + + struct MaterialConstantDef + { + unsigned int nameHash; + char name[12]; + float literal[4]; + }; + + struct complex_s + { + float real; + float imag; + }; + + struct WaterWritable + { + float floatTime; + }; + + struct water_t + { + WaterWritable writable; + complex_s* H0; + float* wTerm; + int M; + int N; + float Lx; + float Lz; + float gravity; + float windvel; + float winddir[2]; + float amplitude; + float codeConstant[4]; + GfxImage* image; + }; + + union MaterialTextureDefInfo + { + GfxImage* image; + water_t* water; + }; + + struct MaterialTextureDef + { + unsigned int nameHash; + char nameStart; + char nameEnd; + char samplerState; + char semantic; + MaterialTextureDefInfo u; + }; + + struct GfxDrawSurfFields + { + uint64_t objectId : 16; + uint64_t reflectionProbeIndex : 8; + uint64_t customIndex : 5; + uint64_t materialSortedIndex : 11; + uint64_t prepass : 2; + uint64_t primaryLightIndex : 8; + uint64_t surfType : 4; + uint64_t primarySortKey : 6; + uint64_t unused : 4; + }; + + union GfxDrawSurf + { + GfxDrawSurfFields fields; + uint64_t packed; + }; + + struct MaterialInfo + { + const char* name; + char gameFlags; + char sortKey; + char textureAtlasRowCount; + char textureAtlasColumnCount; + GfxDrawSurf drawSurf; + unsigned int surfaceTypeBits; + uint16_t hashIndex; + }; + + struct Material + { + MaterialInfo info; + char stateBitsEntry[34]; + char textureCount; + char constantCount; + char stateBitsCount; + char stateFlags; + char cameraRegion; + MaterialTechniqueSet* techniqueSet; + MaterialTextureDef* textureTable; + MaterialConstantDef* constantTable; + GfxStateBits* stateBitsTable; + }; + + struct MaterialArgumentCodeConst + { + uint16_t index; + char firstRow; + char rowCount; + }; + + union MaterialArgumentDef + { + const float* literalConst; + MaterialArgumentCodeConst codeConst; + unsigned int codeSampler; + unsigned int nameHash; + }; + + struct MaterialShaderArgument + { + uint16_t type; + uint16_t dest; + MaterialArgumentDef u; + }; + + struct MaterialStreamRouting + { + char source; + char dest; + }; + + struct MaterialVertexStreamRouting + { + MaterialStreamRouting data[16]; + void/*IDirect3DVertexDeclaration9*/* decl[16]; + }; + + struct MaterialVertexDeclaration + { + char streamCount; + bool hasOptionalSource; + bool isLoaded; + MaterialVertexStreamRouting routing; + }; + + struct GfxVertexShaderLoadDef + { + unsigned int* program; + uint16_t programSize; + uint16_t loadForRenderer; + }; + + struct MaterialVertexShaderProgram + { + void/*IDirect3DVertexShader9*/* vs; + GfxVertexShaderLoadDef loadDef; + }; + + struct MaterialVertexShader + { + const char* name; + MaterialVertexShaderProgram prog; + }; + + struct GfxPixelShaderLoadDef + { + unsigned int* program; + uint16_t programSize; + uint16_t loadForRenderer; + }; + + struct MaterialPixelShaderProgram + { + void/*IDirect3DPixelShader9*/* ps; + GfxPixelShaderLoadDef loadDef; + }; + + struct MaterialPixelShader + { + const char* name; + MaterialPixelShaderProgram prog; + }; + + struct MaterialPass + { + MaterialVertexDeclaration* vertexDecl; + MaterialVertexShader* vertexShader; + MaterialPixelShader* pixelShader; + char perPrimArgCount; + char perObjArgCount; + char stableArgCount; + char customSamplerFlags; + MaterialShaderArgument* args; + }; + + struct MaterialTechnique + { + const char* name; + uint16_t flags; + uint16_t passCount; + MaterialPass passArray[1]; + }; + + struct MaterialTechniqueSet + { + const char* name; + char worldVertFormat; + bool hasBeenUploaded; + char unused[1]; + MaterialTechniqueSet* remappedTechniqueSet; + MaterialTechnique* techniques[34]; + }; + + struct CardMemory + { + int platform[2]; + }; + + struct Picmip + { + char platform[2]; + }; + + struct __declspec(align(4)) GfxImageLoadDef + { + char levelCount; + char flags; + int16_t dimensions[3]; + int format; + int resourceSize; + char data[1]; + }; + + union GfxTexture + { + void/*IDirect3DBaseTexture9*/* basemap; + void/*IDirect3DTexture9*/* map; + void/*IDirect3DVolumeTexture9*/* volmap; + void/*IDirect3DCubeTexture9*/* cubemap; + Texture* texture; + GfxImageLoadDef* loadDef; + }; + + enum MapType + { + MAPTYPE_NONE = 0x0, + MAPTYPE_INVALID1 = 0x1, + MAPTYPE_INVALID2 = 0x2, + MAPTYPE_2D = 0x3, + MAPTYPE_3D = 0x4, + MAPTYPE_CUBE = 0x5, + MAPTYPE_COUNT = 0x6, + }; + + struct GfxImage + { + MapType mapType; + GfxTexture texture; + Picmip picmip; + bool noPicmip; + char semantic; + char track; + CardMemory cardMemory; + uint16_t width; + uint16_t height; + uint16_t depth; + char category; + bool delayLoadPixels; + const char* name; + }; + + struct SndCurve + { + const char* filename; + int knotCount; + float knots[8][2]; + }; + + struct MSSSpeakerLevels + { + int speaker; + int numLevels; + float levels[2]; + }; + + struct MSSChannelMap + { + int speakerCount; + MSSSpeakerLevels speakers[6]; + }; + + struct SpeakerMap + { + bool isDefault; + const char* name; + MSSChannelMap channelMaps[2][2]; + }; + + struct StreamedSound + { + const char* dir; + const char* name; + }; + + union SoundFileRef + { + LoadedSound* loadSnd; + StreamedSound streamSnd; + }; + + struct SoundFile + { + char type; + char exists; + SoundFileRef u; + }; + + struct snd_alias_t + { + const char* aliasName; + const char* subtitle; + const char* secondaryAliasName; + const char* chainAliasName; + SoundFile* soundFile; + int sequence; + float volMin; + float volMax; + float pitchMin; + float pitchMax; + float distMin; + float distMax; + int flags; + float slavePercentage; + float probability; + float lfePercentage; + float centerPercentage; + int startDelay; + SndCurve* volumeFalloffCurve; + float envelopMin; + float envelopMax; + float envelopPercentage; + SpeakerMap* speakerMap; + }; + + struct snd_alias_list_t + { + const char* aliasName; + snd_alias_t* head; + int count; + }; + + struct AILSOUNDINFO + { + int format; + const void* data_ptr; + unsigned int data_len; + unsigned int rate; + int bits; + int channels; + unsigned int samples; + unsigned int block_size; + const void* initial_ptr; + }; + + struct MssSound + { + AILSOUNDINFO info; + char* data; + }; + + struct LoadedSound + { + const char* name; + MssSound sound; + }; + + struct cStaticModelWritable + { + uint16_t nextModelInWorldSector; + }; + + struct cStaticModel_s + { + cStaticModelWritable writable; + XModel* xmodel; + float origin[3]; + float invScaledAxis[3][3]; + float absmin[3]; + float absmax[3]; + }; + + struct dmaterial_t + { + char material[64]; + int surfaceFlags; + int contentFlags; + }; + + struct cNode_t + { + cplane_s* plane; + int16_t children[2]; + }; + + struct cLeaf_t + { + uint16_t firstCollAabbIndex; + uint16_t collAabbCount; + int brushContents; + int terrainContents; + float mins[3]; + float maxs[3]; + int leafBrushNode; + int16_t cluster; + }; + + struct cLeafBrushNodeChildren_t + { + float dist; + float range; + uint16_t childOffset[2]; + }; + + struct cLeafBrushNodeLeaf_t + { + uint16_t* brushes; + }; + + union cLeafBrushNodeData_t + { + cLeafBrushNodeLeaf_t leaf; + cLeafBrushNodeChildren_t children; + }; + + struct cLeafBrushNode_s + { + char axis; + int16_t leafBrushCount; + int contents; + cLeafBrushNodeData_t data; + }; + + struct CollisionBorder + { + float distEq[3]; + float zBase; + float zSlope; + float start; + float length; + }; + + struct CollisionPartition + { + char triCount; + char borderCount; + int firstTri; + CollisionBorder* borders; + }; + + union CollisionAabbTreeIndex + { + int firstChildIndex; + int partitionIndex; + }; + + struct CollisionAabbTree + { + float origin[3]; + float halfSize[3]; + uint16_t materialIndex; + uint16_t childCount; + CollisionAabbTreeIndex u; + }; + + struct cmodel_t + { + float mins[3]; + float maxs[3]; + float radius; + cLeaf_t leaf; + }; + + struct cbrush_t + { + float mins[3]; + int contents; + float maxs[3]; + unsigned int numsides; + cbrushside_t* sides; + int16_t axialMaterialNum[2][3]; + char* baseAdjacentSide; + int16_t firstAdjacentSideOffsets[2][3]; + char edgeCount[2][3]; + }; + + struct GfxPlacement + { + float quat[4]; + float origin[3]; + }; + + enum DynEntityType + { + DYNENT_TYPE_INVALID = 0x0, + DYNENT_TYPE_CLUTTER = 0x1, + DYNENT_TYPE_DESTRUCT = 0x2, + DYNENT_TYPE_COUNT = 0x3, + }; + + struct DynEntityDef + { + DynEntityType type; + GfxPlacement pose; + XModel* xModel; + uint16_t brushModel; + uint16_t physicsBrushModel; + FxEffectDef* destroyFx; + XModelPieces* destroyPieces; + PhysPreset* physPreset; + int health; + PhysMass mass; + int contents; + }; + + struct DynEntityPose + { + GfxPlacement pose; + float radius; + }; + + struct DynEntityClient + { + int physObjId; + uint16_t flags; + uint16_t lightingHandle; + int health; + }; + + struct DynEntityColl + { + uint16_t sector; + uint16_t nextEntInSector; + float linkMins[2]; + float linkMaxs[2]; + }; + + struct clipMap_t + { + const char* name; + int isInUse; + int planeCount; + cplane_s* planes; + unsigned int numStaticModels; + cStaticModel_s* staticModelList; + unsigned int numMaterials; + dmaterial_t* materials; + unsigned int numBrushSides; + cbrushside_t* brushsides; + unsigned int numBrushEdges; + cbrushedge_t* brushEdges; + unsigned int numNodes; + cNode_t* nodes; + unsigned int numLeafs; + cLeaf_t* leafs; + unsigned int leafbrushNodesCount; + cLeafBrushNode_s* leafbrushNodes; + unsigned int numLeafBrushes; + uint16_t* leafbrushes; + unsigned int numLeafSurfaces; + unsigned int* leafsurfaces; + unsigned int vertCount; + float(*verts)[3]; + int triCount; + uint16_t* triIndices; + char* triEdgeIsWalkable; + int borderCount; + CollisionBorder* borders; + int partitionCount; + CollisionPartition* partitions; + int aabbTreeCount; + CollisionAabbTree* aabbTrees; + unsigned int numSubModels; + cmodel_t* cmodels; + uint16_t numBrushes; + cbrush_t* brushes; + int numClusters; + int clusterBytes; + char* visibility; + int vised; + MapEnts* mapEnts; + cbrush_t* box_brush; + cmodel_t box_model; + uint16_t dynEntCount[2]; + DynEntityDef* dynEntDefList[2]; + DynEntityPose* dynEntPoseList[2]; + DynEntityClient* dynEntClientList[2]; + DynEntityColl* dynEntCollList[2]; + unsigned int checksum; + }; + + 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_tree_nodes_t + { + int nodeCount; + uint16_t* nodes; + }; + + struct pathnode_t; + 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 pathbasenode_t + { + float vOrigin[3]; + unsigned int type; + }; + + struct pathnode_transient_t + { + int iSearchFrame; + pathnode_t* pNextOpen; + pathnode_t* pPrevOpen; + pathnode_t* pParent; + float fCost; + float fHeuristic; + float costFactor; + }; + + struct pathnode_dynamic_t + { + void* pOwner; + int iFreeTime; + int iValidTime[3]; + int inPlayerLOSTime; + int16_t wLinkCount; + int16_t wOverlapCount; + int16_t turretEntNumber; + int16_t userCount; + }; + + struct pathlink_s + { + float fDist; + uint16_t nodeNum; + char disconnectCount; + char negotiationLink; + char ubBadPlaceCount[4]; + }; + + enum nodeType + { + NODE_BADNODE = 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_COVER_WIDE_RIGHT = 0x8, + NODE_COVER_WIDE_LEFT = 0x9, + NODE_CONCEALMENT_STAND = 0xA, + NODE_CONCEALMENT_CROUCH = 0xB, + NODE_CONCEALMENT_PRONE = 0xC, + NODE_REACQUIRE = 0xD, + NODE_BALCONY = 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 pathnode_constant_t + { + nodeType type; + uint16_t spawnflags; + uint16_t targetname; + uint16_t script_linkName; + uint16_t script_noteworthy; + uint16_t target; + uint16_t animscript; + int animscriptfunc; + float vOrigin[3]; + float fAngle; + float forward[2]; + float fRadius; + float minUseDistSq; + int16_t wOverlapNode[2]; + int16_t wChainId; + int16_t wChainDepth; + int16_t wChainParent; + uint16_t totalLinkCount; + pathlink_s* Links; + }; + + struct pathnode_t + { + pathnode_constant_t constant; + pathnode_dynamic_t dynamic; + pathnode_transient_t transient; + }; + + struct PathData + { + unsigned int nodeCount; + pathnode_t* nodes; + pathbasenode_t* basenodes; + unsigned int chainNodeCount; + uint16_t* chainNodeForNode; + uint16_t* nodeForChainNode; + int visBytes; + char* pathVis; + int nodeTreeCount; + pathnode_tree_t* nodeTree; + }; + + struct GameWorldSp + { + const char* name; + PathData path; + }; + + struct GameWorldMp + { + const char* name; + }; + + struct MapEnts + { + const char* name; + char* entityString; + int numEntityChars; + }; + + 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 SunLightParseParams + { + char name[64]; + float ambientScale; + float ambientColor[3]; + float diffuseFraction; + float sunLight; + float sunColor[3]; + float diffuseColor[3]; + bool diffuseColorHasBeenSet; + float angles[3]; + }; + + struct __declspec(align(4)) GfxLightImage + { + GfxImage* image; + char samplerState; + }; + + struct GfxLightDef + { + const char* name; + GfxLightImage attenuation; + int lmapLookupStart; + }; + + struct GfxLight + { + char type; + char canUseShadowMap; + char unused[2]; + float color[3]; + float dir[3]; + float origin[3]; + float radius; + float cosHalfFovOuter; + float cosHalfFovInner; + int exponent; + unsigned int spotShadowIndex; + GfxLightDef* def; + }; + + struct GfxReflectionProbe + { + float origin[3]; + GfxImage* reflectionImage; + }; + + struct GfxWorldDpvsPlanes + { + int cellCount; + cplane_s* planes; + uint16_t* nodes; + unsigned int* sceneEntCellBits; + }; + + struct DpvsPlane + { + float coeffs[4]; + char side[3]; + char pad; + }; + + struct GfxCell; + struct GfxPortal; + + struct GfxPortalWritable + { + bool isQueued; + bool isAncestor; + char recursionDepth; + char hullPointCount; + float(*hullPoints)[2]; + GfxPortal* queuedParent; + }; + + struct GfxPortal + { + GfxPortalWritable writable; + DpvsPlane plane; + GfxCell* cell; + float(*vertices)[3]; + char vertexCount; + float hullAxis[2][3]; + }; + + struct GfxAabbTree + { + float mins[3]; + float maxs[3]; + uint16_t childCount; + uint16_t surfaceCount; + uint16_t startSurfIndex; + uint16_t surfaceCountNoDecal; + uint16_t startSurfIndexNoDecal; + uint16_t smodelIndexCount; + uint16_t* smodelIndexes; + int childrenOffset; + }; + + struct GfxCell + { + float mins[3]; + float maxs[3]; + int aabbTreeCount; + GfxAabbTree* aabbTree; + int portalCount; + GfxPortal* portals; + int cullGroupCount; + int* cullGroups; + char reflectionProbeCount; + char* reflectionProbes; + }; + + struct GfxLightmapArray + { + GfxImage* primary; + GfxImage* secondary; + }; + + struct GfxLightGridEntry + { + uint16_t colorsIndex; + char primaryLightIndex; + char needsTrace; + }; + + struct GfxLightGridColors + { + char rgb[56][3]; + }; + + struct GfxLightGrid + { + bool hasLightRegions; + unsigned int sunPrimaryLightIndex; + uint16_t mins[3]; + uint16_t maxs[3]; + unsigned int rowAxis; + unsigned int colAxis; + uint16_t* rowDataStart; + unsigned int rawRowDataSize; + char* rawRowData; + unsigned int entryCount; + GfxLightGridEntry* entries; + unsigned int colorCount; + GfxLightGridColors* colors; + }; + + struct GfxBrushModelWritable + { + float mins[3]; + float maxs[3]; + }; + + struct GfxBrushModel + { + GfxBrushModelWritable writable; + float bounds[2][3]; + uint16_t surfaceCount; + uint16_t startSurfIndex; + uint16_t 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 + { + uint16_t lod; + uint16_t surfId; + }; + + struct GfxSceneDynModel + { + XModelDrawInfo info; + uint16_t dynEntId; + }; + + struct BModelDrawInfo + { + uint16_t surfId; + }; + + struct GfxSceneDynBrush + { + BModelDrawInfo info; + uint16_t dynEntId; + }; + + struct GfxShadowGeometry + { + uint16_t surfaceCount; + uint16_t smodelCount; + uint16_t* sortedSurfIndex; + uint16_t* 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 + { + float cullDist; + GfxPackedPlacement placement; + XModel* model; + uint16_t smodelCacheIndex[4]; + char reflectionProbeIndex; + char primaryLightIndex; + uint16_t lightingHandle; + char flags; + }; + + struct GfxStaticModelInst + { + float mins[3]; + float maxs[3]; + GfxColor groundLighting; + }; + + struct srfTriangles_t + { + int vertexLayerData; + int firstVertex; + uint16_t vertexCount; + uint16_t triCount; + int baseIndex; + }; + + struct GfxSurface + { + srfTriangles_t tris; + Material* material; + char lightmapIndex; + char reflectionProbeIndex; + char primaryLightIndex; + char flags; + float bounds[2][3]; + }; + + struct GfxCullGroup + { + float mins[3]; + float maxs[3]; + int surfaceCount; + int startSurfIndex; + }; + + struct GfxWorldDpvsStatic + { + unsigned int smodelCount; + unsigned int staticSurfaceCount; + unsigned int staticSurfaceCountNoDecal; + unsigned int litSurfsBegin; + unsigned int litSurfsEnd; + unsigned int decalSurfsBegin; + unsigned int decalSurfsEnd; + unsigned int emissiveSurfsBegin; + unsigned int emissiveSurfsEnd; + unsigned int smodelVisDataCount; + unsigned int surfaceVisDataCount; + char* smodelVisData[3]; + char* surfaceVisData[3]; + unsigned int* lodData; + uint16_t* sortedSurfIndex; + GfxStaticModelInst* smodelInsts; + GfxSurface* surfaces; + GfxCullGroup* cullGroups; + GfxStaticModelDrawInst* smodelDrawInsts; + GfxDrawSurf* surfaceMaterials; + unsigned int* surfaceCastsSunShadow; + volatile int usageCount; + }; + + struct GfxWorldDpvsDynamic + { + unsigned int dynEntClientWordCount[2]; + unsigned int dynEntClientCount[2]; + unsigned int* dynEntCellBits[2]; + char* dynEntVisData[2][3]; + }; + + struct GfxWorld + { + const char* name; + const char* baseName; + int planeCount; + int nodeCount; + int indexCount; + uint16_t* indices; + int surfaceCount; + //GfxWorldStreamInfo streamInfo; + int skySurfCount; + int* skyStartSurfs; + GfxImage* skyImage; + char skySamplerState; + unsigned int vertexCount; + GfxWorldVertexData vd; + unsigned int vertexLayerDataSize; + GfxWorldVertexLayerData vld; + SunLightParseParams sunParse; + GfxLight* sunLight; + float sunColorFromBsp[3]; + unsigned int sunPrimaryLightIndex; + unsigned int primaryLightCount; + int cullGroupCount; + unsigned int reflectionProbeCount; + GfxReflectionProbe* reflectionProbes; + GfxTexture* reflectionProbeTextures; + GfxWorldDpvsPlanes dpvsPlanes; + int cellBitsCount; + GfxCell* cells; + int lightmapCount; + GfxLightmapArray* lightmaps; + GfxLightGrid lightGrid; + GfxTexture* lightmapPrimaryTextures; + GfxTexture* lightmapSecondaryTextures; + int modelCount; + GfxBrushModel* models; + float mins[3]; + float maxs[3]; + unsigned int checksum; + int materialMemoryCount; + MaterialMemory* materialMemory; + sunflare_t sun; + float outdoorLookupMatrix[4][4]; + GfxImage* outdoorImage; + unsigned int* cellCasterBits; + GfxSceneDynModel* sceneDynModel; + GfxSceneDynBrush* sceneDynBrush; + unsigned int* primaryLightEntityShadowVis; + unsigned int* primaryLightDynEntShadowVis[2]; + char* nonSunPrimaryLightForModelDynEnt; + GfxShadowGeometry* shadowGeom; + GfxLightRegion* lightRegion; + GfxWorldDpvsStatic dpvs; + GfxWorldDpvsDynamic dpvsDyn; + }; + + struct Glyph + { + uint16_t letter; + char x0; + char y0; + char dx; + char pixelWidth; + char pixelHeight; + float s0; + float t0; + float s1; + float t1; + }; + + struct Font_s + { + const char* fontName; + int pixelHeight; + int glyphCount; + Material* material; + Material* glowMaterial; + Glyph* glyphs; + }; + + struct MenuList + { + const char* name; + int menuCount; + menuDef_t** menus; + }; + + struct rectDef_s + { + float x; + float y; + float w; + float h; + int horzAlign; + int vertAlign; + }; + + struct windowDef_t + { + const char* name; + rectDef_s rect; + rectDef_s rectClient; + const char* group; + int style; + int border; + int ownerDraw; + int ownerDrawFlags; + float borderSize; + int staticFlags; + int dynamicFlags[1]; + int nextTime; + float foreColor[4]; + float backColor[4]; + float borderColor[4]; + float outlineColor[4]; + Material* background; + }; + + struct ItemKeyHandler + { + int key; + const char* action; + ItemKeyHandler* next; + }; + + union operandInternalDataUnion + { + int intVal; + float floatVal; + const char* string; + }; + + enum expDataType + { + VAL_INT = 0x0, + VAL_FLOAT = 0x1, + VAL_STRING = 0x2, + }; + + struct Operand + { + expDataType dataType; + operandInternalDataUnion internals; + }; + + union entryInternalData + { + int op; + Operand operand; + }; + + struct expressionEntry + { + int type; + entryInternalData data; + }; + + struct statement_s + { + int numEntries; + expressionEntry** entries; + }; + + struct columnInfo_s + { + int pos; + int width; + int maxChars; + int alignment; + }; + + struct listBoxDef_s + { + int mousePos; + int startPos[1]; + int endPos[1]; + int drawPadding; + float elementWidth; + float elementHeight; + int elementStyle; + int numColumns; + columnInfo_s columnInfo[16]; + const char* doubleClick; + int notselectable; + int noScrollBars; + int usePaging; + float selectBorder[4]; + float disableColor[4]; + Material* selectIcon; + }; + + struct editFieldDef_s + { + float minVal; + float maxVal; + float defVal; + float range; + int maxChars; + int maxCharsGotoNext; + int maxPaintChars; + int paintOffset; + }; + + struct multiDef_s + { + const char* dvarList[32]; + const char* dvarStr[32]; + float dvarValue[32]; + int count; + int strDef; + }; + + union itemDefData_t + { + listBoxDef_s* listBox; + editFieldDef_s* editField; + multiDef_s* multi; + const char* enumDvarName; + void* data; + }; + + struct itemDef_s + { + windowDef_t window; + rectDef_s textRect[1]; + int type; + int dataType; + int alignment; + int fontEnum; + int textAlignMode; + float textalignx; + float textaligny; + float textscale; + int textStyle; + int gameMsgWindowIndex; + int gameMsgWindowMode; + const char* text; + int itemFlags; + menuDef_t* parent; + const char* mouseEnterText; + const char* mouseExitText; + const char* mouseEnter; + const char* mouseExit; + const char* action; + const char* onAccept; + const char* onFocus; + const char* leaveFocus; + const char* dvar; + const char* dvarTest; + ItemKeyHandler* onKey; + const char* enableDvar; + int dvarFlags; + snd_alias_list_t* focusSound; + float special; + int cursorPos[1]; + itemDefData_t typeData; + int imageTrack; + statement_s visibleExp; + statement_s textExp; + statement_s materialExp; + statement_s rectXExp; + statement_s rectYExp; + statement_s rectWExp; + statement_s rectHExp; + statement_s forecolorAExp; + }; + + struct menuDef_t + { + windowDef_t window; + const char* font; + int fullScreen; + int itemCount; + int fontIndex; + int cursorItem[1]; + int fadeCycle; + float fadeClamp; + float fadeAmount; + float fadeInAmount; + float blurRadius; + const char* onOpen; + const char* onClose; + const char* onESC; + ItemKeyHandler* onKey; + statement_s visibleExp; + const char* allowedBinding; + const char* soundName; + int imageTrack; + float focusColor[4]; + float disableColor[4]; + statement_s rectXExp; + statement_s rectYExp; + itemDef_s** items; + }; + + struct LocalizeEntry + { + const char* value; + const char* name; + }; + + enum weapType_t + { + WEAPTYPE_BULLET = 0x0, + WEAPTYPE_GRENADE = 0x1, + WEAPTYPE_PROJECTILE = 0x2, + WEAPTYPE_BINOCULARS = 0x3, + WEAPTYPE_NUM = 0x4, + }; + + enum weapClass_t + { + WEAPCLASS_RIFLE = 0x0, + WEAPCLASS_MG = 0x1, + WEAPCLASS_SMG = 0x2, + WEAPCLASS_SPREAD = 0x3, + WEAPCLASS_PISTOL = 0x4, + WEAPCLASS_GRENADE = 0x5, + WEAPCLASS_ROCKETLAUNCHER = 0x6, + WEAPCLASS_TURRET = 0x7, + WEAPCLASS_NON_PLAYER = 0x8, + WEAPCLASS_ITEM = 0x9, + WEAPCLASS_NUM = 0xA, + }; + + enum PenetrateType + { + PENETRATE_TYPE_NONE = 0x0, + PENETRATE_TYPE_SMALL = 0x1, + PENETRATE_TYPE_MEDIUM = 0x2, + PENETRATE_TYPE_LARGE = 0x3, + PENETRATE_TYPE_COUNT = 0x4, + }; + + enum ImpactType + { + IMPACT_TYPE_NONE = 0x0, + IMPACT_TYPE_BULLET_SMALL = 0x1, + IMPACT_TYPE_BULLET_LARGE = 0x2, + IMPACT_TYPE_BULLET_AP = 0x3, + IMPACT_TYPE_SHOTGUN = 0x4, + IMPACT_TYPE_GRENADE_BOUNCE = 0x5, + IMPACT_TYPE_GRENADE_EXPLODE = 0x6, + IMPACT_TYPE_ROCKET_EXPLODE = 0x7, + IMPACT_TYPE_PROJECTILE_DUD = 0x8, + IMPACT_TYPE_COUNT = 0x9, + }; + + enum weapInventoryType_t + { + WEAPINVENTORY_PRIMARY = 0x0, + WEAPINVENTORY_OFFHAND = 0x1, + WEAPINVENTORY_ITEM = 0x2, + WEAPINVENTORY_ALTMODE = 0x3, + WEAPINVENTORYCOUNT = 0x4, + }; + + enum weapFireType_t + { + WEAPON_FIRETYPE_FULLAUTO = 0x0, + WEAPON_FIRETYPE_SINGLESHOT = 0x1, + WEAPON_FIRETYPE_BURSTFIRE2 = 0x2, + WEAPON_FIRETYPE_BURSTFIRE3 = 0x3, + WEAPON_FIRETYPE_BURSTFIRE4 = 0x4, + WEAPON_FIRETYPECOUNT = 0x5, + }; + + enum OffhandClass + { + OFFHAND_CLASS_NONE = 0x0, + OFFHAND_CLASS_FRAG_GRENADE = 0x1, + OFFHAND_CLASS_SMOKE_GRENADE = 0x2, + OFFHAND_CLASS_FLASH_GRENADE = 0x3, + OFFHAND_CLASS_COUNT = 0x4, + }; + + enum weapStance_t + { + WEAPSTANCE_STAND = 0x0, + WEAPSTANCE_DUCK = 0x1, + WEAPSTANCE_PRONE = 0x2, + WEAPSTANCE_NUM = 0x3, + }; + + enum activeReticleType_t + { + VEH_ACTIVE_RETICLE_NONE = 0x0, + VEH_ACTIVE_RETICLE_PIP_ON_A_STICK = 0x1, + VEH_ACTIVE_RETICLE_BOUNCING_DIAMOND = 0x2, + VEH_ACTIVE_RETICLE_COUNT = 0x3, + }; + + enum weaponIconRatioType_t + { + WEAPON_ICON_RATIO_1TO1 = 0x0, + WEAPON_ICON_RATIO_2TO1 = 0x1, + WEAPON_ICON_RATIO_4TO1 = 0x2, + WEAPON_ICON_RATIO_COUNT = 0x3, + }; + + enum ammoCounterClipType_t + { + AMMO_COUNTER_CLIP_NONE = 0x0, + AMMO_COUNTER_CLIP_MAGAZINE = 0x1, + AMMO_COUNTER_CLIP_SHORTMAGAZINE = 0x2, + AMMO_COUNTER_CLIP_SHOTGUN = 0x3, + AMMO_COUNTER_CLIP_ROCKET = 0x4, + AMMO_COUNTER_CLIP_BELTFED = 0x5, + AMMO_COUNTER_CLIP_ALTWEAPON = 0x6, + AMMO_COUNTER_CLIP_COUNT = 0x7, + }; + + enum weapOverlayReticle_t + { + WEAPOVERLAYRETICLE_NONE = 0x0, + WEAPOVERLAYRETICLE_CROSSHAIR = 0x1, + WEAPOVERLAYRETICLE_NUM = 0x2, + }; + + enum WeapOverlayInteface_t + { + WEAPOVERLAYINTERFACE_NONE = 0x0, + WEAPOVERLAYINTERFACE_JAVELIN = 0x1, + WEAPOVERLAYINTERFACE_TURRETSCOPE = 0x2, + WEAPOVERLAYINTERFACECOUNT = 0x3, + }; + + enum weapProjExposion_t + { + WEAPPROJEXP_GRENADE = 0x0, + WEAPPROJEXP_ROCKET = 0x1, + WEAPPROJEXP_FLASHBANG = 0x2, + WEAPPROJEXP_NONE = 0x3, + WEAPPROJEXP_DUD = 0x4, + WEAPPROJEXP_SMOKE = 0x5, + WEAPPROJEXP_HEAVY = 0x6, + WEAPPROJEXP_NUM = 0x7, + }; + + enum WeapStickinessType + { + WEAPSTICKINESS_NONE = 0x0, + WEAPSTICKINESS_ALL = 0x1, + WEAPSTICKINESS_GROUND = 0x2, + WEAPSTICKINESS_GROUND_WITH_YAW = 0x3, + WEAPSTICKINESS_COUNT = 0x4, + }; + + enum guidedMissileType_t + { + MISSILE_GUIDANCE_NONE = 0x0, + MISSILE_GUIDANCE_SIDEWINDER = 0x1, + MISSILE_GUIDANCE_HELLFIRE = 0x2, + MISSILE_GUIDANCE_JAVELIN = 0x3, + MISSILE_GUIDANCE_COUNT = 0x4, + }; + + struct WeaponDef + { + const char* szInternalName; + const char* szDisplayName; + const char* szOverlayName; + XModel* gunXModel[16]; + XModel* handXModel; + const char* szXAnims[33]; + const char* szModeName; + uint16_t hideTags[8]; + uint16_t notetrackSoundMapKeys[16]; + uint16_t notetrackSoundMapValues[16]; + int playerAnimType; + weapType_t weapType; + weapClass_t weapClass; + PenetrateType penetrateType; + ImpactType impactType; + weapInventoryType_t inventoryType; + weapFireType_t fireType; + OffhandClass offhandClass; + weapStance_t stance; + FxEffectDef* viewFlashEffect; + FxEffectDef* worldFlashEffect; + snd_alias_list_t* pickupSound; + snd_alias_list_t* pickupSoundPlayer; + snd_alias_list_t* ammoPickupSound; + snd_alias_list_t* ammoPickupSoundPlayer; + snd_alias_list_t* projectileSound; + snd_alias_list_t* pullbackSound; + snd_alias_list_t* pullbackSoundPlayer; + snd_alias_list_t* fireSound; + snd_alias_list_t* fireSoundPlayer; + snd_alias_list_t* fireLoopSound; + snd_alias_list_t* fireLoopSoundPlayer; + snd_alias_list_t* fireStopSound; + snd_alias_list_t* fireStopSoundPlayer; + snd_alias_list_t* fireLastSound; + snd_alias_list_t* fireLastSoundPlayer; + snd_alias_list_t* emptyFireSound; + snd_alias_list_t* emptyFireSoundPlayer; + snd_alias_list_t* meleeSwipeSound; + snd_alias_list_t* meleeSwipeSoundPlayer; + snd_alias_list_t* meleeHitSound; + snd_alias_list_t* meleeMissSound; + snd_alias_list_t* rechamberSound; + snd_alias_list_t* rechamberSoundPlayer; + snd_alias_list_t* reloadSound; + snd_alias_list_t* reloadSoundPlayer; + snd_alias_list_t* reloadEmptySound; + snd_alias_list_t* reloadEmptySoundPlayer; + snd_alias_list_t* reloadStartSound; + snd_alias_list_t* reloadStartSoundPlayer; + snd_alias_list_t* reloadEndSound; + snd_alias_list_t* reloadEndSoundPlayer; + snd_alias_list_t* detonateSound; + snd_alias_list_t* detonateSoundPlayer; + snd_alias_list_t* nightVisionWearSound; + snd_alias_list_t* nightVisionWearSoundPlayer; + snd_alias_list_t* nightVisionRemoveSound; + snd_alias_list_t* nightVisionRemoveSoundPlayer; + snd_alias_list_t* altSwitchSound; + snd_alias_list_t* altSwitchSoundPlayer; + snd_alias_list_t* raiseSound; + snd_alias_list_t* raiseSoundPlayer; + snd_alias_list_t* firstRaiseSound; + snd_alias_list_t* firstRaiseSoundPlayer; + snd_alias_list_t* putawaySound; + snd_alias_list_t* putawaySoundPlayer; + snd_alias_list_t** bounceSound; + FxEffectDef* viewShellEjectEffect; + FxEffectDef* worldShellEjectEffect; + FxEffectDef* viewLastShotEjectEffect; + FxEffectDef* worldLastShotEjectEffect; + Material* reticleCenter; + Material* reticleSide; + int iReticleCenterSize; + int iReticleSideSize; + int iReticleMinOfs; + activeReticleType_t activeReticleType; + float vStandMove[3]; + float vStandRot[3]; + float vDuckedOfs[3]; + float vDuckedMove[3]; + float vDuckedRot[3]; + float vProneOfs[3]; + float vProneMove[3]; + float vProneRot[3]; + float fPosMoveRate; + float fPosProneMoveRate; + float fStandMoveMinSpeed; + float fDuckedMoveMinSpeed; + float fProneMoveMinSpeed; + float fPosRotRate; + float fPosProneRotRate; + float fStandRotMinSpeed; + float fDuckedRotMinSpeed; + float fProneRotMinSpeed; + XModel* worldModel[16]; + XModel* worldClipModel; + XModel* rocketModel; + XModel* knifeModel; + XModel* worldKnifeModel; + Material* hudIcon; + weaponIconRatioType_t hudIconRatio; + Material* ammoCounterIcon; + weaponIconRatioType_t ammoCounterIconRatio; + ammoCounterClipType_t ammoCounterClip; + int iStartAmmo; + const char* szAmmoName; + int iAmmoIndex; + const char* szClipName; + int iClipIndex; + int iMaxAmmo; + int iClipSize; + int shotCount; + const char* szSharedAmmoCapName; + int iSharedAmmoCapIndex; + int iSharedAmmoCap; + int damage; + int playerDamage; + int iMeleeDamage; + int iDamageType; + int iFireDelay; + int iMeleeDelay; + int meleeChargeDelay; + int iDetonateDelay; + int iFireTime; + int iRechamberTime; + int iRechamberBoltTime; + int iHoldFireTime; + int iDetonateTime; + int iMeleeTime; + int meleeChargeTime; + int iReloadTime; + int reloadShowRocketTime; + int iReloadEmptyTime; + int iReloadAddTime; + int iReloadStartTime; + int iReloadStartAddTime; + int iReloadEndTime; + int iDropTime; + int iRaiseTime; + int iAltDropTime; + int iAltRaiseTime; + int quickDropTime; + int quickRaiseTime; + int iFirstRaiseTime; + int iEmptyRaiseTime; + int iEmptyDropTime; + int sprintInTime; + int sprintLoopTime; + int sprintOutTime; + int nightVisionWearTime; + int nightVisionWearTimeFadeOutEnd; + int nightVisionWearTimePowerUp; + int nightVisionRemoveTime; + int nightVisionRemoveTimePowerDown; + int nightVisionRemoveTimeFadeInStart; + int fuseTime; + int aiFuseTime; + int requireLockonToFire; + int noAdsWhenMagEmpty; + int avoidDropCleanup; + float autoAimRange; + float aimAssistRange; + float aimAssistRangeAds; + float aimPadding; + float enemyCrosshairRange; + int crosshairColorChange; + float moveSpeedScale; + float adsMoveSpeedScale; + float sprintDurationScale; + float fAdsZoomFov; + float fAdsZoomInFrac; + float fAdsZoomOutFrac; + Material* overlayMaterial; + Material* overlayMaterialLowRes; + weapOverlayReticle_t overlayReticle; + WeapOverlayInteface_t overlayInterface; + float overlayWidth; + float overlayHeight; + float fAdsBobFactor; + float fAdsViewBobMult; + float fHipSpreadStandMin; + float fHipSpreadDuckedMin; + float fHipSpreadProneMin; + float hipSpreadStandMax; + float hipSpreadDuckedMax; + float hipSpreadProneMax; + float fHipSpreadDecayRate; + float fHipSpreadFireAdd; + float fHipSpreadTurnAdd; + float fHipSpreadMoveAdd; + float fHipSpreadDuckedDecay; + float fHipSpreadProneDecay; + float fHipReticleSidePos; + int iAdsTransInTime; + int iAdsTransOutTime; + float fAdsIdleAmount; + float fHipIdleAmount; + float adsIdleSpeed; + float hipIdleSpeed; + float fIdleCrouchFactor; + float fIdleProneFactor; + float fGunMaxPitch; + float fGunMaxYaw; + float swayMaxAngle; + float swayLerpSpeed; + float swayPitchScale; + float swayYawScale; + float swayHorizScale; + float swayVertScale; + float swayShellShockScale; + float adsSwayMaxAngle; + float adsSwayLerpSpeed; + float adsSwayPitchScale; + float adsSwayYawScale; + float adsSwayHorizScale; + float adsSwayVertScale; + int bRifleBullet; + int armorPiercing; + int bBoltAction; + int aimDownSight; + int bRechamberWhileAds; + float adsViewErrorMin; + float adsViewErrorMax; + int bCookOffHold; + int bClipOnly; + int adsFireOnly; + int cancelAutoHolsterWhenEmpty; + int suppressAmmoReserveDisplay; + int enhanced; + int laserSightDuringNightvision; + Material* killIcon; + weaponIconRatioType_t killIconRatio; + int flipKillIcon; + Material* dpadIcon; + weaponIconRatioType_t dpadIconRatio; + int bNoPartialReload; + int bSegmentedReload; + int iReloadAmmoAdd; + int iReloadStartAdd; + const char* szAltWeaponName; + unsigned int altWeaponIndex; + int iDropAmmoMin; + int iDropAmmoMax; + int blocksProne; + int silenced; + int iExplosionRadius; + int iExplosionRadiusMin; + int iExplosionInnerDamage; + int iExplosionOuterDamage; + float damageConeAngle; + int iProjectileSpeed; + int iProjectileSpeedUp; + int iProjectileSpeedForward; + int iProjectileActivateDist; + float projLifetime; + float timeToAccelerate; + float projectileCurvature; + XModel* projectileModel; + weapProjExposion_t projExplosion; + FxEffectDef* projExplosionEffect; + int projExplosionEffectForceNormalUp; + FxEffectDef* projDudEffect; + snd_alias_list_t* projExplosionSound; + snd_alias_list_t* projDudSound; + int bProjImpactExplode; + WeapStickinessType stickiness; + int hasDetonator; + int timedDetonation; + int rotate; + int holdButtonToThrow; + int freezeMovementWhenFiring; + float lowAmmoWarningThreshold; + float parallelBounce[29]; + float perpendicularBounce[29]; + FxEffectDef* projTrailEffect; + float vProjectileColor[3]; + guidedMissileType_t guidedMissileType; + float maxSteeringAccel; + int projIgnitionDelay; + FxEffectDef* projIgnitionEffect; + snd_alias_list_t* projIgnitionSound; + float fAdsAimPitch; + float fAdsCrosshairInFrac; + float fAdsCrosshairOutFrac; + int adsGunKickReducedKickBullets; + float adsGunKickReducedKickPercent; + float fAdsGunKickPitchMin; + float fAdsGunKickPitchMax; + float fAdsGunKickYawMin; + float fAdsGunKickYawMax; + float fAdsGunKickAccel; + float fAdsGunKickSpeedMax; + float fAdsGunKickSpeedDecay; + float fAdsGunKickStaticDecay; + float fAdsViewKickPitchMin; + float fAdsViewKickPitchMax; + float fAdsViewKickYawMin; + float fAdsViewKickYawMax; + float fAdsViewKickCenterSpeed; + float fAdsViewScatterMin; + float fAdsViewScatterMax; + float fAdsSpread; + int hipGunKickReducedKickBullets; + float hipGunKickReducedKickPercent; + float fHipGunKickPitchMin; + float fHipGunKickPitchMax; + float fHipGunKickYawMin; + float fHipGunKickYawMax; + float fHipGunKickAccel; + float fHipGunKickSpeedMax; + float fHipGunKickSpeedDecay; + float fHipGunKickStaticDecay; + float fHipViewKickPitchMin; + float fHipViewKickPitchMax; + float fHipViewKickYawMin; + float fHipViewKickYawMax; + float fHipViewKickCenterSpeed; + float fHipViewScatterMin; + float fHipViewScatterMax; + float fightDist; + float maxDist; + const char* accuracyGraphName[2]; + float(*accuracyGraphKnots[2])[2]; + float(*originalAccuracyGraphKnots[2])[2]; + int accuracyGraphKnotCount[2]; + int originalAccuracyGraphKnotCount[2]; + int iPositionReloadTransTime; + float leftArc; + float rightArc; + float topArc; + float bottomArc; + float accuracy; + float aiSpread; + float playerSpread; + float minTurnSpeed[2]; + float maxTurnSpeed[2]; + float pitchConvergenceTime; + float yawConvergenceTime; + float suppressTime; + float maxRange; + float fAnimHorRotateInc; + float fPlayerPositionDist; + const char* szUseHintString; + const char* dropHintString; + int iUseHintStringIndex; + int dropHintStringIndex; + float horizViewJitter; + float vertViewJitter; + const char* szScript; + float fOOPosAnimLength[2]; + int minDamage; + int minPlayerDamage; + float fMaxDamageRange; + float fMinDamageRange; + float destabilizationRateTime; + float destabilizationCurvatureMax; + int destabilizeDistance; + float locationDamageMultipliers[19]; + const char* fireRumble; + const char* meleeImpactRumble; + float adsDofStart; + float adsDofEnd; + }; + + struct SndDriverGlobals + { + const char* name; + }; + + struct FxIntRange + { + int base; + int amplitude; + }; + + struct FxFloatRange + { + float base; + float amplitude; + }; + + struct FxSpawnDefOneShot + { + FxIntRange count; + }; + + struct FxSpawnDefLooping + { + int intervalMsec; + int count; + }; + + union FxSpawnDef + { + FxSpawnDefLooping looping; + FxSpawnDefOneShot oneShot; + }; + + struct FxElemAtlas + { + char behavior; + char index; + char fps; + char loopCount; + char colIndexBits; + char rowIndexBits; + int16_t entryCount; + }; + + struct FxElemVec3Range + { + float base[3]; + float amplitude[3]; + }; + + struct FxElemVelStateInFrame + { + FxElemVec3Range velocity; + FxElemVec3Range totalDelta; + }; + + struct FxElemVelStateSample + { + FxElemVelStateInFrame local; + FxElemVelStateInFrame world; + }; + + struct FxElemVisualState + { + char color[4]; + float rotationDelta; + float rotationTotal; + float size[2]; + float scale; + }; + + struct FxElemVisStateSample + { + FxElemVisualState base; + FxElemVisualState amplitude; + }; + + union FxEffectDefRef + { + FxEffectDef* handle; + const char* name; + }; + + union FxElemVisuals + { + const void* anonymous; + Material* material; + XModel* model; + FxEffectDefRef effectDef; + const char* soundName; + }; + + struct FxElemMarkVisuals + { + Material* materials[2]; + }; + + union FxElemDefVisuals + { + FxElemMarkVisuals* markArray; + FxElemVisuals* array; + FxElemVisuals instance; + }; + + struct FxTrailVertex + { + float pos[2]; + float normal[2]; + float texCoord; + }; + + struct FxTrailDef + { + int scrollTimeMsec; + int repeatDist; + int splitDist; + int vertCount; + FxTrailVertex* verts; + int indCount; + uint16_t* inds; + }; + + struct FxElemDef + { + int flags; + FxSpawnDef spawn; + FxFloatRange spawnRange; + FxFloatRange fadeInRange; + FxFloatRange fadeOutRange; + float spawnFrustumCullRadius; + FxIntRange spawnDelayMsec; + FxIntRange lifeSpanMsec; + FxFloatRange spawnOrigin[3]; + FxFloatRange spawnOffsetRadius; + FxFloatRange spawnOffsetHeight; + FxFloatRange spawnAngles[3]; + FxFloatRange angularVelocity[3]; + FxFloatRange initialRotation; + FxFloatRange gravity; + FxFloatRange reflectionFactor; + FxElemAtlas atlas; + char elemType; + char visualCount; + char velIntervalCount; + char visStateIntervalCount; + FxElemVelStateSample* velSamples; + FxElemVisStateSample* visSamples; + FxElemDefVisuals visuals; + float collMins[3]; + float collMaxs[3]; + FxEffectDefRef effectOnImpact; + FxEffectDefRef effectOnDeath; + FxEffectDefRef effectEmitted; + FxFloatRange emitDist; + FxFloatRange emitDistVariance; + FxTrailDef* trailDef; + char sortOrder; + char lightingFrac; + char useItemClip; + char unused[1]; + }; + + struct FxEffectDef + { + const char* name; + int flags; + int totalSize; + int msecLoopingLife; + int elemDefCountLooping; + int elemDefCountOneShot; + int elemDefCountEmission; + FxElemDef* elemDefs; + }; + + struct FxImpactEntry + { + FxEffectDef* nonflesh[29]; + FxEffectDef* flesh[4]; + }; + + struct FxImpactTable + { + const char* name; + FxImpactEntry* table; + }; + + struct RawFile + { + const char* name; + int len; + const char* buffer; + }; + + struct StringTable + { + const char* name; + int columnCount; + int rowCount; + const char** values; + }; + +#ifndef __zonecodegenerator +} +#endif + +#endif + +// EOF diff --git a/src/Linker/Game/IW3/ZoneCreatorIW3.cpp b/src/Linker/Game/IW3/ZoneCreatorIW3.cpp new file mode 100644 index 00000000..b5c4697d --- /dev/null +++ b/src/Linker/Game/IW3/ZoneCreatorIW3.cpp @@ -0,0 +1,43 @@ +#include "ZoneCreatorIW3.h" + +#include "Game/IW3/GameIW3.h" +#include "Game/IW3/GameAssetPoolIW3.h" + +using namespace IW3; + +ZoneCreator::ZoneCreator() +{ + for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) + { + AddAssetTypeName(assetType, GameAssetPoolIW3::AssetTypeNameByType(assetType)); + } +} + +void ZoneCreator::AddAssetTypeName(asset_type_t assetType, std::string name) +{ + m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType)); +} + +void ZoneCreator::CreateZoneAssetPools(Zone* zone) const +{ + zone->m_pools = std::make_unique(zone, zone->m_priority); + + for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) + zone->m_pools->InitPoolDynamic(assetType); +} + +bool ZoneCreator::SupportsGame(const std::string& gameName) const +{ + return gameName == g_GameIW3.GetShortName(); +} + +std::unique_ptr ZoneCreator::CreateZoneForDefinition(ZoneCreationContext& context) const +{ + auto zone = std::make_unique(context.m_zone_name, 0, &g_GameIW3); + zone->m_pools = std::make_unique(zone.get(), zone->m_priority); + + for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++) + zone->m_pools->InitPoolDynamic(assetType); + + return zone; +} diff --git a/src/Linker/Game/IW3/ZoneCreatorIW3.h b/src/Linker/Game/IW3/ZoneCreatorIW3.h new file mode 100644 index 00000000..86ad1a88 --- /dev/null +++ b/src/Linker/Game/IW3/ZoneCreatorIW3.h @@ -0,0 +1,23 @@ +#pragma once +#include +#include + +#include "Zone/ZoneTypes.h" +#include "ZoneCreation/IZoneCreator.h" + +namespace IW3 +{ + class ZoneCreator final : public IZoneCreator + { + std::unordered_map m_asset_types_by_name; + + void AddAssetTypeName(asset_type_t assetType, std::string name); + void CreateZoneAssetPools(Zone* zone) const; + + public: + ZoneCreator(); + + _NODISCARD bool SupportsGame(const std::string& gameName) const override; + _NODISCARD std::unique_ptr CreateZoneForDefinition(ZoneCreationContext& context) const override; + }; +} diff --git a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.cpp b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.cpp new file mode 100644 index 00000000..259c00eb --- /dev/null +++ b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.cpp @@ -0,0 +1,43 @@ +#include "AssetLoaderRawFile.h" + +#include + +#include "Game/IW3/IW3.h" +#include "Pool/GlobalAssetPool.h" + +using namespace IW3; + +void* AssetLoaderRawFile::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) +{ + auto* rawFile = memory->Create(); + memset(rawFile, 0, sizeof(RawFile)); + rawFile->name = memory->Dup(assetName.c_str()); + return rawFile; +} + +bool AssetLoaderRawFile::CanLoadFromRaw() const +{ + return true; +} + +bool AssetLoaderRawFile::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const +{ + const auto file = searchPath->Open(assetName); + if (!file.IsOpen()) + return false; + + auto* rawFile = memory->Create(); + rawFile->name = memory->Dup(assetName.c_str()); + rawFile->len = static_cast(file.m_length); + + auto* fileBuffer = static_cast(memory->Alloc(static_cast(file.m_length + 1))); + file.m_stream->read(fileBuffer, file.m_length); + if (file.m_stream->gcount() != file.m_length) + return false; + fileBuffer[rawFile->len] = '\0'; + + rawFile->buffer = fileBuffer; + manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile); + + return true; +} diff --git a/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.h b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.h new file mode 100644 index 00000000..290fa77c --- /dev/null +++ b/src/ObjLoading/Game/IW3/AssetLoaders/AssetLoaderRawFile.h @@ -0,0 +1,16 @@ +#pragma once +#include "Game/IW3/IW3.h" +#include "AssetLoading/BasicAssetLoader.h" +#include "AssetLoading/IAssetLoadingManager.h" +#include "SearchPath/ISearchPath.h" + +namespace IW3 +{ + class AssetLoaderRawFile final : public BasicAssetLoader + { + public: + _NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override; + _NODISCARD bool CanLoadFromRaw() const override; + bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override; + }; +} diff --git a/src/ObjLoading/Game/IW3/InfoString/InfoStringToStructConverter.cpp b/src/ObjLoading/Game/IW3/InfoString/InfoStringToStructConverter.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjLoading/Game/IW3/InfoString/InfoStringToStructConverter.h b/src/ObjLoading/Game/IW3/InfoString/InfoStringToStructConverter.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp new file mode 100644 index 00000000..f5ad7e93 --- /dev/null +++ b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp @@ -0,0 +1,152 @@ +#include "ObjLoaderIW3.h" +#include "Game/IW4/GameIW4.h" +#include "Game/IW4/GameAssetPoolIW4.h" +#include "ObjContainer/IPak/IPak.h" +#include "ObjLoading.h" +#include "AssetLoaders/AssetLoaderRawFile.h" +#include "AssetLoading/AssetLoadingManager.h" +#include "Image/Texture.h" +#include "Image/IwiLoader.h" + +using namespace IW3; + +ObjLoader::ObjLoader() +{ +#define REGISTER_ASSET_LOADER(t) {auto l = std::make_unique(); m_asset_loaders_by_type[l->GetHandlingAssetType()] = std::move(l);} +#define BASIC_LOADER(assetType, assetClass) BasicAssetLoader + + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_PHYSPRESET, PhysPreset)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_XANIMPARTS, XAnimParts)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_XMODEL, XModel)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MATERIAL, Material)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_IMAGE, GfxImage)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SOUND, snd_alias_list_t)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SOUND_CURVE, SndCurve)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_LOADED_SOUND, LoadedSound)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_CLIPMAP, clipMap_t)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_CLIPMAP_PVS, clipMap_t)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_COMWORLD, ComWorld)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MAP_ENTS, MapEnts)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_GFXWORLD, GfxWorld)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_LIGHT_DEF, GfxLightDef)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FONT, Font_s)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MENULIST, MenuList)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_MENU, menuDef_t)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_WEAPON, WeaponDef)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_FX, FxEffectDef)) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_IMPACT_FX, FxImpactTable)) + REGISTER_ASSET_LOADER(AssetLoaderRawFile) + REGISTER_ASSET_LOADER(BASIC_LOADER(ASSET_TYPE_STRINGTABLE, StringTable)) + +#undef BASIC_LOADER +#undef REGISTER_ASSET_LOADER +} + +bool ObjLoader::SupportsZone(Zone* zone) const +{ + return zone->m_game == &g_GameIW4; +} + +bool ObjLoader::IsMpZone(Zone* zone) +{ + return zone->m_name.compare(0, 3, "mp_") == 0 + || zone->m_name.compare(zone->m_name.length() - 3, 3, "_mp") == 0; +} + +bool ObjLoader::IsZmZone(Zone* zone) +{ + return zone->m_name.compare(0, 3, "zm_") == 0 + || zone->m_name.compare(zone->m_name.length() - 3, 3, "_zm") == 0; +} + +void ObjLoader::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const +{ +} + +void ObjLoader::UnloadContainersOfZone(Zone* zone) const +{ +} + +void ObjLoader::LoadImageFromLoadDef(GfxImage* image, Zone* zone) +{ + // TODO: Load Texture from LoadDef here +} + +void ObjLoader::LoadImageFromIwi(GfxImage* image, ISearchPath* searchPath, Zone* zone) +{ + Texture* loadedTexture = nullptr; + IwiLoader loader(zone->GetMemory()); + + const auto imageFileName = "images/" + std::string(image->name) + ".iwi"; + + { + const auto filePathImage = searchPath->Open(imageFileName); + if (filePathImage.IsOpen()) + { + loadedTexture = loader.LoadIwi(*filePathImage.m_stream); + } + } + + if (loadedTexture != nullptr) + { + image->texture.texture = loadedTexture; + image->cardMemory.platform[0] = 0; + + const auto textureMipCount = loadedTexture->GetMipMapCount(); + for (auto mipLevel = 0; mipLevel < textureMipCount; mipLevel++) + image->cardMemory.platform[0] += static_cast(loadedTexture->GetSizeOfMipLevel(mipLevel) * loadedTexture->GetFaceCount()); + } + else + { + printf("Could not find data for image \"%s\"\n", image->name); + } +} + +void ObjLoader::LoadImageData(ISearchPath* searchPath, Zone* zone) +{ + auto* assetPool = dynamic_cast(zone->m_pools.get()); + + if (assetPool && assetPool->m_image != nullptr) + { + for (auto* imageEntry : *assetPool->m_image) + { + auto* image = imageEntry->Asset(); + + if (image->cardMemory.platform[0] > 0) + { + continue; + } + + // Do not load linked assets + if (image->name && image->name[0] == ',') + { + continue; + } + + if (image->texture.loadDef && image->texture.loadDef->resourceSize > 0) + { + LoadImageFromLoadDef(image, zone); + } + else + { + LoadImageFromIwi(image, searchPath, zone); + } + } + } +} + +void ObjLoader::LoadObjDataForZone(ISearchPath* searchPath, Zone* zone) const +{ + LoadImageData(searchPath, zone); +} + +bool ObjLoader::LoadAssetForZone(AssetLoadingContext* context, asset_type_t assetType, const std::string& assetName) const +{ + AssetLoadingManager assetLoadingManager(m_asset_loaders_by_type, *context); + return assetLoadingManager.LoadAssetFromLoader(assetType, assetName); +} diff --git a/src/ObjLoading/Game/IW3/ObjLoaderIW3.h b/src/ObjLoading/Game/IW3/ObjLoaderIW3.h new file mode 100644 index 00000000..a010049e --- /dev/null +++ b/src/ObjLoading/Game/IW3/ObjLoaderIW3.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include + +#include "IObjLoader.h" +#include "AssetLoading/IAssetLoader.h" +#include "SearchPath/ISearchPath.h" +#include "Game/IW3/IW3.h" + +namespace IW3 +{ + class ObjLoader final : public IObjLoader + { + std::unordered_map> m_asset_loaders_by_type; + + static void LoadImageFromIwi(GfxImage* image, ISearchPath* searchPath, Zone* zone); + static void LoadImageFromLoadDef(GfxImage* image, Zone* zone); + static void LoadImageData(ISearchPath* searchPath, Zone* zone); + + static bool IsMpZone(Zone* zone); + static bool IsZmZone(Zone* zone); + + public: + ObjLoader(); + + bool SupportsZone(Zone* zone) const override; + + void LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const override; + void UnloadContainersOfZone(Zone* zone) const override; + + void LoadObjDataForZone(ISearchPath* searchPath, Zone* zone) const override; + + bool LoadAssetForZone(AssetLoadingContext* context, asset_type_t assetType, const std::string& assetName) const override; + }; +} diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperGfxImage.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperGfxImage.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLoadedSound.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLoadedSound.h b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLoadedSound.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLocalizeEntry.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLocalizeEntry.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperRawFile.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperRawFile.h b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperRawFile.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperStringTable.cpp b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperStringTable.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperStringTable.h b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperStringTable.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperWeapon.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperWeapon.h b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperWeapon.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/InfoString/InfoStringFromStructConverter.cpp b/src/ObjWriting/Game/IW3/InfoString/InfoStringFromStructConverter.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/InfoString/InfoStringFromStructConverter.h b/src/ObjWriting/Game/IW3/InfoString/InfoStringFromStructConverter.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/ZoneDumperIW3.cpp b/src/ObjWriting/Game/IW3/ZoneDumperIW3.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ObjWriting/Game/IW3/ZoneDumperIW3.h b/src/ObjWriting/Game/IW3/ZoneDumperIW3.h new file mode 100644 index 00000000..e69de29b diff --git a/src/Unlinker/Game/IW3/ZoneDefWriterIW3.cpp b/src/Unlinker/Game/IW3/ZoneDefWriterIW3.cpp new file mode 100644 index 00000000..b3ee1bb0 --- /dev/null +++ b/src/Unlinker/Game/IW3/ZoneDefWriterIW3.cpp @@ -0,0 +1,45 @@ +#include "ZoneDefWriterIW3.h" + +#include + +#include "Game/IW3/GameIW3.h" +#include "Game/IW3/GameAssetPoolIW3.h" + +using namespace IW3; + +bool ZoneDefWriter::CanHandleZone(Zone* zone) const +{ + return zone->m_game == &g_GameIW3; +} + +void ZoneDefWriter::WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const +{ +} + +void ZoneDefWriter::WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const +{ + const auto* pools = dynamic_cast(zone->m_pools.get()); + + assert(pools); + if (!pools) + return; + + // Localized strings are all collected in one string file. So only add this to the zone file. + if (!pools->m_localize->m_asset_lookup.empty()) + { + stream.WriteEntry(pools->GetAssetTypeName(ASSET_TYPE_LOCALIZE_ENTRY), zone->m_name); + } + + for (const auto& asset : *pools) + { + switch (asset->m_type) + { + case ASSET_TYPE_LOCALIZE_ENTRY: + break; + + default: + stream.WriteEntry(pools->GetAssetTypeName(asset->m_type), asset->m_name); + break; + } + } +} diff --git a/src/Unlinker/Game/IW3/ZoneDefWriterIW3.h b/src/Unlinker/Game/IW3/ZoneDefWriterIW3.h new file mode 100644 index 00000000..b07e57d1 --- /dev/null +++ b/src/Unlinker/Game/IW3/ZoneDefWriterIW3.h @@ -0,0 +1,16 @@ +#pragma once + +#include "ContentLister/ZoneDefWriter.h" + +namespace IW3 +{ + class ZoneDefWriter final : public AbstractZoneDefWriter + { + protected: + void WriteMetaData(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; + void WriteContent(ZoneDefinitionOutputStream& stream, const UnlinkerArgs* args, Zone* zone) const override; + + public: + bool CanHandleZone(Zone* zone) const override; + }; +} \ No newline at end of file diff --git a/src/ZoneCode.lua b/src/ZoneCode.lua index aafed887..328c3adf 100644 --- a/src/ZoneCode.lua +++ b/src/ZoneCode.lua @@ -1,6 +1,34 @@ ZoneCode = {} ZoneCode.Assets = { + IW3 = { + "PhysPreset", + "XAnimParts", + "XModel", + "Material", + "MaterialTechniqueSet", + "GfxImage", + "snd_alias_list_t", + "SndCurve", + "LoadedSound", + "clipMap_t", + "ComWorld", + "GameWorldSp", + "GameWorldMp", + "MapEnts", + "GfxWorld", + "GfxLightDef", + "Font_s", + "MenuList", + "menuDef_t", + "LocalizeEntry", + "WeaponDef", + "FxEffectDef", + "FxImpactTable", + "RawFile", + "StringTable" + }, + IW4 = { "PhysPreset", "PhysCollmap", @@ -207,6 +235,10 @@ function ZoneCode:project() } filter {} + filter "files:**/IW3.gen" + self:outputForAssets(self.Assets.IW3) + filter {} + filter "files:**/IW4.gen" self:outputForAssets(self.Assets.IW4) filter {} diff --git a/src/ZoneCode/Game/IW3/IW3.gen b/src/ZoneCode/Game/IW3/IW3.gen new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/IW3.h b/src/ZoneCode/Game/IW3/IW3.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/IW3_Commands.txt b/src/ZoneCode/Game/IW3/IW3_Commands.txt new file mode 100644 index 00000000..ef856e90 --- /dev/null +++ b/src/ZoneCode/Game/IW3/IW3_Commands.txt @@ -0,0 +1,69 @@ +// Game: Modern Warfare (IW3) +game IW3; +architecture x86; + +// Game Assets +asset PhysPreset ASSET_TYPE_PHYSPRESET; +asset XAnimParts ASSET_TYPE_XANIMPARTS; +asset XModel ASSET_TYPE_XMODEL; +asset Material ASSET_TYPE_MATERIAL; +asset MaterialTechniqueSet ASSET_TYPE_TECHNIQUE_SET; +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 ComWorld ASSET_TYPE_COMWORLD; +asset GameWorldSp ASSET_TYPE_GAMEWORLD_SP; +asset GameWorldMp ASSET_TYPE_GAMEWORLD_MP; +asset MapEnts ASSET_TYPE_MAP_ENTS; +asset GfxWorld ASSET_TYPE_GFXWORLD; +asset GfxLightDef ASSET_TYPE_LIGHT_DEF; +asset Font_s ASSET_TYPE_FONT; +asset MenuList ASSET_TYPE_MENULIST; +asset menuDef_t ASSET_TYPE_MENU; +asset LocalizeEntry ASSET_TYPE_LOCALIZE_ENTRY; +asset WeaponDef ASSET_TYPE_WEAPON; +asset FxEffectDef ASSET_TYPE_FX; +asset FxImpactTable ASSET_TYPE_IMPACT_FX; +asset RawFile ASSET_TYPE_RAWFILE; +asset StringTable ASSET_TYPE_STRINGTABLE; + +// Setup blocks +block temp XFILE_BLOCK_TEMP default; +block runtime XFILE_BLOCK_RUNTIME default; +block runtime XFILE_BLOCK_LARGE_RUNTIME; +block runtime XFILE_BLOCK_PHYSICAL_RUNTIME; +block normal XFILE_BLOCK_VIRTUAL default; +block normal XFILE_BLOCK_LARGE; +block normal XFILE_BLOCK_PHYSICAL; +block normal XFILE_BLOCK_VERTEX; +block normal XFILE_BLOCK_INDEX; + +#include "XAssets/PhysPreset.txt" +#include "XAssets/XAnimParts.txt" +#include "XAssets/XModel.txt" +#include "XAssets/Material.txt" +#include "XAssets/MaterialTechniqueSet.txt" +#include "XAssets/GfxImage.txt" +#include "XAssets/snd_alias_list_t.txt" +#include "XAssets/SndCurve.txt" +#include "XAssets/LoadedSound.txt" +#include "XAssets/clipMap_t.txt" +#include "XAssets/ComWorld.txt" +#include "XAssets/GameWorldSp.txt" +#include "XAssets/GameWorldMp.txt" +#include "XAssets/MapEnts.txt" +#include "XAssets/GfxWorld.txt" +#include "XAssets/LocalizeEntry.txt" +#include "XAssets/WeaponDef.txt" +#include "XAssets/MenuList.txt" +#include "XAssets/menuDef_t.txt" +#include "XAssets/FxEffectDef.txt" +#include "XAssets/FxImpactTable.txt" +#include "XAssets/GfxLightDef.txt" +#include "XAssets/Font_s.txt" +#include "XAssets/RawFile.txt" +#include "XAssets/StringTable.txt" + +// EOF \ No newline at end of file diff --git a/src/ZoneCode/Game/IW3/XAssets/ComWorld.txt b/src/ZoneCode/Game/IW3/XAssets/ComWorld.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/Font_s.txt b/src/ZoneCode/Game/IW3/XAssets/Font_s.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/FxImpactTable.txt b/src/ZoneCode/Game/IW3/XAssets/FxImpactTable.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/GameWorldMp.txt b/src/ZoneCode/Game/IW3/XAssets/GameWorldMp.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/GameWorldSp.txt b/src/ZoneCode/Game/IW3/XAssets/GameWorldSp.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/GfxImage.txt b/src/ZoneCode/Game/IW3/XAssets/GfxImage.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/GfxLightDef.txt b/src/ZoneCode/Game/IW3/XAssets/GfxLightDef.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/GfxWorld.txt b/src/ZoneCode/Game/IW3/XAssets/GfxWorld.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/LeaderboardDef.txt b/src/ZoneCode/Game/IW3/XAssets/LeaderboardDef.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/LoadedSound.txt b/src/ZoneCode/Game/IW3/XAssets/LoadedSound.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/LocalizeEntry.txt b/src/ZoneCode/Game/IW3/XAssets/LocalizeEntry.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/MapEnts.txt b/src/ZoneCode/Game/IW3/XAssets/MapEnts.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/Material.txt b/src/ZoneCode/Game/IW3/XAssets/Material.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/MenuList.txt b/src/ZoneCode/Game/IW3/XAssets/MenuList.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/PhysPreset.txt b/src/ZoneCode/Game/IW3/XAssets/PhysPreset.txt new file mode 100644 index 00000000..7478bc2a --- /dev/null +++ b/src/ZoneCode/Game/IW3/XAssets/PhysPreset.txt @@ -0,0 +1,7 @@ +// ========================================= +// PhysPreset +// ========================================= +use PhysPreset; +set string name; +set name name; +set string sndAliasPrefix; \ No newline at end of file diff --git a/src/ZoneCode/Game/IW3/XAssets/RawFile.txt b/src/ZoneCode/Game/IW3/XAssets/RawFile.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/SndCurve.txt b/src/ZoneCode/Game/IW3/XAssets/SndCurve.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/StringTable.txt b/src/ZoneCode/Game/IW3/XAssets/StringTable.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt b/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/XAnimParts.txt b/src/ZoneCode/Game/IW3/XAssets/XAnimParts.txt new file mode 100644 index 00000000..87a3a48a --- /dev/null +++ b/src/ZoneCode/Game/IW3/XAssets/XAnimParts.txt @@ -0,0 +1,68 @@ +// ========================================= +// XAnimParts +// ========================================= +use XAnimParts; +set string name; +set name name; +set scriptstring names; +set count names boneCount[9]; +set count notify notifyCount; +set count deltaPart 1; +set count dataByte dataByteCount; +set count dataShort dataShortCount; +set count dataInt dataIntCount; +set count randomDataShort randomDataShortCount; +set count randomDataByte randomDataByteCount; +set count randomDataInt randomDataIntCount; +set count indices::_1 indexCount; +set count indices::_2 indexCount; +set condition indices::_1 numframes < 256; +set condition indices::data never; +reorder: + name + names + notify + deltaPart + dataByte + dataShort + dataInt + randomDataShort + randomDataByte + randomDataInt + indices; + +// XAnimNotifyInfo +set scriptstring XAnimNotifyInfo::name; + +// XAnimDeltaPart +use XAnimDeltaPart; +set count trans 1; +set count quat 1; + +// XAnimPartTrans +use XAnimPartTrans; +set condition u::frames size > 0; +set condition u::frames::indices::_1 XAnimParts::numframes < 256; +set arraysize u::frames::indices::_1 size + 1; +set arraysize u::frames::indices::_2 size + 1; +set condition u::frames::frames::_1 smallTrans; +set count u::frames::frames::_1 size + 1; +set count u::frames::frames::_2 size + 1; + +// XAnimPartTransFrames +reorder XAnimPartTransFrames: + indices + frames; + +// XAnimDeltaPartQuat +use XAnimDeltaPartQuat; +set condition u::frames size > 0; +set condition u::frames::indices::_1 XAnimParts::numframes < 256; +set arraysize u::frames::indices::_1 size + 1; +set arraysize u::frames::indices::_2 size + 1; +set count u::frames::frames size + 1; + +// XAnimDeltaPartQuatDataFrames +reorder XAnimDeltaPartQuatDataFrames: + indices + frames; \ No newline at end of file diff --git a/src/ZoneCode/Game/IW3/XAssets/XModel.txt b/src/ZoneCode/Game/IW3/XAssets/XModel.txt new file mode 100644 index 00000000..55b31df1 --- /dev/null +++ b/src/ZoneCode/Game/IW3/XAssets/XModel.txt @@ -0,0 +1,75 @@ +// ========================================= +// XModel +// ========================================= +use XModel; +set string name; +set name name; +set scriptstring boneNames; +set reusable boneNames; +set count boneNames numBones; +set reusable parentList; +set count parentList numBones - numRootBones; +set reusable quats; +set count quats numBones - numRootBones; +set reusable trans; +set count trans numBones - numRootBones; +set reusable partClassification; +set count partClassification numBones; +set reusable baseMat; +set count baseMat numBones; +set count surfs numsurfs; +set count materialHandles numsurfs; +set count collSurfs numCollSurfs; +set count boneInfo numBones; +set reusable physGeoms; +set count physGeoms 1; + +// PhysGeomList +use PhysGeomList; +set reusable geoms; +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; +set block verts0 XFILE_BLOCK_VERTEX; +set count verts0 vertCount; +set reusable vertList; +set count vertList vertListCount; +set reusable triIndices; +set block triIndices XFILE_BLOCK_INDEX; +set count triIndices triCount; +reorder: + zoneHandle + vertInfo + verts0 + vertList + triIndices; + +// XSurfaceVertexInfo +use XSurfaceVertexInfo; +set reusable vertsBlend; +set count vertsBlend vertCount[0] + + 3 * vertCount[1] + + 5 * vertCount[2] + + 7 * vertCount[3]; + +// XRigidVertList +set reusable XRigidVertList::collisionTree; + +// XSurfaceCollisionTree +use XSurfaceCollisionTree; +set count nodes nodeCount; +set count leafs leafCount; + +// XModelCollSurf_s +set count XModelCollSurf_s::collTris numCollTris; \ No newline at end of file diff --git a/src/ZoneCode/Game/IW3/XAssets/clipMap.txt b/src/ZoneCode/Game/IW3/XAssets/clipMap.txt new file mode 100644 index 00000000..349d39a3 --- /dev/null +++ b/src/ZoneCode/Game/IW3/XAssets/clipMap.txt @@ -0,0 +1,70 @@ +// ========================================= +// clipMap_t +// ========================================= +use clipMap_t; +set string name; +set name name; +set reusable planes; +set count planes planeCount; +set count staticModelList numStaticModels; +set count materials numMaterials; +set count brushsides numBrushSides; +set count brushEdges numBrushEdges; +set count nodes numNodes; +set count leafs numLeafs; +set count leafbrushNodes leafbrushNodesCount; +set count leafbrushes numLeafBrushes; +set count leafsurfaces numLeafSurfaces; +set count verts vertCount; +set count triIndices 3 * triCount; +set count triEdgeIsWalkable ((3 * triCount + 31) / 32) * 4; +set count borders borderCount; +set count partitions partitionCount; +set count aabbTrees aabbTreeCount; +set count cmodels numSubModels; +set count brushes numBrushes; +set count brushBounds numBrushes; +set count brushContents numBrushes; +set count smodelNodes smodelNodeCount; +set count dynEntDefList[0] dynEntCount[0]; +set count dynEntDefList[1] dynEntCount[1]; +set block dynEntPoseList XFILE_BLOCK_RUNTIME; +set count dynEntPoseList[0] dynEntCount[0]; +set count dynEntPoseList[1] dynEntCount[1]; +set block dynEntClientList XFILE_BLOCK_RUNTIME; +set count dynEntClientList[0] dynEntCount[0]; +set count dynEntClientList[1] dynEntCount[1]; +set block dynEntCollList XFILE_BLOCK_RUNTIME; +set count dynEntCollList[0] dynEntCount[0]; +set count dynEntCollList[1] dynEntCount[1]; +reorder: + ... + leafs + leafbrushes + leafbrushNodes; +reorder: + ... + brushContents + smodelNodes + mapEnts; + +// ClipMaterial +set string ClipMaterial::name; + +// cNode_t +set reusable cNode_t::plane; + +// cLeafBrushNode_s +use cLeafBrushNode_s; +set condition data::leaf leafBrushCount > 0; +set reusable data::leaf::brushes; +set count data::leaf::brushes leafBrushCount; + +// CollisionPartition +use CollisionPartition; +set reusable borders; + +// cbrush_t +use cbrush_t; +set reusable sides; +set reusable baseAdjacentSide; \ No newline at end of file diff --git a/src/ZoneCode/Game/IW3/XAssets/menuDef_t.txt b/src/ZoneCode/Game/IW3/XAssets/menuDef_t.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCode/Game/IW3/XAssets/snd_alias_list_t.txt b/src/ZoneCode/Game/IW3/XAssets/snd_alias_list_t.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneCommon/Game/IW3/ZoneConstantsIW3.h b/src/ZoneCommon/Game/IW3/ZoneConstantsIW3.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp b/src/ZoneLoading/Game/IW3/ContentLoaderIW3.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneLoading/Game/IW3/ContentLoaderIW3.h b/src/ZoneLoading/Game/IW3/ContentLoaderIW3.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneLoading/Game/IW3/XAssets/gfximage/gfximage_actions.cpp b/src/ZoneLoading/Game/IW3/XAssets/gfximage/gfximage_actions.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneLoading/Game/IW3/XAssets/gfximage/gfximage_actions.h b/src/ZoneLoading/Game/IW3/XAssets/gfximage/gfximage_actions.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneLoading/Game/IW3/XAssets/loadedsound/loadedsound_actions.cpp b/src/ZoneLoading/Game/IW3/XAssets/loadedsound/loadedsound_actions.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneLoading/Game/IW3/XAssets/loadedsound/loadedsound_actions.h b/src/ZoneLoading/Game/IW3/XAssets/loadedsound/loadedsound_actions.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneLoading/Game/IW3/ZoneLoaderFactoryIW3.cpp b/src/ZoneLoading/Game/IW3/ZoneLoaderFactoryIW3.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneLoading/Game/IW3/ZoneLoaderFactoryIW3.h b/src/ZoneLoading/Game/IW3/ZoneLoaderFactoryIW3.h new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneWriting/Game/IW3/ContentWriterIW3.cpp b/src/ZoneWriting/Game/IW3/ContentWriterIW3.cpp new file mode 100644 index 00000000..ac51ab1b --- /dev/null +++ b/src/ZoneWriting/Game/IW3/ContentWriterIW3.cpp @@ -0,0 +1,203 @@ +#include "ContentWriterIW3.h" + +#include +#include + +#include "Game/IW3/XAssets/clipmap_t/clipmap_t_write_db.h" +#include "Game/IW3/XAssets/comworld/comworld_write_db.h" +#include "Game/IW3/XAssets/font_s/font_s_write_db.h" +#include "Game/IW3/XAssets/fxeffectdef/fxeffectdef_write_db.h" +#include "Game/IW3/XAssets/fximpacttable/fximpacttable_write_db.h" +#include "Game/IW3/XAssets/gameworldmp/gameworldmp_write_db.h" +#include "Game/IW3/XAssets/gameworldsp/gameworldsp_write_db.h" +#include "Game/IW3/XAssets/gfximage/gfximage_write_db.h" +#include "Game/IW3/XAssets/gfxlightdef/gfxlightdef_write_db.h" +#include "Game/IW3/XAssets/gfxworld/gfxworld_write_db.h" +#include "Game/IW3/XAssets/loadedsound/loadedsound_write_db.h" +#include "Game/IW3/XAssets/localizeentry/localizeentry_write_db.h" +#include "Game/IW3/XAssets/mapents/mapents_write_db.h" +#include "Game/IW3/XAssets/material/material_write_db.h" +#include "Game/IW3/XAssets/materialtechniqueset/materialtechniqueset_write_db.h" +#include "Game/IW3/XAssets/menudef_t/menudef_t_write_db.h" +#include "Game/IW3/XAssets/menulist/menulist_write_db.h" +#include "Game/IW3/XAssets/physpreset/physpreset_write_db.h" +#include "Game/IW3/XAssets/rawfile/rawfile_write_db.h" +#include "Game/IW3/XAssets/snd_alias_list_t/snd_alias_list_t_write_db.h" +#include "Game/IW3/XAssets/sndcurve/sndcurve_write_db.h" +#include "Game/IW3/XAssets/stringtable/stringtable_write_db.h" +#include "Game/IW3/XAssets/weapondef/weapondef_write_db.h" +#include "Game/IW3/XAssets/xanimparts/xanimparts_write_db.h" +#include "Game/IW3/XAssets/xmodel/xmodel_write_db.h" + +#include "Writing/WritingException.h" + +using namespace IW3; + +ContentWriter::ContentWriter() + : varXAssetList(nullptr), + varXAsset(nullptr), + varScriptStringList(nullptr) +{ +} + +void ContentWriter::CreateXAssetList(XAssetList& xAssetList, MemoryManager& memory) const +{ + if (!m_zone->m_script_strings.Empty()) + { + assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1); + xAssetList.stringList.count = m_zone->m_script_strings.Count(); + xAssetList.stringList.strings = static_cast(memory.Alloc(sizeof(const char*) * m_zone->m_script_strings.Count())); + + for (auto i = 0u; i < m_zone->m_script_strings.Count(); i++) + { + xAssetList.stringList.strings[i] = m_zone->m_script_strings[i].c_str(); + } + } + else + { + xAssetList.stringList.count = 0; + xAssetList.stringList.strings = nullptr; + } + + const auto assetCount = m_zone->m_pools->GetTotalAssetCount(); + if (assetCount > 0) + { + xAssetList.assetCount = assetCount; + xAssetList.assets = static_cast(memory.Alloc(sizeof(XAsset) * assetCount)); + + const auto end = m_zone->m_pools->end(); + auto index = 0u; + for (auto i = m_zone->m_pools->begin(); i != end; ++i) + { + auto& asset = xAssetList.assets[index++]; + asset.type = static_cast((*i)->m_type); + asset.header.data = (*i)->m_ptr; + } + } + else + { + xAssetList.assetCount = 0; + xAssetList.assets = nullptr; + } +} + +void ContentWriter::WriteScriptStringList(const bool atStreamStart) +{ + m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); + + if (atStreamStart) + varScriptStringList = m_stream->Write(varScriptStringList); + + if (varScriptStringList->strings != nullptr) + { + m_stream->Align(alignof(const char*)); + varXString = varScriptStringList->strings; + WriteXStringArray(true, varScriptStringList->count); + + m_stream->MarkFollowing(varScriptStringList->strings); + } + + m_stream->PopBlock(); +} + +void ContentWriter::WriteXAsset(const bool atStreamStart) +{ +#define WRITE_ASSET(type_index, typeName, headerEntry) \ + case type_index: \ + { \ + Writer_##typeName writer(varXAsset->header.headerEntry, m_zone, m_stream); \ + writer.Write(&varXAsset->header.headerEntry); \ + break; \ + } +#define SKIP_ASSET(type_index, typeName, headerEntry) \ + case type_index: \ + break; + + assert(varXAsset != nullptr); + + if (atStreamStart) + varXAsset = m_stream->Write(varXAsset); + + switch (varXAsset->type) + { + WRITE_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset) + WRITE_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts) + WRITE_ASSET(ASSET_TYPE_XMODEL, XModel, model) + WRITE_ASSET(ASSET_TYPE_MATERIAL, Material, material) + WRITE_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet) + WRITE_ASSET(ASSET_TYPE_IMAGE, GfxImage, image) + WRITE_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound) + WRITE_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve) + WRITE_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd) + WRITE_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap) + WRITE_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap) + WRITE_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld) + WRITE_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp) + WRITE_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp) + WRITE_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts) + WRITE_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld) + WRITE_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef) + WRITE_ASSET(ASSET_TYPE_FONT, Font_s, font) + WRITE_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList) + WRITE_ASSET(ASSET_TYPE_MENU, menuDef_t, menu) + WRITE_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize) + WRITE_ASSET(ASSET_TYPE_WEAPON, WeaponDef, weapon) + SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals) + WRITE_ASSET(ASSET_TYPE_FX, FxEffectDef, fx) + WRITE_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx) + WRITE_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile) + WRITE_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable) + + default: + { + std::ostringstream str; + str << "Unsupported asset type: " << varXAsset->type << "."; + throw WritingException(str.str()); + } + } + +#undef WRITE_ASSET +#undef SKIP_ASSET +} + +void ContentWriter::WriteXAssetArray(const bool atStreamStart, const size_t count) +{ + assert(varXAsset != nullptr); + + if (atStreamStart) + varXAsset = m_stream->Write(varXAsset, count); + + for (size_t index = 0; index < count; index++) + { + WriteXAsset(false); + varXAsset++; + } +} + +void ContentWriter::WriteContent(Zone* zone, IZoneOutputStream* stream) +{ + m_zone = zone; + m_stream = stream; + + m_stream->PushBlock(XFILE_BLOCK_VIRTUAL); + + MemoryManager memory; + XAssetList assetList{}; + + CreateXAssetList(assetList, memory); + + varXAssetList = static_cast(m_stream->WriteDataRaw(&assetList, sizeof(assetList))); + + varScriptStringList = &varXAssetList->stringList; + WriteScriptStringList(false); + + if (varXAssetList->assets != nullptr) + { + m_stream->Align(alignof(XAsset)); + varXAsset = varXAssetList->assets; + WriteXAssetArray(true, varXAssetList->assetCount); + m_stream->MarkFollowing(varXAssetList->assets); + } + + m_stream->PopBlock(); +} diff --git a/src/ZoneWriting/Game/IW3/ContentWriterIW3.h b/src/ZoneWriting/Game/IW3/ContentWriterIW3.h new file mode 100644 index 00000000..45202925 --- /dev/null +++ b/src/ZoneWriting/Game/IW3/ContentWriterIW3.h @@ -0,0 +1,26 @@ +#pragma once +#include "Writing/ContentWriterBase.h" +#include "Writing/IContentWritingEntryPoint.h" +#include "Game/IW3/IW3.h" + +namespace IW3 +{ + class ContentWriter final : public ContentWriterBase, public IContentWritingEntryPoint + { + XAssetList* varXAssetList; + XAsset* varXAsset; + ScriptStringList* varScriptStringList; + + void CreateXAssetList(XAssetList& xAssetList, MemoryManager& memory) const; + + void WriteScriptStringList(bool atStreamStart); + + void WriteXAsset(bool atStreamStart); + void WriteXAssetArray(bool atStreamStart, size_t count); + + public: + ContentWriter(); + + void WriteContent(Zone* zone, IZoneOutputStream* stream) override; + }; +} diff --git a/src/ZoneWriting/Game/IW3/ZoneWriterFactoryIW3.cpp b/src/ZoneWriting/Game/IW3/ZoneWriterFactoryIW3.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/ZoneWriting/Game/IW3/ZoneWriterFactoryIW3.h b/src/ZoneWriting/Game/IW3/ZoneWriterFactoryIW3.h new file mode 100644 index 00000000..e69de29b