From f25422bbd529f8a7fe542a914598b826ebc41188 Mon Sep 17 00:00:00 2001 From: F1F7Y Date: Sun, 25 Aug 2024 17:03:59 +0200 Subject: [PATCH 1/2] project: use pragma pack and remove static_assert spam --- primedev/engine/r2engine.h | 36 ++++----------- primedev/server/r2server.h | 95 ++------------------------------------ 2 files changed, 12 insertions(+), 119 deletions(-) diff --git a/primedev/engine/r2engine.h b/primedev/engine/r2engine.h index c8b2e013a..7a6299ad7 100644 --- a/primedev/engine/r2engine.h +++ b/primedev/engine/r2engine.h @@ -170,6 +170,7 @@ enum class eSignonState : int CHANGELEVEL = 9, // server is changing level; please wait }; +#pragma pack(push, 1) class CBaseClient { public: @@ -198,22 +199,8 @@ class CBaseClient char m_UID[32]; // 0xf500 ( Size: 32 ) char _unk_0xf520[123400]; // 0xf520 ( Size: 123400 ) }; +#pragma pack(pop) static_assert(sizeof(CBaseClient) == 0x2D728); -static_assert(offsetof(CBaseClient, m_Name) == 0x16); -static_assert(offsetof(CBaseClient, m_ConVars) == 0x258); -static_assert(offsetof(CBaseClient, m_Signon) == 0x2A0); -static_assert(offsetof(CBaseClient, m_nDeltaTick) == 0x2A4); -static_assert(offsetof(CBaseClient, m_nOriginID) == 0x2A8); -static_assert(offsetof(CBaseClient, m_nStringTableAckTick) == 0x2B0); -static_assert(offsetof(CBaseClient, m_nSignonTick) == 0x2B4); -static_assert(offsetof(CBaseClient, m_ClanTag) == 0x358); -static_assert(offsetof(CBaseClient, m_bFakePlayer) == 0x484); -static_assert(offsetof(CBaseClient, m_bReceivedPacket) == 0x485); -static_assert(offsetof(CBaseClient, m_bLowViolence) == 0x486); -static_assert(offsetof(CBaseClient, m_bFullyAuthenticated) == 0x487); -static_assert(offsetof(CBaseClient, m_iPersistenceReady) == 0x4A0); -static_assert(offsetof(CBaseClient, m_PersistenceBuffer) == 0x4FA); -static_assert(offsetof(CBaseClient, m_UID) == 0xF500); extern CBaseClient* g_pClientArray; @@ -236,7 +223,9 @@ enum class GameMode_t : int SP_MODE, }; -class CGlobalVars +// FIXME correct this class +#pragma pack(push, 1) +class CGlobalVars // : public CGlobalVarsBase { public: // Absolute time (per frame still - Use Plat_FloatTime() for a high precision real time @@ -285,17 +274,10 @@ class CGlobalVars const char* m_pMapName; // 0x60 ( Size: 8 ) int m_nMapVersion; // 0x68 ( Size: 4 ) + + char unk[0x40]; }; -static_assert(offsetof(CGlobalVars, m_flRealTime) == 0x0); -static_assert(offsetof(CGlobalVars, m_nFrameCount) == 0x8); -static_assert(offsetof(CGlobalVars, m_flAbsoluteFrameTime) == 0xc); -static_assert(offsetof(CGlobalVars, m_flCurTime) == 0x10); -static_assert(offsetof(CGlobalVars, m_flFrameTime) == 0x30); -static_assert(offsetof(CGlobalVars, m_nMaxClients) == 0x34); -static_assert(offsetof(CGlobalVars, m_nGameMode) == 0x38); -static_assert(offsetof(CGlobalVars, m_nTickCount) == 0x3c); -static_assert(offsetof(CGlobalVars, m_flTickInterval) == 0x40); -static_assert(offsetof(CGlobalVars, m_pMapName) == 0x60); -static_assert(offsetof(CGlobalVars, m_nMapVersion) == 0x68); +#pragma pack(pop) +static_assert(sizeof(CGlobalVars) == 0xA8); extern CGlobalVars* g_pGlobals; diff --git a/primedev/server/r2server.h b/primedev/server/r2server.h index 1b7bc0b7a..72be91046 100644 --- a/primedev/server/r2server.h +++ b/primedev/server/r2server.h @@ -6,6 +6,7 @@ class CBaseEntity; extern CBaseEntity* (*Server_GetEntityByIndex)(int index); +// FIXME: Correct this class #pragma pack(push, 1) class CBasePlayer { @@ -159,97 +160,7 @@ class CBasePlayer Vector3 m_upDir; // 0x102284 ( Size: 12 ) }; #pragma pack(pop) - -static_assert(offsetof(CBasePlayer, m_nPlayerIndex) == 0x58); - -static_assert(offsetof(CBasePlayer, m_grappleActive) == 0x23e8); -static_assert(offsetof(CBasePlayer, m_platformUserId) == 0x1D08); -static_assert(offsetof(CBasePlayer, m_classModsActive) == 0x1D10); -static_assert(offsetof(CBasePlayer, m_posClassModsActive) == 0x1D8C); -static_assert(offsetof(CBasePlayer, m_passives) == 0x1DCC); -static_assert(offsetof(CBasePlayer, m_selectedOffhand) == 0x4948); -static_assert(offsetof(CBasePlayer, m_selectedOffhandPendingHybridAction) == 0x1358); -static_assert(offsetof(CBasePlayer, m_playerFlags) == 0x1E88); -static_assert(offsetof(CBasePlayer, m_lastUCmdSimulationTicks) == 0x26A8); -static_assert(offsetof(CBasePlayer, m_lastUCmdSimulationRemainderTime) == 0x26AC); -static_assert(offsetof(CBasePlayer, m_remoteTurret) == 0x1F04); -static_assert(offsetof(CBasePlayer, m_hGroundEntity) == 0x414); -static_assert(offsetof(CBasePlayer, m_titanSoul) == 0x13B8); -static_assert(offsetof(CBasePlayer, m_petTitan) == 0x2054); -static_assert(offsetof(CBasePlayer, m_iHealth) == 0x4D4); -static_assert(offsetof(CBasePlayer, m_iMaxHealth) == 0x4D0); -static_assert(offsetof(CBasePlayer, m_lifeState) == 0x4F1); -static_assert(offsetof(CBasePlayer, m_flMaxspeed) == 0x50C); -static_assert(offsetof(CBasePlayer, m_fFlags) == 0x298); -static_assert(offsetof(CBasePlayer, m_iObserverMode) == 0x1F64); -static_assert(offsetof(CBasePlayer, m_hObserverTarget) == 0x1F6C); -static_assert(offsetof(CBasePlayer, m_hViewModel) == 0x2098); -static_assert(offsetof(CBasePlayer, m_ubEFNointerpParity) == 0x27E4); -static_assert(offsetof(CBasePlayer, m_activeBurnCardIndex) == 0x1FA4); -static_assert(offsetof(CBasePlayer, m_hColorCorrectionCtrl) == 0x1B68); -static_assert(offsetof(CBasePlayer, m_PlayerFog__m_hCtrl) == 0x19E0); -static_assert(offsetof(CBasePlayer, m_bShouldDrawPlayerWhileUsingViewEntity) == 0x26BC); -static_assert(offsetof(CBasePlayer, m_title) == 0x2848); -static_assert(offsetof(CBasePlayer, m_useCredit) == 0x2964); -static_assert(offsetof(CBasePlayer, m_damageImpulseNoDecelEndTime) == 0x1F40); -static_assert(offsetof(CBasePlayer, m_hasMic) == 0x1E8C); -static_assert(offsetof(CBasePlayer, m_inPartyChat) == 0x1E8D); -static_assert(offsetof(CBasePlayer, m_playerMoveSpeedScale) == 0x1E90); -static_assert(offsetof(CBasePlayer, m_flDeathTime) == 0x1F58); -static_assert(offsetof(CBasePlayer, m_iSpawnParity) == 0x25A8); -static_assert(offsetof(CBasePlayer, m_upDir) == 0x102284); -static_assert(offsetof(CBasePlayer, m_lastDodgeTime) == 0x259C); -static_assert(offsetof(CBasePlayer, m_wallHanging) == 0x22E0); -static_assert(offsetof(CBasePlayer, m_traversalType) == 0x22EC); -static_assert(offsetof(CBasePlayer, m_traversalState) == 0x22F0); -static_assert(offsetof(CBasePlayer, m_traversalRefPos) == 0x2328); -static_assert(offsetof(CBasePlayer, m_traversalForwardDir) == 0x231C); -static_assert(offsetof(CBasePlayer, m_traversalYawDelta) == 0x2354); -static_assert(offsetof(CBasePlayer, m_traversalYawPoseParameter) == 0x2358); -static_assert(offsetof(CBasePlayer, m_grappleHook) == 0x2050); -static_assert(offsetof(CBasePlayer, m_autoSprintForced) == 0x27C0); -static_assert(offsetof(CBasePlayer, m_fIsSprinting) == 0x27C4); -static_assert(offsetof(CBasePlayer, m_sprintStartedTime) == 0x27CC); -static_assert(offsetof(CBasePlayer, m_sprintStartedFrac) == 0x27D0); -static_assert(offsetof(CBasePlayer, m_sprintEndedTime) == 0x27D4); -static_assert(offsetof(CBasePlayer, m_sprintEndedFrac) == 0x27D8); -static_assert(offsetof(CBasePlayer, m_stickySprintStartTime) == 0x27DC); -static_assert(offsetof(CBasePlayer, m_smartAmmoPreviousHighestLockOnMeFractionValue) == 0x2998); -static_assert(offsetof(CBasePlayer, m_activeZipline) == 0x23FC); -static_assert(offsetof(CBasePlayer, m_ziplineReverse) == 0x2400); -static_assert(offsetof(CBasePlayer, m_ziplineState) == 0x2410); -static_assert(offsetof(CBasePlayer, m_duckState) == 0x2250); -static_assert(offsetof(CBasePlayer, m_StandHullMin) == 0x2254); -static_assert(offsetof(CBasePlayer, m_StandHullMax) == 0x2260); -static_assert(offsetof(CBasePlayer, m_DuckHullMin) == 0x226C); -static_assert(offsetof(CBasePlayer, m_DuckHullMax) == 0x2278); -static_assert(offsetof(CBasePlayer, m_xp) == 0x205C); -static_assert(offsetof(CBasePlayer, m_generation) == 0x2060); -static_assert(offsetof(CBasePlayer, m_rank) == 0x2064); -static_assert(offsetof(CBasePlayer, m_serverForceIncreasePlayerListGenerationParity) == 0x2068); -static_assert(offsetof(CBasePlayer, m_isPlayingRanked) == 0x206C); -static_assert(offsetof(CBasePlayer, m_skill_mu) == 0x2070); -static_assert(offsetof(CBasePlayer, m_titanSoulBeingRodeoed) == 0x1E80); -static_assert(offsetof(CBasePlayer, m_entitySyncingWithMe) == 0x1E84); -static_assert(offsetof(CBasePlayer, m_nextTitanRespawnAvailable) == 0x2078); -static_assert(offsetof(CBasePlayer, m_hasBadReputation) == 0x1C90); -static_assert(offsetof(CBasePlayer, m_communityName) == 0x1C91); -static_assert(offsetof(CBasePlayer, m_communityClanTag) == 0x1CD1); -static_assert(offsetof(CBasePlayer, m_factionName) == 0x1CE1); -static_assert(offsetof(CBasePlayer, m_hardwareIcon) == 0x1CF1); -static_assert(offsetof(CBasePlayer, m_happyHourActive) == 0x1D01); -static_assert(offsetof(CBasePlayer, m_gestureAutoKillBitfield) == 0x1EF4); -static_assert(offsetof(CBasePlayer, m_pilotClassIndex) == 0x2EA8); -static_assert(offsetof(CBasePlayer, m_vecAbsOrigin) == 0x100490); -static_assert(offsetof(CBasePlayer, m_isPerformingBoostAction) == 0x25BE); -static_assert(offsetof(CBasePlayer, m_ziplineValid3pWeaponLayerAnim) == 0x240C); -static_assert(offsetof(CBasePlayer, m_playerScriptNetDataGlobal) == 0x345C); -static_assert(offsetof(CBasePlayer, m_bZooming) == 0x1598); -static_assert(offsetof(CBasePlayer, m_zoomToggleOn) == 0x1599); -static_assert(offsetof(CBasePlayer, m_zoomBaseFrac) == 0x159C); -static_assert(offsetof(CBasePlayer, m_zoomBaseTime) == 0x15A0); -static_assert(offsetof(CBasePlayer, m_zoomFullStartTime) == 0x15A4); -static_assert(offsetof(CBasePlayer, m_camoIndex) == 0xA04); -static_assert(offsetof(CBasePlayer, m_decalIndex) == 0xA08); +static_assert(sizeof(CBasePlayer) == 0x102290); +// FIXME: Datamaps say this should be 0x3468, how did we end up with this???? extern CBasePlayer*(__fastcall* UTIL_PlayerByIndex)(int playerIndex); From e14daf5473eeca087d88230c9775102fd525e7c2 Mon Sep 17 00:00:00 2001 From: F1F7Y Date: Sun, 25 Aug 2024 17:47:11 +0200 Subject: [PATCH 2/2] fix: fix github actions --- primedev/engine/r2engine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primedev/engine/r2engine.h b/primedev/engine/r2engine.h index 7a6299ad7..59a6c06c5 100644 --- a/primedev/engine/r2engine.h +++ b/primedev/engine/r2engine.h @@ -275,7 +275,7 @@ class CGlobalVars // : public CGlobalVarsBase const char* m_pMapName; // 0x60 ( Size: 8 ) int m_nMapVersion; // 0x68 ( Size: 4 ) - char unk[0x40]; + char unk[0x3C]; }; #pragma pack(pop) static_assert(sizeof(CGlobalVars) == 0xA8);