refactor(ContextMenu): improve code (#1173)

* chore: remove unused classes from replay
* feat(ContextMenu): keep drawing even if menu is open
This commit is contained in:
Andreas Maerten 2023-04-02 01:30:51 +02:00 committed by GitHub
parent ea33c09e8c
commit 06a215b90c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1158 additions and 1213 deletions

View File

@ -1,43 +1,43 @@
#include "backend/player_command.hpp" #include "backend/player_command.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "pointers.hpp" #include "pointers.hpp"
namespace big namespace big
{ {
class kill_player : player_command class kill_player : player_command
{ {
using player_command::player_command; using player_command::player_command;
virtual CommandAccessLevel get_access_level() virtual CommandAccessLevel get_access_level()
{ {
return CommandAccessLevel::AGGRESSIVE; return CommandAccessLevel::AGGRESSIVE;
} }
virtual void execute(player_ptr player, const std::vector<std::uint64_t>& _args, const std::shared_ptr<command_context> ctx) virtual void execute(player_ptr player, const std::vector<std::uint64_t>& _args, const std::shared_ptr<command_context> ctx)
{ {
if (!player->get_ped()) if (!player->get_ped())
return; return;
g_pointers->m_send_network_damage((CEntity*)g_player_service->get_self()->get_ped(), g_pointers->m_send_network_damage(g_player_service->get_self()->get_ped(),
(CEntity*)player->get_ped(), player->get_ped(),
player->get_ped()->m_navigation->get_position(), player->get_ped()->m_navigation->get_position(),
0, 0,
true, true,
RAGE_JOAAT("weapon_explosion"), RAGE_JOAAT("weapon_explosion"),
10000.0f, 10000.0f,
2, 2,
0, 0,
(1 << 4), (1 << 4),
0, 0,
0, 0,
0, 0,
false, false,
false, false,
true, true,
true, true,
nullptr); nullptr);
} }
}; };
kill_player g_kill_player("kill", "Kill Player", "Kills the player, bypassing most forms of interior godmode", 0); kill_player g_kill_player("kill", "Kill Player", "Kills the player, bypassing most forms of interior godmode", 0);
} }

View File

@ -1,62 +1,62 @@
#include "backend/looped/looped.hpp" #include "backend/looped/looped.hpp"
#include "gta/pickup_rewards.hpp" #include "gta/pickup_rewards.hpp"
#include "services/players/player_service.hpp" #include "services/players/player_service.hpp"
#include "util/globals.hpp" #include "util/globals.hpp"
#include "util/misc.hpp" #include "util/misc.hpp"
#include "util/toxic.hpp" #include "util/toxic.hpp"
namespace big namespace big
{ {
void looped::player_toxic_options() void looped::player_toxic_options()
{ {
if (!*g_pointers->m_is_session_started) if (!*g_pointers->m_is_session_started)
return; return;
int rotate_cam_bits = 0; int rotate_cam_bits = 0;
g_player_service->iterate([&rotate_cam_bits](const player_entry& entry) { g_player_service->iterate([&rotate_cam_bits](const player_entry& entry) {
if (g_player_service->get_self()->get_ped() && entry.second->get_ped() && entry.second->get_ped()->m_health > 0) if (g_player_service->get_self()->get_ped() && entry.second->get_ped() && entry.second->get_ped()->m_health > 0)
{ {
if (entry.second->kill_loop && !(entry.second->get_ped()->m_damage_bits & (1 << 8))) if (entry.second->kill_loop && !(entry.second->get_ped()->m_damage_bits & (1 << 8)))
g_pointers->m_send_network_damage((CEntity*)g_player_service->get_self()->get_ped(), g_pointers->m_send_network_damage(g_player_service->get_self()->get_ped(),
(CEntity*)entry.second->get_ped(), entry.second->get_ped(),
entry.second->get_ped()->m_navigation->get_position(), entry.second->get_ped()->m_navigation->get_position(),
0, 0,
true, true,
RAGE_JOAAT("weapon_explosion"), RAGE_JOAAT("weapon_explosion"),
10000.0f, 10000.0f,
2, 2,
0, 0,
(1 << 4), (1 << 4),
0, 0,
0, 0,
0, 0,
false, false,
false, false,
true, true,
true, true,
nullptr); nullptr);
if (entry.second->explosion_loop) if (entry.second->explosion_loop)
toxic::blame_explode_player(entry.second, entry.second, EXP_TAG_SUBMARINE_BIG, 9999.0f, true, false, 9999.0f); toxic::blame_explode_player(entry.second, entry.second, EXP_TAG_SUBMARINE_BIG, 9999.0f, true, false, 9999.0f);
if (entry.second->freeze_loop && entry.second->get_ped()->m_net_object) if (entry.second->freeze_loop && entry.second->get_ped()->m_net_object)
g_pointers->m_clear_ped_tasks_network(entry.second->get_ped(), true); g_pointers->m_clear_ped_tasks_network(entry.second->get_ped(), true);
if (entry.second->ragdoll_loop && entry.second->get_ped()->m_net_object) if (entry.second->ragdoll_loop && entry.second->get_ped()->m_net_object)
g_pointers->m_request_ragdoll(entry.second->get_ped()->m_net_object->m_object_id); g_pointers->m_request_ragdoll(entry.second->get_ped()->m_net_object->m_object_id);
if (entry.second->rotate_cam_loop) if (entry.second->rotate_cam_loop)
rotate_cam_bits |= (1 << entry.second->id()); rotate_cam_bits |= (1 << entry.second->id());
} }
if (rotate_cam_bits) if (rotate_cam_bits)
{ {
const size_t arg_count = 3; const size_t arg_count = 3;
int64_t args[arg_count] = {(int64_t)eRemoteEvent::TSECommand, (int64_t)self::id, (int64_t)eRemoteEvent::TSECommandRotateCam}; int64_t args[arg_count] = {(int64_t)eRemoteEvent::TSECommand, (int64_t)self::id, (int64_t)eRemoteEvent::TSECommandRotateCam};
g_pointers->m_trigger_script_event(1, args, arg_count, rotate_cam_bits); g_pointers->m_trigger_script_event(1, args, arg_count, rotate_cam_bits);
} }
}); });
} }
} }

View File

@ -1,139 +1,139 @@
#pragma once #pragma once
#include <rage/rlTaskStatus.hpp> #include <rage/rlTaskStatus.hpp>
class CMsgJoinResponse; class CMsgJoinResponse;
class NetworkGameFilterMatchmakingComponent; class NetworkGameFilterMatchmakingComponent;
class sCloudFile; class sCloudFile;
class CPlayerGameStateDataNode; class CPlayerGameStateDataNode;
class CVehicleGadgetDataNode; class CVehicleGadgetDataNode;
enum eVehicleGadgetType : uint32_t; enum eVehicleGadgetType : uint32_t;
namespace rage namespace rage
{ {
class netConnectionManager; class netConnectionManager;
class netConnectionPeer; class netConnectionPeer;
class snMsgRemoveGamersFromSessionCmd; class snMsgRemoveGamersFromSessionCmd;
class snSession; class snSession;
class snPlayer; class snPlayer;
class CDynamicEntity; class CDynamicEntity;
class netTimeSyncMsg; class netTimeSyncMsg;
class snConnectToPeerTaskData; class snConnectToPeerTaskData;
class snConnectToPeerTaskResult; class snConnectToPeerTaskResult;
class rlScHandle; class rlScHandle;
class rlQueryPresenceAttributesContext; class rlQueryPresenceAttributesContext;
enum class eThreadState : uint32_t; enum class eThreadState : uint32_t;
} }
namespace datafile_commands namespace datafile_commands
{ {
class SveFileObject; class SveFileObject;
} }
namespace big::functions namespace big::functions
{ {
using run_script_threads = bool (*)(std::uint32_t ops_to_execute); using run_script_threads = bool (*)(std::uint32_t ops_to_execute);
using get_native_handler = rage::scrNativeHandler (*)(rage::scrNativeRegistrationTable* registration_table, rage::scrNativeHash hash); using get_native_handler = rage::scrNativeHandler (*)(rage::scrNativeRegistrationTable* registration_table, rage::scrNativeHash hash);
using fix_vectors = void (*)(rage::scrNativeCallContext* call_ctx); using fix_vectors = void (*)(rage::scrNativeCallContext* call_ctx);
using get_net_game_player = CNetGamePlayer* (*)(Player player); using get_net_game_player = CNetGamePlayer* (*)(Player player);
using trigger_script_event = void (*)(int event_group, int64_t* args, int arg_count, int player_bits); using trigger_script_event = void (*)(int event_group, int64_t* args, int arg_count, int player_bits);
using increment_stat_event = bool (*)(uint64_t net_event_struct, int64_t sender, int64_t a3); using increment_stat_event = bool (*)(uint64_t net_event_struct, int64_t sender, int64_t a3);
using ptr_to_handle = Entity (*)(void*); using ptr_to_handle = Entity (*)(void*);
using handle_to_ptr = rage::CDynamicEntity* (*)(Entity); using handle_to_ptr = rage::CDynamicEntity* (*)(Entity);
using check_chat_profanity = int(__int64 chat_type, const char* input, const char** output); using check_chat_profanity = int(__int64 chat_type, const char* input, const char** output);
using write_player_game_state_data_node = bool (*)(rage::netObject* plr, CPlayerGameStateDataNode* node); using write_player_game_state_data_node = bool (*)(rage::netObject* plr, CPlayerGameStateDataNode* node);
using get_gameplay_cam_coords = Vector3 (*)(); using get_gameplay_cam_coords = Vector3 (*)();
using get_screen_coords_for_world_coords = bool (*)(float* world_coords, float* out_x, float* out_y); using get_screen_coords_for_world_coords = bool (*)(float* world_coords, float* out_x, float* out_y);
using give_pickup_rewards = void (*)(int players, uint32_t hash); using give_pickup_rewards = void (*)(int players, uint32_t hash);
// Bitbuffer read/write START // Bitbuffer read/write START
using read_bitbuf_dword = bool (*)(rage::datBitBuffer* buffer, PVOID read, int bits); using read_bitbuf_dword = bool (*)(rage::datBitBuffer* buffer, PVOID read, int bits);
using read_bitbuf_string = bool (*)(rage::datBitBuffer* buffer, char* read, int bits); using read_bitbuf_string = bool (*)(rage::datBitBuffer* buffer, char* read, int bits);
using read_bitbuf_bool = bool (*)(rage::datBitBuffer* buffer, bool* read, int bits); using read_bitbuf_bool = bool (*)(rage::datBitBuffer* buffer, bool* read, int bits);
using read_bitbuf_array = bool (*)(rage::datBitBuffer* buffer, PVOID read, int bits, int unk); using read_bitbuf_array = bool (*)(rage::datBitBuffer* buffer, PVOID read, int bits, int unk);
using write_bitbuf_qword = bool (*)(rage::datBitBuffer* buffer, uint64_t val, int bits); using write_bitbuf_qword = bool (*)(rage::datBitBuffer* buffer, uint64_t val, int bits);
using write_bitbuf_dword = bool (*)(rage::datBitBuffer* buffer, uint32_t val, int bits); using write_bitbuf_dword = bool (*)(rage::datBitBuffer* buffer, uint32_t val, int bits);
using write_bitbuf_int64 = bool (*)(rage::datBitBuffer* buffer, int64_t val, int bits); using write_bitbuf_int64 = bool (*)(rage::datBitBuffer* buffer, int64_t val, int bits);
using write_bitbuf_int32 = bool (*)(rage::datBitBuffer* buffer, int32_t val, int bits); using write_bitbuf_int32 = bool (*)(rage::datBitBuffer* buffer, int32_t val, int bits);
using write_bitbuf_bool = bool (*)(rage::datBitBuffer* buffer, bool val, int bits); using write_bitbuf_bool = bool (*)(rage::datBitBuffer* buffer, bool val, int bits);
using write_bitbuf_array = bool (*)(rage::datBitBuffer* buffer, void* val, int bits, int unk); using write_bitbuf_array = bool (*)(rage::datBitBuffer* buffer, void* val, int bits, int unk);
// Bitbuffer read/write END // Bitbuffer read/write END
// Received Event Signatures START // Received Event Signatures START
using send_event_ack = void (*)(rage::netEventMgr* event_manager, CNetGamePlayer* source_player, CNetGamePlayer* target_player, int event_index, int event_handled_bitset); using send_event_ack = void (*)(rage::netEventMgr* event_manager, CNetGamePlayer* source_player, CNetGamePlayer* target_player, int event_index, int event_handled_bitset);
// Received Event Signatures END // Received Event Signatures END
//Sync signatures START //Sync signatures START
using get_sync_type_info = const char* (*)(uint16_t sync_type, char a2); using get_sync_type_info = const char* (*)(uint16_t sync_type, char a2);
using get_sync_tree_for_type = rage::netSyncTree* (*)(CNetworkObjectMgr* mgr, uint16_t sync_type); using get_sync_tree_for_type = rage::netSyncTree* (*)(CNetworkObjectMgr* mgr, uint16_t sync_type);
using get_net_object = rage::netObject* (*)(CNetworkObjectMgr* mgr, int16_t id, bool can_delete_be_pending); using get_net_object = rage::netObject* (*)(CNetworkObjectMgr* mgr, int16_t id, bool can_delete_be_pending);
using get_net_object_for_player = rage::netObject* (*)(CNetworkObjectMgr*, int16_t, CNetGamePlayer*, bool); using get_net_object_for_player = rage::netObject* (*)(CNetworkObjectMgr*, int16_t, CNetGamePlayer*, bool);
using read_bitbuffer_into_sync_tree = void (*)(rage::netSyncTree* tree, uint64_t flag, uint32_t flag2, rage::datBitBuffer* buffer, uint64_t netLogStub); using read_bitbuffer_into_sync_tree = void (*)(rage::netSyncTree* tree, uint64_t flag, uint32_t flag2, rage::datBitBuffer* buffer, uint64_t netLogStub);
//Sync signatures END //Sync signatures END
using reset_network_complaints = void (*)(CNetComplaintMgr* mgr); using reset_network_complaints = void (*)(CNetComplaintMgr* mgr);
using fidevice_get_device = rage::fiDevice* (*)(const char* path, bool allow_root); using fidevice_get_device = rage::fiDevice* (*)(const char* path, bool allow_root);
using fipackfile_ctor = rage::fiPackfile* (*)(rage::fiPackfile* this_); using fipackfile_ctor = rage::fiPackfile* (*)(rage::fiPackfile* this_);
using fipackfile_open_archive = bool (*)(rage::fiPackfile* this_, const char* archive, bool b_true, int type, intptr_t very_false); using fipackfile_open_archive = bool (*)(rage::fiPackfile* this_, const char* archive, bool b_true, int type, intptr_t very_false);
using fipackfile_mount = bool (*)(rage::fiPackfile* this_, const char* mount_point); using fipackfile_mount = bool (*)(rage::fiPackfile* this_, const char* mount_point);
using fipackfile_unmount = bool (*)(const char* mount_point); using fipackfile_unmount = bool (*)(const char* mount_point);
using start_get_session_by_gamer_handle = bool (*)(int profile_index, rage::rlGamerHandle* handles, int count, rage::rlSessionByGamerTaskResult* result, int unk, bool* success, rage::rlTaskStatus* state); using start_get_session_by_gamer_handle = bool (*)(int profile_index, rage::rlGamerHandle* handles, int count, rage::rlSessionByGamerTaskResult* result, int unk, bool* success, rage::rlTaskStatus* state);
using start_matchmaking_find_sessions = bool (*)(int profile_index, int available_slots, NetworkGameFilterMatchmakingComponent* m_filter, unsigned int max_sessions, rage::rlSessionInfo* result_sessions, int* result_session_count, rage::rlTaskStatus* state); using start_matchmaking_find_sessions = bool (*)(int profile_index, int available_slots, NetworkGameFilterMatchmakingComponent* m_filter, unsigned int max_sessions, rage::rlSessionInfo* result_sessions, int* result_session_count, rage::rlTaskStatus* state);
using start_get_presence_attributes = bool (*)(int profile_index, rage::rlScHandle* handle, rage::rlQueryPresenceAttributesContext* contexts, int count, rage::rlTaskStatus* state); using start_get_presence_attributes = bool (*)(int profile_index, rage::rlScHandle* handle, rage::rlQueryPresenceAttributesContext* contexts, int count, rage::rlTaskStatus* state);
using join_session_by_info = bool (*)(Network* network, rage::rlSessionInfo* info, int unk, int flags, rage::rlGamerHandle* handles, int handlecount); using join_session_by_info = bool (*)(Network* network, rage::rlSessionInfo* info, int unk, int flags, rage::rlGamerHandle* handles, int handlecount);
using generate_uuid = bool (*)(std::uint64_t* uuid); using generate_uuid = bool (*)(std::uint64_t* uuid);
using get_vehicle_gadget_array_size = int (*)(eVehicleGadgetType type); using get_vehicle_gadget_array_size = int (*)(eVehicleGadgetType type);
using write_join_response_data = bool (*)(CMsgJoinResponse* response, void* data, int size, uint32_t* size_used); using write_join_response_data = bool (*)(CMsgJoinResponse* response, void* data, int size, uint32_t* size_used);
using queue_packet = bool (*)(rage::netConnectionManager* mgr, int msg_id, void* data, int size, int flags, void* unk); using queue_packet = bool (*)(rage::netConnectionManager* mgr, int msg_id, void* data, int size, int flags, void* unk);
using generate_uuid = bool (*)(std::uint64_t* uuid); using generate_uuid = bool (*)(std::uint64_t* uuid);
using send_chat_message = bool (*)(int64_t* send_chat_ptr, rage::rlGamerInfo* gamer_info, char* message, bool is_team); using send_chat_message = bool (*)(int64_t* send_chat_ptr, rage::rlGamerInfo* gamer_info, char* message, bool is_team);
using send_network_damage = void (*)(CEntity* source, CEntity* target, rage::fvector3* position, int hit_component, bool override_default_damage, int weapon_type, float override_damage, int tire_index, int suspension_index, int flags, std::uint32_t action_result_hash, std::int16_t action_result_id, int action_unk, bool hit_weapon, bool hit_weapon_ammo_attachment, bool silenced, bool unk, rage::fvector3* impact_direction); using send_network_damage = void (*)(rage::CEntity* source, rage::CEntity* target, rage::fvector3* position, int hit_component, bool override_default_damage, int weapon_type, float override_damage, int tire_index, int suspension_index, int flags, std::uint32_t action_result_hash, std::int16_t action_result_id, int action_unk, bool hit_weapon, bool hit_weapon_ammo_attachment, bool silenced, bool unk, rage::fvector3* impact_direction);
using request_ragdoll = void (*)(uint16_t object_id); using request_ragdoll = void (*)(uint16_t object_id);
using request_control = void (*)(rage::netObject* net_object); using request_control = void (*)(rage::netObject* net_object);
using get_connection_peer = rage::netConnectionPeer* (*)(rage::netConnectionManager* manager, int peer_id); using get_connection_peer = rage::netConnectionPeer* (*)(rage::netConnectionManager* manager, int peer_id);
using send_remove_gamer_cmd = void (*)(rage::netConnectionManager* net_connection_mgr, rage::netConnectionPeer* player, int connection_id, rage::snMsgRemoveGamersFromSessionCmd* cmd, int flags); using send_remove_gamer_cmd = void (*)(rage::netConnectionManager* net_connection_mgr, rage::netConnectionPeer* player, int connection_id, rage::snMsgRemoveGamersFromSessionCmd* cmd, int flags);
using handle_remove_gamer_cmd = void* (*)(rage::snSession* session, rage::snPlayer* origin, rage::snMsgRemoveGamersFromSessionCmd* cmd); using handle_remove_gamer_cmd = void* (*)(rage::snSession* session, rage::snPlayer* origin, rage::snMsgRemoveGamersFromSessionCmd* cmd);
using script_vm = rage::eThreadState (*)(uint64_t* stack, int64_t** scr_globals, rage::scrProgram* program, rage::scrThreadContext* ctx); using script_vm = rage::eThreadState (*)(uint64_t* stack, int64_t** scr_globals, rage::scrProgram* program, rage::scrThreadContext* ctx);
using encode_session_info = bool (*)(rage::rlSessionInfo* info, char* buffer, int buffer_size, int* bytes_written); using encode_session_info = bool (*)(rage::rlSessionInfo* info, char* buffer, int buffer_size, int* bytes_written);
using decode_session_info = bool (*)(rage::rlSessionInfo* out_info, char* buffer, int* bytes_read); using decode_session_info = bool (*)(rage::rlSessionInfo* out_info, char* buffer, int* bytes_read);
using decode_peer_info = bool (*)(rage::rlGamerInfoBase* info, char* buffer, int* bytes_read); using decode_peer_info = bool (*)(rage::rlGamerInfoBase* info, char* buffer, int* bytes_read);
using load_cloud_file = void (*)(sCloudFile** out_cloud_file, char* buffer, int size, const char* reason); using load_cloud_file = void (*)(sCloudFile** out_cloud_file, char* buffer, int size, const char* reason);
using set_as_active_cloud_file = void (*)(datafile_commands::SveFileObject* object, sCloudFile** file); using set_as_active_cloud_file = void (*)(datafile_commands::SveFileObject* object, sCloudFile** file);
using save_json_data = char* (*)(datafile_commands::SveFileObject* object, int* out_length, const char* reason); using save_json_data = char* (*)(datafile_commands::SveFileObject* object, int* out_length, const char* reason);
using sync_network_time = bool (*)(rage::netConnectionManager* mgr, rage::netConnectionPeer* peer, int connection_id, rage::netTimeSyncMsg* msg, int flags); using sync_network_time = bool (*)(rage::netConnectionManager* mgr, rage::netConnectionPeer* peer, int connection_id, rage::netTimeSyncMsg* msg, int flags);
using send_packet = bool (*)(rage::netConnectionManager* mgr, rage::netConnectionPeer* peer, int connection_id, void* data, int size, int flags); using send_packet = bool (*)(rage::netConnectionManager* mgr, rage::netConnectionPeer* peer, int connection_id, void* data, int size, int flags);
using connect_to_peer = bool (*)(rage::netConnectionManager* mgr, rage::rlGamerInfoBase* gamer_info, rage::snConnectToPeerTaskData* data, rage::snConnectToPeerTaskResult* result, rage::rlTaskStatus* status); using connect_to_peer = bool (*)(rage::netConnectionManager* mgr, rage::rlGamerInfoBase* gamer_info, rage::snConnectToPeerTaskData* data, rage::snConnectToPeerTaskResult* result, rage::rlTaskStatus* status);
using clear_ped_tasks_network = void (*)(CPed* ped, bool immediately); using clear_ped_tasks_network = void (*)(CPed* ped, bool immediately);
using get_next_carriage = void* (*)(void* carriage); using get_next_carriage = void* (*)(void* carriage);
using get_entity_attached_to = rage::CDynamicEntity* (*)(rage::CDynamicEntity* entity); using get_entity_attached_to = rage::CDynamicEntity* (*)(rage::CDynamicEntity* entity);
using migrate_object = void (*)(CNetGamePlayer* player, rage::netObject* object, int type); using migrate_object = void (*)(CNetGamePlayer* player, rage::netObject* object, int type);
} }

View File

@ -1,75 +1,76 @@
#pragma once #pragma once
namespace rage namespace rage
{ {
template<typename T> template<typename T>
class atArray; class atArray;
class datBitBuffer; class CEntity;
class sysMemAllocator;
class datBitBuffer;
class scriptIdBase; class sysMemAllocator;
class scriptId;
class scriptHandler; class scriptIdBase;
class scriptHandlerNetComponent; class scriptId;
class scriptHandlerObject; class scriptHandler;
class scriptHandlerMgr; class scriptHandlerNetComponent;
class scriptHandlerObject;
class scrProgram; class scriptHandlerMgr;
class scrProgramTable;
class scrProgram;
class scrThreadContext; class scrProgramTable;
class scrThread;
class tlsContext; class scrThreadContext;
class scrThread;
class netLoggingInterface; class tlsContext;
class netLogStub;
class netLoggingInterface;
class netPlayer; class netLogStub;
class netPlayerMgr;
class netPlayer;
class netGameEvent; class netPlayerMgr;
class netEventMgr;
class netGameEvent;
class netSyncTree; class netEventMgr;
class netObject; class netSyncTree;
class netObjectMgrBase;
class netObject;
class scrNativeCallContext; class netObjectMgrBase;
class scrNativeRegistration;
class scrNativeRegistrationTable; class scrNativeCallContext;
class scrNativeRegistration;
class fwRefAwareBase; class scrNativeRegistrationTable;
class fwExtensibleBase;
class fwArchetype; class fwRefAwareBase;
class fwExtensibleBase;
class fiDevice; class fwArchetype;
class fiPackfile;
class fiDevice;
class rlSessionInfo; class fiPackfile;
class rlSessionByGamerTaskResult;
} class rlSessionInfo;
class rlSessionByGamerTaskResult;
class GtaThread; }
class CGameScriptId; class GtaThread;
class CGameScriptHandler;
class CGameScriptHandlerNetwork; class CGameScriptId;
class CGameScriptHandlerMgr; class CGameScriptHandler;
class CGameScriptHandlerNetwork;
class CEntity; class CGameScriptHandlerMgr;
class CPhysical;
class CPhysical;
class CObject;
class CPickup; class CObject;
class CPickup;
class CPedFactory;
class CVehicleFactory; class CPedFactory;
class CVehicleFactory;
class Network;
class CNetGamePlayer; class Network;
class CNetworkPlayerMgr; class CNetGamePlayer;
class CPlayerInfo; class CNetworkPlayerMgr;
class CNetworkObjectMgr; class CPlayerInfo;
class CNetComplaintMgr; class CNetworkObjectMgr;
class CNetComplaintMgr;

View File

@ -1,140 +1,94 @@
#pragma once #pragma once
#pragma pack(push, 4) #pragma pack(push, 4)
#include "common.hpp" #include "common.hpp"
#include "fwddec.hpp" #include "fwddec.hpp"
#include "base/CObject.hpp"
namespace rage
{ namespace rage
class CObject : public fwEntity {
{ template<typename T = CDynamicEntity>
public: class CEntityEntry
};//Size: 0x018C {
public:
class CPedFactory T* m_entity_ptr; //0x0000
{ int32_t m_handle; //0x0008
public: char pad_000C[4]; //0x000C
virtual ~CPedFactory() = default; }; //Size: 0x0010
class CPed* m_local_ped;//0x0008 static_assert(sizeof(CEntityEntry<CDynamicEntity>) == 0x10, "CEntityHandle is not properly sized");
}; //Size: 0x0010
class CObjectEntry : public CEntityEntry<CObject>
//CUSTOM CLASS TO IMPROVE R* SHIT CLASS STRUCTURE {
class CEntityHandle };
{
public: class CPedEntry : public CEntityEntry<CPed>
class fwEntity* m_entity_ptr;//0x0000 {
int32_t m_handle; //0x0008 };
char pad_000C[4]; //0x000C
}; //Size: 0x0010 class CVehicleEntry : public CEntityEntry<CVehicle>
static_assert(sizeof(CEntityHandle) == 0x10, "CEntityHandle is not properly sized"); {
}; //Size: 0x8FC0
class CObjectHandle
{ class CObjectInterface
public: {
class CObject* m_object;//0x0000 public:
int32_t m_handle; //0x0008 char pad_0000[344]; //0x0000
char pad_000C[4]; //0x000C std::array<CObjectEntry, 2300>* m_object_list; //0x0158
}; //Size: 0x0010 int32_t m_max_objects; //0x0160
static_assert(sizeof(CObjectHandle) == 0x10, "CObjectHandle is not properly sized"); char pad_0164[4]; //0x0164
int32_t m_cur_objects; //0x0168
class CObjectList
{ CObject* get_object(const int& index)
public: {
class CEntityHandle m_objects[2300];//0x0000 if (index < m_max_objects)
}; //Size: 0x8FC0 return (*m_object_list)[index].m_entity_ptr;
return nullptr;
class CObjectInterface }
{ }; //Size: 0x016C
public:
char pad_0000[344]; //0x0000 class CPedInterface
class CObjectList* m_object_list;//0x0158 {
int32_t m_max_objects; //0x0160 public:
char pad_0164[4]; //0x0164 char pad_0000[256]; //0x0000
int32_t m_cur_objects; //0x0168 std::array<CPedEntry, 256>* m_ped_list; //0x0100
int32_t m_max_peds; //0x0108
rage::fwEntity* get_object(const int& index) char pad_010C[4]; //0x010C
{ int32_t m_cur_peds; //0x0110
if (index < m_max_objects)
return m_object_list->m_objects[index].m_entity_ptr; CPed* get_ped(const int& index)
return nullptr; {
} if (index < m_max_peds)
};//Size: 0x016C return (*m_ped_list)[index].m_entity_ptr;
return nullptr;
class CPedHandle }
{ }; //Size: 0x0114
public:
class CPed* m_ped;//0x0000 class CVehicleInterface
int32_t m_handle; //0x0008 {
char pad_000C[4]; //0x000C public:
}; //Size: 0x0010 char pad_0000[384]; //0x0000
static_assert(sizeof(CPedHandle) == 0x10, "CPedHandle is not properly sized"); std::array<CVehicleEntry, 300>* m_vehicle_list; //0x0180
int32_t m_max_vehicles; //0x0188
class CPedList char pad_018C[4]; //0x018C
{ int32_t m_cur_vehicles; //0x0190
public:
//CHANGED FROM CPedHandle CVehicle* get_vehicle(const int& index)
class CEntityHandle m_peds[256];//0x0000 {
}; //Size: 0x1000 if (index < m_max_vehicles)
return (*m_vehicle_list)[index].m_entity_ptr;
class CPedInterface return nullptr;
{ }
public: }; //Size: 0x0194
char pad_0000[256]; //0x0000
class CPedList* m_ped_list;//0x0100
int32_t m_max_peds; //0x0108 class CReplayInterface
char pad_010C[4]; //0x010C {
int32_t m_cur_peds; //0x0110 public:
char pad_0000[16]; //0x0000
fwEntity* get_ped(const int& index) class CVehicleInterface* m_vehicle_interface; //0x0010
{ class CPedInterface* m_ped_interface; //0x0018
if (index < m_max_peds) char pad_0020[8]; //0x0020
return m_ped_list->m_peds[index].m_entity_ptr; class CObjectInterface* m_object_interface; //0x0028
return nullptr; }; //Size: 0x0030
} }
};//Size: 0x0114
class CVehicleHandle
{
public:
class CAutomobile* m_vehicle;//0x0000
int32_t m_handle; //0x0008
char pad_000C[4]; //0x000C
}; //Size: 0x0010
static_assert(sizeof(CVehicleHandle) == 0x10, "CVehicleHandle is not properly sized");
class CVehicleList
{
public:
//CHANGED FROM CVehicleHandle
class CEntityHandle m_vehicles[300];//0x0000
}; //Size: 0x12C0
class CVehicleInterface
{
public:
char pad_0000[384]; //0x0000
class CVehicleList* m_vehicle_list;//0x0180
int32_t m_max_vehicles; //0x0188
char pad_018C[4]; //0x018C
int32_t m_cur_vehicles; //0x0190
fwEntity* get_vehicle(const int& index)
{
if (index < m_max_vehicles)
return m_vehicle_list->m_vehicles[index].m_entity_ptr;
return nullptr;
}
};//Size: 0x0194
class CReplayInterface
{
public:
char pad_0000[16]; //0x0000
class CVehicleInterface* m_vehicle_interface;//0x0010
class CPedInterface* m_ped_interface; //0x0018
char pad_0020[8]; //0x0020
class CObjectInterface* m_object_interface; //0x0028
}; //Size: 0x0030
}
#pragma pack(pop) #pragma pack(pop)

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
#include "context_menu_service.hpp" #include "context_menu_service.hpp"
#include "fiber_pool.hpp"
#include "gta/replay.hpp" #include "gta/replay.hpp"
#include "gui.hpp" #include "gui.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "pointers.hpp" #include "pointers.hpp"
#include "util/misc.hpp" #include "util/misc.hpp"
#include "fiber_pool.hpp"
namespace big namespace big
{ {
@ -113,19 +113,19 @@ namespace big
double context_menu_service::distance_to_middle_of_screen(const rage::fvector2& screen_pos) double context_menu_service::distance_to_middle_of_screen(const rage::fvector2& screen_pos)
{ {
double cumulative_distance{}; double cum_dist{};
if (screen_pos.x > 0.5) if (screen_pos.x > 0.5)
cumulative_distance += screen_pos.x - 0.5; cum_dist += screen_pos.x - 0.5;
else else
cumulative_distance += 0.5 - screen_pos.x; cum_dist += 0.5 - screen_pos.x;
if (screen_pos.y > 0.5) if (screen_pos.y > 0.5)
cumulative_distance += screen_pos.y - 0.5; cum_dist += screen_pos.y - 0.5;
else else
cumulative_distance += 0.5 - screen_pos.y; cum_dist += 0.5 - screen_pos.y;
return cumulative_distance; return cum_dist;
} }
s_context_menu* context_menu_service::get_context_menu() s_context_menu* context_menu_service::get_context_menu()
@ -142,6 +142,7 @@ namespace big
} }
return &options.at(ContextEntityType::OBJECT); return &options.at(ContextEntityType::OBJECT);
} }
case eModelType::OnlineOnlyPed:
case eModelType::Ped: case eModelType::Ped:
{ {
if (const auto ped = reinterpret_cast<CPed*>(m_pointer); ped) if (const auto ped = reinterpret_cast<CPed*>(m_pointer); ped)
@ -200,48 +201,52 @@ namespace big
if (veh_interface && ped_interface && obj_interface) if (veh_interface && ped_interface && obj_interface)
{ {
const auto veh_interface_size = veh_interface->m_max_vehicles; double distance = 1;
const auto ped_interface_size = ped_interface->m_max_peds;
const auto obj_interface_size = obj_interface->m_max_objects;
const auto all_entities = std::make_unique<rage::CEntityHandle[]>(veh_interface_size + ped_interface_size + obj_interface_size);
const auto ptr = all_entities.get(); const auto get_closest_to_center = [this, &distance](auto entity_list) -> auto
std::uint32_t offset = 0;
std::copy(ped_interface->m_ped_list->m_peds, ped_interface->m_ped_list->m_peds + ped_interface_size, ptr);
offset += ped_interface_size;
std::copy(veh_interface->m_vehicle_list->m_vehicles, veh_interface->m_vehicle_list->m_vehicles + veh_interface_size, ptr + offset);
offset += veh_interface_size;
std::copy(obj_interface->m_object_list->m_objects, obj_interface->m_object_list->m_objects + obj_interface_size, ptr + offset);
offset += obj_interface_size;
double distance = 1;
bool got_an_entity = false;
rage::fvector2 screen_pos{};
for (std::uint32_t i = 0; i < offset; i++)
{ {
if (!all_entities[i].m_entity_ptr) rage::fvector2 screen_pos{};
continue; bool got_an_entity = false;
for (const auto entity : *entity_list)
const auto temp_pointer = all_entities[i].m_entity_ptr;
const auto temp_handle = g_pointers->m_ptr_to_handle(temp_pointer);
if (!temp_pointer->m_navigation)
continue;
const auto pos = *temp_pointer->m_navigation->get_position();
HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos.x, pos.y, pos.z, &screen_pos.x, &screen_pos.y);
if (distance_to_middle_of_screen(screen_pos) < distance && ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(PLAYER::PLAYER_PED_ID(), temp_handle, 17) && temp_handle != PLAYER::PLAYER_PED_ID())
{ {
m_handle = temp_handle; const auto temp_pointer = entity.m_entity_ptr;
m_pointer = temp_pointer; if (!temp_pointer || !temp_pointer->m_navigation)
distance = distance_to_middle_of_screen(screen_pos); continue;
got_an_entity = true; const auto temp_handle = g_pointers->m_ptr_to_handle(temp_pointer);
const auto pos = temp_pointer->m_navigation->get_position();
HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos->x,
pos->y,
pos->z,
&screen_pos.x,
&screen_pos.y);
const auto distance_from_middle = distance_to_middle_of_screen(screen_pos);
if (distance_from_middle < distance && ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(self::ped, temp_handle, 17) && temp_handle != self::ped)
{
m_handle = temp_handle;
m_pointer = temp_pointer;
distance = distance_from_middle;
got_an_entity = true;
}
} }
} return got_an_entity;
};
// I'm using bitwise OR instead or || to avoid compiler optimisation, all functions HAVE to execute
auto got_an_entity = get_closest_to_center(veh_interface->m_vehicle_list);
got_an_entity |= get_closest_to_center(ped_interface->m_ped_list);
got_an_entity |= get_closest_to_center(obj_interface->m_object_list);
if (got_an_entity) if (got_an_entity)
{ {
// if the ped is driving a vehicle take their vehicle instead of the ped (aka. prevent jank)
if ((m_pointer->m_model_info->m_model_type == eModelType::Ped || m_pointer->m_model_info->m_model_type == eModelType::OnlineOnlyPed)
&& reinterpret_cast<CPed*>(m_pointer)->m_vehicle)
{
m_pointer = reinterpret_cast<CPed*>(m_pointer)->m_vehicle;
m_handle = g_pointers->m_ptr_to_handle(m_pointer);
}
fill_model_bounding_box_screen_space(); fill_model_bounding_box_screen_space();
} }
} }
@ -303,12 +308,6 @@ namespace big
continue; continue;
} }
if (g_gui->is_open())
{
script::get_current()->yield();
continue;
}
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_VEH_DUCK)) if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_VEH_DUCK))
{ {
g_context_menu_service->enabled = !g_context_menu_service->enabled; g_context_menu_service->enabled = !g_context_menu_service->enabled;
@ -326,25 +325,23 @@ namespace big
script::get_current()->yield(); script::get_current()->yield();
continue; continue;
} }
else
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT))
cm->current_option = cm->options.size() <= cm->current_option + 1 ? 0 : cm->current_option + 1;
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
cm->current_option = 0 > cm->current_option - 1 ? static_cast<int>(cm->options.size()) - 1 : cm->current_option - 1;
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) || PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_SPECIAL_ABILITY))
{ {
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT)) if (!g_context_menu_service->m_pointer)
cm->current_option = cm->options.size() <= cm->current_option + 1 ? 0 : cm->current_option + 1;
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
cm->current_option = 0 > cm->current_option - 1 ? static_cast<int>(cm->options.size()) - 1 : cm->current_option - 1;
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) || PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_SPECIAL_ABILITY))
{ {
if (!g_context_menu_service->m_pointer) script::get_current()->yield();
{ continue;
continue;
}
g_fiber_pool->queue_job([cm] {
cm->options.at(cm->current_option).command();
});
} }
g_fiber_pool->queue_job([cm] {
cm->options.at(cm->current_option).command();
});
} }
} }

