Skip to content

Commit

Permalink
fix: sync classes(nlohmann#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bela Proinsias authored and core committed Sep 26, 2024
1 parent 6360d49 commit c645b62
Show file tree
Hide file tree
Showing 27 changed files with 468 additions and 96 deletions.
8 changes: 7 additions & 1 deletion classes/src/classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "enums/eExplosionTag.hpp"
#include "enums/eHandlingType.hpp"
#include "game_files/CGameConfig.hpp"
#include "game_files/GameDataHash.hpp"
#include "misc/CTunables.hpp"
#include "misc/vfx/TimecycleKeyframeData.hpp"
#include "netsync/CProjectBaseSyncDataNode.hpp"
Expand Down Expand Up @@ -113,6 +114,7 @@
#include "network/ChatData.hpp"
#include "network/CJoinRequestContext.hpp"
#include "network/ClanData.hpp"
#include "network/CMsgJoinRequest.hpp"
#include "network/CMsgJoinResponse.hpp"
#include "network/CMsgTextMessage.hpp"
#include "network/CNetComplaintMgr.hpp"
Expand All @@ -122,11 +124,13 @@
#include "network/MatchmakingAttributes.hpp"
#include "network/MatchmakingId.hpp"
#include "network/netObject.hpp"
#include "network/netObjectIds.hpp"
#include "network/netPeerAddress.hpp"
#include "network/netPlayer.hpp"
#include "network/netPlayerMgrBase.hpp"
#include "network/netTime.hpp"
#include "network/Network.hpp"
#include "network/P2pSecurity.hpp"
#include "network/RemoteGamerInfoMsg.hpp"
#include "network/snConnectToPeerTask.hpp"
#include "network/snSession.hpp"
Expand Down Expand Up @@ -168,6 +172,8 @@
#include "script/globals/GSBD_Kicking.hpp"
#include "script/globals/GSBD_PropertyInstances.hpp"
#include "script/globals/g_AMC_playerBD.hpp"
#include "script/CGameScriptHandler.hpp"
#include "script/CGameScriptHandlerNetComponent.hpp"
#include "script/CGameScriptObjInfo.hpp"
#include "script/GtaThread.hpp"
#include "script/HudColor.hpp"
Expand Down Expand Up @@ -216,4 +222,4 @@
#include "weapon/CItemInfo.hpp"
#include "weapon/CWeaponBoneId.hpp"
#include "weapon/CWeaponInfo.hpp"
#include "ui/CBlipList.hpp"
#include "ui/CBlipList.hpp"
13 changes: 13 additions & 0 deletions classes/src/game_files/GameDataHash.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once
#include "security/ObfVar.hpp"
#include <array>

#pragma pack(push, 8)
class GameDataHash
{
public:
bool m_is_japanese_version;
std::array<rage::Obf32, 15> m_data;
};
static_assert(sizeof(GameDataHash) == 0xF4);
#pragma pack(pop)
1 change: 1 addition & 0 deletions classes/src/netsync/nodes/ped/CPedGameStateDataNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CPedGameStateDataNode : CSyncDataNodeInfrequent
uint16_t m_mount_id; //0x0142
uint16_t m_custodian_id; //0x0144
uint16_t unk_0146; // 0x0146
uint8_t new_014C;
bool m_tint_index; //0x0148
char pad_0149; //0x0149
uint8_t unk_014A; // 0x014A
Expand Down
25 changes: 25 additions & 0 deletions classes/src/network/CMsgJoinRequest.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#include <cstdint>

#include "game_files/GameDataHash.hpp"
#include "CNetGamePlayerDataMsg.hpp"
#include "rage/rlGamerHandle.hpp"

#pragma pack(push, 8)
class CMsgJoinRequest
{
public:
std::uint32_t m_version_number;
std::uint32_t m_flags;
std::uint32_t m_unk_zero;
std::uint32_t m_magic;
GameDataHash m_game_data_hash;
std::uint32_t m_dlc_hash;
std::uint32_t m_timeout_time;
std::uint32_t dword10C;
bool m_no_handle;
rage::rlGamerHandle m_gamer_handle;
CNetGamePlayerDataMsg m_player_data_msg;
};
static_assert(sizeof(CMsgJoinRequest) == 0x168);
#pragma pack(pop)
12 changes: 6 additions & 6 deletions classes/src/network/CNetGamePlayerDataMsg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

class datBitBuffer;

#pragma pack(push,8)
#pragma pack(push, 8)
namespace rage {
class playerDataMsg
{
public:
virtual ~playerDataMsg() = 0;
virtual int GetBufferSize() = 0;
virtual void Log() = 0;
virtual bool Serialize(datBitBuffer* buffer) = 0;
virtual bool Deserialize(datBitBuffer* buffer) = 0;
virtual ~playerDataMsg() = default;
virtual int GetBufferSize() { return 0; };
virtual void Log() {};
virtual bool Serialize(datBitBuffer* buffer) { return true; };
virtual bool Deserialize(datBitBuffer* buffer) { return true; };

uint32_t m_game_version; //0x0008
uint32_t m_nat_type; //0x000C
Expand Down
2 changes: 1 addition & 1 deletion classes/src/network/MatchmakingId.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class MatchmakingId
std::uint64_t m_data2;
std::uint64_t m_data3;
};
static_assert(offsetof(MatchmakingId, MatchmakingId::m_data3) == 0x2E);
static_assert(offsetof(MatchmakingId, m_data3) == 0x2E);
#pragma pack(pop)
13 changes: 9 additions & 4 deletions classes/src/network/Network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ class MatchmakingSessionResult
{
public:
class rage::rlSessionDetail m_detail;
char pad_03B8[24]; //0x03B8
char pad_03B8[88]; //0x03B8
}; //Size: 0x03D0
static_assert(sizeof(MatchmakingSessionResult) == 0x490);
static_assert(sizeof(MatchmakingSessionResult) == 0x4D0);

class PlayerNameMapNode
{
Expand Down Expand Up @@ -178,6 +178,8 @@ static_assert(sizeof(InvitedGamers) == 0xC88);
class Network
{
public:
bool m_unk;
char pad_0001[0x7];
rage::rlSessionInfo m_steam_unk_session; //0x0000
rage::Obf32 m_num_dinput8_instances; //0x0070
rage::Obf32 m_last_time_dinput8_checked; //0x0080
Expand Down Expand Up @@ -206,7 +208,7 @@ class Network
bool m_was_invited; //0xB3FD
char pad_B3FE[26]; //0xB3FE TODO: the reclass file is broken
class rage::rlSessionInfo m_unk_session_info; //0xB408
char pad_B4D8[635]; //0xB4D8
char pad_B4D8[643]; //0xB4D8
bool m_need_host_change; //0xB753
char pad_B754[74316]; //0xB754
class rage::rlSessionDetail m_joining_session_detail; //0x1D9A0
Expand Down Expand Up @@ -238,6 +240,9 @@ class Network
class rage::rlGamerHandle m_inviter_handle; //0x2DCE0
class CNetComplaintMgr m_game_complaint_mgr; //0x2DCF0
class CNetComplaintMgr m_transition_complaint_mgr; //0x2EB88

// fields beyond this point are likely outdated!

char pad_2FA20[32]; //0x2FA20
class JoiningPlayerNameMap m_unused_joining_player_name_map; //0x2FA40
char pad_31048[8]; //0x31048
Expand Down Expand Up @@ -280,5 +285,5 @@ class Network
uint32_t m_follower_count; //0x49EE0
char pad_49EE4[628]; //0x49EE4
}; //Size: 0x38650
static_assert(sizeof(Network) == 0x4A168);
static_assert(sizeof(Network) == 0x4A678);
#pragma pack(pop)
67 changes: 67 additions & 0 deletions classes/src/network/P2pSecurity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once
#include "rage/rlGamerInfo.hpp"

#pragma pack(push, 2)
namespace rage
{
class SecurityPeer
{
public:
#pragma pack(push, 8)
struct Info
{
uint8_t platform;
rage::rlGamerHandle handle;
char name[16];
};
#pragma pack(pop)

std::uint8_t gap0[80];
int m_security_id_2;
std::uint8_t gap54[52];
int m_time_initialized;
std::uint8_t gap8C[4];
int dword90;
int m_security_id;
int gap98;
std::uint8_t gap9C[4];
rage::netPeerAddress m_address;
rage::netPeerAddress m_real_address;
std::uint64_t qwordE0; // unk data from the bitbuffer
std::uint64_t qwordE8;
std::uint64_t qwordF0;
std::uint64_t m_peer_id;
rage::rlGamerHandle m_unverified_handle;
char m_dtls_cxn_type;
std::uint8_t gap111[3];
char m_timeouts[0x40];
std::uint8_t gap154[4];
char m_decryption_lock[0x28];
void* m_WolfSSL;
rage::SecurityPeer::Info m_info;
std::uint8_t gap1B0[48];
rage::netPeerAddress m_last_provided_address;
int m_last_provided_security_id;
std::uint8_t gap204[44];
char m_peer_query_stage;
std::uint8_t gap231[3];
int m_get_peer_address_status;
std::uint8_t gap238[8];
rage::netPeerAddress m_peer_query_result;
bool m_errored;
std::uint8_t m_dtls_cxn_establish_state;
char aaaa[2];
int m_error_code;
std::uint8_t gap268[96]; // error queue
std::uint8_t m_info_requests;
std::uint8_t m_failed_decryption_attempts;
std::uint8_t gap2CA[6];
int m_certificate_verify_error_code;
int m_certificate_verify_status;
std::uint8_t gap2D8[8];
char m_flags;
std::uint8_t gap2E1[761];
};
static_assert(sizeof(rage::SecurityPeer) == 0x5DA);
}
#pragma pack(pop)
69 changes: 45 additions & 24 deletions classes/src/network/netConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,59 @@ namespace rage
uint64_t m_count;
};

class netConnection
#pragma pack(push, 8)
class netEvent
{
public:
class InFrame
enum class Type
{
public:
enum class EventType
{
ConnectionClosed = 3,
FrameReceived = 4,
BandwidthExceeded = 6,
OutOfMemory = 7
};
ConnectionRequested = 0, // seems to be identical to rage::netConnection::InFrame
ConnectionError = 2,
ConnectionClosed = 3,
FrameReceived = 4, // rage::netConnection::InFrame
BandwidthExceeded = 6,
OutOfMemory = 7
};

virtual ~netEvent() = default;

virtual ~InFrame() = default;
virtual void destroy() = 0;
virtual Type get_event_type() = 0;
virtual uint32_t _0x18() = 0;

virtual void destroy() = 0;
virtual EventType get_event_type() = 0;
virtual uint32_t _0x18() = 0;
std::uint32_t m_timestamp; // 0x0008
char pad_0008[52]; // 0x000C
std::uint32_t m_msg_id; // 0x0040
std::uint32_t m_connection_identifier; // 0x0044
rage::netEvent* m_this; // 0x0048
uint32_t m_peer_id; // 0x0050
};
static_assert(sizeof(rage::netEvent) == 0x58);

class netEventConnectionError : public rage::netEvent
{
public:
std::uint64_t m_unk; // 0x0058 (always 2)
char m_data[0x80]; // 0x0060
std::uint32_t m_size; // 0x00E0
};
static_assert(sizeof(rage::netEventConnectionError) == 0xE8);
#pragma pack(pop)

uint32_t m_timestamp; //0x0008
char pad_0008[52]; //0x000C
uint32_t m_msg_id; //0x0040
uint32_t m_connection_identifier; //0x0044
InFrame* m_this; //0x0048
uint32_t m_peer_id; //0x0050
char pad_0050[44]; //0x0058
uint32_t m_length; //0x0080
char pad_007C[4]; //0x0084
void* m_data; //0x0088
class netConnection
{
public:
#pragma pack(push, 8)
class InFrame : public rage::netEvent
{
public:
alignas(8) int m_security_id; // 0x0058
rage::netPeerAddress m_peer_address; // 0x0060
std::uint32_t m_length; // 0x0080
void* m_data; // 0x0088
};
static_assert(sizeof(rage::netConnection::InFrame) == 0x90);
#pragma pack(pop)

char gap0[8];
rage::netConnectionPeer* m_connection_peer;
Expand Down
6 changes: 5 additions & 1 deletion classes/src/network/netObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../netsync/netSyncTree.hpp"
#include "../base/atRTTI.hpp"

#pragma pack(push, 4)
class CObject;
namespace rage
{
Expand All @@ -20,6 +21,8 @@ namespace rage
bool m_wants_to_delete; //0x004D
char pad_004E[1]; //0x004E
bool m_should_not_be_delete; //0x004F
char pad_0050[0x38]; //0x0050
int m_ownership_token; //0x0088

DEFINE_RAGE_RTTI(rage::netObject)

Expand Down Expand Up @@ -129,5 +132,6 @@ namespace rage
virtual void m_320() = 0;
virtual void UpdatePendingVisibilityChanges() = 0;
}; //Size: 0x0050
static_assert(sizeof(netObject) == 0x50);
static_assert(sizeof(netObject) == 0x8C); // incorrect, but will do for now
}
#pragma pack(pop)
Loading

0 comments on commit c645b62

Please sign in to comment.