From 0541f9d095098fe1421ede47a7c1beb68a32814d Mon Sep 17 00:00:00 2001 From: diamante0018 Date: Tue, 1 Apr 2025 18:48:40 +0200 Subject: [PATCH] chore: update some other stuff --- scripts/format.sh | 14 ++++++++ src/client/game/game.cpp | 21 +++++++++++ src/client/game/game.hpp | 2 ++ src/client/game/structs.hpp | 70 +++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 scripts/format.sh diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100644 index 0000000..7294f59 --- /dev/null +++ b/scripts/format.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Navigate to the repository root +cd "$(dirname "$0")/.." || exit 2 + +# Set the clang-format binary (defaults to 'clang-format') +CLANG_FORMAT_BIN="${CLANG_FORMAT_BIN:-clang-format}" + +# Find and format all .hpp and .cpp files in the src directory +find ./src \( -iname '*.hpp' -o -iname '*.cpp' \) -print0 | + xargs -0 "$CLANG_FORMAT_BIN" -i || { + echo "Error: clang-format failed." >&2 + exit 1 + } diff --git a/src/client/game/game.cpp b/src/client/game/game.cpp index 425bb8c..6135b36 100644 --- a/src/client/game/game.cpp +++ b/src/client/game/game.cpp @@ -24,4 +24,25 @@ void __declspec(naked) Dvar_SetVariant(dvar_t* /*dvar*/, DvarValue /*value*/, ret } } + +XAssetEntry* db_find_x_asset_entry(int type_, const char* name) { + static DWORD DB_FindXAssetEntry_t = 0x5c88a0; + XAssetEntry* result{}; + + __asm { + pushad + push name + mov edi, type_ + call DB_FindXAssetEntry_t + add esp, 0x4 + mov result, eax + popad + } + + return result; +} + +XAssetEntry* DB_FindXAssetEntry(int type, const char* name) { + return db_find_x_asset_entry(type, name); +} } // namespace game diff --git a/src/client/game/game.hpp b/src/client/game/game.hpp index cb20be1..02e0355 100644 --- a/src/client/game/game.hpp +++ b/src/client/game/game.hpp @@ -18,6 +18,8 @@ private: // clang-format off extern ScreenPlacement* ScrPlace_GetUnsafeFullPlacement(); extern void Dvar_SetVariant(dvar_t* dvar, DvarValue value, DvarSetSource source); + +extern XAssetEntry* DB_FindXAssetEntry(int type, const char* name); // clang-format on } // namespace game diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index 4dd97a4..c8d7c36 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -9,6 +9,59 @@ typedef vec_t vec2_t[2]; typedef vec_t vec3_t[3]; typedef vec_t vec4_t[4]; +struct MaterialTechniqueSet { + const char* name; + unsigned char worldVertFormat; + unsigned char unused[2]; + MaterialTechniqueSet* remappedTechniqueSet; + void* techniques[54]; +}; + +struct __declspec(align(8)) GfxDrawSurfFields { + uint64_t unused : 1; + uint64_t primarySortKey : 6; + uint64_t surfType : 4; + uint64_t viewModelRender : 1; + uint64_t sceneLightIndex : 8; + uint64_t useHeroLighting : 1; + uint64_t prepass : 2; + uint64_t materialSortedIndex : 12; + uint64_t customIndex : 5; + uint64_t hasGfxEntIndex : 1; + uint64_t reflectionProbeIndex : 8; + uint64_t objectId : 15; +}; + +union GfxDrawSurf { + __declspec(align(8)) GfxDrawSurfFields fields; + __declspec(align(8)) uint64_t packed; +}; + +struct MaterialInfo { + const char* name; + unsigned char gameFlags; + unsigned char sortKey; + unsigned char textureAtlasRowCount; + unsigned char textureAtlasColumnCount; + GfxDrawSurf drawSurf; + unsigned int surfaceTypeBits; +}; + +struct Material { + MaterialInfo info; + char stateBitsEntry[54]; + unsigned char textureCount; + unsigned char constantCount; + unsigned char stateBitsCount; + unsigned char stateFlags; + unsigned char cameraRegion; + MaterialTechniqueSet* techniqueSet; + void* textureTable; + void* constantTable; + void* stateBitsTable; + const char** subMaterials; +}; + enum bdLogMessageType { BD_LOG_INFO, BD_LOG_WARNING, @@ -261,6 +314,8 @@ struct usercmd_s { int remoteControlMove; }; +static_assert(offsetof(usercmd_s, buttons) == 0x4); + enum LocSelInputState { LOC_SEL_INPUT_NONE = 0, LOC_SEL_INPUT_CONFIRM = 1, @@ -367,6 +422,21 @@ struct Font_s { union XAssetHeader { Font_s* font; + Material* material; +}; + +struct XAsset { + int type; + XAssetHeader header; +}; + +struct XAssetEntry { + XAsset asset; + char zoneIndex; + volatile char inuseMask; + bool printedMissingAsset; + unsigned __int16 nextHash; + unsigned __int16 nextOverride; }; } // namespace game