Skip to content

Commit a2a74e1

Browse files
authored
Invoker stuff (YimMenu#1)
* feat: initialize classes repo * feat(script): stuff for native invoker * feat: add some more classes * feat(player): complete CNetworkPlayerMgr * feat(network): add some more stuff * feat(network): add rlGamerInfo * feat(player): add CPlayerInfo
1 parent d07e253 commit a2a74e1

21 files changed

Lines changed: 800 additions & 0 deletions

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.vscode
2+
.vs
3+
build/
4+
*.suo
5+
*.db
6+
*.db-shm
7+
*.db-wal
8+
*.opendb
9+
*.sln
10+
*.vcxproj
11+
*.user
12+
*.filters

CMakeLists.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cmake_minimum_required(VERSION 3.11)
2+
3+
project(RDR-Classes)
4+
5+
include(CheckIncludeFileCXX)
6+
7+
set(CMAKE_CXX_EXTENSIONS OFF)
8+
set(CMAKE_CXX_STANDARD 20)
9+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
10+
11+
set(CMAKE_REQUIRED_QUIET ON)
12+
13+
set(OK TRUE)
14+
15+
file(GLOB_RECURSE HEADERS "**.hpp")
16+
file(GLOB_RECURSE SRC_MAIN "classes.cpp")
17+
source_group(FILES ${SRC_MAIN})
18+
add_library(RDR-Classes MODULE "${SRC_MAIN}")
19+
20+
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
21+
22+
message(STATUS "")
23+
24+
target_include_directories(RDR-Classes PRIVATE
25+
"${SRC_DIR}"
26+
)
27+
28+
if(NOT OK)
29+
file(READ "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeError.log" LOG)
30+
message(STATUS ${LOG})
31+
endif()

classes.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "network/CNetGamePlayer.hpp"
2+
#include "network/CNetworkPlayerMgr.hpp"
3+
#include "network/netPeerAddress.hpp"
4+
#include "network/netPlayer.hpp"
5+
#include "network/netPlayerMgrBase.hpp"
6+
#include "network/rlGamerHandle.hpp"
7+
#include "network/rlGamerInfoBase.hpp"
8+
#include "network/rlGamerInfo.hpp"
9+
#include "player/CPlayerInfo.hpp"
10+
#include "rage/joaat.hpp"
11+
#include "rage/vector.hpp"
12+
#include "script/scriptHandlerNetComponent.hpp"
13+
#include "script/scrNativeHandler.hpp"
14+
#include "script/scrThread.hpp"
15+
#include "script/scrThreadContext.hpp"
16+
#include "script/scrVector.hpp"
17+
#include "script/types.hpp"

network/CNetGamePlayer.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
#include "netPlayer.hpp"
3+
4+
class CPlayerInfo;
5+
class CNetGamePlayer : public rage::netPlayer
6+
{
7+
public:
8+
CPlayerInfo* m_PlayerInfo; //0x0128
9+
char pad_0130[2432]; //0x0130
10+
}; //Size: 0x0AB0
11+
static_assert(sizeof(CNetGamePlayer) == 0xAB0);

network/CNetworkPlayerMgr.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
#include "netPlayerMgrBase.hpp"
3+
#include "CNetGamePlayer.hpp"
4+
5+
#include <cstdint>
6+
#pragma pack(push, 8)
7+
class CNetworkPlayerMgr : public rage::netPlayerMgrBase
8+
{
9+
public:
10+
CNetGamePlayer m_PlayerStorage[32]; // 0x08E0
11+
CNetGamePlayer* m_FirstPlayer; // 0x15EE0
12+
CNetGamePlayer* m_LastPlayer; // 0x15EE8
13+
std::uint64_t m_UnkCounter; // 0x15EF0
14+
};
15+
static_assert(sizeof(CNetworkPlayerMgr) == 0x15EF8);
16+
#pragma pack(pop)

network/netPeerAddress.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
#include <cstdint>
3+
4+
union netAddress {
5+
uint32_t m_packed; //0x0000
6+
struct {
7+
uint8_t m_field4; //0x0000
8+
uint8_t m_field3; //0x0001
9+
uint8_t m_field2; //0x0002
10+
uint8_t m_field1; //0x0003
11+
};
12+
}; //Size: 0x0004
13+
static_assert(sizeof(netAddress) == 0x04);
14+
15+
namespace rage
16+
{
17+
#pragma pack(push, 4)
18+
class netPeerAddress
19+
{
20+
public:
21+
netAddress m_internal_ip; //0x0000
22+
uint16_t m_internal_port; //0x0004
23+
netAddress m_external_ip; //0x0008
24+
uint16_t m_external_port; //0x000C
25+
uint64_t m_peer_id; //0x0010
26+
netAddress m_relay_address; //0x0018
27+
uint16_t m_relay_port; //0x001C
28+
uint8_t m_connection_type; //0x001E
29+
};
30+
static_assert(sizeof(netPeerAddress) == 0x20);
31+
#pragma pack(pop)
32+
}

network/netPlayer.hpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
#include <cstdint>
3+
4+
namespace rage
5+
{
6+
class rlGamerInfo;
7+
class netPlayer
8+
{
9+
public:
10+
virtual ~netPlayer() = default; // 0x00
11+
virtual void Initialize(void* unk, int message_id, int unk2) {}; // 0x08
12+
virtual void Initialize2(int unk) {}; // 0x10
13+
virtual void Reset() {}; // 0x18
14+
virtual bool IsValid() { return false; }; // 0x20
15+
virtual const char* GetName() { return nullptr; }; // 0x28
16+
virtual void* GetUnk() { return nullptr; }; // 0x30
17+
virtual void SetTeam(int new_team) {}; // 0x38
18+
virtual bool IsSameTeam(netPlayer* other) { return false; }; // 0x40
19+
virtual void _0x48() {}; // 0x48 some posse stuff
20+
virtual void RefreshData() {}; // 0x50
21+
virtual bool IsHost() { return true; }; // 0x58
22+
virtual rage::rlGamerInfo* GetGamerInfo() { return nullptr; }; // 0x60
23+
24+
char pad_0008[12]; //0x0008
25+
uint32_t m_MessageId; //0x0014
26+
uint8_t m_ActiveIndex; //0x0018
27+
uint8_t m_PlayerIndex; //0x0019
28+
char pad_001A[10]; //0x001A
29+
uint32_t m_JoinTime; //0x0024
30+
char pad_0028[4]; //0x0028
31+
uint32_t m_Team; //0x002C
32+
char pad_0030[248]; //0x0030
33+
}; //Size: 0x0128
34+
static_assert(sizeof(rage::netPlayer) == 0x128);
35+
}

network/netPlayerMgrBase.hpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#pragma once
2+
#include <cstdint>
3+
4+
class CNetGamePlayer;
5+
class CNetGamePlayerDataMsg;
6+
class CNonPhysicalPlayerData;
7+
8+
namespace rage
9+
{
10+
class rlGamerInfo;
11+
class netConnectionManager;
12+
#pragma pack(push, 8)
13+
// the same as GTA 1.63
14+
class netPlayerMgrBase
15+
{
16+
public:
17+
virtual ~netPlayerMgrBase() = default;
18+
virtual void Initialize() = 0;
19+
virtual void Shutdown() = 0;
20+
virtual void unk_0x18() = 0;
21+
virtual CNetGamePlayer* AddPlayer_raw(rage::rlGamerInfo* gamer_info, uint32_t a2, CNetGamePlayerDataMsg* player_data, CNonPhysicalPlayerData* non_physical_player_data) = 0;
22+
virtual void RemovePlayer(CNetGamePlayer* net_game_player) = 0;
23+
virtual void UpdatePlayerListsForPlayer(CNetGamePlayer* net_game_player) = 0;
24+
virtual CNetGamePlayer* AddPlayer(rage::rlGamerInfo* gamer_info, uint32_t a3, CNetGamePlayerDataMsg* player_data, CNonPhysicalPlayerData* non_physical_player_data) = 0;
25+
26+
rage::netConnectionManager* m_NetConnectionManager; //0x0008
27+
uint64_t* m_NetBandwidthManager; //0x0010
28+
char pad_0018[208]; //0x0018
29+
CNetGamePlayer* m_LocalPlayer; //0x00E8
30+
char pad_00F0[144]; //0x00F0
31+
CNetGamePlayer* m_PlayerList[32]; //0x0180 (TODO: is this used?)
32+
uint16_t m_PlayerLimit; //0x0280
33+
char pad_0282[10]; //0x0282
34+
uint16_t m_PlayerCount; //0x028C
35+
char pad_0290[1618]; //0x0290
36+
}; //Size: 0x08E0
37+
static_assert(sizeof(netPlayerMgrBase) == 0x8E0);
38+
#pragma pack(pop)
39+
}

network/rlGamerHandle.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
5+
namespace rage
6+
{
7+
#pragma pack(push,8)
8+
class rlGamerHandle
9+
{
10+
public:
11+
uint64_t m_rockstar_id; //0x0000
12+
uint8_t m_platform; //0x0008
13+
uint8_t unk_0009; //0x0009
14+
15+
inline rlGamerHandle() = default;
16+
17+
inline rlGamerHandle(uint64_t rockstar_id) :
18+
m_rockstar_id(rockstar_id),
19+
m_platform(3),
20+
unk_0009(0)
21+
{
22+
}
23+
}; //Size: 0x0010
24+
static_assert(sizeof(rlGamerHandle) == 0x10);
25+
#pragma pack(pop)
26+
}

network/rlGamerInfo.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
#include <cstdint>
3+
#include "rlGamerInfoBase.hpp"
4+
5+
#pragma pack(push, 8)
6+
namespace rage
7+
{
8+
class rlGamerInfo : public rage::rlGamerInfoBase
9+
{
10+
uint64_t m_HostToken;
11+
uint64_t m_PeerId2;
12+
rage::rlGamerHandle m_GamerHandle2;
13+
uint32_t m_ProfileIndex;
14+
char m_Name[21];
15+
uint8_t m_Flags;
16+
};
17+
static_assert(sizeof(rage::rlGamerInfo) == 0xD8);
18+
}
19+
#pragma pack(pop)

0 commit comments

Comments
 (0)