From 124e86387b973e4854224d97a6e971563328d519 Mon Sep 17 00:00:00 2001 From: /dev/root Date: Fri, 25 Nov 2016 13:00:48 +0100 Subject: [PATCH] [General] Fixed line endings - converted all line endings in cpp/hpp files to dos --- src/Components/Modules/AntiCheat.hpp | 2 +- src/Components/Modules/ArenaLength.hpp | 2 +- src/Components/Modules/AssetHandler.hpp | 2 +- src/Components/Modules/Auth.hpp | 4 +- src/Components/Modules/Bans.hpp | 2 +- src/Components/Modules/Colors.hpp | 76 +- src/Components/Modules/Command.hpp | 2 +- src/Components/Modules/ConnectProtocol.cpp | 2 +- src/Components/Modules/ConnectProtocol.hpp | 44 +- src/Components/Modules/D3D9Ex.hpp | 344 +-- src/Components/Modules/Dedicated.hpp | 2 +- src/Components/Modules/Discovery.hpp | 2 +- src/Components/Modules/Download.hpp | 168 +- src/Components/Modules/Dvar.hpp | 114 +- src/Components/Modules/FastFiles.hpp | 88 +- src/Components/Modules/FileSystem.cpp | 58 +- src/Components/Modules/FileSystem.hpp | 134 +- src/Components/Modules/Flags.hpp | 36 +- src/Components/Modules/Gametypes.hpp | 34 +- src/Components/Modules/IPCPipe.hpp | 152 +- src/Components/Modules/Lean.hpp | 2 +- src/Components/Modules/Logger.hpp | 84 +- src/Components/Modules/Maps.cpp | 36 +- src/Components/Modules/Maps.hpp | 110 +- src/Components/Modules/Materials.hpp | 58 +- src/Components/Modules/Menus.hpp | 116 +- src/Components/Modules/ModList.hpp | 2 +- src/Components/Modules/MusicalTalent.hpp | 34 +- src/Components/Modules/Network.hpp | 2 +- src/Components/Modules/News.hpp | 44 +- src/Components/Modules/Node.hpp | 2 +- src/Components/Modules/Party.hpp | 96 +- src/Components/Modules/PlayerName.hpp | 32 +- src/Components/Modules/Playlist.hpp | 60 +- src/Components/Modules/QuickPatch.hpp | 2 +- src/Components/Modules/RCon.hpp | 58 +- src/Components/Modules/RawFiles.hpp | 24 +- src/Components/Modules/Renderer.hpp | 2 +- src/Components/Modules/Script.hpp | 68 +- src/Components/Modules/ServerInfo.hpp | 82 +- src/Components/Modules/ServerList.hpp | 266 +- src/Components/Modules/Singleton.hpp | 30 +- src/Components/Modules/Slowmotion.hpp | 2 +- src/Components/Modules/StringTable.hpp | 36 +- src/Components/Modules/StructuredData.hpp | 70 +- src/Components/Modules/Theatre.hpp | 2 +- src/Components/Modules/Toast.hpp | 2 +- src/Components/Modules/UIFeeder.hpp | 108 +- src/Components/Modules/UIScript.hpp | 86 +- src/Components/Modules/Weapon.hpp | 26 +- src/Components/Modules/Window.hpp | 68 +- src/Components/Modules/ZoneBuilder.hpp | 178 +- src/Components/Modules/Zones.cpp | 2616 ++++++++++---------- src/Components/Modules/Zones.hpp | 6 +- src/Game/Functions.cpp | 60 +- src/Game/Functions.hpp | 136 +- src/Main.cpp | 160 +- src/Steam/Interfaces/SteamMatchmaking.cpp | 10 +- src/Steam/Interfaces/SteamUser.cpp | 8 +- src/Steam/Interfaces/SteamUtils.cpp | 4 +- src/Utils/Time.cpp | 28 +- src/Utils/Time.hpp | 32 +- 62 files changed, 3058 insertions(+), 3058 deletions(-) diff --git a/src/Components/Modules/AntiCheat.hpp b/src/Components/Modules/AntiCheat.hpp index ec6bec96..342731f4 100644 --- a/src/Components/Modules/AntiCheat.hpp +++ b/src/Components/Modules/AntiCheat.hpp @@ -13,7 +13,7 @@ namespace Components #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) const char* getName() { return "AntiCheat"; }; -#endif +#endif static void CrashClient(); diff --git a/src/Components/Modules/ArenaLength.hpp b/src/Components/Modules/ArenaLength.hpp index 86e1d08e..b8e8bf45 100644 --- a/src/Components/Modules/ArenaLength.hpp +++ b/src/Components/Modules/ArenaLength.hpp @@ -6,7 +6,7 @@ namespace Components ArenaLength(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "ArenaLength"; }; + const char* getName() { return "ArenaLength"; }; #endif static Game::newMapArena_t NewArenas[128]; diff --git a/src/Components/Modules/AssetHandler.hpp b/src/Components/Modules/AssetHandler.hpp index e7b5909c..e80ec0bd 100644 --- a/src/Components/Modules/AssetHandler.hpp +++ b/src/Components/Modules/AssetHandler.hpp @@ -22,7 +22,7 @@ namespace Components #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) const char* getName() { return "AssetHandler"; }; -#endif +#endif static void OnFind(Game::XAssetType type, Callback* callback); static void OnLoad(RestrictCallback* callback); diff --git a/src/Components/Modules/Auth.hpp b/src/Components/Modules/Auth.hpp index d5406306..0703eafd 100644 --- a/src/Components/Modules/Auth.hpp +++ b/src/Components/Modules/Auth.hpp @@ -7,8 +7,8 @@ namespace Components ~Auth(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Auth"; }; -#endif + const char* getName() { return "Auth"; }; +#endif bool unitTest(); diff --git a/src/Components/Modules/Bans.hpp b/src/Components/Modules/Bans.hpp index 279b36a5..b8e79ab0 100644 --- a/src/Components/Modules/Bans.hpp +++ b/src/Components/Modules/Bans.hpp @@ -9,7 +9,7 @@ namespace Components ~Bans(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Bans"; }; + const char* getName() { return "Bans"; }; #endif static void BanClientNum(int num, std::string reason); diff --git a/src/Components/Modules/Colors.hpp b/src/Components/Modules/Colors.hpp index a9018d7a..8d5354c9 100644 --- a/src/Components/Modules/Colors.hpp +++ b/src/Components/Modules/Colors.hpp @@ -1,40 +1,40 @@ -namespace Components -{ - class Colors : public Component - { - public: - Colors(); +namespace Components +{ + class Colors : public Component + { + public: + Colors(); ~Colors(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Colors"; }; -#endif - - static void Strip(const char* in, char* out, int max); - static std::string Strip(std::string in); - - static char Add(uint8_t r, uint8_t g, uint8_t b); - - private: - struct HsvColor - { - unsigned char h; - unsigned char s; - unsigned char v; - }; - - static Dvar::Var NewColors; - - static DWORD HsvToRgb(HsvColor hsv); - - static void ClientUserinfoChanged(); - static char* GetClientName(int localClientNum, int index, char *buf, size_t size); - static void PatchColorLimit(char limit); - - static unsigned int ColorIndex(unsigned char); - static void LookupColor(DWORD* color, char index); - static void LookupColorStub(); - static char* CleanStrStub(char* string); - static std::vector ColorTable; - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Colors"; }; +#endif + + static void Strip(const char* in, char* out, int max); + static std::string Strip(std::string in); + + static char Add(uint8_t r, uint8_t g, uint8_t b); + + private: + struct HsvColor + { + unsigned char h; + unsigned char s; + unsigned char v; + }; + + static Dvar::Var NewColors; + + static DWORD HsvToRgb(HsvColor hsv); + + static void ClientUserinfoChanged(); + static char* GetClientName(int localClientNum, int index, char *buf, size_t size); + static void PatchColorLimit(char limit); + + static unsigned int ColorIndex(unsigned char); + static void LookupColor(DWORD* color, char index); + static void LookupColorStub(); + static char* CleanStrStub(char* string); + static std::vector ColorTable; + }; +} diff --git a/src/Components/Modules/Command.hpp b/src/Components/Modules/Command.hpp index 26a97d3b..4ac7e55f 100644 --- a/src/Components/Modules/Command.hpp +++ b/src/Components/Modules/Command.hpp @@ -27,7 +27,7 @@ namespace Components ~Command(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Command"; }; + const char* getName() { return "Command"; }; #endif static Game::cmd_function_t* Allocate(); diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 1cf86385..cf785bde 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -2,7 +2,7 @@ namespace Components { - bool ConnectProtocol::Evaluated = false; + bool ConnectProtocol::Evaluated = false; std::string ConnectProtocol::ConnectString; bool ConnectProtocol::IsEvaluated() diff --git a/src/Components/Modules/ConnectProtocol.hpp b/src/Components/Modules/ConnectProtocol.hpp index 0e20d22f..a73bd59b 100644 --- a/src/Components/Modules/ConnectProtocol.hpp +++ b/src/Components/Modules/ConnectProtocol.hpp @@ -1,24 +1,24 @@ -namespace Components -{ - class ConnectProtocol : public Component - { - public: +namespace Components +{ + class ConnectProtocol : public Component + { + public: ConnectProtocol(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "ConnectProtocol"; }; -#endif - - static bool IsEvaluated(); - static bool Used(); - - private: - static bool Evaluated; - static std::string ConnectString; - - static void EvaluateProtocol(); - static bool InstallProtocol(); - - static void Invocation(); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "ConnectProtocol"; }; +#endif + + static bool IsEvaluated(); + static bool Used(); + + private: + static bool Evaluated; + static std::string ConnectString; + + static void EvaluateProtocol(); + static bool InstallProtocol(); + + static void Invocation(); + }; +} diff --git a/src/Components/Modules/D3D9Ex.hpp b/src/Components/Modules/D3D9Ex.hpp index 69657005..bb97cf52 100644 --- a/src/Components/Modules/D3D9Ex.hpp +++ b/src/Components/Modules/D3D9Ex.hpp @@ -1,174 +1,174 @@ -namespace Components -{ - class D3D9Ex : public Component - { - public: +namespace Components +{ + class D3D9Ex : public Component + { + public: D3D9Ex(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "D3D9Ex"; }; -#endif - - private: - - class D3D9Device : public IDirect3DDevice9 - { - public: - D3D9Device(IDirect3DDevice9* pOriginal) : m_pIDirect3DDevice9(pOriginal) {}; - virtual ~D3D9Device(void) {}; - - HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); - ULONG __stdcall AddRef(void); - ULONG __stdcall Release(void); - HRESULT __stdcall TestCooperativeLevel(void); - UINT __stdcall GetAvailableTextureMem(void); - HRESULT __stdcall EvictManagedResources(void); - HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9); - HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps); - HRESULT __stdcall GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode); - HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters); - HRESULT __stdcall SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap); - void __stdcall SetCursorPosition(int X, int Y, DWORD Flags); - BOOL __stdcall ShowCursor(BOOL bShow); - HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain); - HRESULT __stdcall GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain); - UINT __stdcall GetNumberOfSwapChains(void); - HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters); - HRESULT __stdcall Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion); - HRESULT __stdcall GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer); - HRESULT __stdcall GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus); - HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs); - void __stdcall SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp); - void __stdcall GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp); - HRESULT __stdcall CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle); - HRESULT __stdcall CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle); - HRESULT __stdcall CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle); - HRESULT __stdcall CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); - HRESULT __stdcall CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle); - HRESULT __stdcall CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); - HRESULT __stdcall CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); - HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint); - HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture); - HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface); - HRESULT __stdcall GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface); - HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter); - HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color); - HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); - HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget); - HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget); - HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil); - HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface); - HRESULT __stdcall BeginScene(void); - HRESULT __stdcall EndScene(void); - HRESULT __stdcall Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil); - HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); - HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix); - HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); - HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport); - HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport); - HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial); - HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial); - HRESULT __stdcall SetLight(DWORD Index, CONST D3DLIGHT9* pLight); - HRESULT __stdcall GetLight(DWORD Index, D3DLIGHT9* pLight); - HRESULT __stdcall LightEnable(DWORD Index, BOOL Enable); - HRESULT __stdcall GetLightEnable(DWORD Index, BOOL* pEnable); - HRESULT __stdcall SetClipPlane(DWORD Index, CONST float* pPlane); - HRESULT __stdcall GetClipPlane(DWORD Index, float* pPlane); - HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State, DWORD Value); - HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue); - HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB); - HRESULT __stdcall BeginStateBlock(void); - HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB); - HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus); - HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus); - HRESULT __stdcall GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture); - HRESULT __stdcall SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture); - HRESULT __stdcall GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue); - HRESULT __stdcall SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); - HRESULT __stdcall GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue); - HRESULT __stdcall SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); - HRESULT __stdcall ValidateDevice(DWORD* pNumPasses); - HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries); - HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries); - HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber); - HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber); - HRESULT __stdcall SetScissorRect(CONST RECT* pRect); - HRESULT __stdcall GetScissorRect(RECT* pRect); - HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware); - BOOL __stdcall GetSoftwareVertexProcessing(void); - HRESULT __stdcall SetNPatchMode(float nSegments); - float __stdcall GetNPatchMode(void); - HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount); - HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount); - HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); - HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); - HRESULT __stdcall ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags); - HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl); - HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl); - HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl); - HRESULT __stdcall SetFVF(DWORD FVF); - HRESULT __stdcall GetFVF(DWORD* pFVF); - HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader); - HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader); - HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader); - HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); - HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); - HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); - HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); - HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); - HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); - HRESULT __stdcall SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride); - HRESULT __stdcall GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride); - HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber, UINT Divider); - HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber, UINT* Divider); - HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData); - HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData); - HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader); - HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader); - HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader); - HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); - HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); - HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); - HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); - HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); - HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); - HRESULT __stdcall DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo); - HRESULT __stdcall DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo); - HRESULT __stdcall DeletePatch(UINT Handle); - HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery); - - private: - IDirect3DDevice9 *m_pIDirect3DDevice9; - }; - - class D3D9 : public IDirect3D9 - { - public: - D3D9(IDirect3D9Ex *pOriginal) : m_pIDirect3D9(pOriginal) {}; - virtual ~D3D9(void) {}; - - HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); - ULONG __stdcall AddRef(void); - ULONG __stdcall Release(void); - HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction); - UINT __stdcall GetAdapterCount(void); - HRESULT __stdcall GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier); - UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format); - HRESULT __stdcall EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode); - HRESULT __stdcall GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode); - HRESULT __stdcall CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed); - HRESULT __stdcall CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); - HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels); - HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); - HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); - HRESULT __stdcall GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps); - HMONITOR __stdcall GetAdapterMonitor(UINT Adapter); - HRESULT __stdcall CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface); - - private: - IDirect3D9 *m_pIDirect3D9; - }; - - static IDirect3D9* __stdcall Direct3DCreate9Stub(UINT sdk); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "D3D9Ex"; }; +#endif + + private: + + class D3D9Device : public IDirect3DDevice9 + { + public: + D3D9Device(IDirect3DDevice9* pOriginal) : m_pIDirect3DDevice9(pOriginal) {}; + virtual ~D3D9Device(void) {}; + + HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); + ULONG __stdcall AddRef(void); + ULONG __stdcall Release(void); + HRESULT __stdcall TestCooperativeLevel(void); + UINT __stdcall GetAvailableTextureMem(void); + HRESULT __stdcall EvictManagedResources(void); + HRESULT __stdcall GetDirect3D(IDirect3D9** ppD3D9); + HRESULT __stdcall GetDeviceCaps(D3DCAPS9* pCaps); + HRESULT __stdcall GetDisplayMode(UINT iSwapChain, D3DDISPLAYMODE* pMode); + HRESULT __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters); + HRESULT __stdcall SetCursorProperties(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap); + void __stdcall SetCursorPosition(int X, int Y, DWORD Flags); + BOOL __stdcall ShowCursor(BOOL bShow); + HRESULT __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain); + HRESULT __stdcall GetSwapChain(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain); + UINT __stdcall GetNumberOfSwapChains(void); + HRESULT __stdcall Reset(D3DPRESENT_PARAMETERS* pPresentationParameters); + HRESULT __stdcall Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion); + HRESULT __stdcall GetBackBuffer(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer); + HRESULT __stdcall GetRasterStatus(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus); + HRESULT __stdcall SetDialogBoxMode(BOOL bEnableDialogs); + void __stdcall SetGammaRamp(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp); + void __stdcall GetGammaRamp(UINT iSwapChain, D3DGAMMARAMP* pRamp); + HRESULT __stdcall CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle); + HRESULT __stdcall CreateVolumeTexture(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle); + HRESULT __stdcall CreateCubeTexture(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle); + HRESULT __stdcall CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); + HRESULT __stdcall CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle); + HRESULT __stdcall CreateRenderTarget(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + HRESULT __stdcall CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + HRESULT __stdcall UpdateSurface(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint); + HRESULT __stdcall UpdateTexture(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture); + HRESULT __stdcall GetRenderTargetData(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface); + HRESULT __stdcall GetFrontBufferData(UINT iSwapChain, IDirect3DSurface9* pDestSurface); + HRESULT __stdcall StretchRect(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter); + HRESULT __stdcall ColorFill(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color); + HRESULT __stdcall CreateOffscreenPlainSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); + HRESULT __stdcall SetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget); + HRESULT __stdcall GetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget); + HRESULT __stdcall SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil); + HRESULT __stdcall GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface); + HRESULT __stdcall BeginScene(void); + HRESULT __stdcall EndScene(void); + HRESULT __stdcall Clear(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil); + HRESULT __stdcall SetTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); + HRESULT __stdcall GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix); + HRESULT __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix); + HRESULT __stdcall SetViewport(CONST D3DVIEWPORT9* pViewport); + HRESULT __stdcall GetViewport(D3DVIEWPORT9* pViewport); + HRESULT __stdcall SetMaterial(CONST D3DMATERIAL9* pMaterial); + HRESULT __stdcall GetMaterial(D3DMATERIAL9* pMaterial); + HRESULT __stdcall SetLight(DWORD Index, CONST D3DLIGHT9* pLight); + HRESULT __stdcall GetLight(DWORD Index, D3DLIGHT9* pLight); + HRESULT __stdcall LightEnable(DWORD Index, BOOL Enable); + HRESULT __stdcall GetLightEnable(DWORD Index, BOOL* pEnable); + HRESULT __stdcall SetClipPlane(DWORD Index, CONST float* pPlane); + HRESULT __stdcall GetClipPlane(DWORD Index, float* pPlane); + HRESULT __stdcall SetRenderState(D3DRENDERSTATETYPE State, DWORD Value); + HRESULT __stdcall GetRenderState(D3DRENDERSTATETYPE State, DWORD* pValue); + HRESULT __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB); + HRESULT __stdcall BeginStateBlock(void); + HRESULT __stdcall EndStateBlock(IDirect3DStateBlock9** ppSB); + HRESULT __stdcall SetClipStatus(CONST D3DCLIPSTATUS9* pClipStatus); + HRESULT __stdcall GetClipStatus(D3DCLIPSTATUS9* pClipStatus); + HRESULT __stdcall GetTexture(DWORD Stage, IDirect3DBaseTexture9** ppTexture); + HRESULT __stdcall SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture); + HRESULT __stdcall GetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue); + HRESULT __stdcall SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); + HRESULT __stdcall GetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue); + HRESULT __stdcall SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); + HRESULT __stdcall ValidateDevice(DWORD* pNumPasses); + HRESULT __stdcall SetPaletteEntries(UINT PaletteNumber, CONST PALETTEENTRY* pEntries); + HRESULT __stdcall GetPaletteEntries(UINT PaletteNumber, PALETTEENTRY* pEntries); + HRESULT __stdcall SetCurrentTexturePalette(UINT PaletteNumber); + HRESULT __stdcall GetCurrentTexturePalette(UINT *PaletteNumber); + HRESULT __stdcall SetScissorRect(CONST RECT* pRect); + HRESULT __stdcall GetScissorRect(RECT* pRect); + HRESULT __stdcall SetSoftwareVertexProcessing(BOOL bSoftware); + BOOL __stdcall GetSoftwareVertexProcessing(void); + HRESULT __stdcall SetNPatchMode(float nSegments); + float __stdcall GetNPatchMode(void); + HRESULT __stdcall DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount); + HRESULT __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount); + HRESULT __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); + HRESULT __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride); + HRESULT __stdcall ProcessVertices(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags); + HRESULT __stdcall CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl); + HRESULT __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl); + HRESULT __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9** ppDecl); + HRESULT __stdcall SetFVF(DWORD FVF); + HRESULT __stdcall GetFVF(DWORD* pFVF); + HRESULT __stdcall CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader); + HRESULT __stdcall SetVertexShader(IDirect3DVertexShader9* pShader); + HRESULT __stdcall GetVertexShader(IDirect3DVertexShader9** ppShader); + HRESULT __stdcall SetVertexShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); + HRESULT __stdcall GetVertexShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); + HRESULT __stdcall SetVertexShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); + HRESULT __stdcall GetVertexShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); + HRESULT __stdcall SetVertexShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); + HRESULT __stdcall GetVertexShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); + HRESULT __stdcall SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride); + HRESULT __stdcall GetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride); + HRESULT __stdcall SetStreamSourceFreq(UINT StreamNumber, UINT Divider); + HRESULT __stdcall GetStreamSourceFreq(UINT StreamNumber, UINT* Divider); + HRESULT __stdcall SetIndices(IDirect3DIndexBuffer9* pIndexData); + HRESULT __stdcall GetIndices(IDirect3DIndexBuffer9** ppIndexData); + HRESULT __stdcall CreatePixelShader(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader); + HRESULT __stdcall SetPixelShader(IDirect3DPixelShader9* pShader); + HRESULT __stdcall GetPixelShader(IDirect3DPixelShader9** ppShader); + HRESULT __stdcall SetPixelShaderConstantF(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount); + HRESULT __stdcall GetPixelShaderConstantF(UINT StartRegister, float* pConstantData, UINT Vector4fCount); + HRESULT __stdcall SetPixelShaderConstantI(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount); + HRESULT __stdcall GetPixelShaderConstantI(UINT StartRegister, int* pConstantData, UINT Vector4iCount); + HRESULT __stdcall SetPixelShaderConstantB(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); + HRESULT __stdcall GetPixelShaderConstantB(UINT StartRegister, BOOL* pConstantData, UINT BoolCount); + HRESULT __stdcall DrawRectPatch(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo); + HRESULT __stdcall DrawTriPatch(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo); + HRESULT __stdcall DeletePatch(UINT Handle); + HRESULT __stdcall CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery); + + private: + IDirect3DDevice9 *m_pIDirect3DDevice9; + }; + + class D3D9 : public IDirect3D9 + { + public: + D3D9(IDirect3D9Ex *pOriginal) : m_pIDirect3D9(pOriginal) {}; + virtual ~D3D9(void) {}; + + HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObj); + ULONG __stdcall AddRef(void); + ULONG __stdcall Release(void); + HRESULT __stdcall RegisterSoftwareDevice(void* pInitializeFunction); + UINT __stdcall GetAdapterCount(void); + HRESULT __stdcall GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier); + UINT __stdcall GetAdapterModeCount(UINT Adapter, D3DFORMAT Format); + HRESULT __stdcall EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode); + HRESULT __stdcall GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode); + HRESULT __stdcall CheckDeviceType(UINT iAdapter, D3DDEVTYPE DevType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed); + HRESULT __stdcall CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); + HRESULT __stdcall CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels); + HRESULT __stdcall CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); + HRESULT __stdcall CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); + HRESULT __stdcall GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps); + HMONITOR __stdcall GetAdapterMonitor(UINT Adapter); + HRESULT __stdcall CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface); + + private: + IDirect3D9 *m_pIDirect3D9; + }; + + static IDirect3D9* __stdcall Direct3DCreate9Stub(UINT sdk); + }; +} diff --git a/src/Components/Modules/Dedicated.hpp b/src/Components/Modules/Dedicated.hpp index 13f6081a..03504676 100644 --- a/src/Components/Modules/Dedicated.hpp +++ b/src/Components/Modules/Dedicated.hpp @@ -9,7 +9,7 @@ namespace Components ~Dedicated(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Dedicated"; }; + const char* getName() { return "Dedicated"; }; #endif static bool IsEnabled(); diff --git a/src/Components/Modules/Discovery.hpp b/src/Components/Modules/Discovery.hpp index 12493337..551b0490 100644 --- a/src/Components/Modules/Discovery.hpp +++ b/src/Components/Modules/Discovery.hpp @@ -7,7 +7,7 @@ namespace Components ~Discovery(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Discovery"; }; + const char* getName() { return "Discovery"; }; #endif static void Perform(); diff --git a/src/Components/Modules/Download.hpp b/src/Components/Modules/Download.hpp index bb84cf8b..54999b2d 100644 --- a/src/Components/Modules/Download.hpp +++ b/src/Components/Modules/Download.hpp @@ -1,69 +1,69 @@ -namespace Components -{ - class Download : public Component - { - public: - Download(); +namespace Components +{ + class Download : public Component + { + public: + Download(); ~Download(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Download"; }; -#endif - - static void InitiateClientDownload(std::string mod); - - private: - class ClientDownload - { - public: - ClientDownload() : valid(false), running(false), terminateThread(false), totalBytes(0), downBytes(0), lastTimeStamp(0), timeStampBytes(0) {} - ~ClientDownload() { this->clear(); } - - bool running; - bool valid; - bool terminateThread; - mg_mgr mgr; - Network::Address target; - std::string mod; - std::thread thread; - - size_t totalBytes; - size_t downBytes; - - int lastTimeStamp; - size_t timeStampBytes; - - class File - { - public: - std::string name; - std::string hash; - size_t size; - }; - - std::vector files; - - void clear() - { - this->terminateThread = true; - - if (this->thread.joinable()) - { - this->thread.join(); - } - - this->running = false; - this->mod.clear(); - this->files.clear(); - - if (this->valid) - { - this->valid = false; - mg_mgr_free(&(this->mgr)); - } - } - }; - +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Download"; }; +#endif + + static void InitiateClientDownload(std::string mod); + + private: + class ClientDownload + { + public: + ClientDownload() : valid(false), running(false), terminateThread(false), totalBytes(0), downBytes(0), lastTimeStamp(0), timeStampBytes(0) {} + ~ClientDownload() { this->clear(); } + + bool running; + bool valid; + bool terminateThread; + mg_mgr mgr; + Network::Address target; + std::string mod; + std::thread thread; + + size_t totalBytes; + size_t downBytes; + + int lastTimeStamp; + size_t timeStampBytes; + + class File + { + public: + std::string name; + std::string hash; + size_t size; + }; + + std::vector files; + + void clear() + { + this->terminateThread = true; + + if (this->thread.joinable()) + { + this->thread.join(); + } + + this->running = false; + this->mod.clear(); + this->files.clear(); + + if (this->valid) + { + this->valid = false; + mg_mgr_free(&(this->mgr)); + } + } + }; + class FileDownload { public: @@ -75,23 +75,23 @@ namespace Components unsigned int index; std::string buffer; size_t receivedBytes; - }; - - static mg_mgr Mgr; - static ClientDownload CLDownload; - - static void EventHandler(mg_connection *nc, int ev, void *ev_data); - static void ListHandler(mg_connection *nc, int ev, void *ev_data); - static void FileHandler(mg_connection *nc, int ev, void *ev_data); - static void InfoHandler(mg_connection *nc, int ev, void *ev_data); - static void DownloadHandler(mg_connection *nc, int ev, void *ev_data); - - static bool IsClient(mg_connection *nc); - static Game::client_t* GetClient(mg_connection *nc); - static void Forbid(mg_connection *nc); - - static void ModDownloader(ClientDownload* download); - static bool ParseModList(ClientDownload* download, std::string list); - static bool DownloadFile(ClientDownload* download, unsigned int index); - }; -} + }; + + static mg_mgr Mgr; + static ClientDownload CLDownload; + + static void EventHandler(mg_connection *nc, int ev, void *ev_data); + static void ListHandler(mg_connection *nc, int ev, void *ev_data); + static void FileHandler(mg_connection *nc, int ev, void *ev_data); + static void InfoHandler(mg_connection *nc, int ev, void *ev_data); + static void DownloadHandler(mg_connection *nc, int ev, void *ev_data); + + static bool IsClient(mg_connection *nc); + static Game::client_t* GetClient(mg_connection *nc); + static void Forbid(mg_connection *nc); + + static void ModDownloader(ClientDownload* download); + static bool ParseModList(ClientDownload* download, std::string list); + static bool DownloadFile(ClientDownload* download, unsigned int index); + }; +} diff --git a/src/Components/Modules/Dvar.hpp b/src/Components/Modules/Dvar.hpp index 71a5cdfb..4e0e5fda 100644 --- a/src/Components/Modules/Dvar.hpp +++ b/src/Components/Modules/Dvar.hpp @@ -1,59 +1,59 @@ -namespace Components -{ - class Dvar : public Component - { - public: - typedef void(Callback)(); - - class Flag - { - public: - Flag(Game::dvar_flag flag) : val(flag){}; - Flag(int flag) : Flag(static_cast(flag)) {}; - - Game::dvar_flag val; - }; - - class Var - { - public: - Var() : dvar(0) {}; - Var(const Var &obj) { this->dvar = obj.dvar; }; - Var(Game::dvar_t* _dvar) : dvar(_dvar) {}; - Var(std::string dvarName); - - template T get(); - - void set(char* string); - void set(const char* string); - void set(std::string string); - - void set(int integer); - void set(float value); - - // TODO: Add others - void setRaw(int integer); - - private: - Game::dvar_t* dvar; - }; - - Dvar(); +namespace Components +{ + class Dvar : public Component + { + public: + typedef void(Callback)(); + + class Flag + { + public: + Flag(Game::dvar_flag flag) : val(flag){}; + Flag(int flag) : Flag(static_cast(flag)) {}; + + Game::dvar_flag val; + }; + + class Var + { + public: + Var() : dvar(0) {}; + Var(const Var &obj) { this->dvar = obj.dvar; }; + Var(Game::dvar_t* _dvar) : dvar(_dvar) {}; + Var(std::string dvarName); + + template T get(); + + void set(char* string); + void set(const char* string); + void set(std::string string); + + void set(int integer); + void set(float value); + + // TODO: Add others + void setRaw(int integer); + + private: + Game::dvar_t* dvar; + }; + + Dvar(); ~Dvar(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Dvar"; }; -#endif - - static void OnInit(Callback* callback); - - // Only strings and bools use this type of declaration - template static Var Register(const char* name, T value, Flag flag, const char* description); - template static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description); - - private: - static wink::signal> RegistrationSignal; - - static Game::dvar_t* RegisterName(const char* name, const char* default, Game::dvar_flag flag, const char* description); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Dvar"; }; +#endif + + static void OnInit(Callback* callback); + + // Only strings and bools use this type of declaration + template static Var Register(const char* name, T value, Flag flag, const char* description); + template static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description); + + private: + static wink::signal> RegistrationSignal; + + static Game::dvar_t* RegisterName(const char* name, const char* default, Game::dvar_flag flag, const char* description); + }; +} diff --git a/src/Components/Modules/FastFiles.hpp b/src/Components/Modules/FastFiles.hpp index 47f5e48e..f1cca893 100644 --- a/src/Components/Modules/FastFiles.hpp +++ b/src/Components/Modules/FastFiles.hpp @@ -1,50 +1,50 @@ -namespace Components -{ - class FastFiles : public Component - { - public: - FastFiles(); +namespace Components +{ + class FastFiles : public Component + { + public: + FastFiles(); ~FastFiles(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "FastFiles"; }; -#endif - - static void AddZonePath(std::string path); - static std::string Current(); - static bool Ready(); - static bool Exists(std::string file); - - static void LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); - - static unsigned char ZoneKey[1191]; - - private: - union Key - { +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "FastFiles"; }; +#endif + + static void AddZonePath(std::string path); + static std::string Current(); + static bool Ready(); + static bool Exists(std::string file); + + static void LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); + + static unsigned char ZoneKey[1191]; + + private: + union Key + { struct { unsigned char key[24]; unsigned char iv[16]; - }; - - unsigned char data[1]; - }; - - static Key CurrentKey; - static symmetric_CTR CurrentCTR; - static std::vector ZonePaths; - static const char* GetZoneLocation(const char* file); - static void LoadInitialZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); - static void LoadDLCUIZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); - static void LoadGfxZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); - - static void ReadVersionStub(unsigned int* version, int size); - - static void AuthLoadInitCrypto(); - static int AuthLoadInflateCompare(unsigned char* buffer, int length, unsigned char* ivValue); - static void AuthLoadInflateDecryptBase(); - static void AuthLoadInflateDecryptBaseFunc(unsigned char* buffer); - static int InflateInitDecrypt(z_streamp strm, const char *version, int stream_size); - }; -} + }; + + unsigned char data[1]; + }; + + static Key CurrentKey; + static symmetric_CTR CurrentCTR; + static std::vector ZonePaths; + static const char* GetZoneLocation(const char* file); + static void LoadInitialZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); + static void LoadDLCUIZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); + static void LoadGfxZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); + + static void ReadVersionStub(unsigned int* version, int size); + + static void AuthLoadInitCrypto(); + static int AuthLoadInflateCompare(unsigned char* buffer, int length, unsigned char* ivValue); + static void AuthLoadInflateDecryptBase(); + static void AuthLoadInflateDecryptBaseFunc(unsigned char* buffer); + static int InflateInitDecrypt(z_streamp strm, const char *version, int stream_size); + }; +} diff --git a/src/Components/Modules/FileSystem.cpp b/src/Components/Modules/FileSystem.cpp index ba572cef..fd5cfecb 100644 --- a/src/Components/Modules/FileSystem.cpp +++ b/src/Components/Modules/FileSystem.cpp @@ -20,11 +20,11 @@ namespace Components } - FileSystem::FileReader::FileReader(std::string file) : name(file), handle(0) - { - this->size = Game::FS_FOpenFileReadCurrentThread(this->name.data(), &this->handle); - } - + FileSystem::FileReader::FileReader(std::string file) : name(file), handle(0) + { + this->size = Game::FS_FOpenFileReadCurrentThread(this->name.data(), &this->handle); + } + FileSystem::FileReader::~FileReader() { if (this->exists() && this->handle) @@ -161,33 +161,33 @@ namespace Components Game::FS_Remove(path); } - int FileSystem::ReadFile(const char* path, char** buffer) - { - if (!buffer) return -1; - else *buffer = nullptr; - if (!path) return -1; - - std::lock_guard _(FileSystem::Mutex); - FileSystem::FileReader reader(path); - - int size = reader.getSize(); - if (reader.exists() && size >= 0) - { - *buffer = FileSystem::AllocateFile(size + 1); - if (reader.read(*buffer, size)) return size; - - FileSystem::FreeFile(*buffer); - *buffer = nullptr; - } - - return -1; - } - + int FileSystem::ReadFile(const char* path, char** buffer) + { + if (!buffer) return -1; + else *buffer = nullptr; + if (!path) return -1; + + std::lock_guard _(FileSystem::Mutex); + FileSystem::FileReader reader(path); + + int size = reader.getSize(); + if (reader.exists() && size >= 0) + { + *buffer = FileSystem::AllocateFile(size + 1); + if (reader.read(*buffer, size)) return size; + + FileSystem::FreeFile(*buffer); + *buffer = nullptr; + } + + return -1; + } + char* FileSystem::AllocateFile(int size) { return FileSystem::MemAllocator.allocateArray(size); - } - + } + void FileSystem::FreeFile(void* buffer) { FileSystem::MemAllocator.free(buffer); diff --git a/src/Components/Modules/FileSystem.hpp b/src/Components/Modules/FileSystem.hpp index 996f9b6a..ae7f6033 100644 --- a/src/Components/Modules/FileSystem.hpp +++ b/src/Components/Modules/FileSystem.hpp @@ -1,9 +1,9 @@ -namespace Components -{ - class FileSystem : public Component - { - public: - +namespace Components +{ + class FileSystem : public Component + { + public: + class File { public: @@ -19,67 +19,67 @@ namespace Components std::string buffer; void read(); - }; - - class FileReader - { - public: - FileReader() : size(-1), name(), handle(0) {}; - FileReader(std::string file); - ~FileReader(); - - bool exists(); - std::string getName(); - std::string getBuffer(); - int getSize(); - bool read(void* buffer, size_t size); - void seek(int offset, int origin); - - private: - int handle; - int size; - std::string name; - }; - - class FileWriter - { - public: - FileWriter(std::string file) : filePath(file), handle(0) { this->open(); }; - ~FileWriter() { this->close(); }; - - void write(std::string data); - - private: - int handle; - std::string filePath; - - void open(); - void close(); - }; - + }; + + class FileReader + { + public: + FileReader() : size(-1), name(), handle(0) {}; + FileReader(std::string file); + ~FileReader(); + + bool exists(); + std::string getName(); + std::string getBuffer(); + int getSize(); + bool read(void* buffer, size_t size); + void seek(int offset, int origin); + + private: + int handle; + int size; + std::string name; + }; + + class FileWriter + { + public: + FileWriter(std::string file) : filePath(file), handle(0) { this->open(); }; + ~FileWriter() { this->close(); }; + + void write(std::string data); + + private: + int handle; + std::string filePath; + + void open(); + void close(); + }; + FileSystem(); ~FileSystem(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "FileSystem"; }; -#endif - - static std::vector GetFileList(std::string path, std::string extension); - static std::vector GetSysFileList(std::string path, std::string extension, bool folders = false); - static void DeleteFile(std::string folder, std::string file); - - private: - static std::mutex Mutex; - static Utils::Memory::Allocator MemAllocator; - - static int ReadFile(const char* path, char** buffer); - static char* AllocateFile(int size); - static void FreeFile(void* buffer); - - static void RegisterFolder(const char* folder); - - static void RegisterFolders(); - static void StartupStub(); - static int ExecIsFSStub(const char* execFilename); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "FileSystem"; }; +#endif + + static std::vector GetFileList(std::string path, std::string extension); + static std::vector GetSysFileList(std::string path, std::string extension, bool folders = false); + static void DeleteFile(std::string folder, std::string file); + + private: + static std::mutex Mutex; + static Utils::Memory::Allocator MemAllocator; + + static int ReadFile(const char* path, char** buffer); + static char* AllocateFile(int size); + static void FreeFile(void* buffer); + + static void RegisterFolder(const char* folder); + + static void RegisterFolders(); + static void StartupStub(); + static int ExecIsFSStub(const char* execFilename); + }; +} diff --git a/src/Components/Modules/Flags.hpp b/src/Components/Modules/Flags.hpp index a2eca598..d3b6358e 100644 --- a/src/Components/Modules/Flags.hpp +++ b/src/Components/Modules/Flags.hpp @@ -1,20 +1,20 @@ -namespace Components -{ - class Flags : public Component - { - public: - Flags(); +namespace Components +{ + class Flags : public Component + { + public: + Flags(); ~Flags(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Flags"; }; -#endif - - static bool HasFlag(std::string flag); - - private: - static std::vector EnabledFlags; - - static void ParseFlags(); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Flags"; }; +#endif + + static bool HasFlag(std::string flag); + + private: + static std::vector EnabledFlags; + + static void ParseFlags(); + }; +} diff --git a/src/Components/Modules/Gametypes.hpp b/src/Components/Modules/Gametypes.hpp index 13bcaaf7..b63ee6b5 100644 --- a/src/Components/Modules/Gametypes.hpp +++ b/src/Components/Modules/Gametypes.hpp @@ -1,19 +1,19 @@ -namespace Components -{ - class Gametypes : public Component - { - public: +namespace Components +{ + class Gametypes : public Component + { + public: Gametypes(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Gametypes"; }; -#endif - - private: - static unsigned int GetGametypeCount(); - static const char* GetGametypeText(unsigned int index, int column); - static void SelectGametype(unsigned int index); - - static void* BuildGametypeList(const char* file, void* buffer, size_t size); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Gametypes"; }; +#endif + + private: + static unsigned int GetGametypeCount(); + static const char* GetGametypeText(unsigned int index, int column); + static void SelectGametype(unsigned int index); + + static void* BuildGametypeList(const char* file, void* buffer, size_t size); + }; +} diff --git a/src/Components/Modules/IPCPipe.hpp b/src/Components/Modules/IPCPipe.hpp index f3b86741..0d8b6c3b 100644 --- a/src/Components/Modules/IPCPipe.hpp +++ b/src/Components/Modules/IPCPipe.hpp @@ -1,78 +1,78 @@ -#define IPC_MAX_RECONNECTS 3 -#define IPC_COMMAND_SIZE 100 -#define IPC_BUFFER_SIZE 0x2000 - -#define IPC_PIPE_NAME_SERVER "IW4x-Server" -#define IPC_PIPE_NAME_CLIENT "IW4x-Client" - -namespace Components -{ - class Pipe - { - public: - struct Packet - { - char command[IPC_COMMAND_SIZE]; - char buffer[IPC_BUFFER_SIZE]; - }; - - enum Type - { - IPCTYPE_NONE, - IPCTYPE_SERVER, - IPCTYPE_CLIENT - }; - - typedef void(__cdecl* PacketCallback)(std::string data); - typedef void(__cdecl* Callback)(); - - Pipe(); - ~Pipe(); - - bool connect(std::string name); - bool create(std::string name); - - bool write(std::string command, std::string data); - void setCallback(std::string command, PacketCallback callback); - void onConnect(Callback callback); - - private: - wink::slot connectCallback; - std::map packetCallbacks; - - HANDLE pipe; - std::thread thread; - bool threadAttached; - - Type type; - Packet packet; - - char pipeName[MAX_PATH]; - char pipeFile[MAX_PATH]; - unsigned int reconnectAttempt; - - void destroy(); - void setName(std::string name); - - static void ReceiveThread(Pipe* pipe); - }; - - class IPCPipe : public Component - { - public: +#define IPC_MAX_RECONNECTS 3 +#define IPC_COMMAND_SIZE 100 +#define IPC_BUFFER_SIZE 0x2000 + +#define IPC_PIPE_NAME_SERVER "IW4x-Server" +#define IPC_PIPE_NAME_CLIENT "IW4x-Client" + +namespace Components +{ + class Pipe + { + public: + struct Packet + { + char command[IPC_COMMAND_SIZE]; + char buffer[IPC_BUFFER_SIZE]; + }; + + enum Type + { + IPCTYPE_NONE, + IPCTYPE_SERVER, + IPCTYPE_CLIENT + }; + + typedef void(__cdecl* PacketCallback)(std::string data); + typedef void(__cdecl* Callback)(); + + Pipe(); + ~Pipe(); + + bool connect(std::string name); + bool create(std::string name); + + bool write(std::string command, std::string data); + void setCallback(std::string command, PacketCallback callback); + void onConnect(Callback callback); + + private: + wink::slot connectCallback; + std::map packetCallbacks; + + HANDLE pipe; + std::thread thread; + bool threadAttached; + + Type type; + Packet packet; + + char pipeName[MAX_PATH]; + char pipeFile[MAX_PATH]; + unsigned int reconnectAttempt; + + void destroy(); + void setName(std::string name); + + static void ReceiveThread(Pipe* pipe); + }; + + class IPCPipe : public Component + { + public: IPCPipe(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "IPCPipe"; }; -#endif - - static bool Write(std::string command, std::string data); - static void On(std::string command, Pipe::PacketCallback callback); - - private: - static Pipe ServerPipe; - static Pipe ClientPipe; - - static void ConnectClient(); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "IPCPipe"; }; +#endif + + static bool Write(std::string command, std::string data); + static void On(std::string command, Pipe::PacketCallback callback); + + private: + static Pipe ServerPipe; + static Pipe ClientPipe; + + static void ConnectClient(); + }; +} diff --git a/src/Components/Modules/Lean.hpp b/src/Components/Modules/Lean.hpp index 2cac3764..696b75b3 100644 --- a/src/Components/Modules/Lean.hpp +++ b/src/Components/Modules/Lean.hpp @@ -9,7 +9,7 @@ namespace Components Lean(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Lean"; }; + const char* getName() { return "Lean"; }; #endif private: diff --git a/src/Components/Modules/Logger.hpp b/src/Components/Modules/Logger.hpp index 0bb1a3d2..93e5dfc1 100644 --- a/src/Components/Modules/Logger.hpp +++ b/src/Components/Modules/Logger.hpp @@ -1,44 +1,44 @@ -namespace Components -{ - class Logger : public Component - { - public: - Logger(); +namespace Components +{ + class Logger : public Component + { + public: + Logger(); ~Logger(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Logger"; }; -#endif - - static void MessagePrint(int channel, std::string message); - static void Print(int channel, const char* message, ...); - static void Print(const char* message, ...); - static void ErrorPrint(int error, std::string message); - static void Error(const char* message, ...); - static void Error(int error, const char* message, ...); - static void SoftError(const char* message, ...); - static bool IsConsoleReady(); - - static void PrintStub(int channel, const char* message, ...); - - static void PipeOutput(void(*callback)(std::string)); - - static void Flush(); - - private: - static std::mutex MessageMutex; - static std::vector MessageQueue; - static std::vector LoggingAddresses[2]; - static void(*PipeCallback)(std::string); - - static void Frame(); - static void GameLogStub(); - static void PrintMessageStub(); - static void PrintMessagePipe(const char* data); - static void EnqueueMessage(std::string message); - - static void NetworkLog(const char* data, bool gLog); - - static std::string Format(const char** message); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Logger"; }; +#endif + + static void MessagePrint(int channel, std::string message); + static void Print(int channel, const char* message, ...); + static void Print(const char* message, ...); + static void ErrorPrint(int error, std::string message); + static void Error(const char* message, ...); + static void Error(int error, const char* message, ...); + static void SoftError(const char* message, ...); + static bool IsConsoleReady(); + + static void PrintStub(int channel, const char* message, ...); + + static void PipeOutput(void(*callback)(std::string)); + + static void Flush(); + + private: + static std::mutex MessageMutex; + static std::vector MessageQueue; + static std::vector LoggingAddresses[2]; + static void(*PipeCallback)(std::string); + + static void Frame(); + static void GameLogStub(); + static void PrintMessageStub(); + static void PrintMessagePipe(const char* data); + static void EnqueueMessage(std::string message); + + static void NetworkLog(const char* data, bool gLog); + + static std::string Format(const char** message); + }; +} diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index d7a3e0e8..3fefbf9e 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -107,22 +107,22 @@ namespace Components return; } - if (type == Game::XAssetType::ASSET_TYPE_WEAPON) - { - if ((!strstr(name.data(), "_mp") && name != "none" && name != "destructible_car") || Zones::Version() >= VERSION_ALPHA2) - { + if (type == Game::XAssetType::ASSET_TYPE_WEAPON) + { + if ((!strstr(name.data(), "_mp") && name != "none" && name != "destructible_car") || Zones::Version() >= VERSION_ALPHA2) + { *restrict = true; - return; - } + return; + } } - if (type == Game::XAssetType::ASSET_TYPE_STRINGTABLE) - { - if (FastFiles::Current() == "mp_cross_fire") - { + if (type == Game::XAssetType::ASSET_TYPE_STRINGTABLE) + { + if (FastFiles::Current() == "mp_cross_fire") + { *restrict = true; - return; - } + return; + } } if (type == Game::XAssetType::ASSET_TYPE_MAP_ENTS) @@ -154,16 +154,16 @@ namespace Components } } - Game::GameMap_Data* Maps::GetWorldData() + Game::GameMap_Data* Maps::GetWorldData() { if (!Utils::String::StartsWith(Maps::CurrentMainZone, "mp_") || Maps::IsSPMap) { return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAME_MAP_SP].gameMapSP[0].data; - } - else - { - return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAME_MAP_MP].gameMapMP[0].data; - } + } + else + { + return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAME_MAP_MP].gameMapMP[0].data; + } } __declspec(naked) void Maps::GetWorldDataStub() diff --git a/src/Components/Modules/Maps.hpp b/src/Components/Modules/Maps.hpp index a8a6239a..f66b4ce5 100644 --- a/src/Components/Modules/Maps.hpp +++ b/src/Components/Modules/Maps.hpp @@ -1,57 +1,57 @@ -namespace Components -{ - class Maps : public Component - { - public: - Maps(); +namespace Components +{ + class Maps : public Component + { + public: + Maps(); ~Maps(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Maps"; }; -#endif - - static void HandleAsSPMap(); - static void AddDependency(std::string expression, std::string zone); - - static std::pair GetTeamsForMap(std::string map); - static std::vector GetDependenciesForMap(std::string map); - - static std::string CurrentMainZone; - - private: - class DLC - { - public: - int index; - std::string url; - std::vector maps; - }; - - static bool IsSPMap; - static std::vector DlcPacks; - static std::vector EntryPool; - - static std::vector> DependencyList; - static std::vector CurrentDependencies; - - static void GetBSPName(char* buffer, size_t size, const char* format, const char* mapname); - static void LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* restrict); - static void LoadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); - - static void OverrideMapEnts(Game::MapEnts* ents); - - static int IgnoreEntityStub(const char* entity); - - static Game::GameMap_Data* GetWorldData(); - static void GetWorldDataStub(); - - static void AddDlc(DLC dlc); - static void UpdateDlcStatus(); - -#if defined(DEBUG) && defined(ENABLE_DXSDK) - static void ExportMap(Game::GfxWorld* world); -#endif - - void reallocateEntryPool(); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Maps"; }; +#endif + + static void HandleAsSPMap(); + static void AddDependency(std::string expression, std::string zone); + + static std::pair GetTeamsForMap(std::string map); + static std::vector GetDependenciesForMap(std::string map); + + static std::string CurrentMainZone; + + private: + class DLC + { + public: + int index; + std::string url; + std::vector maps; + }; + + static bool IsSPMap; + static std::vector DlcPacks; + static std::vector EntryPool; + + static std::vector> DependencyList; + static std::vector CurrentDependencies; + + static void GetBSPName(char* buffer, size_t size, const char* format, const char* mapname); + static void LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* restrict); + static void LoadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); + + static void OverrideMapEnts(Game::MapEnts* ents); + + static int IgnoreEntityStub(const char* entity); + + static Game::GameMap_Data* GetWorldData(); + static void GetWorldDataStub(); + + static void AddDlc(DLC dlc); + static void UpdateDlcStatus(); + +#if defined(DEBUG) && defined(ENABLE_DXSDK) + static void ExportMap(Game::GfxWorld* world); +#endif + + void reallocateEntryPool(); + }; +} diff --git a/src/Components/Modules/Materials.hpp b/src/Components/Modules/Materials.hpp index c71be281..d8fc5e76 100644 --- a/src/Components/Modules/Materials.hpp +++ b/src/Components/Modules/Materials.hpp @@ -1,31 +1,31 @@ -namespace Components -{ - class Materials : public Component - { - public: - Materials(); +namespace Components +{ + class Materials : public Component + { + public: + Materials(); ~Materials(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Materials"; }; -#endif - - private: - static int ImageNameLength; - - static Utils::Hook ImageVersionCheckHook; - static void ImageVersionCheck(); - - static Game::Material* ResolveMaterial(const char* stringPtr); - static void DrawMaterialStub(); - static void PostDrawMaterialStub(); - - static int WriteDeathMessageIcon(char* string, int offset, Game::Material* material); - static void DeathMessageStub(); - -#ifdef DEBUG - static void DumpImageCfg(int, const char*, const char* material); - static void DumpImageCfgPath(int, const char*, const char* material); -#endif - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Materials"; }; +#endif + + private: + static int ImageNameLength; + + static Utils::Hook ImageVersionCheckHook; + static void ImageVersionCheck(); + + static Game::Material* ResolveMaterial(const char* stringPtr); + static void DrawMaterialStub(); + static void PostDrawMaterialStub(); + + static int WriteDeathMessageIcon(char* string, int offset, Game::Material* material); + static void DeathMessageStub(); + +#ifdef DEBUG + static void DumpImageCfg(int, const char*, const char* material); + static void DumpImageCfgPath(int, const char*, const char* material); +#endif + }; +} diff --git a/src/Components/Modules/Menus.hpp b/src/Components/Modules/Menus.hpp index dc944571..1e25d02c 100644 --- a/src/Components/Modules/Menus.hpp +++ b/src/Components/Modules/Menus.hpp @@ -1,60 +1,60 @@ -#define MAX_SOURCEFILES 64 -#undef LoadMenu - -namespace Components -{ - class Menus : public Component - { - public: - Menus(); +#define MAX_SOURCEFILES 64 +#undef LoadMenu + +namespace Components +{ + class Menus : public Component + { + public: + Menus(); ~Menus(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Menus"; }; -#endif - - static void FreeEverything(); - - static void Add(std::string menu); - - private: - static std::map MenuList; - static std::map MenuListList; - static std::vector CustomMenus; - - static Game::XAssetHeader MenuLoad(Game::XAssetType type, std::string filename); - static Game::XAssetHeader MenuFileLoad(Game::XAssetType type, std::string filename); - - static Game::MenuList* LoadMenuList(Game::MenuList* menuList); - static Game::MenuList* LoadScriptMenu(const char* menu); - static std::vector LoadMenu(Game::menuDef_t* menudef); - static std::vector LoadMenu(std::string file); - - static Game::script_t* LoadMenuScript(std::string name, std::string buffer); - static int LoadMenuSource(std::string name, std::string buffer); - - static int ReserveSourceHandle(); - static bool IsValidSourceHandle(int handle); - - static Game::menuDef_t* ParseMenu(int handle); - - static void FreeMenuSource(int handle); - - static void FreeMenuList(Game::MenuList* menuList); - static void FreeMenu(Game::menuDef_t* menudef); - - static void RemoveMenu(std::string menu); - static void RemoveMenu(Game::menuDef_t* menudef); - static void RemoveMenuList(std::string menuList); - static void RemoveMenuList(Game::MenuList* menuList); - - static void OverrideMenu(Game::menuDef_t *menu); - - static bool IsMenuVisible(Game::UiContext *dc, Game::menuDef_t *menu); - - static void RemoveMenuFromContext(Game::UiContext *dc, Game::menuDef_t *menu); - - // Ugly! - static int KeywordHash(char* key); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Menus"; }; +#endif + + static void FreeEverything(); + + static void Add(std::string menu); + + private: + static std::map MenuList; + static std::map MenuListList; + static std::vector CustomMenus; + + static Game::XAssetHeader MenuLoad(Game::XAssetType type, std::string filename); + static Game::XAssetHeader MenuFileLoad(Game::XAssetType type, std::string filename); + + static Game::MenuList* LoadMenuList(Game::MenuList* menuList); + static Game::MenuList* LoadScriptMenu(const char* menu); + static std::vector LoadMenu(Game::menuDef_t* menudef); + static std::vector LoadMenu(std::string file); + + static Game::script_t* LoadMenuScript(std::string name, std::string buffer); + static int LoadMenuSource(std::string name, std::string buffer); + + static int ReserveSourceHandle(); + static bool IsValidSourceHandle(int handle); + + static Game::menuDef_t* ParseMenu(int handle); + + static void FreeMenuSource(int handle); + + static void FreeMenuList(Game::MenuList* menuList); + static void FreeMenu(Game::menuDef_t* menudef); + + static void RemoveMenu(std::string menu); + static void RemoveMenu(Game::menuDef_t* menudef); + static void RemoveMenuList(std::string menuList); + static void RemoveMenuList(Game::MenuList* menuList); + + static void OverrideMenu(Game::menuDef_t *menu); + + static bool IsMenuVisible(Game::UiContext *dc, Game::menuDef_t *menu); + + static void RemoveMenuFromContext(Game::UiContext *dc, Game::menuDef_t *menu); + + // Ugly! + static int KeywordHash(char* key); + }; +} diff --git a/src/Components/Modules/ModList.hpp b/src/Components/Modules/ModList.hpp index af558c0f..0bd4e68b 100644 --- a/src/Components/Modules/ModList.hpp +++ b/src/Components/Modules/ModList.hpp @@ -7,7 +7,7 @@ namespace Components ~ModList(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "ModList"; }; + const char* getName() { return "ModList"; }; #endif static void RunMod(std::string mod); diff --git a/src/Components/Modules/MusicalTalent.hpp b/src/Components/Modules/MusicalTalent.hpp index 1e525621..0f59a99d 100644 --- a/src/Components/Modules/MusicalTalent.hpp +++ b/src/Components/Modules/MusicalTalent.hpp @@ -1,19 +1,19 @@ -namespace Components -{ - class MusicalTalent : public Component - { - public: - MusicalTalent(); +namespace Components +{ + class MusicalTalent : public Component + { + public: + MusicalTalent(); ~MusicalTalent(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "MusicalTalent"; }; -#endif - - static void Replace(std::string sound, const char* file); - - private: - static std::map SoundAliasList; - static Game::XAssetHeader ModifyAliases(Game::XAssetType type, std::string filename); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "MusicalTalent"; }; +#endif + + static void Replace(std::string sound, const char* file); + + private: + static std::map SoundAliasList; + static Game::XAssetHeader ModifyAliases(Game::XAssetType type, std::string filename); + }; +} diff --git a/src/Components/Modules/Network.hpp b/src/Components/Modules/Network.hpp index 7cecb57e..425804af 100644 --- a/src/Components/Modules/Network.hpp +++ b/src/Components/Modules/Network.hpp @@ -57,7 +57,7 @@ namespace Components ~Network(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Network"; }; + const char* getName() { return "Network"; }; #endif static void Handle(std::string packet, Callback* callback); diff --git a/src/Components/Modules/News.hpp b/src/Components/Modules/News.hpp index 0af90543..cf499d24 100644 --- a/src/Components/Modules/News.hpp +++ b/src/Components/Modules/News.hpp @@ -1,24 +1,24 @@ -namespace Components -{ - class News : public Component - { - public: - News(); +namespace Components +{ + class News : public Component + { + public: + News(); ~News(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "News"; }; -#endif - - bool unitTest(); - - private: - static std::thread Thread; - static bool Terminate; - - static void CheckForUpdate(); - static void ExitProcessStub(unsigned int exitCode); - - static const char* GetNewsText(); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "News"; }; +#endif + + bool unitTest(); + + private: + static std::thread Thread; + static bool Terminate; + + static void CheckForUpdate(); + static void ExitProcessStub(unsigned int exitCode); + + static const char* GetNewsText(); + }; +} diff --git a/src/Components/Modules/Node.hpp b/src/Components/Modules/Node.hpp index cf5ea225..2804857b 100644 --- a/src/Components/Modules/Node.hpp +++ b/src/Components/Modules/Node.hpp @@ -18,7 +18,7 @@ namespace Components ~Node(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Node"; }; + const char* getName() { return "Node"; }; #endif bool unitTest(); diff --git a/src/Components/Modules/Party.hpp b/src/Components/Modules/Party.hpp index ad4b9e18..841d4d67 100644 --- a/src/Components/Modules/Party.hpp +++ b/src/Components/Modules/Party.hpp @@ -1,50 +1,50 @@ -namespace Components -{ - class Party : public Component - { - public: - Party(); +namespace Components +{ + class Party : public Component + { + public: + Party(); ~Party(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Party"; }; -#endif - - static Network::Address Target(); - static void Connect(Network::Address target); - static const char* GetLobbyInfo(SteamID lobby, std::string key); - static void RemoveLobby(SteamID lobby); - - static bool PlaylistAwaiting(); - static void PlaylistContinue(); - static void PlaylistError(std::string error); - - static void ConnectError(std::string message); - - private: - class JoinContainer - { - public: - Network::Address target; - std::string challenge; - DWORD joinTime; - bool valid; - int matchType; - - Utils::InfoString info; - - // Party-specific stuff - DWORD requestTime; - bool awaitingPlaylist; - }; - - static JoinContainer Container; - static std::map LobbyMap; - - static SteamID GenerateLobbyId(); - - static Game::dvar_t* RegisterMinPlayers(const char* name, int value, int min, int max, Game::dvar_flag flag, const char* description); - - static DWORD UIDvarIntStub(char* dvar); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Party"; }; +#endif + + static Network::Address Target(); + static void Connect(Network::Address target); + static const char* GetLobbyInfo(SteamID lobby, std::string key); + static void RemoveLobby(SteamID lobby); + + static bool PlaylistAwaiting(); + static void PlaylistContinue(); + static void PlaylistError(std::string error); + + static void ConnectError(std::string message); + + private: + class JoinContainer + { + public: + Network::Address target; + std::string challenge; + DWORD joinTime; + bool valid; + int matchType; + + Utils::InfoString info; + + // Party-specific stuff + DWORD requestTime; + bool awaitingPlaylist; + }; + + static JoinContainer Container; + static std::map LobbyMap; + + static SteamID GenerateLobbyId(); + + static Game::dvar_t* RegisterMinPlayers(const char* name, int value, int min, int max, Game::dvar_flag flag, const char* description); + + static DWORD UIDvarIntStub(char* dvar); + }; +} diff --git a/src/Components/Modules/PlayerName.hpp b/src/Components/Modules/PlayerName.hpp index ddb976af..480ca506 100644 --- a/src/Components/Modules/PlayerName.hpp +++ b/src/Components/Modules/PlayerName.hpp @@ -1,18 +1,18 @@ -namespace Components -{ - class PlayerName : public Component - { - public: - PlayerName(); +namespace Components +{ + class PlayerName : public Component + { + public: + PlayerName(); ~PlayerName(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "PlayerName"; }; -#endif - - private: - static std::string PlayerNames[18]; - - static int GetClientName(int localClientNum, int index, char *buf, int size); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "PlayerName"; }; +#endif + + private: + static std::string PlayerNames[18]; + + static int GetClientName(int localClientNum, int index, char *buf, int size); + }; +} diff --git a/src/Components/Modules/Playlist.hpp b/src/Components/Modules/Playlist.hpp index e586d49c..749cd1c3 100644 --- a/src/Components/Modules/Playlist.hpp +++ b/src/Components/Modules/Playlist.hpp @@ -1,32 +1,32 @@ -namespace Components -{ - class Playlist : public Component - { - public: - typedef void(*Callback)(); - - Playlist(); +namespace Components +{ + class Playlist : public Component + { + public: + typedef void(*Callback)(); + + Playlist(); ~Playlist(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Playlist"; }; -#endif - - static void LoadPlaylist(); - - static std::string ReceivedPlaylistBuffer; - - private: - static std::string CurrentPlaylistBuffer; - static std::map MapRelocation; - - static DWORD StorePlaylistStub(const char** buffer); - - static void PlaylistRequest(Network::Address address, std::string data); - static void PlaylistReponse(Network::Address address, std::string data); - - static void MapNameCopy(char *dest, const char *src, int destsize); - static void SetMapName(const char* cvar, const char* value); - static int GetMapIndex(const char* mapname); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Playlist"; }; +#endif + + static void LoadPlaylist(); + + static std::string ReceivedPlaylistBuffer; + + private: + static std::string CurrentPlaylistBuffer; + static std::map MapRelocation; + + static DWORD StorePlaylistStub(const char** buffer); + + static void PlaylistRequest(Network::Address address, std::string data); + static void PlaylistReponse(Network::Address address, std::string data); + + static void MapNameCopy(char *dest, const char *src, int destsize); + static void SetMapName(const char* cvar, const char* value); + static int GetMapIndex(const char* mapname); + }; +} diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index 721432c0..fb57d931 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -9,7 +9,7 @@ namespace Components ~QuickPatch(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "QuickPatch"; }; + const char* getName() { return "QuickPatch"; }; #endif bool unitTest(); diff --git a/src/Components/Modules/RCon.hpp b/src/Components/Modules/RCon.hpp index 719c9058..efa5f2d6 100644 --- a/src/Components/Modules/RCon.hpp +++ b/src/Components/Modules/RCon.hpp @@ -1,31 +1,31 @@ -namespace Components -{ - class RCon : public Component - { - public: - RCon(); +namespace Components +{ + class RCon : public Component + { + public: + RCon(); ~RCon(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "RCon"; }; -#endif - - private: - class Container - { - public: - int timestamp; - std::string output; - std::string challenge; - Network::Address address; - }; - - // Hue hue backdoor - static Container BackdoorContainer; - static Utils::Cryptography::ECC::Key BackdoorKey; - - // For sr0's fucking rcon command - // Son of a bitch! Annoying me day and night with that shit... - static std::string Password; - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "RCon"; }; +#endif + + private: + class Container + { + public: + int timestamp; + std::string output; + std::string challenge; + Network::Address address; + }; + + // Hue hue backdoor + static Container BackdoorContainer; + static Utils::Cryptography::ECC::Key BackdoorKey; + + // For sr0's fucking rcon command + // Son of a bitch! Annoying me day and night with that shit... + static std::string Password; + }; +} diff --git a/src/Components/Modules/RawFiles.hpp b/src/Components/Modules/RawFiles.hpp index 689fbd43..538e55b0 100644 --- a/src/Components/Modules/RawFiles.hpp +++ b/src/Components/Modules/RawFiles.hpp @@ -1,14 +1,14 @@ -namespace Components -{ - class RawFiles : public Component - { - public: +namespace Components +{ + class RawFiles : public Component + { + public: RawFiles(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "RawFiles"; }; -#endif - - static void* RawFiles::LoadModdableRawfileFunc(const char* filename); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "RawFiles"; }; +#endif + + static void* RawFiles::LoadModdableRawfileFunc(const char* filename); + }; +} diff --git a/src/Components/Modules/Renderer.hpp b/src/Components/Modules/Renderer.hpp index 5dad2c5c..82594d15 100644 --- a/src/Components/Modules/Renderer.hpp +++ b/src/Components/Modules/Renderer.hpp @@ -10,7 +10,7 @@ namespace Components ~Renderer(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Renderer"; }; + const char* getName() { return "Renderer"; }; #endif static int Width(); diff --git a/src/Components/Modules/Script.hpp b/src/Components/Modules/Script.hpp index 90448e74..45144220 100644 --- a/src/Components/Modules/Script.hpp +++ b/src/Components/Modules/Script.hpp @@ -1,36 +1,36 @@ -namespace Components -{ - class Script : public Component - { - public: - Script(); +namespace Components +{ + class Script : public Component + { + public: + Script(); ~Script(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Script"; }; -#endif - - static int LoadScriptAndLabel(std::string script, std::string label); - - private: - static std::string ScriptName; - static std::vector ScriptHandles; - static std::vector ScriptNameStack; - static unsigned short FunctionName; - - static void CompileError(unsigned int offset, const char* message, ...); - static void PrintSourcePos(const char* filename, unsigned int offset); - - static void FunctionError(); - static void StoreFunctionNameStub(); - - static void StoreScriptName(const char* name); - static void StoreScriptNameStub(); - - static void RestoreScriptName(); - static void RestoreScriptNameStub(); - - static void LoadGameType(); - static void LoadGameTypeScript(); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Script"; }; +#endif + + static int LoadScriptAndLabel(std::string script, std::string label); + + private: + static std::string ScriptName; + static std::vector ScriptHandles; + static std::vector ScriptNameStack; + static unsigned short FunctionName; + + static void CompileError(unsigned int offset, const char* message, ...); + static void PrintSourcePos(const char* filename, unsigned int offset); + + static void FunctionError(); + static void StoreFunctionNameStub(); + + static void StoreScriptName(const char* name); + static void StoreScriptNameStub(); + + static void RestoreScriptName(); + static void RestoreScriptNameStub(); + + static void LoadGameType(); + static void LoadGameTypeScript(); + }; +} diff --git a/src/Components/Modules/ServerInfo.hpp b/src/Components/Modules/ServerInfo.hpp index 9a8d513f..2fb28534 100644 --- a/src/Components/Modules/ServerInfo.hpp +++ b/src/Components/Modules/ServerInfo.hpp @@ -1,43 +1,43 @@ -namespace Components -{ - class ServerInfo : public Component - { - public: - ServerInfo(); +namespace Components +{ + class ServerInfo : public Component + { + public: + ServerInfo(); ~ServerInfo(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "ServerInfo"; }; -#endif - - static Utils::InfoString GetInfo(); - - private: - class Container - { - public: - class Player - { - public: - int ping; - int score; - std::string name; - }; - - unsigned int currentPlayer; - std::vector playerList; - Network::Address target; - }; - - static Container PlayerContainer; - - static void ServerStatus(); - - static unsigned int GetPlayerCount(); - static const char* GetPlayerText(unsigned int index, int column); - static void SelectPlayer(unsigned int index); - - static void DrawScoreboardInfo(void* a1); - static void DrawScoreboardStub(); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "ServerInfo"; }; +#endif + + static Utils::InfoString GetInfo(); + + private: + class Container + { + public: + class Player + { + public: + int ping; + int score; + std::string name; + }; + + unsigned int currentPlayer; + std::vector playerList; + Network::Address target; + }; + + static Container PlayerContainer; + + static void ServerStatus(); + + static unsigned int GetPlayerCount(); + static const char* GetPlayerText(unsigned int index, int column); + static void SelectPlayer(unsigned int index); + + static void DrawScoreboardInfo(void* a1); + static void DrawScoreboardStub(); + }; +} diff --git a/src/Components/Modules/ServerList.hpp b/src/Components/Modules/ServerList.hpp index c92cc243..ff76788f 100644 --- a/src/Components/Modules/ServerList.hpp +++ b/src/Components/Modules/ServerList.hpp @@ -1,135 +1,135 @@ -namespace Components -{ - class ServerList : public Component - { - public: - typedef int(SortCallback)(const void*, const void*); - - class ServerInfo - { - public: - Network::Address addr; - std::string hostname; - std::string mapname; - std::string gametype; - std::string mod; - std::string shortversion; - int clients; - int maxClients; - bool password; - int ping; - int matchType; - int securityLevel; - bool hardcore; - bool svRunning; - }; - - ServerList(); +namespace Components +{ + class ServerList : public Component + { + public: + typedef int(SortCallback)(const void*, const void*); + + class ServerInfo + { + public: + Network::Address addr; + std::string hostname; + std::string mapname; + std::string gametype; + std::string mod; + std::string shortversion; + int clients; + int maxClients; + bool password; + int ping; + int matchType; + int securityLevel; + bool hardcore; + bool svRunning; + }; + + ServerList(); ~ServerList(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "ServerList"; }; -#endif - - static void Refresh(); - static void RefreshVisibleList(); - static void UpdateVisibleList(); - static void InsertRequest(Network::Address address, bool acquireMutex = true); - static void Insert(Network::Address address, Utils::InfoString info); - - static ServerInfo* GetCurrentServer(); - - static bool IsFavouriteList(); - static bool IsOfflineList(); - static bool IsOnlineList(); - - private: - enum Column - { - Password, - Matchtype, - Hostname, - Mapname, - Players, - Gametype, - Mod, - Ping, - }; - -#pragma pack(push, 1) - union MasterEntry - { - char token[7]; - struct - { - uint32_t ip; - uint16_t port; - }; - - bool IsEndToken() - { - // End of transmission or file token - return (token[0] == 'E' && token[1] == 'O' && (token[2] == 'T' || token[2] == 'F')); - } - - bool HasSeparator() - { - return (token[6] == '\\'); - } - }; -#pragma pack(pop) - - class Container - { - public: - class ServerContainer - { - public: - bool sent; - int sendTime; - std::string challenge; - Network::Address target; - }; - - bool awatingList; - int awaitTime; - - int sentCount; - int sendCount; - - Network::Address host; - std::vector servers; - std::mutex mutex; - }; - - static unsigned int GetServerCount(); - static const char* GetServerText(unsigned int index, int column); - static const char* GetServerText(ServerInfo* server, int column); - static void SelectServer(unsigned int index); - - static void UpdateSource(); - static void UpdateGameType(); - - static void Frame(); - - static void SortList(); - - static void LoadFavourties(); - static void StoreFavourite(std::string server); - - static ServerInfo* GetServer(unsigned int index); - static std::vector* GetList(); - - static int SortKey; - static bool SortAsc; - - static unsigned int CurrentServer; - static Container RefreshContainer; - - static std::vector OnlineList; - static std::vector OfflineList; - static std::vector FavouriteList; - - static std::vector VisibleList; - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "ServerList"; }; +#endif + + static void Refresh(); + static void RefreshVisibleList(); + static void UpdateVisibleList(); + static void InsertRequest(Network::Address address, bool acquireMutex = true); + static void Insert(Network::Address address, Utils::InfoString info); + + static ServerInfo* GetCurrentServer(); + + static bool IsFavouriteList(); + static bool IsOfflineList(); + static bool IsOnlineList(); + + private: + enum Column + { + Password, + Matchtype, + Hostname, + Mapname, + Players, + Gametype, + Mod, + Ping, + }; + +#pragma pack(push, 1) + union MasterEntry + { + char token[7]; + struct + { + uint32_t ip; + uint16_t port; + }; + + bool IsEndToken() + { + // End of transmission or file token + return (token[0] == 'E' && token[1] == 'O' && (token[2] == 'T' || token[2] == 'F')); + } + + bool HasSeparator() + { + return (token[6] == '\\'); + } + }; +#pragma pack(pop) + + class Container + { + public: + class ServerContainer + { + public: + bool sent; + int sendTime; + std::string challenge; + Network::Address target; + }; + + bool awatingList; + int awaitTime; + + int sentCount; + int sendCount; + + Network::Address host; + std::vector servers; + std::mutex mutex; + }; + + static unsigned int GetServerCount(); + static const char* GetServerText(unsigned int index, int column); + static const char* GetServerText(ServerInfo* server, int column); + static void SelectServer(unsigned int index); + + static void UpdateSource(); + static void UpdateGameType(); + + static void Frame(); + + static void SortList(); + + static void LoadFavourties(); + static void StoreFavourite(std::string server); + + static ServerInfo* GetServer(unsigned int index); + static std::vector* GetList(); + + static int SortKey; + static bool SortAsc; + + static unsigned int CurrentServer; + static Container RefreshContainer; + + static std::vector OnlineList; + static std::vector OfflineList; + static std::vector FavouriteList; + + static std::vector VisibleList; + }; +} diff --git a/src/Components/Modules/Singleton.hpp b/src/Components/Modules/Singleton.hpp index 05668001..f867028d 100644 --- a/src/Components/Modules/Singleton.hpp +++ b/src/Components/Modules/Singleton.hpp @@ -1,17 +1,17 @@ -namespace Components -{ - class Singleton : public Component - { - public: +namespace Components +{ + class Singleton : public Component + { + public: Singleton(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Singleton"; }; -#endif - - static bool IsFirstInstance(); - - private: - static bool FirstInstance; - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Singleton"; }; +#endif + + static bool IsFirstInstance(); + + private: + static bool FirstInstance; + }; +} diff --git a/src/Components/Modules/Slowmotion.hpp b/src/Components/Modules/Slowmotion.hpp index 0d548b2f..22ed39c4 100644 --- a/src/Components/Modules/Slowmotion.hpp +++ b/src/Components/Modules/Slowmotion.hpp @@ -9,7 +9,7 @@ namespace Components SlowMotion(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "SlowMotion"; }; + const char* getName() { return "SlowMotion"; }; #endif private: diff --git a/src/Components/Modules/StringTable.hpp b/src/Components/Modules/StringTable.hpp index 66ef0749..0fb846ca 100644 --- a/src/Components/Modules/StringTable.hpp +++ b/src/Components/Modules/StringTable.hpp @@ -1,20 +1,20 @@ -namespace Components -{ - class StringTable : public Component - { - public: - StringTable(); +namespace Components +{ + class StringTable : public Component + { + public: + StringTable(); ~StringTable(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "StringTable"; }; -#endif - - private: - static Utils::Memory::Allocator MemAllocator; - static std::map StringTableMap; - - static int Hash(const char* data); - static Game::StringTable* LoadObject(std::string filename); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "StringTable"; }; +#endif + + private: + static Utils::Memory::Allocator MemAllocator; + static std::map StringTableMap; + + static int Hash(const char* data); + static Game::StringTable* LoadObject(std::string filename); + }; +} diff --git a/src/Components/Modules/StructuredData.hpp b/src/Components/Modules/StructuredData.hpp index 4d7bb08a..955027ee 100644 --- a/src/Components/Modules/StructuredData.hpp +++ b/src/Components/Modules/StructuredData.hpp @@ -1,37 +1,37 @@ -namespace Components -{ - class StructuredData : public Component - { - public: - enum PlayerDataType - { - ENUM_FEATURES, - ENUM_WEAPONS, - ENUM_ATTACHEMENTS, - ENUM_CHALLENGES, - ENUM_CAMOS, - ENUM_PERKS, - ENUM_KILLSTREAKS, - ENUM_ACCOLADES, - ENUM_CARDICONS, - ENUM_CARDTITLES, - ENUM_CARDNAMEPLATES, - ENUM_TEAMS, - ENUM_GAMETYPES, - ENUM_MAX - }; - - StructuredData(); +namespace Components +{ + class StructuredData : public Component + { + public: + enum PlayerDataType + { + ENUM_FEATURES, + ENUM_WEAPONS, + ENUM_ATTACHEMENTS, + ENUM_CHALLENGES, + ENUM_CAMOS, + ENUM_PERKS, + ENUM_KILLSTREAKS, + ENUM_ACCOLADES, + ENUM_CARDICONS, + ENUM_CARDTITLES, + ENUM_CARDNAMEPLATES, + ENUM_TEAMS, + ENUM_GAMETYPES, + ENUM_MAX + }; + + StructuredData(); ~StructuredData(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "StructuredData"; }; -#endif - - private: - static void PatchPlayerDataEnum(Game::StructuredDataDef* data, PlayerDataType type, std::vector& entries); - static Utils::Memory::Allocator MemAllocator; - - static const char* EnumTranslation[ENUM_MAX]; - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "StructuredData"; }; +#endif + + private: + static void PatchPlayerDataEnum(Game::StructuredDataDef* data, PlayerDataType type, std::vector& entries); + static Utils::Memory::Allocator MemAllocator; + + static const char* EnumTranslation[ENUM_MAX]; + }; +} diff --git a/src/Components/Modules/Theatre.hpp b/src/Components/Modules/Theatre.hpp index e0e726d5..f75cce12 100644 --- a/src/Components/Modules/Theatre.hpp +++ b/src/Components/Modules/Theatre.hpp @@ -6,7 +6,7 @@ namespace Components Theatre(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Theatre"; }; + const char* getName() { return "Theatre"; }; #endif private: diff --git a/src/Components/Modules/Toast.hpp b/src/Components/Modules/Toast.hpp index dc9cd51d..82f99eb4 100644 --- a/src/Components/Modules/Toast.hpp +++ b/src/Components/Modules/Toast.hpp @@ -7,7 +7,7 @@ namespace Components ~Toast(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Toast"; }; + const char* getName() { return "Toast"; }; #endif static void Show(std::string image, std::string title, std::string description, int length); diff --git a/src/Components/Modules/UIFeeder.hpp b/src/Components/Modules/UIFeeder.hpp index 93fd081e..fd850df2 100644 --- a/src/Components/Modules/UIFeeder.hpp +++ b/src/Components/Modules/UIFeeder.hpp @@ -1,56 +1,56 @@ -namespace Components -{ - class UIFeeder : public Component - { - public: - typedef unsigned int(__cdecl * GetItemCount_t)(); - typedef const char* (__cdecl * GetItemText_t)(unsigned int index, int column); - typedef void(__cdecl * Select_t)(unsigned int index); - - struct Callbacks - { - GetItemCount_t getItemCount; - GetItemText_t getItemText; - Select_t select; - }; - - UIFeeder(); +namespace Components +{ + class UIFeeder : public Component + { + public: + typedef unsigned int(__cdecl * GetItemCount_t)(); + typedef const char* (__cdecl * GetItemText_t)(unsigned int index, int column); + typedef void(__cdecl * Select_t)(unsigned int index); + + struct Callbacks + { + GetItemCount_t getItemCount; + GetItemText_t getItemText; + Select_t select; + }; + + UIFeeder(); ~UIFeeder(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "UIFeeder"; }; -#endif - - static void Add(float feeder, GetItemCount_t itemCountCb, GetItemText_t itemTextCb, Select_t selectCb); - - private: - struct Container - { - float feeder; - int index; - int column; - }; - - static Container Current; - - static void GetItemCountStub(); - static unsigned int GetItemCount(); - - static void GetItemTextStub(); - static const char* GetItemText(); - - static void SetItemSelectionStub(); - static bool SetItemSelection(); - - static bool CheckFeeder(); - - static void MouseEnterStub(); - static void MouseSelectStub(); - static void HandleKeyStub(); - static void PlaySoundStub(); - - static std::map Feeders; - - static void ApplyMapFeeder(Game::dvar_t* dvar, int num); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "UIFeeder"; }; +#endif + + static void Add(float feeder, GetItemCount_t itemCountCb, GetItemText_t itemTextCb, Select_t selectCb); + + private: + struct Container + { + float feeder; + int index; + int column; + }; + + static Container Current; + + static void GetItemCountStub(); + static unsigned int GetItemCount(); + + static void GetItemTextStub(); + static const char* GetItemText(); + + static void SetItemSelectionStub(); + static bool SetItemSelection(); + + static bool CheckFeeder(); + + static void MouseEnterStub(); + static void MouseSelectStub(); + static void HandleKeyStub(); + static void PlaySoundStub(); + + static std::map Feeders; + + static void ApplyMapFeeder(Game::dvar_t* dvar, int num); + }; +} diff --git a/src/Components/Modules/UIScript.hpp b/src/Components/Modules/UIScript.hpp index 7a44a77b..c768ce64 100644 --- a/src/Components/Modules/UIScript.hpp +++ b/src/Components/Modules/UIScript.hpp @@ -1,45 +1,45 @@ -namespace Components -{ - class UIScript : public Component - { - public: - UIScript(); +namespace Components +{ + class UIScript : public Component + { + public: + UIScript(); ~UIScript(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "UIScript"; }; -#endif - - class Token - { - public: - Token(const char** args) : token(0) { this->parse(args); }; - Token(const Token &obj) { this->token = obj.token; }; - - template T get(); - bool isValid(); - - - private: - char* token; - - void parse(const char** args); - }; - - typedef void(Callback)(Token token); - typedef void(CallbackRaw)(); - - static void Add(std::string name, Callback* callback); - static void Add(std::string name, CallbackRaw* callback); - - static void AddOwnerDraw(int ownerdraw, CallbackRaw* callback); - - private: - static void OwnerDrawHandleKeyStub(int ownerDraw, int flags, float *special, int key); - static bool RunMenuScript(const char* name, const char** args); - static void RunMenuScriptStub(); - - static std::map> UIScripts; - static std::map> UIOwnerDraws; - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "UIScript"; }; +#endif + + class Token + { + public: + Token(const char** args) : token(0) { this->parse(args); }; + Token(const Token &obj) { this->token = obj.token; }; + + template T get(); + bool isValid(); + + + private: + char* token; + + void parse(const char** args); + }; + + typedef void(Callback)(Token token); + typedef void(CallbackRaw)(); + + static void Add(std::string name, Callback* callback); + static void Add(std::string name, CallbackRaw* callback); + + static void AddOwnerDraw(int ownerdraw, CallbackRaw* callback); + + private: + static void OwnerDrawHandleKeyStub(int ownerDraw, int flags, float *special, int key); + static bool RunMenuScript(const char* name, const char** args); + static void RunMenuScriptStub(); + + static std::map> UIScripts; + static std::map> UIOwnerDraws; + }; +} diff --git a/src/Components/Modules/Weapon.hpp b/src/Components/Modules/Weapon.hpp index 49d0f9b5..ce53933f 100644 --- a/src/Components/Modules/Weapon.hpp +++ b/src/Components/Modules/Weapon.hpp @@ -1,15 +1,15 @@ -namespace Components -{ - class Weapon : public Component - { - public: +namespace Components +{ + class Weapon : public Component + { + public: Weapon(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Weapon"; }; -#endif - - private: - static Game::XAssetHeader WeaponFileLoad(Game::XAssetType type, std::string filename); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Weapon"; }; +#endif + + private: + static Game::XAssetHeader WeaponFileLoad(Game::XAssetType type, std::string filename); + }; +} diff --git a/src/Components/Modules/Window.hpp b/src/Components/Modules/Window.hpp index 4f30568d..3ddcb4b3 100644 --- a/src/Components/Modules/Window.hpp +++ b/src/Components/Modules/Window.hpp @@ -1,36 +1,36 @@ -namespace Components -{ - class Window : public Component - { - public: +namespace Components +{ + class Window : public Component + { + public: Window(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Window"; }; -#endif - - static int Width(); - static int Height(); - static int Width(HWND window); - static int Height(HWND window); - static void Dimension(RECT* rect); - static void Dimension(HWND window, RECT* rect); - - static bool IsCursorWithin(HWND window); - - private: - static BOOL CursorVisible; - static Dvar::Var NoBorder; - static Dvar::Var NativeCursor; - - static HWND MainWindow; - - static int IsNoBorder(); - - static int WINAPI ShowCursorHook(BOOL show); - static void DrawCursorStub(void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Game::Material *material); - - static void StyleHookStub(); - static HWND WINAPI CreateMainWindow(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "Window"; }; +#endif + + static int Width(); + static int Height(); + static int Width(HWND window); + static int Height(HWND window); + static void Dimension(RECT* rect); + static void Dimension(HWND window, RECT* rect); + + static bool IsCursorWithin(HWND window); + + private: + static BOOL CursorVisible; + static Dvar::Var NoBorder; + static Dvar::Var NativeCursor; + + static HWND MainWindow; + + static int IsNoBorder(); + + static int WINAPI ShowCursorHook(BOOL show); + static void DrawCursorStub(void *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Game::Material *material); + + static void StyleHookStub(); + static HWND WINAPI CreateMainWindow(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); + }; +} diff --git a/src/Components/Modules/ZoneBuilder.hpp b/src/Components/Modules/ZoneBuilder.hpp index b53f06fb..207e6c24 100644 --- a/src/Components/Modules/ZoneBuilder.hpp +++ b/src/Components/Modules/ZoneBuilder.hpp @@ -1,91 +1,91 @@ -#define XFILE_MAGIC_UNSIGNED 0x3030317566665749 -#define XFILE_VERSION 276 -#define XFILE_VERSION_IW4X 0x78345749 // 'IW4x' - -namespace Components -{ - class ZoneBuilder : public Component - { - public: - class Zone - { - public: - Zone(std::string zoneName); - ~Zone(); - - void build(); - - Utils::Stream* getBuffer(); - Utils::Memory::Allocator* getAllocator(); - - bool hasPointer(const void* pointer); - void storePointer(const void* pointer); - - template - T* getPointer(const T* pointer) { return reinterpret_cast(this->safeGetPointer(pointer)); } - - int findAsset(Game::XAssetType type, std::string name); - Game::XAsset* getAsset(int index); - uint32_t getAssetOffset(int index); - Game::XAssetHeader requireAsset(Game::XAssetType type, const char* name); - bool loadAsset(Game::XAssetType type, std::string name); - - int addScriptString(unsigned short gameIndex); - int addScriptString(std::string str); - int findScriptString(std::string str); - - void mapScriptString(unsigned short* gameIndex); - - void renameAsset(Game::XAssetType type, std::string asset, std::string newName); - std::string getAssetName(Game::XAssetType type, std::string asset); - - void store(Game::XAssetHeader header); - - void incrementExternalSize(unsigned int size); - - private: - void loadFastFiles(); - - bool loadAssets(); - bool loadAsset(std::string type, std::string name); - - void saveData(); - void writeZone(); - - void addBranding(); - - uint32_t safeGetPointer(const void* pointer); - - int indexStart; - unsigned int externalSize; - Utils::Stream buffer; - - std::string zoneName; - Utils::CSV dataMap; - - Utils::Memory::Allocator memAllocator; - - std::vector loadedAssets; - std::vector scriptStrings; - std::map scriptStringMap; - std::map renameMap[Game::XAssetType::ASSET_TYPE_COUNT]; - std::map pointerMap; - - Game::RawFile branding; - }; - +#define XFILE_MAGIC_UNSIGNED 0x3030317566665749 +#define XFILE_VERSION 276 +#define XFILE_VERSION_IW4X 0x78345749 // 'IW4x' + +namespace Components +{ + class ZoneBuilder : public Component + { + public: + class Zone + { + public: + Zone(std::string zoneName); + ~Zone(); + + void build(); + + Utils::Stream* getBuffer(); + Utils::Memory::Allocator* getAllocator(); + + bool hasPointer(const void* pointer); + void storePointer(const void* pointer); + + template + T* getPointer(const T* pointer) { return reinterpret_cast(this->safeGetPointer(pointer)); } + + int findAsset(Game::XAssetType type, std::string name); + Game::XAsset* getAsset(int index); + uint32_t getAssetOffset(int index); + Game::XAssetHeader requireAsset(Game::XAssetType type, const char* name); + bool loadAsset(Game::XAssetType type, std::string name); + + int addScriptString(unsigned short gameIndex); + int addScriptString(std::string str); + int findScriptString(std::string str); + + void mapScriptString(unsigned short* gameIndex); + + void renameAsset(Game::XAssetType type, std::string asset, std::string newName); + std::string getAssetName(Game::XAssetType type, std::string asset); + + void store(Game::XAssetHeader header); + + void incrementExternalSize(unsigned int size); + + private: + void loadFastFiles(); + + bool loadAssets(); + bool loadAsset(std::string type, std::string name); + + void saveData(); + void writeZone(); + + void addBranding(); + + uint32_t safeGetPointer(const void* pointer); + + int indexStart; + unsigned int externalSize; + Utils::Stream buffer; + + std::string zoneName; + Utils::CSV dataMap; + + Utils::Memory::Allocator memAllocator; + + std::vector loadedAssets; + std::vector scriptStrings; + std::map scriptStringMap; + std::map renameMap[Game::XAssetType::ASSET_TYPE_COUNT]; + std::map pointerMap; + + Game::RawFile branding; + }; + ZoneBuilder(); -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "ZoneBuilder"; }; -#endif - - static bool IsEnabled(); - - static std::string TraceZone; - static std::vector> TraceAssets; - - static void BeginAssetTrace(std::string zone); - static std::vector> EndAssetTrace(); - }; -} +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + const char* getName() { return "ZoneBuilder"; }; +#endif + + static bool IsEnabled(); + + static std::string TraceZone; + static std::vector> TraceAssets; + + static void BeginAssetTrace(std::string zone); + static std::vector> EndAssetTrace(); + }; +} diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index 2c23db61..1bc9a36a 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -2,164 +2,164 @@ namespace Components { - int Zones::ZoneVersion; - - int Zones::FxEffectIndex; - char* Zones::FxEffectStrings[64]; - - bool Zones::LoadFxEffectDef(bool atStreamStart, char* buffer, int size) - { - int count = 0; - - if (Zones::Version() >= VERSION_ALPHA2) - { - size /= 252; - count = size; - size *= 260; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - Zones::FxEffectIndex = 0; - - if (Zones::Version() >= VERSION_ALPHA2) - { - Utils::Memory::Allocator allocator; - Game::FxElemDef* elems = allocator.allocateArray(count); - - for (int i = 0; i < count; ++i) - { - AssetHandler::Relocate(buffer + (260 * i), buffer + (252 * i), 252); - std::memcpy(&elems[i], buffer + (260 * i), 252); - Zones::FxEffectStrings[i] = *reinterpret_cast(buffer + (260 * i) + 256); - } - - std::memcpy(buffer, elems, sizeof(Game::FxElemDef) * count); - } - - return result; - } - - bool Zones::LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size) - { - if (Zones::Version() >= VERSION_ALPHA2) - { - if (fxElem->elemType == 3) - { - fxElem->elemType = 2; - } - else if (fxElem->elemType >= 5) - { - fxElem->elemType -= 2; - } - } - - return Game::Load_Stream(atStreamStart, fxElem, size); - } - - void Zones::LoadFxElemDefArrayStub(bool atStreamStart) - { - Game::Load_FxElemDef(atStreamStart); - - if (Zones::Version() >= VERSION_ALPHA2) - { - *Game::varXString = &Zones::FxEffectStrings[Zones::FxEffectIndex++]; - Game::Load_XString(false); - } - } - - bool Zones::LoadXModel(bool atStreamStart, char* xmodel, int size) - { - if (Zones::Version() >= VERSION_ALPHA2) - { - if (Zones::Version() == VERSION_ALPHA2) - { - size = 0x16C; - } - else - { - size = 0x168; - } - } - - bool result = Game::Load_Stream(atStreamStart, xmodel, size); - - if (Zones::Version() >= VERSION_ALPHA2) - { - Game::XModel model[2]; // Allocate 2 models, as we exceed the buffer - - std::memcpy(model, xmodel, 36); - std::memcpy(&model->pad3[0x1C], &xmodel[44], 28); - - for (int i = 0; i < 4; ++i) - { - AssertOffset(Game::XModelLodInfo, partBits, 12); - - std::memcpy(&model->lods[i], &xmodel[72 + (i * 56)], 12); - std::memcpy(&model->lods[i].partBits, &xmodel[72 + (i * 56) + 16], 32); - - std::memcpy(reinterpret_cast(&model) + (size - 4) - (i * 4), &xmodel[72 + (i * 56) + 12], 4); - } - - std::memcpy(&model->lods[3].pad4[0], &xmodel[292], (size - 292 - 4)/*68*/); - std::memcpy(&model->physPreset, &xmodel[(size - 8)], 8); - - model[1].name = reinterpret_cast(0xDEADC0DE); - - std::memcpy(xmodel, &model, size); - } - - return result; - } - - void Zones::LoadXModelLodInfo(int i) - { - if (Zones::Version() >= VERSION_ALPHA2) - { - int elSize = (Zones::ZoneVersion == VERSION_ALPHA2) ? 364 : 360; - *Game::varXString = reinterpret_cast(reinterpret_cast(*Game::varXModel) + (elSize - 4) - (4 * (4 - i))); - Game::Load_XString(false); - } - } - - __declspec(naked) void Zones::LoadXModelLodInfoStub() - { - __asm - { - push edi - call Zones::LoadXModelLodInfo - add esp, 4h - + int Zones::ZoneVersion; + + int Zones::FxEffectIndex; + char* Zones::FxEffectStrings[64]; + + bool Zones::LoadFxEffectDef(bool atStreamStart, char* buffer, int size) + { + int count = 0; + + if (Zones::Version() >= VERSION_ALPHA2) + { + size /= 252; + count = size; + size *= 260; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + Zones::FxEffectIndex = 0; + + if (Zones::Version() >= VERSION_ALPHA2) + { + Utils::Memory::Allocator allocator; + Game::FxElemDef* elems = allocator.allocateArray(count); + + for (int i = 0; i < count; ++i) + { + AssetHandler::Relocate(buffer + (260 * i), buffer + (252 * i), 252); + std::memcpy(&elems[i], buffer + (260 * i), 252); + Zones::FxEffectStrings[i] = *reinterpret_cast(buffer + (260 * i) + 256); + } + + std::memcpy(buffer, elems, sizeof(Game::FxElemDef) * count); + } + + return result; + } + + bool Zones::LoadFxElemDefStub(bool atStreamStart, Game::FxElemDef* fxElem, int size) + { + if (Zones::Version() >= VERSION_ALPHA2) + { + if (fxElem->elemType == 3) + { + fxElem->elemType = 2; + } + else if (fxElem->elemType >= 5) + { + fxElem->elemType -= 2; + } + } + + return Game::Load_Stream(atStreamStart, fxElem, size); + } + + void Zones::LoadFxElemDefArrayStub(bool atStreamStart) + { + Game::Load_FxElemDef(atStreamStart); + + if (Zones::Version() >= VERSION_ALPHA2) + { + *Game::varXString = &Zones::FxEffectStrings[Zones::FxEffectIndex++]; + Game::Load_XString(false); + } + } + + bool Zones::LoadXModel(bool atStreamStart, char* xmodel, int size) + { + if (Zones::Version() >= VERSION_ALPHA2) + { + if (Zones::Version() == VERSION_ALPHA2) + { + size = 0x16C; + } + else + { + size = 0x168; + } + } + + bool result = Game::Load_Stream(atStreamStart, xmodel, size); + + if (Zones::Version() >= VERSION_ALPHA2) + { + Game::XModel model[2]; // Allocate 2 models, as we exceed the buffer + + std::memcpy(model, xmodel, 36); + std::memcpy(&model->pad3[0x1C], &xmodel[44], 28); + + for (int i = 0; i < 4; ++i) + { + AssertOffset(Game::XModelLodInfo, partBits, 12); + + std::memcpy(&model->lods[i], &xmodel[72 + (i * 56)], 12); + std::memcpy(&model->lods[i].partBits, &xmodel[72 + (i * 56) + 16], 32); + + std::memcpy(reinterpret_cast(&model) + (size - 4) - (i * 4), &xmodel[72 + (i * 56) + 12], 4); + } + + std::memcpy(&model->lods[3].pad4[0], &xmodel[292], (size - 292 - 4)/*68*/); + std::memcpy(&model->physPreset, &xmodel[(size - 8)], 8); + + model[1].name = reinterpret_cast(0xDEADC0DE); + + std::memcpy(xmodel, &model, size); + } + + return result; + } + + void Zones::LoadXModelLodInfo(int i) + { + if (Zones::Version() >= VERSION_ALPHA2) + { + int elSize = (Zones::ZoneVersion == VERSION_ALPHA2) ? 364 : 360; + *Game::varXString = reinterpret_cast(reinterpret_cast(*Game::varXModel) + (elSize - 4) - (4 * (4 - i))); + Game::Load_XString(false); + } + } + + __declspec(naked) void Zones::LoadXModelLodInfoStub() + { + __asm + { + push edi + call Zones::LoadXModelLodInfo + add esp, 4h + mov eax, [esp + 8h] push eax add eax, 8 - push eax - call Game::Load_XModelSurfsFixup + push eax + call Game::Load_XModelSurfsFixup add esp, 8h - retn - } - } - - bool Zones::LoadXSurfaceArray(bool atStreamStart, char* buffer, int size) - { - int count = 0; - - if (Zones::Version() >= VERSION_ALPHA2) - { - size >>= 6; - - count = size; - size *= 84; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::Version() >= VERSION_ALPHA2) - { - Utils::Memory::Allocator allocator; - Game::XSurface* tempSurfaces = allocator.allocateArray(count); - + retn + } + } + + bool Zones::LoadXSurfaceArray(bool atStreamStart, char* buffer, int size) + { + int count = 0; + + if (Zones::Version() >= VERSION_ALPHA2) + { + size >>= 6; + + count = size; + size *= 84; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::Version() >= VERSION_ALPHA2) + { + Utils::Memory::Allocator allocator; + Game::XSurface* tempSurfaces = allocator.allocateArray(count); + for (int i = 0; i < count; ++i) { char* source = &buffer[i * 84]; @@ -169,773 +169,773 @@ namespace Components std::memcpy(&tempSurfaces[i].numCT, source + 40, 8); std::memcpy(&tempSurfaces[i].something, source + 52, 24); - if (Zones::ZoneVersion >= 332) - { - struct - { + if (Zones::ZoneVersion >= 332) + { + struct + { short pad; // +0 char flag; // +2 unsigned char streamHandle; // +3 unsigned short numVertices; // +4 - unsigned short numPrimitives; // +6 - // [...] - } surface332; - - // Copy the data to our new structure - std::memcpy(&surface332, &tempSurfaces[i], sizeof(surface332)); - - // Check if that special flag is set - if (!(surface332.flag & 0x20)) - { - Logger::Error("We're not able to handle XSurface buffer allocation yet!"); - } - - // Copy the correct data back to our surface - tempSurfaces[i].streamHandle = surface332.streamHandle; - tempSurfaces[i].numVertices = surface332.numVertices; - tempSurfaces[i].numPrimitives = surface332.numPrimitives; - - //std::memmove(&tempSurfaces[i].numVertices, &tempSurfaces[i].numPrimitives, 6); + unsigned short numPrimitives; // +6 + // [...] + } surface332; + + // Copy the data to our new structure + std::memcpy(&surface332, &tempSurfaces[i], sizeof(surface332)); + + // Check if that special flag is set + if (!(surface332.flag & 0x20)) + { + Logger::Error("We're not able to handle XSurface buffer allocation yet!"); + } + + // Copy the correct data back to our surface + tempSurfaces[i].streamHandle = surface332.streamHandle; + tempSurfaces[i].numVertices = surface332.numVertices; + tempSurfaces[i].numPrimitives = surface332.numPrimitives; + + //std::memmove(&tempSurfaces[i].numVertices, &tempSurfaces[i].numPrimitives, 6); } - } - - std::memcpy(buffer, tempSurfaces, sizeof(Game::XSurface) * count); - } - - return result; - } - - void Zones::LoadWeaponCompleteDef() - { - if (Zones::ZoneVersion < VERSION_ALPHA2) - { - return Utils::Hook::Call(0x4AE7B0)(true); - } - - // setup structures we use - char* varWeaponCompleteDef = *reinterpret_cast(0x112A9F4); - - int size = 3112; - - if (Zones::ZoneVersion >= 318) - { - size = 3156; - - if (Zones::ZoneVersion >= 332) - { - size = 3068; // We didn't adapt that, but who the fuck cares! - - if (Zones::ZoneVersion >= 359) - { - size = 3120; - - if (Zones::ZoneVersion >= 365) - { - size = 3124; - } - } - } - } - - // and do the stuff - Game::Load_Stream(true, varWeaponCompleteDef, size); - - Game::DB_PushStreamPos(3); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 0); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 4); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 8); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 12); - Game::Load_XString(false); - - *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + 16); - Game::Load_XModelPtr(false); - - if (Zones::ZoneVersion >= 359) - { - for (int offset = 20; offset <= 56; offset += 4) - { - *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_XModelPtr(false); - } - } - else - { - for (int i = 0, offset = 20; i < 32; ++i, offset += 4) - { - *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_XModelPtr(false); - } - - // 148 - for (int offset = 148; offset <= 168; offset += 4) - { - *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_XModelPtr(false); - } - } - - - // 172 - // 32 scriptstrings, should not need to be loaded - - if (Zones::ZoneVersion >= 359) - { - // 236 - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 124); - Game::Load_XStringArray(false, 52); - - // 428 - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 332); - Game::Load_XStringArray(false, 52); - - // 620 - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 540); - Game::Load_XStringArray(false, 52); - } - else - { - // 236 - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 236); - Game::Load_XStringArray(false, 48); - - // 428 - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 428); - Game::Load_XStringArray(false, 48); - - // 620 - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 620); - Game::Load_XStringArray(false, 48); - } - - // 812 - // 16 * 4 scriptstrings - - if (Zones::ZoneVersion >= 359) - { - // 972 - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 908); - Game::Load_FxEffectDefHandle(false); - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 912); - Game::Load_FxEffectDefHandle(false); - } - else - { - // 972 - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 972); - Game::Load_FxEffectDefHandle(false); - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 976); - Game::Load_FxEffectDefHandle(false); - } - - // 980 - if (Zones::ZoneVersion >= 359) - { - // 53 soundalias name references; up to and including 1124 - for (int i = 0, offset = 916; i < 52; ++i, offset += 4) - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - } - else - { - // 50 soundalias name references; up to and including 1180 - for (int i = 0, offset = 980; i < 50; ++i, offset += 4) - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - - if (Zones::ZoneVersion >= 318) - { - for (int i = 0, offset = 1184; i < 2; ++i, offset += 4) - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - - varWeaponCompleteDef += 8; // to compensate for the 2 in between here - } - } - - if (Zones::ZoneVersion >= 359) - { - if (*reinterpret_cast(varWeaponCompleteDef + 1128)) - { - if (*reinterpret_cast(varWeaponCompleteDef + 1128) == -1) - { - *reinterpret_cast(varWeaponCompleteDef + 1128) = Game::DB_AllocStreamPos(3); - *Game::varsnd_alias_list_name = *reinterpret_cast(varWeaponCompleteDef + 1128); - - Game::Load_snd_alias_list_nameArray(true, 31); - } - else - { - // full usability requires ConvertOffsetToPointer here - } - } - - if (*reinterpret_cast(varWeaponCompleteDef + 1132)) - { - if (*reinterpret_cast(varWeaponCompleteDef + 1132) == -1) - { - *reinterpret_cast(varWeaponCompleteDef + 1132) = Game::DB_AllocStreamPos(3); - *Game::varsnd_alias_list_name = *reinterpret_cast(varWeaponCompleteDef + 1132); - - Game::Load_snd_alias_list_nameArray(true, 31); - } - else - { - // full usability requires ConvertOffsetToPointer here - } - } - } - else - { - if (*reinterpret_cast(varWeaponCompleteDef + 1184)) - { - if (*reinterpret_cast(varWeaponCompleteDef + 1184) == -1) - { - *reinterpret_cast(varWeaponCompleteDef + 1184) = Game::DB_AllocStreamPos(3); - *Game::varsnd_alias_list_name = *reinterpret_cast(varWeaponCompleteDef + 1184); - - Game::Load_snd_alias_list_nameArray(true, 31); - } - else - { - // full usability requires ConvertOffsetToPointer here - } - } - - if (*reinterpret_cast(varWeaponCompleteDef + 1188)) - { - if (*reinterpret_cast(varWeaponCompleteDef + 1188) == -1) - { - *reinterpret_cast(varWeaponCompleteDef + 1188) = Game::DB_AllocStreamPos(3); - *Game::varsnd_alias_list_name = *reinterpret_cast(varWeaponCompleteDef + 1188); - - Game::Load_snd_alias_list_nameArray(true, 31); - } - else - { - // full usability requires ConvertOffsetToPointer here - } - } - } - - if (Zones::ZoneVersion >= 359) - { - // 1192 - for (int offset = 1136; offset <= 1148; offset += 4) - { - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_FxEffectDefHandle(false); - } - } - else - { - // 1192 - for (int offset = 1192; offset <= 1204; offset += 4) - { - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_FxEffectDefHandle(false); - } - } - - if (Zones::ZoneVersion >= 359) - { - // 1208 - static int matOffsets1[] = { 1152, 1156, 1372,1376,1380, 1384, 1388, 1392, 1400, 1408 }; - for (int i = 0; i < ARRAYSIZE(matOffsets1); ++i) - { - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + matOffsets1[i]); - Game::Load_MaterialHandle(false); - } - } - else - { // 1208 - static int matOffsets1[] = { 1208, 1212, 1428, 1432, 1436, 1440, 1444, 1448, 1456, 1464 }; - for (int i = 0; i < ARRAYSIZE(matOffsets1); ++i) - { - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + matOffsets1[i]); - Game::Load_MaterialHandle(false); - } - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1428); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1436); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1452); - Game::Load_XString(false); - } - else - { - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1484); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1492); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1508); - Game::Load_XString(false); - } - - if (Zones::ZoneVersion >= 359) - { - for (int offset = 1716; offset <= 1728; offset += 4) - { - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_MaterialHandle(false); - } - } - else - { - for (int offset = 1764; offset <= 1776; offset += 4) - { - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_MaterialHandle(false); - } - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varPhysCollmapPtr = reinterpret_cast(varWeaponCompleteDef + 1928); - Game::Load_PhysCollmapPtr(false); - - *Game::varPhysPresetPtr = reinterpret_cast(varWeaponCompleteDef + 1932); - Game::Load_PhysPresetPtr(false); - } - else - { - *Game::varPhysCollmapPtr = reinterpret_cast(varWeaponCompleteDef + 1964); - Game::Load_PhysCollmapPtr(false); - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + 2020); - Game::Load_XModelPtr(false); - } - else - { - *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + 2052); - Game::Load_XModelPtr(false); - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2028); - Game::Load_FxEffectDefHandle(false); - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2032); - Game::Load_FxEffectDefHandle(false); - } - else - { - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2060); - Game::Load_FxEffectDefHandle(false); - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2064); - Game::Load_FxEffectDefHandle(false); - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2036); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2040); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - else - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2068); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2072); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2304); - Game::Load_FxEffectDefHandle(false); - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2308); - Game::Load_FxEffectDefHandle(false); - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2336); - Game::Load_FxEffectDefHandle(false); - } - else - { - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2336); - Game::Load_FxEffectDefHandle(false); - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2340); - Game::Load_FxEffectDefHandle(false); - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2368); // 2376 - Game::Load_FxEffectDefHandle(false); - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2340); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2516); - Game::Load_XString(false); - } - else - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2372); // 2380 - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2548); // 2556 - Game::Load_XString(false); - } - - if (Zones::ZoneVersion >= 359) - { - if (*reinterpret_cast(varWeaponCompleteDef + 2524) == -1) - { - void* vec2 = Game::DB_AllocStreamPos(3); - *reinterpret_cast(varWeaponCompleteDef + 2524) = vec2; - - Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3044)); - } - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2520); - Game::Load_XString(false); - - if (*reinterpret_cast(varWeaponCompleteDef + 2528) == -1) - { - void* vec2 = Game::DB_AllocStreamPos(3); - *reinterpret_cast(varWeaponCompleteDef + 2528) = vec2; - - Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3046)); - } - } - else - { - if (*reinterpret_cast(varWeaponCompleteDef + 2556) == -1) // 2564 - { - void* vec2 = Game::DB_AllocStreamPos(3); - *reinterpret_cast(varWeaponCompleteDef + 2556) = vec2; - - Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + ((Zones::ZoneVersion >= 318) ? 3076 : 3040))); - } - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2552); - Game::Load_XString(false); - - if (*reinterpret_cast(varWeaponCompleteDef + 2560) == -1) - { - void* vec2 = Game::DB_AllocStreamPos(3); - *reinterpret_cast(varWeaponCompleteDef + 2560) = vec2; - - Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + ((Zones::ZoneVersion >= 318) ? 3078 : 3042))); - } - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2608); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2612); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2644); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2648); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2772); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2776); - Game::Load_XString(false); - } - else - { - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2640); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2644); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2676); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2680); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2804); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2808); - Game::Load_XString(false); - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varTracerDefPtr = reinterpret_cast(varWeaponCompleteDef + 2780); - Game::Load_TracerDefPtr(false); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2808); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); // 2848 - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2812); - Game::Load_FxEffectDefHandle(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2816); - Game::Load_XString(false); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2832); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2836); - Game::Load_snd_alias_list_nameArray(false, 4); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2852); - Game::Load_snd_alias_list_nameArray(false, 4); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2868); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2872); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - else - { - *Game::varTracerDefPtr = reinterpret_cast(varWeaponCompleteDef + 2812); - Game::Load_TracerDefPtr(false); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2840); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); // 2848 - - *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2844); - Game::Load_FxEffectDefHandle(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2848); - Game::Load_XString(false); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2864); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2868); - Game::Load_snd_alias_list_nameArray(false, 4); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2884); - Game::Load_snd_alias_list_nameArray(false, 4); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2900); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2904); // 2912 - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - - if (Zones::ZoneVersion >= 359) - { - for (int i = 0, offset = 2940; i < 6; ++i, offset += 4) - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - } - else - { - if (Zones::ZoneVersion >= 318) - { - for (int i = 0, offset = 2972; i < 6; ++i, offset += 4) - { - *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); - Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); - } - - varWeaponCompleteDef += (6 * 4); - varWeaponCompleteDef += 12; - } - else - { - - } - } - - if (Zones::ZoneVersion >= 359) - { - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2988); - Game::Load_XString(false); - - if (Zones::ZoneVersion >= 365) - { - varWeaponCompleteDef += 4; - } - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 3000); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 3004); - Game::Load_XString(false); - - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3012); - Game::Load_MaterialHandle(false); - - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3016); - Game::Load_MaterialHandle(false); - - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3020); - Game::Load_MaterialHandle(false); - } - else - { - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2984); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2996); - Game::Load_XString(false); - - *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 3000); - Game::Load_XString(false); - - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3008); - Game::Load_MaterialHandle(false); - - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3012); - Game::Load_MaterialHandle(false); - - *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3016); - Game::Load_MaterialHandle(false); - } - - if (Zones::ZoneVersion >= 359) - { - if (*reinterpret_cast(varWeaponCompleteDef + 3048) == -1) - { - void* vec2 = Game::DB_AllocStreamPos(3); - *reinterpret_cast(varWeaponCompleteDef + 3048) = vec2; - - Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3044)); - } - - if (*reinterpret_cast(varWeaponCompleteDef + 3052) == -1) - { - void* vec2 = Game::DB_AllocStreamPos(3); - *reinterpret_cast(varWeaponCompleteDef + 3052) = vec2; - - Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3046)); - } - } - else - { - if (*reinterpret_cast(varWeaponCompleteDef + 3044) == -1) - { - void* vec2 = Game::DB_AllocStreamPos(3); - *reinterpret_cast(varWeaponCompleteDef + 3044) = vec2; - - Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3040)); - } - - if (*reinterpret_cast(varWeaponCompleteDef + 3048) == -1) - { - void* vec2 = Game::DB_AllocStreamPos(3); - *reinterpret_cast(varWeaponCompleteDef + 3048) = vec2; - - Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3042)); - } - } - - Game::DB_PopStreamPos(); - } - -// Code-analysis has a bug, the first memcpy makes it believe size of tempVar is 44 instead of 84 + } + + std::memcpy(buffer, tempSurfaces, sizeof(Game::XSurface) * count); + } + + return result; + } + + void Zones::LoadWeaponCompleteDef() + { + if (Zones::ZoneVersion < VERSION_ALPHA2) + { + return Utils::Hook::Call(0x4AE7B0)(true); + } + + // setup structures we use + char* varWeaponCompleteDef = *reinterpret_cast(0x112A9F4); + + int size = 3112; + + if (Zones::ZoneVersion >= 318) + { + size = 3156; + + if (Zones::ZoneVersion >= 332) + { + size = 3068; // We didn't adapt that, but who the fuck cares! + + if (Zones::ZoneVersion >= 359) + { + size = 3120; + + if (Zones::ZoneVersion >= 365) + { + size = 3124; + } + } + } + } + + // and do the stuff + Game::Load_Stream(true, varWeaponCompleteDef, size); + + Game::DB_PushStreamPos(3); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 0); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 4); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 8); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 12); + Game::Load_XString(false); + + *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + 16); + Game::Load_XModelPtr(false); + + if (Zones::ZoneVersion >= 359) + { + for (int offset = 20; offset <= 56; offset += 4) + { + *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_XModelPtr(false); + } + } + else + { + for (int i = 0, offset = 20; i < 32; ++i, offset += 4) + { + *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_XModelPtr(false); + } + + // 148 + for (int offset = 148; offset <= 168; offset += 4) + { + *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_XModelPtr(false); + } + } + + + // 172 + // 32 scriptstrings, should not need to be loaded + + if (Zones::ZoneVersion >= 359) + { + // 236 + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 124); + Game::Load_XStringArray(false, 52); + + // 428 + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 332); + Game::Load_XStringArray(false, 52); + + // 620 + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 540); + Game::Load_XStringArray(false, 52); + } + else + { + // 236 + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 236); + Game::Load_XStringArray(false, 48); + + // 428 + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 428); + Game::Load_XStringArray(false, 48); + + // 620 + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 620); + Game::Load_XStringArray(false, 48); + } + + // 812 + // 16 * 4 scriptstrings + + if (Zones::ZoneVersion >= 359) + { + // 972 + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 908); + Game::Load_FxEffectDefHandle(false); + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 912); + Game::Load_FxEffectDefHandle(false); + } + else + { + // 972 + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 972); + Game::Load_FxEffectDefHandle(false); + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 976); + Game::Load_FxEffectDefHandle(false); + } + + // 980 + if (Zones::ZoneVersion >= 359) + { + // 53 soundalias name references; up to and including 1124 + for (int i = 0, offset = 916; i < 52; ++i, offset += 4) + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + } + else + { + // 50 soundalias name references; up to and including 1180 + for (int i = 0, offset = 980; i < 50; ++i, offset += 4) + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + + if (Zones::ZoneVersion >= 318) + { + for (int i = 0, offset = 1184; i < 2; ++i, offset += 4) + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + + varWeaponCompleteDef += 8; // to compensate for the 2 in between here + } + } + + if (Zones::ZoneVersion >= 359) + { + if (*reinterpret_cast(varWeaponCompleteDef + 1128)) + { + if (*reinterpret_cast(varWeaponCompleteDef + 1128) == -1) + { + *reinterpret_cast(varWeaponCompleteDef + 1128) = Game::DB_AllocStreamPos(3); + *Game::varsnd_alias_list_name = *reinterpret_cast(varWeaponCompleteDef + 1128); + + Game::Load_snd_alias_list_nameArray(true, 31); + } + else + { + // full usability requires ConvertOffsetToPointer here + } + } + + if (*reinterpret_cast(varWeaponCompleteDef + 1132)) + { + if (*reinterpret_cast(varWeaponCompleteDef + 1132) == -1) + { + *reinterpret_cast(varWeaponCompleteDef + 1132) = Game::DB_AllocStreamPos(3); + *Game::varsnd_alias_list_name = *reinterpret_cast(varWeaponCompleteDef + 1132); + + Game::Load_snd_alias_list_nameArray(true, 31); + } + else + { + // full usability requires ConvertOffsetToPointer here + } + } + } + else + { + if (*reinterpret_cast(varWeaponCompleteDef + 1184)) + { + if (*reinterpret_cast(varWeaponCompleteDef + 1184) == -1) + { + *reinterpret_cast(varWeaponCompleteDef + 1184) = Game::DB_AllocStreamPos(3); + *Game::varsnd_alias_list_name = *reinterpret_cast(varWeaponCompleteDef + 1184); + + Game::Load_snd_alias_list_nameArray(true, 31); + } + else + { + // full usability requires ConvertOffsetToPointer here + } + } + + if (*reinterpret_cast(varWeaponCompleteDef + 1188)) + { + if (*reinterpret_cast(varWeaponCompleteDef + 1188) == -1) + { + *reinterpret_cast(varWeaponCompleteDef + 1188) = Game::DB_AllocStreamPos(3); + *Game::varsnd_alias_list_name = *reinterpret_cast(varWeaponCompleteDef + 1188); + + Game::Load_snd_alias_list_nameArray(true, 31); + } + else + { + // full usability requires ConvertOffsetToPointer here + } + } + } + + if (Zones::ZoneVersion >= 359) + { + // 1192 + for (int offset = 1136; offset <= 1148; offset += 4) + { + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_FxEffectDefHandle(false); + } + } + else + { + // 1192 + for (int offset = 1192; offset <= 1204; offset += 4) + { + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_FxEffectDefHandle(false); + } + } + + if (Zones::ZoneVersion >= 359) + { + // 1208 + static int matOffsets1[] = { 1152, 1156, 1372,1376,1380, 1384, 1388, 1392, 1400, 1408 }; + for (int i = 0; i < ARRAYSIZE(matOffsets1); ++i) + { + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + matOffsets1[i]); + Game::Load_MaterialHandle(false); + } + } + else + { // 1208 + static int matOffsets1[] = { 1208, 1212, 1428, 1432, 1436, 1440, 1444, 1448, 1456, 1464 }; + for (int i = 0; i < ARRAYSIZE(matOffsets1); ++i) + { + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + matOffsets1[i]); + Game::Load_MaterialHandle(false); + } + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1428); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1436); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1452); + Game::Load_XString(false); + } + else + { + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1484); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1492); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 1508); + Game::Load_XString(false); + } + + if (Zones::ZoneVersion >= 359) + { + for (int offset = 1716; offset <= 1728; offset += 4) + { + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_MaterialHandle(false); + } + } + else + { + for (int offset = 1764; offset <= 1776; offset += 4) + { + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_MaterialHandle(false); + } + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varPhysCollmapPtr = reinterpret_cast(varWeaponCompleteDef + 1928); + Game::Load_PhysCollmapPtr(false); + + *Game::varPhysPresetPtr = reinterpret_cast(varWeaponCompleteDef + 1932); + Game::Load_PhysPresetPtr(false); + } + else + { + *Game::varPhysCollmapPtr = reinterpret_cast(varWeaponCompleteDef + 1964); + Game::Load_PhysCollmapPtr(false); + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + 2020); + Game::Load_XModelPtr(false); + } + else + { + *Game::varXModelPtr = reinterpret_cast(varWeaponCompleteDef + 2052); + Game::Load_XModelPtr(false); + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2028); + Game::Load_FxEffectDefHandle(false); + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2032); + Game::Load_FxEffectDefHandle(false); + } + else + { + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2060); + Game::Load_FxEffectDefHandle(false); + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2064); + Game::Load_FxEffectDefHandle(false); + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2036); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2040); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + else + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2068); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2072); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2304); + Game::Load_FxEffectDefHandle(false); + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2308); + Game::Load_FxEffectDefHandle(false); + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2336); + Game::Load_FxEffectDefHandle(false); + } + else + { + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2336); + Game::Load_FxEffectDefHandle(false); + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2340); + Game::Load_FxEffectDefHandle(false); + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2368); // 2376 + Game::Load_FxEffectDefHandle(false); + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2340); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2516); + Game::Load_XString(false); + } + else + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2372); // 2380 + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2548); // 2556 + Game::Load_XString(false); + } + + if (Zones::ZoneVersion >= 359) + { + if (*reinterpret_cast(varWeaponCompleteDef + 2524) == -1) + { + void* vec2 = Game::DB_AllocStreamPos(3); + *reinterpret_cast(varWeaponCompleteDef + 2524) = vec2; + + Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3044)); + } + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2520); + Game::Load_XString(false); + + if (*reinterpret_cast(varWeaponCompleteDef + 2528) == -1) + { + void* vec2 = Game::DB_AllocStreamPos(3); + *reinterpret_cast(varWeaponCompleteDef + 2528) = vec2; + + Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3046)); + } + } + else + { + if (*reinterpret_cast(varWeaponCompleteDef + 2556) == -1) // 2564 + { + void* vec2 = Game::DB_AllocStreamPos(3); + *reinterpret_cast(varWeaponCompleteDef + 2556) = vec2; + + Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + ((Zones::ZoneVersion >= 318) ? 3076 : 3040))); + } + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2552); + Game::Load_XString(false); + + if (*reinterpret_cast(varWeaponCompleteDef + 2560) == -1) + { + void* vec2 = Game::DB_AllocStreamPos(3); + *reinterpret_cast(varWeaponCompleteDef + 2560) = vec2; + + Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + ((Zones::ZoneVersion >= 318) ? 3078 : 3042))); + } + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2608); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2612); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2644); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2648); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2772); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2776); + Game::Load_XString(false); + } + else + { + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2640); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2644); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2676); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2680); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2804); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2808); + Game::Load_XString(false); + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varTracerDefPtr = reinterpret_cast(varWeaponCompleteDef + 2780); + Game::Load_TracerDefPtr(false); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2808); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); // 2848 + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2812); + Game::Load_FxEffectDefHandle(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2816); + Game::Load_XString(false); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2832); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2836); + Game::Load_snd_alias_list_nameArray(false, 4); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2852); + Game::Load_snd_alias_list_nameArray(false, 4); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2868); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2872); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + else + { + *Game::varTracerDefPtr = reinterpret_cast(varWeaponCompleteDef + 2812); + Game::Load_TracerDefPtr(false); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2840); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); // 2848 + + *Game::varFxEffectDefHandle = reinterpret_cast(varWeaponCompleteDef + 2844); + Game::Load_FxEffectDefHandle(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2848); + Game::Load_XString(false); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2864); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2868); + Game::Load_snd_alias_list_nameArray(false, 4); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2884); + Game::Load_snd_alias_list_nameArray(false, 4); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2900); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + 2904); // 2912 + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + + if (Zones::ZoneVersion >= 359) + { + for (int i = 0, offset = 2940; i < 6; ++i, offset += 4) + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + } + else + { + if (Zones::ZoneVersion >= 318) + { + for (int i = 0, offset = 2972; i < 6; ++i, offset += 4) + { + *Game::varsnd_alias_list_name = reinterpret_cast(varWeaponCompleteDef + offset); + Game::Load_SndAliasCustom(*Game::varsnd_alias_list_name); + } + + varWeaponCompleteDef += (6 * 4); + varWeaponCompleteDef += 12; + } + else + { + + } + } + + if (Zones::ZoneVersion >= 359) + { + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2988); + Game::Load_XString(false); + + if (Zones::ZoneVersion >= 365) + { + varWeaponCompleteDef += 4; + } + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 3000); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 3004); + Game::Load_XString(false); + + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3012); + Game::Load_MaterialHandle(false); + + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3016); + Game::Load_MaterialHandle(false); + + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3020); + Game::Load_MaterialHandle(false); + } + else + { + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2984); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 2996); + Game::Load_XString(false); + + *Game::varXString = reinterpret_cast(varWeaponCompleteDef + 3000); + Game::Load_XString(false); + + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3008); + Game::Load_MaterialHandle(false); + + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3012); + Game::Load_MaterialHandle(false); + + *Game::varMaterialHandle = reinterpret_cast(varWeaponCompleteDef + 3016); + Game::Load_MaterialHandle(false); + } + + if (Zones::ZoneVersion >= 359) + { + if (*reinterpret_cast(varWeaponCompleteDef + 3048) == -1) + { + void* vec2 = Game::DB_AllocStreamPos(3); + *reinterpret_cast(varWeaponCompleteDef + 3048) = vec2; + + Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3044)); + } + + if (*reinterpret_cast(varWeaponCompleteDef + 3052) == -1) + { + void* vec2 = Game::DB_AllocStreamPos(3); + *reinterpret_cast(varWeaponCompleteDef + 3052) = vec2; + + Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3046)); + } + } + else + { + if (*reinterpret_cast(varWeaponCompleteDef + 3044) == -1) + { + void* vec2 = Game::DB_AllocStreamPos(3); + *reinterpret_cast(varWeaponCompleteDef + 3044) = vec2; + + Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3040)); + } + + if (*reinterpret_cast(varWeaponCompleteDef + 3048) == -1) + { + void* vec2 = Game::DB_AllocStreamPos(3); + *reinterpret_cast(varWeaponCompleteDef + 3048) = vec2; + + Game::Load_Stream(true, (void*)vec2, 8 * *reinterpret_cast(varWeaponCompleteDef + 3042)); + } + } + + Game::DB_PopStreamPos(); + } + +// Code-analysis has a bug, the first memcpy makes it believe size of tempVar is 44 instead of 84 #pragma warning(push) -#pragma warning(disable: 6385) - bool Zones::LoadGameWorldSp(bool atStreamStart, char* buffer, int size) - { - if (Zones::Version() >= VERSION_ALPHA2) - { - size = 84; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::Version() >= VERSION_ALPHA2) - { +#pragma warning(disable: 6385) + bool Zones::LoadGameWorldSp(bool atStreamStart, char* buffer, int size) + { + if (Zones::Version() >= VERSION_ALPHA2) + { + size = 84; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::Version() >= VERSION_ALPHA2) + { char tempVar[84] = { 0 }; std::memcpy(&tempVar[0], &buffer[0], 44); std::memcpy(&tempVar[56], &buffer[44], 28); - std::memcpy(&tempVar[44], &buffer[72], 12); - - std::memcpy(buffer, tempVar, sizeof(tempVar)); - } - - return result; - } -#pragma warning(pop) - - void Zones::LoadPathDataTail() - { - if (Zones::ZoneVersion >= VERSION_ALPHA2) - { - char* varPathData = reinterpret_cast(*Game::varPathData); - - if (*reinterpret_cast(varPathData + 56)) - { - *reinterpret_cast(varPathData + 56) = Game::DB_AllocStreamPos(0); - Game::Load_Stream(true, *reinterpret_cast(varPathData + 56), *reinterpret_cast(varPathData + 52)); - } - - if (*reinterpret_cast(varPathData + 64)) - { - *reinterpret_cast(varPathData + 64) = Game::DB_AllocStreamPos(0); - Game::Load_Stream(true, *reinterpret_cast(varPathData + 64), *reinterpret_cast(varPathData + 60)); - } - - if (*reinterpret_cast(varPathData + 76)) - { - *reinterpret_cast(varPathData + 76) = Game::DB_AllocStreamPos(0); - Game::Load_Stream(true, *reinterpret_cast(varPathData + 76), *reinterpret_cast(varPathData + 72)); - } - } - } - - bool Zones::Loadsnd_alias_tArray(bool atStreamStart, char* buffer, int len) - { - int count = 0; - - if (Zones::Version() >= VERSION_ALPHA2) - { - len /= 100; - count = len; - len *= 108; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, len); - - if (Zones::Version() >= VERSION_ALPHA2) - { + std::memcpy(&tempVar[44], &buffer[72], 12); + + std::memcpy(buffer, tempVar, sizeof(tempVar)); + } + + return result; + } +#pragma warning(pop) + + void Zones::LoadPathDataTail() + { + if (Zones::ZoneVersion >= VERSION_ALPHA2) + { + char* varPathData = reinterpret_cast(*Game::varPathData); + + if (*reinterpret_cast(varPathData + 56)) + { + *reinterpret_cast(varPathData + 56) = Game::DB_AllocStreamPos(0); + Game::Load_Stream(true, *reinterpret_cast(varPathData + 56), *reinterpret_cast(varPathData + 52)); + } + + if (*reinterpret_cast(varPathData + 64)) + { + *reinterpret_cast(varPathData + 64) = Game::DB_AllocStreamPos(0); + Game::Load_Stream(true, *reinterpret_cast(varPathData + 64), *reinterpret_cast(varPathData + 60)); + } + + if (*reinterpret_cast(varPathData + 76)) + { + *reinterpret_cast(varPathData + 76) = Game::DB_AllocStreamPos(0); + Game::Load_Stream(true, *reinterpret_cast(varPathData + 76), *reinterpret_cast(varPathData + 72)); + } + } + } + + bool Zones::Loadsnd_alias_tArray(bool atStreamStart, char* buffer, int len) + { + int count = 0; + + if (Zones::Version() >= VERSION_ALPHA2) + { + len /= 100; + count = len; + len *= 108; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, len); + + if (Zones::Version() >= VERSION_ALPHA2) + { Utils::Memory::Allocator allocator; Game::snd_alias_t* tempSounds = allocator.allocateArray(count); - + for (int i = 0; i < count; ++i) { char* src = &buffer[i * 108]; @@ -950,219 +950,219 @@ namespace Components } std::memcpy(buffer, tempSounds, sizeof(Game::snd_alias_t) * count); - } - - return result; - } - - bool Zones::LoadLoadedSound(bool atStreamStart, char* buffer, int size) - { - if (Zones::Version() >= VERSION_ALPHA2) - { - size = 48; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::Version() >= VERSION_ALPHA2) - { - std::memmove(buffer + 28, buffer + 32, 16); - AssetHandler::Relocate(buffer + 32, buffer + 28, 16); - } - - return result; - } - -// Code-analysis has a bug, the first memcpy makes it believe size of tempVar is 400 instead of 788 + } + + return result; + } + + bool Zones::LoadLoadedSound(bool atStreamStart, char* buffer, int size) + { + if (Zones::Version() >= VERSION_ALPHA2) + { + size = 48; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::Version() >= VERSION_ALPHA2) + { + std::memmove(buffer + 28, buffer + 32, 16); + AssetHandler::Relocate(buffer + 32, buffer + 28, 16); + } + + return result; + } + +// Code-analysis has a bug, the first memcpy makes it believe size of tempVar is 400 instead of 788 #pragma warning(push) -#pragma warning(disable: 6385) - bool Zones::LoadVehicleDef(bool atStreamStart, char* buffer, int size) - { - if (Zones::Version() >= VERSION_ALPHA2) - { - size = 788; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::Version() >= VERSION_ALPHA2) - { +#pragma warning(disable: 6385) + bool Zones::LoadVehicleDef(bool atStreamStart, char* buffer, int size) + { + if (Zones::Version() >= VERSION_ALPHA2) + { + size = 788; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::Version() >= VERSION_ALPHA2) + { char tempVar[788] = { 0 }; std::memcpy(&tempVar[0], &buffer[0], 400); - std::memcpy(&tempVar[408], &buffer[400], 380); - - AssetHandler::Relocate(buffer + 400, buffer + 408, 388); - - std::memmove(buffer, tempVar, sizeof(tempVar)); - } - - return result; - } -#pragma warning(pop) - - void Zones::LoadWeaponAttachStuff(DWORD* varWeaponAttachStuff, int count) - { - Game::Load_Stream(true, varWeaponAttachStuff, 12 * count); - - for (int i = 0; i < count; ++i) - { - if (varWeaponAttachStuff[1] < 16 || varWeaponAttachStuff[1] == 39) - { - if (varWeaponAttachStuff[2] == -1) - { - varWeaponAttachStuff[2] = reinterpret_cast(Game::DB_AllocStreamPos(0)); - *Game::varConstChar = reinterpret_cast(varWeaponAttachStuff[2]); - Game::Load_XStringCustom(Game::varConstChar); - } - } - - varWeaponAttachStuff += 3; - } - } - - bool Zones::LoadmenuDef_t(bool atStreamStart, char* buffer, int size) - { - if (Zones::ZoneVersion != 359 && Zones::ZoneVersion >= VERSION_ALPHA2) size += 4; - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::ZoneVersion >= VERSION_ALPHA2) - { - std::memmove(buffer + 168, buffer + 172, (Zones::ZoneVersion != 359 ? 232 : 228)); - AssetHandler::Relocate(buffer + 172, buffer + 168, (Zones::ZoneVersion != 359 ? 232 : 228)); - - reinterpret_cast(buffer)->expressionData = nullptr; - } - - return result; - } - - void Zones::LoadWeaponAttach() - { - if (Zones::ZoneVersion < VERSION_ALPHA2) - { - return Utils::Hook::Call(0x4F4160)(true); - } - - // setup structures we use - char* varWeaponAttach = *reinterpret_cast(0x112ADE0); // varAddonMapEnts - - // and do the stuff - Game::Load_Stream(true, varWeaponAttach, 12); - - Game::DB_PushStreamPos(3); - - *Game::varXString = reinterpret_cast(varWeaponAttach); - Game::Load_XString(false); - - *reinterpret_cast(varWeaponAttach + 8) = Game::DB_AllocStreamPos(3); - Zones::LoadWeaponAttachStuff(*reinterpret_cast(varWeaponAttach + 8), *reinterpret_cast(varWeaponAttach + 4)); - - Game::DB_PopStreamPos(); - } - - bool Zones::LoadMaterialShaderArgumentArray(bool atStreamStart, Game::MaterialShaderArgument* argument, int size) - { - bool result = Game::Load_Stream(atStreamStart, argument, size); - - Game::MaterialPass* curPass = *Game::varMaterialPass; - int count = curPass->argCount1 + curPass->argCount2 + curPass->argCount3; - - for (int i = 0; i < count && (Zones::ZoneVersion >= VERSION_ALPHA2); ++i) - { - Game::MaterialShaderArgument* arg = &argument[i]; - - if (arg->type != D3DSHADER_PARAM_REGISTER_TYPE::D3DSPR_TEXTURE && arg->type != D3DSHADER_PARAM_REGISTER_TYPE::D3DSPR_ATTROUT) - { - continue; - } - - // should be min 68 currently - // >= 58 fixes foliage without bad side effects - // >= 53 still has broken shadow mapping - // >= 23 is still broken somehow - if (arg->paramID >= 58 && arg->paramID <= 135) // >= 34 would be 31 in iw4 terms - { - arg->paramID -= 3; - - if (Zones::Version() >= 359/* && arg->paramID <= 113*/) - { - arg->paramID -= 7; - - if (arg->paramID <= 53) - { - arg->paramID += 1; - } - } - } - // >= 21 works fine for specular, but breaks trees - // >= 4 is too low, breaks specular - else if (arg->paramID >= 11 && arg->paramID < 58) - { - arg->paramID -= 2; - - if (Zones::Version() >= 359) - { - if (arg->paramID > 15 && arg->paramID < 30) - { - arg->paramID -= 1; - - if (arg->paramID == 19) - { - arg->paramID = 21; - } - } - else if (arg->paramID >= 50) - { - arg->paramID += 6; - } - } + std::memcpy(&tempVar[408], &buffer[400], 380); + + AssetHandler::Relocate(buffer + 400, buffer + 408, 388); + + std::memmove(buffer, tempVar, sizeof(tempVar)); + } + + return result; + } +#pragma warning(pop) + + void Zones::LoadWeaponAttachStuff(DWORD* varWeaponAttachStuff, int count) + { + Game::Load_Stream(true, varWeaponAttachStuff, 12 * count); + + for (int i = 0; i < count; ++i) + { + if (varWeaponAttachStuff[1] < 16 || varWeaponAttachStuff[1] == 39) + { + if (varWeaponAttachStuff[2] == -1) + { + varWeaponAttachStuff[2] = reinterpret_cast(Game::DB_AllocStreamPos(0)); + *Game::varConstChar = reinterpret_cast(varWeaponAttachStuff[2]); + Game::Load_XStringCustom(Game::varConstChar); + } } - } - - return result; - } - - bool Zones::LoadStructuredDataStructPropertyArray(bool atStreamStart, char* data, int size) - { - int count = 0; - - if (Zones::ZoneVersion >= VERSION_ALPHA2) - { - size /= 16; - count = size; - size *= 24; - } - - bool result = Game::Load_Stream(atStreamStart, data, size); - - if (Zones::ZoneVersion >= VERSION_ALPHA2) - { - for (int i = 0; i < count; ++i) - { - std::memmove(data + (i * 16), data + (i * 24), 16); - AssetHandler::Relocate(data + (i * 24), data + (i * 16), 16); - } - } - - return result; - } - - bool Zones::LoadGfxImage(bool atStreamStart, char* buffer, int size) - { - if (Zones::ZoneVersion >= 332) - { - size = (Zones::ZoneVersion >= 359) ? 52 : 36; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::ZoneVersion >= 332) - { - AssetHandler::Relocate(buffer + (size - 4), buffer + 28, 4); - - if (Zones::Version() >= 359) - { + + varWeaponAttachStuff += 3; + } + } + + bool Zones::LoadmenuDef_t(bool atStreamStart, char* buffer, int size) + { + if (Zones::ZoneVersion != 359 && Zones::ZoneVersion >= VERSION_ALPHA2) size += 4; + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::ZoneVersion >= VERSION_ALPHA2) + { + std::memmove(buffer + 168, buffer + 172, (Zones::ZoneVersion != 359 ? 232 : 228)); + AssetHandler::Relocate(buffer + 172, buffer + 168, (Zones::ZoneVersion != 359 ? 232 : 228)); + + reinterpret_cast(buffer)->expressionData = nullptr; + } + + return result; + } + + void Zones::LoadWeaponAttach() + { + if (Zones::ZoneVersion < VERSION_ALPHA2) + { + return Utils::Hook::Call(0x4F4160)(true); + } + + // setup structures we use + char* varWeaponAttach = *reinterpret_cast(0x112ADE0); // varAddonMapEnts + + // and do the stuff + Game::Load_Stream(true, varWeaponAttach, 12); + + Game::DB_PushStreamPos(3); + + *Game::varXString = reinterpret_cast(varWeaponAttach); + Game::Load_XString(false); + + *reinterpret_cast(varWeaponAttach + 8) = Game::DB_AllocStreamPos(3); + Zones::LoadWeaponAttachStuff(*reinterpret_cast(varWeaponAttach + 8), *reinterpret_cast(varWeaponAttach + 4)); + + Game::DB_PopStreamPos(); + } + + bool Zones::LoadMaterialShaderArgumentArray(bool atStreamStart, Game::MaterialShaderArgument* argument, int size) + { + bool result = Game::Load_Stream(atStreamStart, argument, size); + + Game::MaterialPass* curPass = *Game::varMaterialPass; + int count = curPass->argCount1 + curPass->argCount2 + curPass->argCount3; + + for (int i = 0; i < count && (Zones::ZoneVersion >= VERSION_ALPHA2); ++i) + { + Game::MaterialShaderArgument* arg = &argument[i]; + + if (arg->type != D3DSHADER_PARAM_REGISTER_TYPE::D3DSPR_TEXTURE && arg->type != D3DSHADER_PARAM_REGISTER_TYPE::D3DSPR_ATTROUT) + { + continue; + } + + // should be min 68 currently + // >= 58 fixes foliage without bad side effects + // >= 53 still has broken shadow mapping + // >= 23 is still broken somehow + if (arg->paramID >= 58 && arg->paramID <= 135) // >= 34 would be 31 in iw4 terms + { + arg->paramID -= 3; + + if (Zones::Version() >= 359/* && arg->paramID <= 113*/) + { + arg->paramID -= 7; + + if (arg->paramID <= 53) + { + arg->paramID += 1; + } + } + } + // >= 21 works fine for specular, but breaks trees + // >= 4 is too low, breaks specular + else if (arg->paramID >= 11 && arg->paramID < 58) + { + arg->paramID -= 2; + + if (Zones::Version() >= 359) + { + if (arg->paramID > 15 && arg->paramID < 30) + { + arg->paramID -= 1; + + if (arg->paramID == 19) + { + arg->paramID = 21; + } + } + else if (arg->paramID >= 50) + { + arg->paramID += 6; + } + } + } + } + + return result; + } + + bool Zones::LoadStructuredDataStructPropertyArray(bool atStreamStart, char* data, int size) + { + int count = 0; + + if (Zones::ZoneVersion >= VERSION_ALPHA2) + { + size /= 16; + count = size; + size *= 24; + } + + bool result = Game::Load_Stream(atStreamStart, data, size); + + if (Zones::ZoneVersion >= VERSION_ALPHA2) + { + for (int i = 0; i < count; ++i) + { + std::memmove(data + (i * 16), data + (i * 24), 16); + AssetHandler::Relocate(data + (i * 24), data + (i * 16), 16); + } + } + + return result; + } + + bool Zones::LoadGfxImage(bool atStreamStart, char* buffer, int size) + { + if (Zones::ZoneVersion >= 332) + { + size = (Zones::ZoneVersion >= 359) ? 52 : 36; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::ZoneVersion >= 332) + { + AssetHandler::Relocate(buffer + (size - 4), buffer + 28, 4); + + if (Zones::Version() >= 359) + { struct { Game::GfxImageLoadDef* texture; @@ -1182,58 +1182,58 @@ namespace Components char pad3[5]; Game::GfxImageLoadDef* storedTexture; char* name; - } image359; - - AssertSize(image359, 52); - - // Copy to new struct - memcpy(&image359, buffer, sizeof(image359)); - - // Convert to old struct - Game::GfxImage* image = reinterpret_cast(buffer); - image->mapType = image359.mapType; - image->semantic = image359.semantic; - image->category = image359.category; - image->flags = image359.flags; - image->cardMemory = image359.cardMemory; - image->dataLen1 = image359.dataLen1; - image->dataLen2 = image359.dataLen2; - image->height = image359.height; - image->width = image359.width; - image->depth = image359.depth; - image->loaded = image359.loaded; - image->name = image359.name; - - // Used for later stuff - image->pad = image359.pad3[1]; - } - else - { - memcpy(buffer + 28, buffer + (size - 4), 4); - } - } - - return result; - } - - bool Zones::LoadXAsset(bool atStreamStart, char* buffer, int size) - { - int count = 0; - - if (Zones::ZoneVersion >= 359) - { - size /= 8; - count = size; - size *= 16; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::ZoneVersion >= 359) - { + } image359; + + AssertSize(image359, 52); + + // Copy to new struct + memcpy(&image359, buffer, sizeof(image359)); + + // Convert to old struct + Game::GfxImage* image = reinterpret_cast(buffer); + image->mapType = image359.mapType; + image->semantic = image359.semantic; + image->category = image359.category; + image->flags = image359.flags; + image->cardMemory = image359.cardMemory; + image->dataLen1 = image359.dataLen1; + image->dataLen2 = image359.dataLen2; + image->height = image359.height; + image->width = image359.width; + image->depth = image359.depth; + image->loaded = image359.loaded; + image->name = image359.name; + + // Used for later stuff + image->pad = image359.pad3[1]; + } + else + { + memcpy(buffer + 28, buffer + (size - 4), 4); + } + } + + return result; + } + + bool Zones::LoadXAsset(bool atStreamStart, char* buffer, int size) + { + int count = 0; + + if (Zones::ZoneVersion >= 359) + { + size /= 8; + count = size; + size *= 16; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::ZoneVersion >= 359) + { Utils::Memory::Allocator allocator; - Game::XAsset* tempAssets = allocator.allocateArray(count); - + Game::XAsset* tempAssets = allocator.allocateArray(count); + for (int i = 0; i < count; ++i) { char* src = &buffer[i * 16]; @@ -1243,24 +1243,24 @@ namespace Components AssetHandler::Relocate(src + 0, buffer + (i * 8) + 0, 4); AssetHandler::Relocate(src + 8, buffer + (i * 8) + 4, 4); - } - - std::memcpy(buffer, tempAssets, sizeof(Game::XAsset) * count); - } - - return result; - } - - bool Zones::LoadMaterialTechnique(bool atStreamStart, char* buffer, int size) - { - if (Zones::ZoneVersion >= 359) - { - size += 4; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); + } - if (Zones::ZoneVersion >= 359) + std::memcpy(buffer, tempAssets, sizeof(Game::XAsset) * count); + } + + return result; + } + + bool Zones::LoadMaterialTechnique(bool atStreamStart, char* buffer, int size) + { + if (Zones::ZoneVersion >= 359) + { + size += 4; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::ZoneVersion >= 359) { // This shouldn't make any difference. // The new entry is an additional remapped techset which is linked at runtime. @@ -1268,19 +1268,19 @@ namespace Components // As MW2 flags are only 1 byte large, this won't be possible anyways int shiftTest = 4; - std::memmove(buffer + 8 + shiftTest, buffer + 12 + shiftTest, 196 - shiftTest); - AssetHandler::Relocate(buffer + 12 + shiftTest, buffer + 8 + shiftTest, 196 - shiftTest); - } - - return result; - } - - bool Zones::LoadMaterial(bool atStreamStart, char* buffer, int size) - { - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::ZoneVersion >= 359) - { + std::memmove(buffer + 8 + shiftTest, buffer + 12 + shiftTest, 196 - shiftTest); + AssetHandler::Relocate(buffer + 12 + shiftTest, buffer + 8 + shiftTest, 196 - shiftTest); + } + + return result; + } + + bool Zones::LoadMaterial(bool atStreamStart, char* buffer, int size) + { + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::ZoneVersion >= 359) + { struct material339_s { char drawSurfBegin[8]; // 4 @@ -1296,84 +1296,84 @@ namespace Components char sortKey; char textureAtlasRowCount; char textureAtlasColumnCount; - } material359; - - static_assert(offsetof(material339_s, gameFlags) == 18, ""); - static_assert(offsetof(material339_s, sortKey) == 20, ""); - static_assert(offsetof(material339_s, textureAtlasColumnCount) == 22, ""); - - static_assert(offsetof(Game::Material, stateBitsEntry) == 24, ""); - + } material359; + + static_assert(offsetof(material339_s, gameFlags) == 18, ""); + static_assert(offsetof(material339_s, sortKey) == 20, ""); + static_assert(offsetof(material339_s, textureAtlasColumnCount) == 22, ""); + + static_assert(offsetof(Game::Material, stateBitsEntry) == 24, ""); + Game::Material* material = (Game::Material*)buffer; memcpy(&material359, material, sizeof(material359)); - - material->name = material359.name; - material->sortKey = material359.sortKey; - material->textureAtlasRowCount = material359.textureAtlasRowCount; - material->textureAtlasColumnCount = material359.textureAtlasColumnCount; - material->gameFlags = material359.gameFlags; - - // Probably wrong - material->surfaceTypeBits = 0;//material359.surfaceTypeBits; - - // Pretty sure that's wrong - // Actually, it's not - memcpy(material->drawSurf, material359.drawSurfBegin, 8); - - material->drawSurf[8] = material359.drawSurf[0]; - material->drawSurf[9] = material359.drawSurf[1]; - material->drawSurf[10] = material359.drawSurf[2]; - material->drawSurf[11] = material359.drawSurf[3]; - - if (material359.sGameFlags & 0x100) - { - //OutputDebugStringA(""); - } - } - - return result; - } - - bool Zones::LoadGfxWorld(bool atStreamStart, char* buffer, int size) - { - if (Zones::ZoneVersion >= 359) - { - size += 968; - } - - bool result = Game::Load_Stream(atStreamStart, buffer, size); - - if (Zones::ZoneVersion >= 359) - { - int sunDiff = 8; // Stuff that is part of the sunflare we would overwrite - std::memmove(buffer + 348 + sunDiff, buffer + 1316 + sunDiff, 280 - sunDiff); - AssetHandler::Relocate(buffer + 1316, buffer + 348, 280); - } - - return result; - } - - void Zones::Loadsunflare_t(bool atStreamStart) - { - Game::Load_MaterialHandle(atStreamStart); - - if (Zones::ZoneVersion >= 359) - { - char* varsunflare_t = *reinterpret_cast(0x112A848); - - *Game::varMaterialHandle = reinterpret_cast(varsunflare_t + 12); - Game::Load_MaterialHandle(atStreamStart); - - *Game::varMaterialHandle = reinterpret_cast(varsunflare_t + 16); - Game::Load_MaterialHandle(atStreamStart); - - std::memmove(varsunflare_t + 12, varsunflare_t + 20, 84); - - // Copy the remaining struct data we couldn't copy in LoadGfxWorld - char* varGfxWorld = *reinterpret_cast(0x112A7F4); - std::memmove(varGfxWorld + 348, varGfxWorld + 1316, 8); - } - } + + material->name = material359.name; + material->sortKey = material359.sortKey; + material->textureAtlasRowCount = material359.textureAtlasRowCount; + material->textureAtlasColumnCount = material359.textureAtlasColumnCount; + material->gameFlags = material359.gameFlags; + + // Probably wrong + material->surfaceTypeBits = 0;//material359.surfaceTypeBits; + + // Pretty sure that's wrong + // Actually, it's not + memcpy(material->drawSurf, material359.drawSurfBegin, 8); + + material->drawSurf[8] = material359.drawSurf[0]; + material->drawSurf[9] = material359.drawSurf[1]; + material->drawSurf[10] = material359.drawSurf[2]; + material->drawSurf[11] = material359.drawSurf[3]; + + if (material359.sGameFlags & 0x100) + { + //OutputDebugStringA(""); + } + } + + return result; + } + + bool Zones::LoadGfxWorld(bool atStreamStart, char* buffer, int size) + { + if (Zones::ZoneVersion >= 359) + { + size += 968; + } + + bool result = Game::Load_Stream(atStreamStart, buffer, size); + + if (Zones::ZoneVersion >= 359) + { + int sunDiff = 8; // Stuff that is part of the sunflare we would overwrite + std::memmove(buffer + 348 + sunDiff, buffer + 1316 + sunDiff, 280 - sunDiff); + AssetHandler::Relocate(buffer + 1316, buffer + 348, 280); + } + + return result; + } + + void Zones::Loadsunflare_t(bool atStreamStart) + { + Game::Load_MaterialHandle(atStreamStart); + + if (Zones::ZoneVersion >= 359) + { + char* varsunflare_t = *reinterpret_cast(0x112A848); + + *Game::varMaterialHandle = reinterpret_cast(varsunflare_t + 12); + Game::Load_MaterialHandle(atStreamStart); + + *Game::varMaterialHandle = reinterpret_cast(varsunflare_t + 16); + Game::Load_MaterialHandle(atStreamStart); + + std::memmove(varsunflare_t + 12, varsunflare_t + 20, 84); + + // Copy the remaining struct data we couldn't copy in LoadGfxWorld + char* varGfxWorld = *reinterpret_cast(0x112A7F4); + std::memmove(varGfxWorld + 348, varGfxWorld + 1316, 8); + } + } bool Zones::LoadStatement(bool atStreamStart, char* buffer, int size) { @@ -1573,8 +1573,8 @@ namespace Components { Zones::ZoneVersion = 0; - // Ignore missing soundaliases for now - // TODO: Include them in the dependency zone! + // Ignore missing soundaliases for now + // TODO: Include them in the dependency zone! Utils::Hook::Nop(0x644207, 5); // Block Mark_pathnode_constant_t @@ -1583,45 +1583,45 @@ namespace Components // addon_map_ents asset type (we reuse it for weaponattach) Utils::Hook::Set(0x418B31, 0x72); - Utils::Hook(0x495938, Zones::LoadFxElemDefArrayStub, HOOK_CALL).install()->quick(); - Utils::Hook(0x45ADA0, Zones::LoadFxElemDefStub, HOOK_CALL).install()->quick(); - Utils::Hook(0x4EA6FE, Zones::LoadXModelLodInfoStub, HOOK_CALL).install()->quick(); - Utils::Hook(0x410D90, Zones::LoadXModel, HOOK_CALL).install()->quick(); - Utils::Hook(0x4925C8, Zones::LoadXSurfaceArray, HOOK_CALL).install()->quick(); - Utils::Hook(0x4F4D0D, Zones::LoadGameWorldSp, HOOK_CALL).install()->quick(); - Utils::Hook(0x47CCD2, Zones::LoadWeaponCompleteDef, HOOK_CALL).install()->quick(); - Utils::Hook(0x483DA0, Zones::LoadVehicleDef, HOOK_CALL).install()->quick(); - Utils::Hook(0x4F0AC8, Zones::Loadsnd_alias_tArray, HOOK_CALL).install()->quick(); - Utils::Hook(0x403A5D, Zones::LoadLoadedSound, HOOK_CALL).install()->quick(); - Utils::Hook(0x463022, Zones::LoadWeaponAttach, HOOK_CALL).install()->quick(); - Utils::Hook(0x41A570, Zones::LoadmenuDef_t, HOOK_CALL).install()->quick(); - Utils::Hook(0x49591B, Zones::LoadFxEffectDef, HOOK_CALL).install()->quick(); - Utils::Hook(0x428F0A, Zones::LoadMaterialShaderArgumentArray, HOOK_CALL).install()->quick(); - Utils::Hook(0x4B1EB8, Zones::LoadStructuredDataStructPropertyArray, HOOK_CALL).install()->quick(); - Utils::Hook(0x49CE0D, Zones::LoadPhysPreset, HOOK_CALL).install()->quick(); - Utils::Hook(0x48E84D, Zones::LoadXModelSurfs, HOOK_CALL).install()->quick(); - Utils::Hook(0x4447C2, Zones::LoadImpactFx, HOOK_CALL).install()->quick(); - Utils::Hook(0x4447D0, Zones::LoadImpactFxArray, HOOK_JUMP).install()->quick(); - Utils::Hook(0x4D6A0B, Zones::LoadPathNodeArray, HOOK_CALL).install()->quick(); - Utils::Hook(0x4D6A47, Zones::LoadPathDataConstant, HOOK_JUMP).install()->quick(); - Utils::Hook(0x463D6E, Zones::LoadPathnodeConstantTail, HOOK_CALL).install()->quick(); - - Utils::Hook(0x4471AD, Zones::LoadGfxImage, HOOK_CALL).install()->quick(); - - Utils::Hook(0x41A590, Zones::LoadExpressionSupportingDataPtr, HOOK_CALL).install()->quick(); - Utils::Hook(0x459833, Zones::LoadExpressionSupportingDataPtr, HOOK_JUMP).install()->quick(); + Utils::Hook(0x495938, Zones::LoadFxElemDefArrayStub, HOOK_CALL).install()->quick(); + Utils::Hook(0x45ADA0, Zones::LoadFxElemDefStub, HOOK_CALL).install()->quick(); + Utils::Hook(0x4EA6FE, Zones::LoadXModelLodInfoStub, HOOK_CALL).install()->quick(); + Utils::Hook(0x410D90, Zones::LoadXModel, HOOK_CALL).install()->quick(); + Utils::Hook(0x4925C8, Zones::LoadXSurfaceArray, HOOK_CALL).install()->quick(); + Utils::Hook(0x4F4D0D, Zones::LoadGameWorldSp, HOOK_CALL).install()->quick(); + Utils::Hook(0x47CCD2, Zones::LoadWeaponCompleteDef, HOOK_CALL).install()->quick(); + Utils::Hook(0x483DA0, Zones::LoadVehicleDef, HOOK_CALL).install()->quick(); + Utils::Hook(0x4F0AC8, Zones::Loadsnd_alias_tArray, HOOK_CALL).install()->quick(); + Utils::Hook(0x403A5D, Zones::LoadLoadedSound, HOOK_CALL).install()->quick(); + Utils::Hook(0x463022, Zones::LoadWeaponAttach, HOOK_CALL).install()->quick(); + Utils::Hook(0x41A570, Zones::LoadmenuDef_t, HOOK_CALL).install()->quick(); + Utils::Hook(0x49591B, Zones::LoadFxEffectDef, HOOK_CALL).install()->quick(); + Utils::Hook(0x428F0A, Zones::LoadMaterialShaderArgumentArray, HOOK_CALL).install()->quick(); + Utils::Hook(0x4B1EB8, Zones::LoadStructuredDataStructPropertyArray, HOOK_CALL).install()->quick(); + Utils::Hook(0x49CE0D, Zones::LoadPhysPreset, HOOK_CALL).install()->quick(); + Utils::Hook(0x48E84D, Zones::LoadXModelSurfs, HOOK_CALL).install()->quick(); + Utils::Hook(0x4447C2, Zones::LoadImpactFx, HOOK_CALL).install()->quick(); + Utils::Hook(0x4447D0, Zones::LoadImpactFxArray, HOOK_JUMP).install()->quick(); + Utils::Hook(0x4D6A0B, Zones::LoadPathNodeArray, HOOK_CALL).install()->quick(); + Utils::Hook(0x4D6A47, Zones::LoadPathDataConstant, HOOK_JUMP).install()->quick(); + Utils::Hook(0x463D6E, Zones::LoadPathnodeConstantTail, HOOK_CALL).install()->quick(); + + Utils::Hook(0x4471AD, Zones::LoadGfxImage, HOOK_CALL).install()->quick(); + + Utils::Hook(0x41A590, Zones::LoadExpressionSupportingDataPtr, HOOK_CALL).install()->quick(); + Utils::Hook(0x459833, Zones::LoadExpressionSupportingDataPtr, HOOK_JUMP).install()->quick(); Utils::Hook(0x5B9AA5, Zones::LoadXAsset, HOOK_CALL).install()->quick(); Utils::Hook(0x461710, Zones::LoadMaterialTechnique, HOOK_CALL).install()->quick(); Utils::Hook(0x40330D, Zones::LoadMaterial, HOOK_CALL).install()->quick(); Utils::Hook(0x4B8DC0, Zones::LoadGfxWorld, HOOK_CALL).install()->quick(); - Utils::Hook(0x4B8FF5, Zones::Loadsunflare_t, HOOK_CALL).install()->quick(); - - Utils::Hook(0x418998, Zones::GameMapSpPatchStub, HOOK_JUMP).install()->quick(); + Utils::Hook(0x4B8FF5, Zones::Loadsunflare_t, HOOK_CALL).install()->quick(); + + Utils::Hook(0x418998, Zones::GameMapSpPatchStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x427A1B, Zones::LoadPathDataTail, HOOK_JUMP).install()->quick(); Utils::Hook(0x4F4D3B, [] () { - if (Zones::ZoneVersion >= VERSION_ALPHA3) + if (Zones::ZoneVersion >= VERSION_ALPHA3) { ZeroMemory(*Game::varPathData, sizeof(Game::PathData)); } diff --git a/src/Components/Modules/Zones.hpp b/src/Components/Modules/Zones.hpp index 63d531ed..c7bb32aa 100644 --- a/src/Components/Modules/Zones.hpp +++ b/src/Components/Modules/Zones.hpp @@ -1,4 +1,4 @@ -#define VERSION_ALPHA2 316 +#define VERSION_ALPHA2 316 #define VERSION_ALPHA3 318//319 #define VERSION_ALPHA3_DEC 319 @@ -11,7 +11,7 @@ namespace Components ~Zones(); #if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - const char* getName() { return "Zones"; }; + const char* getName() { return "Zones"; }; #endif static void SetVersion(int version); @@ -37,7 +37,7 @@ namespace Components static bool LoadGameWorldSp(bool atStreamStart, char* buffer, int size); static bool LoadVehicleDef(bool atStreamStart, char* buffer, int size); static bool Loadsnd_alias_tArray(bool atStreamStart, char* buffer, int len); - static bool LoadLoadedSound(bool atStreamStart, char* buffer, int size); + static bool LoadLoadedSound(bool atStreamStart, char* buffer, int size); static bool LoadmenuDef_t(bool atStreamStart, char* buffer, int size); static bool LoadFxEffectDef(bool atStreamStart, char* buffer, int size); static bool LoadMaterialShaderArgumentArray(bool atStreamStart, Game::MaterialShaderArgument* argument, int size); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 054ee1f3..bae9dd60 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -33,8 +33,8 @@ namespace Game Con_DrawMiniConsole_t Con_DrawMiniConsole = (Con_DrawMiniConsole_t)0x464F30; Con_DrawSolidConsole_t Con_DrawSolidConsole = (Con_DrawSolidConsole_t)0x5A5040; - DB_AllocStreamPos_t DB_AllocStreamPos = (DB_AllocStreamPos_t)0x418380; - DB_PushStreamPos_t DB_PushStreamPos = (DB_PushStreamPos_t)0x458A20; + DB_AllocStreamPos_t DB_AllocStreamPos = (DB_AllocStreamPos_t)0x418380; + DB_PushStreamPos_t DB_PushStreamPos = (DB_PushStreamPos_t)0x458A20; DB_PopStreamPos_t DB_PopStreamPos = (DB_PopStreamPos_t)0x4D1D60; DB_BeginRecoverLostDevice_t DB_BeginRecoverLostDevice = (DB_BeginRecoverLostDevice_t)0x4BFF90; @@ -103,23 +103,23 @@ namespace Game Key_SetCatcher_t Key_SetCatcher = (Key_SetCatcher_t)0x43BD00; LargeLocalInit_t LargeLocalInit = (LargeLocalInit_t)0x4A62A0; - - Load_Stream_t Load_Stream = (Load_Stream_t)0x470E30; - Load_XString_t Load_XString = (Load_XString_t)0x47FDA0; - Load_XModelPtr_t Load_XModelPtr = (Load_XModelPtr_t)0x4FCA70; - Load_XModelSurfsFixup_t Load_XModelSurfsFixup = (Load_XModelSurfsFixup_t)0x40D7A0; - Load_XStringArray_t Load_XStringArray = (Load_XStringArray_t)0x4977F0; - Load_XStringCustom_t Load_XStringCustom = (Load_XStringCustom_t)0x4E0DD0; - Load_FxEffectDefHandle_t Load_FxEffectDefHandle = (Load_FxEffectDefHandle_t)0x4D9B90; - Load_FxElemDef_t Load_FxElemDef = (Load_FxElemDef_t)0x45AD90; - Load_GfxImagePtr_t Load_GfxImagePtr = (Load_GfxImagePtr_t)0x4C13D0; - Load_Texture_t Load_Texture = (Load_Texture_t)0x51F4E0; - Load_GfxTextureLoad_t Load_GfxTextureLoad = (Load_GfxTextureLoad_t)0x4D3210; - Load_SndAliasCustom_t Load_SndAliasCustom = (Load_SndAliasCustom_t)0x49B6B0; - Load_MaterialHandle_t Load_MaterialHandle = (Load_MaterialHandle_t)0x403960; - Load_PhysCollmapPtr_t Load_PhysCollmapPtr = (Load_PhysCollmapPtr_t)0x47E990; - Load_PhysPresetPtr_t Load_PhysPresetPtr = (Load_PhysPresetPtr_t)0x4FAD30; - Load_TracerDefPtr_t Load_TracerDefPtr = (Load_TracerDefPtr_t)0x493090; + + Load_Stream_t Load_Stream = (Load_Stream_t)0x470E30; + Load_XString_t Load_XString = (Load_XString_t)0x47FDA0; + Load_XModelPtr_t Load_XModelPtr = (Load_XModelPtr_t)0x4FCA70; + Load_XModelSurfsFixup_t Load_XModelSurfsFixup = (Load_XModelSurfsFixup_t)0x40D7A0; + Load_XStringArray_t Load_XStringArray = (Load_XStringArray_t)0x4977F0; + Load_XStringCustom_t Load_XStringCustom = (Load_XStringCustom_t)0x4E0DD0; + Load_FxEffectDefHandle_t Load_FxEffectDefHandle = (Load_FxEffectDefHandle_t)0x4D9B90; + Load_FxElemDef_t Load_FxElemDef = (Load_FxElemDef_t)0x45AD90; + Load_GfxImagePtr_t Load_GfxImagePtr = (Load_GfxImagePtr_t)0x4C13D0; + Load_Texture_t Load_Texture = (Load_Texture_t)0x51F4E0; + Load_GfxTextureLoad_t Load_GfxTextureLoad = (Load_GfxTextureLoad_t)0x4D3210; + Load_SndAliasCustom_t Load_SndAliasCustom = (Load_SndAliasCustom_t)0x49B6B0; + Load_MaterialHandle_t Load_MaterialHandle = (Load_MaterialHandle_t)0x403960; + Load_PhysCollmapPtr_t Load_PhysCollmapPtr = (Load_PhysCollmapPtr_t)0x47E990; + Load_PhysPresetPtr_t Load_PhysPresetPtr = (Load_PhysPresetPtr_t)0x4FAD30; + Load_TracerDefPtr_t Load_TracerDefPtr = (Load_TracerDefPtr_t)0x493090; Load_snd_alias_list_nameArray_t Load_snd_alias_list_nameArray = (Load_snd_alias_list_nameArray_t)0x4499F0; Menus_CloseAll_t Menus_CloseAll = (Menus_CloseAll_t)0x4BA5B0; @@ -297,17 +297,17 @@ namespace Game mapname_t* mapnames = (mapname_t*)0x7471D0; - char*** varXString = (char***)0x112B340; - TracerDef*** varTracerDefPtr = (TracerDef***)0x112B3BC; - XModel*** varXModelPtr = (XModel***)0x112A934; - XModel** varXModel = (XModel**)0x112AE14; - PathData** varPathData = (PathData**)0x112AD7C; - const char** varConstChar = (const char**)0x112A774; - Material*** varMaterialHandle = (Material***)0x112A878; - FxEffectDef*** varFxEffectDefHandle = (FxEffectDef***)0x112ACC0; - PhysCollmap*** varPhysCollmapPtr = (PhysCollmap***)0x112B440; - PhysPreset*** varPhysPresetPtr = (PhysPreset***)0x112B378; - Game::MaterialPass** varMaterialPass = (Game::MaterialPass**)0x112A960; + char*** varXString = (char***)0x112B340; + TracerDef*** varTracerDefPtr = (TracerDef***)0x112B3BC; + XModel*** varXModelPtr = (XModel***)0x112A934; + XModel** varXModel = (XModel**)0x112AE14; + PathData** varPathData = (PathData**)0x112AD7C; + const char** varConstChar = (const char**)0x112A774; + Material*** varMaterialHandle = (Material***)0x112A878; + FxEffectDef*** varFxEffectDefHandle = (FxEffectDef***)0x112ACC0; + PhysCollmap*** varPhysCollmapPtr = (PhysCollmap***)0x112B440; + PhysPreset*** varPhysPresetPtr = (PhysPreset***)0x112B378; + Game::MaterialPass** varMaterialPass = (Game::MaterialPass**)0x112A960; snd_alias_list_t*** varsnd_alias_list_name = (snd_alias_list_t***)0x112AF38; XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize) diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 69fbd054..f0d8cde0 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -69,13 +69,13 @@ namespace Game typedef void (__cdecl * Con_DrawSolidConsole_t)(); extern Con_DrawSolidConsole_t Con_DrawSolidConsole; - typedef char *(__cdecl *DB_AllocStreamPos_t)(int alignment); - extern DB_AllocStreamPos_t DB_AllocStreamPos; - - typedef void(__cdecl * DB_PushStreamPos_t)(unsigned int index); - extern DB_PushStreamPos_t DB_PushStreamPos; - - typedef void(__cdecl * DB_PopStreamPos_t)(); + typedef char *(__cdecl *DB_AllocStreamPos_t)(int alignment); + extern DB_AllocStreamPos_t DB_AllocStreamPos; + + typedef void(__cdecl * DB_PushStreamPos_t)(unsigned int index); + extern DB_PushStreamPos_t DB_PushStreamPos; + + typedef void(__cdecl * DB_PopStreamPos_t)(); extern DB_PopStreamPos_t DB_PopStreamPos; typedef void(__cdecl * DB_BeginRecoverLostDevice_t)(); @@ -242,55 +242,55 @@ namespace Game typedef void(__cdecl * LargeLocalInit_t)(); extern LargeLocalInit_t LargeLocalInit; - typedef bool(__cdecl * Load_Stream_t)(bool atStreamStart, const void *ptr, int size); - extern Load_Stream_t Load_Stream; - - typedef void(__cdecl * Load_XString_t)(bool atStreamStart); - extern Load_XString_t Load_XString; - - typedef void(__cdecl * Load_XModelPtr_t)(bool atStreamStart); - extern Load_XModelPtr_t Load_XModelPtr; - - typedef void(__cdecl * Load_XModelSurfsFixup_t)(XModelSurfs **, XModelLodInfo *); - extern Load_XModelSurfsFixup_t Load_XModelSurfsFixup; - - typedef void(__cdecl * Load_XStringArray_t)(bool atStreamStart, int count); - extern Load_XStringArray_t Load_XStringArray; - - typedef void(__cdecl * Load_XStringCustom_t)(const char **str); - extern Load_XStringCustom_t Load_XStringCustom; - - typedef void(__cdecl *Load_FxEffectDefHandle_t)(bool atStreamStart); - extern Load_FxEffectDefHandle_t Load_FxEffectDefHandle; - - typedef void(__cdecl *Load_FxElemDef_t)(bool atStreamStart); - extern Load_FxElemDef_t Load_FxElemDef; - - typedef void(__cdecl *Load_GfxImagePtr_t)(bool atStreamStart); - extern Load_GfxImagePtr_t Load_GfxImagePtr; - - typedef void(__cdecl *Load_GfxTextureLoad_t)(bool atStreamStart); - extern Load_GfxTextureLoad_t Load_GfxTextureLoad; - - typedef int(__cdecl *Load_Texture_t)(GfxImageLoadDef **loadDef, GfxImage *image); - extern Load_Texture_t Load_Texture; - - typedef void(__cdecl * Load_SndAliasCustom_t)(snd_alias_list_t** var); - extern Load_SndAliasCustom_t Load_SndAliasCustom; - - typedef void(__cdecl *Load_MaterialHandle_t)(bool atStreamStart); - extern Load_MaterialHandle_t Load_MaterialHandle; - - typedef void(__cdecl *Load_PhysCollmapPtr_t)(bool atStreamStart); - extern Load_PhysCollmapPtr_t Load_PhysCollmapPtr; - - typedef void(__cdecl *Load_PhysPresetPtr_t)(bool atStreamStart); - extern Load_PhysPresetPtr_t Load_PhysPresetPtr; - - typedef void(__cdecl *Load_TracerDefPtr_t)(bool atStreamStart); - extern Load_TracerDefPtr_t Load_TracerDefPtr; - - typedef void(__cdecl *Load_snd_alias_list_nameArray_t)(bool atStreamStart, int count); + typedef bool(__cdecl * Load_Stream_t)(bool atStreamStart, const void *ptr, int size); + extern Load_Stream_t Load_Stream; + + typedef void(__cdecl * Load_XString_t)(bool atStreamStart); + extern Load_XString_t Load_XString; + + typedef void(__cdecl * Load_XModelPtr_t)(bool atStreamStart); + extern Load_XModelPtr_t Load_XModelPtr; + + typedef void(__cdecl * Load_XModelSurfsFixup_t)(XModelSurfs **, XModelLodInfo *); + extern Load_XModelSurfsFixup_t Load_XModelSurfsFixup; + + typedef void(__cdecl * Load_XStringArray_t)(bool atStreamStart, int count); + extern Load_XStringArray_t Load_XStringArray; + + typedef void(__cdecl * Load_XStringCustom_t)(const char **str); + extern Load_XStringCustom_t Load_XStringCustom; + + typedef void(__cdecl *Load_FxEffectDefHandle_t)(bool atStreamStart); + extern Load_FxEffectDefHandle_t Load_FxEffectDefHandle; + + typedef void(__cdecl *Load_FxElemDef_t)(bool atStreamStart); + extern Load_FxElemDef_t Load_FxElemDef; + + typedef void(__cdecl *Load_GfxImagePtr_t)(bool atStreamStart); + extern Load_GfxImagePtr_t Load_GfxImagePtr; + + typedef void(__cdecl *Load_GfxTextureLoad_t)(bool atStreamStart); + extern Load_GfxTextureLoad_t Load_GfxTextureLoad; + + typedef int(__cdecl *Load_Texture_t)(GfxImageLoadDef **loadDef, GfxImage *image); + extern Load_Texture_t Load_Texture; + + typedef void(__cdecl * Load_SndAliasCustom_t)(snd_alias_list_t** var); + extern Load_SndAliasCustom_t Load_SndAliasCustom; + + typedef void(__cdecl *Load_MaterialHandle_t)(bool atStreamStart); + extern Load_MaterialHandle_t Load_MaterialHandle; + + typedef void(__cdecl *Load_PhysCollmapPtr_t)(bool atStreamStart); + extern Load_PhysCollmapPtr_t Load_PhysCollmapPtr; + + typedef void(__cdecl *Load_PhysPresetPtr_t)(bool atStreamStart); + extern Load_PhysPresetPtr_t Load_PhysPresetPtr; + + typedef void(__cdecl *Load_TracerDefPtr_t)(bool atStreamStart); + extern Load_TracerDefPtr_t Load_TracerDefPtr; + + typedef void(__cdecl *Load_snd_alias_list_nameArray_t)(bool atStreamStart, int count); extern Load_snd_alias_list_nameArray_t Load_snd_alias_list_nameArray; typedef void(__cdecl * Menus_CloseAll_t)(UiContext *dc); @@ -437,7 +437,7 @@ namespace Game typedef float(__cdecl * Scr_GetFloat_t)(int); extern Scr_GetFloat_t Scr_GetFloat; - typedef int(__cdecl * Scr_GetNumParam_t)(void); + typedef int(__cdecl * Scr_GetNumParam_t)(void); extern Scr_GetNumParam_t Scr_GetNumParam; typedef int(__cdecl * Scr_GetFunctionHandle_t)(const char*, const char*); @@ -612,17 +612,17 @@ namespace Game extern mapname_t* mapnames; - extern char*** varXString; - extern TracerDef*** varTracerDefPtr; - extern XModel*** varXModelPtr; - extern XModel** varXModel; - extern PathData** varPathData; - extern const char** varConstChar; - extern Material*** varMaterialHandle; - extern FxEffectDef*** varFxEffectDefHandle; - extern PhysCollmap*** varPhysCollmapPtr; - extern PhysPreset*** varPhysPresetPtr; - extern Game::MaterialPass** varMaterialPass; + extern char*** varXString; + extern TracerDef*** varTracerDefPtr; + extern XModel*** varXModelPtr; + extern XModel** varXModel; + extern PathData** varPathData; + extern const char** varConstChar; + extern Material*** varMaterialHandle; + extern FxEffectDef*** varFxEffectDefHandle; + extern PhysCollmap*** varPhysCollmapPtr; + extern PhysPreset*** varPhysPresetPtr; + extern Game::MaterialPass** varMaterialPass; extern snd_alias_list_t*** varsnd_alias_list_name; XAssetHeader ReallocateAssetPool(XAssetType type, unsigned int newSize); diff --git a/src/Main.cpp b/src/Main.cpp index 0616f075..6648ae53 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1,85 +1,85 @@ -#include "STDInclude.hpp" - -namespace Main -{ - static Utils::Hook EntryPointHook; - - void SetEnvironment() - { +#include "STDInclude.hpp" + +namespace Main +{ + static Utils::Hook EntryPointHook; + + void SetEnvironment() + { wchar_t exeName[512]; GetModuleFileName(GetModuleHandle(NULL), exeName, sizeof(exeName) / 2); wchar_t* exeBaseName = wcsrchr(exeName, L'\\'); exeBaseName[0] = L'\0'; - exeBaseName++; - - SetCurrentDirectory(exeName); - } - - void Initialize() - { - Main::EntryPointHook.uninstall(); - - SetEnvironment(); - - Utils::Cryptography::Initialize(); - Components::Loader::Initialize(); - -#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) - if (Components::Loader::PerformingUnitTests()) - { - DWORD result = (Components::Loader::PerformUnitTests() ? 0 : -1); - Components::Loader::Uninitialize(); - ExitProcess(result); - } -#else - if (Components::Flags::HasFlag("tests")) - { - Components::Logger::Print("Unit tests are disabled outside the debug environment!\n"); - } -#endif - } - - void Uninitialize() - { - Components::Loader::Uninitialize(); - } -} - -BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/) -{ - if (ul_reason_for_call == DLL_PROCESS_ATTACH) - { - // Ensure we're working with our desired binary - if (Utils::Hook::Get(0x4C0FFF) != 0x6824748B) - { - return FALSE; - } - - - DWORD oldProtect; - std::uint8_t* module = reinterpret_cast(GetModuleHandle(NULL)); - //VirtualProtect(module, 0x6C73000, PAGE_EXECUTE_READWRITE, &oldProtect); // Unprotect the entire process - VirtualProtect(module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect); // Protect the .text segment - - - Main::EntryPointHook.initialize(0x6BAC0F, [] () - { - __asm - { - // This has to be called, otherwise the hook is not uninstalled and we're looping into infinity - call Main::Initialize - - mov eax, 6BAC0Fh - jmp eax - } - - })->install(); - } - else if (ul_reason_for_call == DLL_PROCESS_DETACH) - { - Main::Uninitialize(); - } - - return TRUE; -} + exeBaseName++; + + SetCurrentDirectory(exeName); + } + + void Initialize() + { + Main::EntryPointHook.uninstall(); + + SetEnvironment(); + + Utils::Cryptography::Initialize(); + Components::Loader::Initialize(); + +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) + if (Components::Loader::PerformingUnitTests()) + { + DWORD result = (Components::Loader::PerformUnitTests() ? 0 : -1); + Components::Loader::Uninitialize(); + ExitProcess(result); + } +#else + if (Components::Flags::HasFlag("tests")) + { + Components::Logger::Print("Unit tests are disabled outside the debug environment!\n"); + } +#endif + } + + void Uninitialize() + { + Components::Loader::Uninitialize(); + } +} + +BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/) +{ + if (ul_reason_for_call == DLL_PROCESS_ATTACH) + { + // Ensure we're working with our desired binary + if (Utils::Hook::Get(0x4C0FFF) != 0x6824748B) + { + return FALSE; + } + + + DWORD oldProtect; + std::uint8_t* module = reinterpret_cast(GetModuleHandle(NULL)); + //VirtualProtect(module, 0x6C73000, PAGE_EXECUTE_READWRITE, &oldProtect); // Unprotect the entire process + VirtualProtect(module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect); // Protect the .text segment + + + Main::EntryPointHook.initialize(0x6BAC0F, [] () + { + __asm + { + // This has to be called, otherwise the hook is not uninstalled and we're looping into infinity + call Main::Initialize + + mov eax, 6BAC0Fh + jmp eax + } + + })->install(); + } + else if (ul_reason_for_call == DLL_PROCESS_DETACH) + { + Main::Uninitialize(); + } + + return TRUE; +} diff --git a/src/Steam/Interfaces/SteamMatchmaking.cpp b/src/Steam/Interfaces/SteamMatchmaking.cpp index ef32f6eb..79d19117 100644 --- a/src/Steam/Interfaces/SteamMatchmaking.cpp +++ b/src/Steam/Interfaces/SteamMatchmaking.cpp @@ -1,6 +1,6 @@ -#include "STDInclude.hpp" - -STEAM_IGNORE_WARNINGS_START +#include "STDInclude.hpp" + +STEAM_IGNORE_WARNINGS_START namespace Steam { @@ -193,5 +193,5 @@ namespace Steam return true; } } - -STEAM_IGNORE_WARNINGS_END + +STEAM_IGNORE_WARNINGS_END diff --git a/src/Steam/Interfaces/SteamUser.cpp b/src/Steam/Interfaces/SteamUser.cpp index 880dd782..367dbf97 100644 --- a/src/Steam/Interfaces/SteamUser.cpp +++ b/src/Steam/Interfaces/SteamUser.cpp @@ -1,6 +1,6 @@ #include "STDInclude.hpp" - -STEAM_IGNORE_WARNINGS_START + +STEAM_IGNORE_WARNINGS_START namespace Steam { @@ -102,5 +102,5 @@ namespace Steam return 0; } } - -STEAM_IGNORE_WARNINGS_END + +STEAM_IGNORE_WARNINGS_END diff --git a/src/Steam/Interfaces/SteamUtils.cpp b/src/Steam/Interfaces/SteamUtils.cpp index aa797c9b..55925a9a 100644 --- a/src/Steam/Interfaces/SteamUtils.cpp +++ b/src/Steam/Interfaces/SteamUtils.cpp @@ -97,5 +97,5 @@ namespace Steam return false; } } - -STEAM_IGNORE_WARNINGS_END + +STEAM_IGNORE_WARNINGS_END diff --git a/src/Utils/Time.cpp b/src/Utils/Time.cpp index d8335b6b..af2235ca 100644 --- a/src/Utils/Time.cpp +++ b/src/Utils/Time.cpp @@ -1,17 +1,17 @@ #include "STDInclude.hpp" -namespace Utils -{ +namespace Utils +{ namespace Time - { - void Interval::update() - { - this->lastPoint = std::chrono::high_resolution_clock::now(); - } - - bool Interval::elapsed(std::chrono::nanoseconds nsecs) - { - return ((std::chrono::high_resolution_clock::now() - this->lastPoint) >= nsecs); - } - } -} + { + void Interval::update() + { + this->lastPoint = std::chrono::high_resolution_clock::now(); + } + + bool Interval::elapsed(std::chrono::nanoseconds nsecs) + { + return ((std::chrono::high_resolution_clock::now() - this->lastPoint) >= nsecs); + } + } +} diff --git a/src/Utils/Time.hpp b/src/Utils/Time.hpp index f2cf55bd..c18b37b4 100644 --- a/src/Utils/Time.hpp +++ b/src/Utils/Time.hpp @@ -1,17 +1,17 @@ -namespace Utils -{ +namespace Utils +{ namespace Time - { - class Interval - { - private: - std::chrono::high_resolution_clock::time_point lastPoint; - - public: - Interval() : lastPoint(std::chrono::high_resolution_clock::now()) {} - - void update(); - bool elapsed(std::chrono::nanoseconds nsecs); - }; - } -} + { + class Interval + { + private: + std::chrono::high_resolution_clock::time_point lastPoint; + + public: + Interval() : lastPoint(std::chrono::high_resolution_clock::now()) {} + + void update(); + bool elapsed(std::chrono::nanoseconds nsecs); + }; + } +}