Skip to content

Commit

Permalink
fix(gta-game/five): update CNetGamePlayer accessors to support b3095
Browse files Browse the repository at this point in the history
This was forgotten during the initial work on 3095 support for FiveM. Also did some minor code cleanup.
  • Loading branch information
Disquse committed Jan 11, 2024
1 parent a654bcc commit 7a62907
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions code/components/gta-game-five/include/NetworkPlayerMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include <netPeerAddress.h>

#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
Expand Down Expand Up @@ -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;
Expand All @@ -96,18 +97,20 @@ 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
{
public:
static GTA_GAME_EXPORT CNetGamePlayer* GetPlayer(int playerIndex);
};

#undef DECLARE_ACCESSOR

0 comments on commit 7a62907

Please sign in to comment.