Toxic update (#641)
This commit is contained in:
218
src/gta/net_array.hpp
Normal file
218
src/gta/net_array.hpp
Normal file
@ -0,0 +1,218 @@
|
||||
#pragma once
|
||||
#include "fwddec.hpp"
|
||||
|
||||
class CGameArrayMgr
|
||||
{
|
||||
public:
|
||||
char padding[0x40];
|
||||
rage::netArrayHandlerBase* m_start;
|
||||
};
|
||||
static_assert(sizeof(CGameArrayMgr) == 0x48);
|
||||
|
||||
namespace rage
|
||||
{
|
||||
class netSyncDataUnit_Dynamic
|
||||
{
|
||||
public:
|
||||
virtual ~netSyncDataUnit_Dynamic() = default; // 0x00
|
||||
|
||||
virtual void _0x08() = 0;
|
||||
|
||||
virtual void _0x10() = 0;
|
||||
|
||||
virtual void set_data_counter(int index, uint16_t counter) = 0; // 0x18
|
||||
|
||||
virtual void reset_data_counter(int index) = 0; // 0x20
|
||||
|
||||
// ...
|
||||
|
||||
int m_players_need_ack; // 0x08
|
||||
int m_players_need_sync; // 0x0C
|
||||
};
|
||||
|
||||
class netSyncData_Dynamic
|
||||
{
|
||||
public:
|
||||
virtual ~netSyncData_Dynamic() = default; // 0x00
|
||||
|
||||
virtual rage::datBitBuffer* _0x08() = 0;
|
||||
|
||||
virtual rage::datBitBuffer* _0x10() = 0;
|
||||
|
||||
virtual int get_num_receivers() = 0; // 0x18
|
||||
|
||||
virtual int _0x20() = 0;
|
||||
|
||||
virtual void _0x28() = 0; // same as get_sync_unit_for_element
|
||||
|
||||
virtual netSyncDataUnit_Dynamic* get_sync_unit_for_element(uint32_t element) = 0; // 0x30
|
||||
|
||||
// ...
|
||||
};
|
||||
|
||||
class netArrayHandlerBase
|
||||
{
|
||||
public:
|
||||
virtual ~netArrayHandlerBase() = default; // 0x00
|
||||
|
||||
virtual void _0x08() = 0;
|
||||
|
||||
virtual void _0x10() = 0;
|
||||
|
||||
virtual void _0x18() = 0;
|
||||
|
||||
virtual void _0x20() = 0;
|
||||
|
||||
virtual void _0x28() = 0;
|
||||
|
||||
virtual void _0x30() = 0;
|
||||
|
||||
virtual void _0x38() = 0; //
|
||||
|
||||
virtual void _0x40() = 0; //
|
||||
|
||||
virtual int _0x48(CNetGamePlayer* player, int max_size, uint32_t* a3, uint32_t* a4) = 0; //
|
||||
|
||||
virtual int get_size(CNetGamePlayer* player, int max_size, uint32_t element) = 0; // 0x50
|
||||
|
||||
virtual int pack_array_data(CNetGamePlayer* player, rage::datBitBuffer* bit_buffer, uint16_t counter, uint32_t* elem_start, bool silent) = 0; // 0x58
|
||||
|
||||
virtual void _0x60() = 0; //
|
||||
|
||||
virtual bool _0x68(CNetGamePlayer* player) = 0; // is_player_out_of_scope or something like that
|
||||
|
||||
virtual void _0x70() = 0; //
|
||||
|
||||
virtual bool can_send_update(CNetGamePlayer* player) = 0; // 0x78
|
||||
|
||||
virtual void _0x80() = 0; //
|
||||
|
||||
virtual void _0x88() = 0; //
|
||||
|
||||
virtual void* get_identifier() = 0; // 0x90
|
||||
|
||||
virtual void* _0x98() = 0; // same as get_identifier
|
||||
|
||||
virtual void _0xA0() = 0; //
|
||||
|
||||
virtual bool can_verify_array_data() = 0; // 0xA8
|
||||
|
||||
virtual void _0xB0() = 0; //
|
||||
|
||||
virtual void _0xB8() = 0; //
|
||||
|
||||
virtual void should_sync_element(uint32_t element) = 0; // 0xC0
|
||||
|
||||
virtual void _0xC8() = 0; //
|
||||
|
||||
virtual void _0xD0() = 0; //
|
||||
|
||||
virtual bool are_all_elements_in_scope() = 0; // 0xD8
|
||||
|
||||
virtual void _0xE0() = 0; //
|
||||
|
||||
virtual void verify_array_data() = 0; // 0xE8
|
||||
|
||||
virtual void _0xF0() = 0; //
|
||||
|
||||
virtual char* get_name() = 0; // 0xF8
|
||||
|
||||
virtual bool is_local_player_owner_of_array() = 0; // 0x100
|
||||
|
||||
virtual CNetGamePlayer* get_owner_of_array() = 0; // 0x108
|
||||
|
||||
virtual void _0x110() = 0;
|
||||
|
||||
virtual uint32_t get_array_hash() = 0;
|
||||
|
||||
virtual int _0x120() = 0; // gets array size for hashing
|
||||
|
||||
virtual netSyncData_Dynamic* _0x128() = 0; // same as get_dynamic_sync_data
|
||||
|
||||
virtual netSyncData_Dynamic* get_dynamic_sync_data() = 0; // 0x130
|
||||
|
||||
virtual void _0x138() = 0;
|
||||
|
||||
virtual bool is_element_in_scope(uint32_t element, CNetGamePlayer* player) = 0; // 0x140
|
||||
|
||||
virtual int get_receiver_index_from_player(CNetGamePlayer*) = 0; // 0x148
|
||||
|
||||
virtual void _0x150() = 0;
|
||||
|
||||
virtual void _0x158() = 0;
|
||||
|
||||
// pasted from fivem
|
||||
virtual bool is_element_empty(uint32_t element) = 0; // 0x160
|
||||
|
||||
virtual void set_element_empty(uint32_t element) = 0; // 0x168
|
||||
|
||||
virtual void write_element_index(rage::datBitBuffer& buffer, uint32_t) = 0; // 0x170
|
||||
|
||||
virtual void read_element_index(rage::datBitBuffer& buffer, uint32_t&) = 0; // 0x178
|
||||
|
||||
virtual bool is_valid_index(uint32_t) = 0; // 0x180
|
||||
|
||||
virtual void recalculate_dirty_elements() = 0; // 0x188
|
||||
|
||||
virtual void reset_element_sync_data(uint32_t element) = 0; // 0x190
|
||||
|
||||
virtual void do_post_read_processing() = 0; // 0x198
|
||||
|
||||
virtual void do_post_element_read_processing(uint32_t element) = 0; // 0x1A0
|
||||
|
||||
virtual bool can_apply_element_data(uint32_t element, const rage::netPlayer& sender, bool force) = 0; // 0x1A8
|
||||
|
||||
virtual void extract_data_for_serializing(uint32_t elem) = 0; // 0x1B0
|
||||
|
||||
virtual void write_element(rage::datBitBuffer& buffer, uint32_t elem, void* logger) = 0; // 0x1B8
|
||||
|
||||
virtual void read_element(rage::datBitBuffer& buffer, uint32_t elem, void* logger) = 0; // 0x1C0
|
||||
|
||||
virtual void log_element(uint32_t elem, void* logger) = 0; // 0x1C8
|
||||
|
||||
virtual uint32_t get_current_element_size_in_bits(uint32_t elem) = 0; // 0x1D0
|
||||
|
||||
virtual void apply_element_data(uint32_t element, const rage::netPlayer& sender) = 0; // 0x1D8
|
||||
|
||||
virtual void _0x1E0() = 0;
|
||||
|
||||
virtual void _0x1E8(bool) = 0; // very important! changes send function to use some kind of cached buffer that prevents us from modifing array data per player
|
||||
|
||||
void* m_something; // 0x10
|
||||
|
||||
netArrayHandlerBase* m_next; // 0x18
|
||||
|
||||
uint8_t m_pad[100 - 0x18]; // +8
|
||||
uint32_t m_hash;
|
||||
uint8_t m_pad2[244 - 104]; // +8
|
||||
uint16_t m_index; // 244
|
||||
uint16_t m_count; // 246
|
||||
uint8_t m_max_elements; // 248
|
||||
uint8_t m_element_size; // 249
|
||||
uint8_t m_element_size_2; // 250
|
||||
uint8_t m_pad3[13]; // 251
|
||||
void* m_array; // 264
|
||||
|
||||
#if 0
|
||||
static inline netArrayHandlerBase* get_by_data(void* data)
|
||||
{
|
||||
if (auto array_mgr = *big::g_pointers->m_game_array_mgr)
|
||||
{
|
||||
if (auto handler = array_mgr->m_start)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (handler->m_array == data)
|
||||
return handler;
|
||||
}
|
||||
while (handler = handler->m_next);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
static_assert(sizeof(netArrayHandlerBase) == 272);
|
||||
}
|
@ -423,6 +423,24 @@ namespace rage
|
||||
virtual void unk_0x38() = 0;
|
||||
};
|
||||
|
||||
struct sEntityDamagedData
|
||||
{
|
||||
alignas(8) Entity m_victim_index;
|
||||
alignas(8) Entity m_damager_index;
|
||||
alignas(8) float m_damage;
|
||||
alignas(8) float m_endurance_damage;
|
||||
alignas(8) bool m_victim_incapacitated;
|
||||
alignas(8) bool m_victim_destroyed;
|
||||
alignas(8) int m_weapon_used;
|
||||
alignas(8) float m_victim_speed;
|
||||
alignas(8) float m_damager_speed;
|
||||
alignas(8) bool m_is_responsible_for_collision;
|
||||
alignas(8) bool m_is_headshot;
|
||||
alignas(8) bool m_is_with_melee_weapon;
|
||||
alignas(8) int m_hit_material;
|
||||
};
|
||||
static_assert(sizeof(sEntityDamagedData) == 0x68);
|
||||
|
||||
class netGameEvent
|
||||
{
|
||||
public:
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "../pointers.hpp"
|
||||
#include "replay.hpp"
|
||||
|
||||
class CNetGamePlayer;
|
||||
|
||||
namespace rage
|
||||
{
|
||||
@ -55,7 +56,6 @@ namespace rage
|
||||
};
|
||||
|
||||
class netObject;
|
||||
class CNetGamePlayer;
|
||||
|
||||
class netObjectMgrBase
|
||||
{
|
||||
|
25
src/gta/script_handler.cpp
Normal file
25
src/gta/script_handler.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "script_handler.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include <network/CNetworkPlayerMgr.hpp>
|
||||
|
||||
int CGameScriptHandlerNetComponent::get_participant_index(CNetGamePlayer* player)
|
||||
{
|
||||
if (player == (*big::g_pointers->m_network_player_mgr)->m_local_net_player)
|
||||
return m_local_participant_index;
|
||||
|
||||
if (m_num_participants <= 1)
|
||||
return -1;
|
||||
|
||||
for (int i = 0; i < m_num_participants - 1; i++)
|
||||
{
|
||||
if (m_participants[i] && m_participants[i]->m_net_game_player == player)
|
||||
return m_participants[i]->m_participant_index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CGameScriptHandlerNetComponent::is_player_a_participant(CNetGamePlayer* player)
|
||||
{
|
||||
return m_participant_bitset & (1 << player->m_player_id);
|
||||
}
|
@ -16,10 +16,10 @@ namespace rage
|
||||
class scriptResourceEntry
|
||||
{
|
||||
public:
|
||||
scriptResource *m_data; // 0x00
|
||||
scriptResource* m_data; // 0x00
|
||||
std::uint32_t m_unk; // 0x04
|
||||
char m_padding[0x0C]; // 0x0C
|
||||
scriptResourceEntry *m_next; // 0x18
|
||||
scriptResourceEntry* m_next; // 0x18
|
||||
};
|
||||
|
||||
class scriptHandlerNetComponent
|
||||
@ -28,7 +28,7 @@ namespace rage
|
||||
virtual ~scriptHandlerNetComponent() = default;
|
||||
|
||||
public:
|
||||
scriptHandler *m_script_handler; // 0x08
|
||||
scriptHandler* m_script_handler; // 0x08
|
||||
};
|
||||
|
||||
class scriptHandler
|
||||
@ -46,9 +46,9 @@ namespace rage
|
||||
|
||||
virtual void cleanup_objects() = 0; // 3 (0x18)
|
||||
|
||||
virtual scriptId *_0x20() = 0; // 4 (0x20)
|
||||
virtual scriptId* _0x20() = 0; // 4 (0x20)
|
||||
|
||||
virtual scriptId *get_id() = 0; // 5 (0x28)
|
||||
virtual scriptId* get_id() = 0; // 5 (0x28)
|
||||
|
||||
// Returns whether the script handler belongs to a networked script.
|
||||
virtual bool is_networked() = 0; // 6 (0x30)
|
||||
@ -84,14 +84,14 @@ namespace rage
|
||||
|
||||
virtual void _0x98() = 0; // 19 (0x98)
|
||||
public:
|
||||
void *m_0x08; // 0x08
|
||||
void *m_0x10; // 0x10
|
||||
scrThread *m_script_thread; // 0x18
|
||||
void* m_0x08; // 0x08
|
||||
void* m_0x10; // 0x10
|
||||
scrThread* m_script_thread; // 0x18
|
||||
atDList<atDScriptObjectNode> m_objects; // 0x20
|
||||
scriptResource *m_resource_list_head; // 0x30
|
||||
scriptResource *m_resource_list_tail; // 0x38
|
||||
void *m_0x40; // 0x40
|
||||
scriptHandlerNetComponent *m_net_component; // 0x48
|
||||
scriptResource* m_resource_list_head; // 0x30
|
||||
scriptResource* m_resource_list_tail; // 0x38
|
||||
void* m_0x40; // 0x40
|
||||
scriptHandlerNetComponent* m_net_component; // 0x48
|
||||
std::uint32_t m_0x50; // 0x50
|
||||
std::uint32_t m_0x54; // 0x54
|
||||
std::uint32_t m_0x58; // 0x58
|
||||
@ -120,10 +120,10 @@ namespace rage
|
||||
virtual void _0x38(scrThread*) = 0; // 7 (0x38)
|
||||
|
||||
// Allocates and constructs a script handler.
|
||||
virtual scriptHandler *create_script_handler() = 0; // 8 (0x40)
|
||||
virtual scriptHandler* create_script_handler() = 0; // 8 (0x40)
|
||||
|
||||
// Finds the script handler for a given script id.
|
||||
virtual scriptHandler *get_script_handler(scriptId*) = 0; // 9 (0x48)
|
||||
virtual scriptHandler* get_script_handler(scriptId*) = 0; // 9 (0x48)
|
||||
|
||||
// Attaches a script thread.
|
||||
virtual void attach_thread(scrThread*) = 0; // 10 (0x50)
|
||||
@ -138,13 +138,13 @@ namespace rage
|
||||
virtual void on_player_left(netPlayer*) = 0; // 13 (0x68)
|
||||
|
||||
virtual std::int32_t _0x70() = 0; // 14 (0x70)
|
||||
virtual void *_0x78() = 0; // 15 (0x78)
|
||||
virtual void* _0x78() = 0; // 15 (0x78)
|
||||
public:
|
||||
char m_padding1[0x28]; // 0x08
|
||||
bool m_initialized; // 0x30
|
||||
bool m_initialized2; // 0x31
|
||||
char m_padding2[0x0E]; // 0x32
|
||||
rage::netLoggingInterface *m_logger; // 0x40
|
||||
rage::netLoggingInterface* m_logger; // 0x40
|
||||
};
|
||||
}
|
||||
|
||||
@ -179,6 +179,17 @@ class CGameScriptHandlerMgr : public rage::scriptHandlerMgr
|
||||
{
|
||||
};
|
||||
|
||||
class CScriptParticipant
|
||||
{
|
||||
public:
|
||||
char pad_0000[16]; //0x0000
|
||||
class CNetGamePlayer* m_net_game_player; //0x0010
|
||||
char pad_0018[2]; //0x0018
|
||||
int16_t m_participant_index; //0x001A
|
||||
char pad_001C[12]; //0x001C
|
||||
}; //Size: 0x0028
|
||||
static_assert(sizeof(CScriptParticipant) == 0x28);
|
||||
|
||||
class CGameScriptHandlerNetComponent
|
||||
{
|
||||
public:
|
||||
@ -255,9 +266,50 @@ public:
|
||||
virtual bool _0x118() = 0; // related to above function
|
||||
|
||||
CGameScriptHandler* m_script_handler; //0x0008
|
||||
char pad_0010[48]; //0x0010
|
||||
std::uint32_t m_participants; //0x0040
|
||||
};
|
||||
char pad_0010[32]; //0x0010
|
||||
class CScriptParticipant* m_host; //0x0030
|
||||
int16_t m_local_participant_index; //0x0038
|
||||
char pad_003A[6]; //0x003A
|
||||
uint32_t m_participant_bitset; //0x0040
|
||||
char pad_0044[36]; //0x0044
|
||||
class CScriptParticipant* m_participants[32]; //0x0068
|
||||
char pad_0168[12]; //0x0168
|
||||
int16_t m_num_participants; //0x0174
|
||||
char pad_0176[28]; //0x0176
|
||||
uint8_t m_host_migration_flags; //0x0192
|
||||
char pad_0193[29]; //0x0193
|
||||
|
||||
int get_participant_index(CNetGamePlayer* player);
|
||||
bool is_player_a_participant(CNetGamePlayer* player);
|
||||
|
||||
inline bool is_local_player_host()
|
||||
{
|
||||
if (!m_host)
|
||||
return true; // or return false?
|
||||
|
||||
return m_host->m_participant_index == m_local_participant_index;
|
||||
}
|
||||
|
||||
inline CNetGamePlayer* get_host()
|
||||
{
|
||||
if (!m_host)
|
||||
return nullptr;
|
||||
|
||||
return m_host->m_net_game_player;
|
||||
}
|
||||
|
||||
// not 100% foolproof
|
||||
inline void block_host_migration(bool toggle)
|
||||
{
|
||||
if (toggle)
|
||||
m_host_migration_flags |= (1 << 7);
|
||||
else
|
||||
m_host_migration_flags &= ~(1 << 7);
|
||||
}
|
||||
|
||||
}; //Size: 0x01B0
|
||||
static_assert(sizeof(CGameScriptHandlerNetComponent) == 0x1B0);
|
||||
|
||||
|
||||
static_assert(sizeof(rage::scriptHandler) == 0x60);
|
||||
static_assert(sizeof(CGameScriptHandler) == 0xA0);
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "joaat.hpp"
|
||||
#include "tls_context.hpp"
|
||||
|
||||
class CGameScriptHandlerNetComponent;
|
||||
|
||||
namespace rage
|
||||
{
|
||||
enum class eThreadState : std::uint32_t
|
||||
@ -47,17 +49,17 @@ namespace rage
|
||||
return rage::tlsContext::get()->m_script_thread;
|
||||
}
|
||||
public:
|
||||
scrThreadContext m_context; // 0x08
|
||||
void* m_stack; // 0xB0
|
||||
char m_padding[0x4]; // 0xB8
|
||||
uint32_t m_arg_size; // 0xBC
|
||||
uint32_t m_arg_loc; // 0xC0
|
||||
char m_padding2[0x4]; // 0xC4
|
||||
const char* m_exit_message; // 0xC8
|
||||
std::uint32_t m_name_hash; // 0xCC
|
||||
char m_name[0x40]; // 0xD4
|
||||
scriptHandler* m_handler; // 0x114
|
||||
scriptHandlerNetComponent* m_net_component; // 0x11C
|
||||
scrThreadContext m_context; // 0x08
|
||||
void* m_stack; // 0xB0
|
||||
char m_padding[0x4]; // 0xB8
|
||||
uint32_t m_arg_size; // 0xBC
|
||||
uint32_t m_arg_loc; // 0xC0
|
||||
char m_padding2[0x4]; // 0xC4
|
||||
const char* m_exit_message; // 0xC8
|
||||
std::uint32_t m_name_hash; // 0xCC
|
||||
char m_name[0x40]; // 0xD4
|
||||
scriptHandler* m_handler; // 0x114
|
||||
CGameScriptHandlerNetComponent* m_net_component; // 0x11C
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,10 @@ namespace rage
|
||||
public:
|
||||
scrVector() = default;
|
||||
|
||||
scrVector(rage::fvector3 vec) :
|
||||
x(vec.x), y(vec.y), z(vec.z)
|
||||
{}
|
||||
|
||||
scrVector(float x, float y, float z) :
|
||||
x(x), y(y), z(z)
|
||||
{}
|
||||
|
Reference in New Issue
Block a user