View File

@ -209,14 +209,11 @@ namespace big::entity
Entity closest_entity{}; Entity closest_entity{};
float distance = 1; float distance = 1;
//if (!vehicleInterface || !pedInterface)
// return 0;
auto replayInterface = *g_pointers->m_replay_interface; auto replayInterface = *g_pointers->m_replay_interface;
auto vehicleInterface = replayInterface->m_vehicle_interface; auto vehicleInterface = replayInterface->m_vehicle_interface;
auto pedInterface = replayInterface->m_ped_interface; auto pedInterface = replayInterface->m_ped_interface;
for (auto veh : vehicleInterface->m_vehicle_list->m_vehicles) for (const auto veh : (*vehicleInterface->m_vehicle_list))
{ {
if (veh.m_entity_ptr) if (veh.m_entity_ptr)
{ {
@ -233,7 +230,7 @@ namespace big::entity
} }
} }
for (auto ped : pedInterface->m_ped_list->m_peds) for (auto ped : *pedInterface->m_ped_list)
{ {
if (ped.m_entity_ptr) if (ped.m_entity_ptr)
{ {

View File

@ -108,15 +108,11 @@ namespace big::vehicle
float min_dist = FLT_MAX; float min_dist = FLT_MAX;
int32_t m_handle = 0; int32_t m_handle = 0;
for (int32_t i = 0; i < veh_interface_size; i++) for (const auto veh_entity : *veh_interface->m_vehicle_list)
{ {
auto veh_entity = veh_interface->m_vehicle_list->m_vehicles[i]; const auto veh_ptr = veh_entity.m_entity_ptr;
auto veh_ptr = veh_entity.m_entity_ptr;
if (!veh_ptr || !veh_ptr->m_navigation) if (!veh_ptr || !veh_ptr->m_navigation)
{
continue; continue;
}
auto veh_pos_arr = *veh_ptr->m_navigation->get_position(); auto veh_pos_arr = *veh_ptr->m_navigation->get_position();
Vector3 veh_pos(veh_pos_arr.x, veh_pos_arr.y, veh_pos_arr.z); Vector3 veh_pos(veh_pos_arr.x, veh_pos_arr.y, veh_pos_arr.z);