From 7a6290774bf721681f685d0fd9bde9e110624caf Mon Sep 17 00:00:00 2001 From: Disquse Date: Thu, 11 Jan 2024 15:25:51 +0300 Subject: [PATCH] fix(gta-game/five): update `CNetGamePlayer` accessors to support b3095 This was forgotten during the initial work on 3095 support for FiveM. Also did some minor code cleanup. --- .../gta-game-five/include/NetworkPlayerMgr.h | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/code/components/gta-game-five/include/NetworkPlayerMgr.h b/code/components/gta-game-five/include/NetworkPlayerMgr.h index 28e6161b52..d20fc46163 100644 --- a/code/components/gta-game-five/include/NetworkPlayerMgr.h +++ b/code/components/gta-game-five/include/NetworkPlayerMgr.h @@ -12,13 +12,13 @@ #include #define DECLARE_ACCESSOR(x) \ - decltype(impl.m2372.x)& x() \ - { \ - return (xbr::IsGameBuildOrGreater<2372>()) ? impl.m2372.x : (xbr::IsGameBuildOrGreater<2060>()) ? impl.m2060.x : impl.m1604.x; \ + decltype(impl.m3095.x)& x() \ + { \ + return (xbr::IsGameBuildOrGreater<3095>()) ? impl.m3095.x : (xbr::IsGameBuildOrGreater<2372>()) ? impl.m2372.x : (xbr::IsGameBuildOrGreater<2060>()) ? impl.m2060.x : impl.m1604.x; \ } \ - const decltype(impl.m2372.x)& x() const \ - { \ - return (xbr::IsGameBuildOrGreater<2372>()) ? impl.m2372.x : (xbr::IsGameBuildOrGreater<2060>()) ? impl.m2060.x : impl.m1604.x; \ + const decltype(impl.m3095.x)& x() const \ + { \ + return (xbr::IsGameBuildOrGreater<3095>()) ? impl.m3095.x : (xbr::IsGameBuildOrGreater<2372>()) ? impl.m2372.x : (xbr::IsGameBuildOrGreater<2060>()) ? impl.m2060.x : impl.m1604.x; \ } #ifdef COMPILING_GTA_GAME_FIVE @@ -85,6 +85,7 @@ class CNetGamePlayer : public rage::netPlayer char end[EndPad]; }; + // Do not forget to update `DECLARE_ACCESSOR` define when adding new impl! union { Impl<12, 0, 28> m1604; @@ -96,14 +97,14 @@ class CNetGamePlayer : public rage::netPlayer public: void* GetPlayerInfo() { - return (xbr::IsGameBuildOrGreater<3095>()) ? impl.m3095.playerInfo : (xbr::IsGameBuildOrGreater<2372>()) ? impl.m2372.playerInfo : (xbr::IsGameBuildOrGreater<2060>()) ? impl.m2060.playerInfo : impl.m1604.playerInfo; + return playerInfo(); } public: - DECLARE_ACCESSOR(nonPhysicalPlayerData); - DECLARE_ACCESSOR(activePlayerIndex); - DECLARE_ACCESSOR(physicalPlayerIndex); - DECLARE_ACCESSOR(playerInfo); + DECLARE_ACCESSOR(nonPhysicalPlayerData) + DECLARE_ACCESSOR(activePlayerIndex) + DECLARE_ACCESSOR(physicalPlayerIndex) + DECLARE_ACCESSOR(playerInfo) }; class CNetworkPlayerMgr @@ -111,3 +112,5 @@ class CNetworkPlayerMgr public: static GTA_GAME_EXPORT CNetGamePlayer* GetPlayer(int playerIndex); }; + +#undef DECLARE_ACCESSOR