From 152642cf1b5a575d6668156bf43306978ba715f1 Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Sun, 16 Jul 2023 12:24:40 -0400 Subject: [PATCH] =?UTF-8?q?Refactored=20Allow=20All=20Weapons=20In=20Vehic?= =?UTF-8?q?le=20to=20force=20all=20vehicles=20to=20use=20=E2=80=A6=20(#173?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactored Allow All Weapons In Vehicle to force all vehicles to use all GROUPs. * Refactored project to not depend on src/gta files that already exist in the GTA-V-Classes project. * feat(cmake): bump GTAV-Classes --- scripts/gtav-classes.cmake | 2 +- src/backend/backend.cpp | 1 + .../commands/player/toxic/turn_into_beast.cpp | 6 +- .../looped/hud/hud_transition_state.cpp | 3 +- src/backend/looped/looped.hpp | 1 + .../looped/session/randomize_ceo_colors.cpp | 2 +- .../looped/vehicle/allow_all_weapons.cpp | 54 ++++++++++ src/core/settings.hpp | 3 +- src/gta/net_object_mgr.hpp | 2 +- src/gta/node_list.hpp | 24 ----- src/gta/script_handler.hpp | 90 +---------------- src/gta/script_id.hpp | 99 ------------------- src/gta/script_program.hpp | 2 +- src/gta/script_thread.hpp | 59 ----------- src/gta/tls_context.hpp | 23 ----- src/gta/weapons.hpp | 1 + src/gta_pointers.hpp | 5 + src/gta_util.hpp | 2 +- src/hooking.cpp | 2 - src/hooking.hpp | 1 - src/hooks/misc/allow_weapons_in_vehicle.cpp | 16 --- src/hooks/protections/receive_net_message.cpp | 2 +- .../protections/received_array_update.cpp | 2 +- src/hooks/protections/received_event.cpp | 2 +- .../protections/script_event_handler.cpp | 4 +- src/hooks/toxic/broadcast_net_array.cpp | 2 +- src/logger/stack_trace.cpp | 2 +- src/native_hooks/freemode.hpp | 2 +- src/pointers.cpp | 11 +++ src/script_function.cpp | 4 +- src/script_mgr.cpp | 2 +- .../creator_storage_service.cpp | 2 +- .../script_connection/script_connection.cpp | 4 +- src/util/scripts.hpp | 4 +- src/views/network/missions/cp_collection.hpp | 2 +- src/views/network/view_network.cpp | 4 +- 36 files changed, 108 insertions(+), 339 deletions(-) create mode 100644 src/backend/looped/vehicle/allow_all_weapons.cpp delete mode 100644 src/gta/node_list.hpp delete mode 100644 src/gta/script_id.hpp delete mode 100644 src/gta/tls_context.hpp delete mode 100644 src/hooks/misc/allow_weapons_in_vehicle.cpp diff --git a/scripts/gtav-classes.cmake b/scripts/gtav-classes.cmake index 713c6dfd..69229f98 100644 --- a/scripts/gtav-classes.cmake +++ b/scripts/gtav-classes.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( gtav_classes GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git - GIT_TAG 95dadd6e7ee7bfa15d66bb2c597d13e97c631727 + GIT_TAG e56523456c42d918bb19814863827a7e6b77ae89 GIT_PROGRESS TRUE CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp index c172217f..02e9efa0 100644 --- a/src/backend/backend.cpp +++ b/src/backend/backend.cpp @@ -89,6 +89,7 @@ namespace big while (g_running) { looped::vehicle_auto_drive(); + looped::vehicle_allow_all_weapons(); looped::vehicle_boost_behavior(); looped::derail_train(); looped::drive_train(); diff --git a/src/backend/commands/player/toxic/turn_into_beast.cpp b/src/backend/commands/player/toxic/turn_into_beast.cpp index 9184617e..aa8a429b 100644 --- a/src/backend/commands/player/toxic/turn_into_beast.cpp +++ b/src/backend/commands/player/toxic/turn_into_beast.cpp @@ -54,7 +54,7 @@ namespace big auto thread = gta_util::find_script_thread(RAGE_JOAAT("am_hunt_the_beast")); auto stack = thread->m_stack; - auto net_component = thread->m_net_component; + auto net_component = (CGameScriptHandlerNetComponent*)thread->m_net_component; auto idx = scr_locals::am_hunt_the_beast::broadcast_idx; if (!stack || !net_component || !player->is_valid()) @@ -112,13 +112,13 @@ namespace big return; auto stack = thread->m_stack; - auto net_component = thread->m_net_component; + auto net_component = (CGameScriptHandlerNetComponent*)thread->m_net_component; auto idx = scr_locals::am_hunt_the_beast::broadcast_idx; if (!stack || !net_component) return; - thread->m_net_component->block_host_migration(true); + ((CGameScriptHandlerNetComponent*)thread->m_net_component)->block_host_migration(true); thread->m_context.m_state = rage::eThreadState::unk_3; g.m_hunt_the_beast_thread = thread; diff --git a/src/backend/looped/hud/hud_transition_state.cpp b/src/backend/looped/hud/hud_transition_state.cpp index 666a757e..994d1d1d 100644 --- a/src/backend/looped/hud/hud_transition_state.cpp +++ b/src/backend/looped/hud/hud_transition_state.cpp @@ -46,7 +46,8 @@ namespace big int num_array_handlers{}; int received_array_handlers{}; - while (auto handler = g_pointers->m_gta.m_get_host_array_handler_by_index(freemode->m_net_component, num_array_handlers++)) + while ( + auto handler = g_pointers->m_gta.m_get_host_array_handler_by_index((CGameScriptHandlerNetComponent*)freemode->m_net_component, num_array_handlers++)) if (handler->m_flags & 1) received_array_handlers++; diff --git a/src/backend/looped/looped.hpp b/src/backend/looped/looped.hpp index 9e0657ee..74a0b098 100644 --- a/src/backend/looped/looped.hpp +++ b/src/backend/looped/looped.hpp @@ -42,6 +42,7 @@ namespace big static void system_rainbow(); static void vehicle_auto_drive(); + static void vehicle_allow_all_weapons(); static void vehicle_boost_behavior(); static void vehicle_ls_customs(); static void vehicle_rainbow_paint(); diff --git a/src/backend/looped/session/randomize_ceo_colors.cpp b/src/backend/looped/session/randomize_ceo_colors.cpp index 445cda90..29db62f3 100644 --- a/src/backend/looped/session/randomize_ceo_colors.cpp +++ b/src/backend/looped/session/randomize_ceo_colors.cpp @@ -12,7 +12,7 @@ namespace big if (g.session.randomize_ceo_colors && *g_pointers->m_gta.m_is_session_started && !STREAMING::IS_PLAYER_SWITCH_IN_PROGRESS() && SCRIPT::GET_NUMBER_OF_THREADS_RUNNING_THE_SCRIPT_WITH_THIS_HASH(RAGE_JOAAT("maintransition")) == 0) { if (auto freemode = gta_util::find_script_thread(RAGE_JOAAT("freemode")); - freemode && freemode->m_net_component && freemode->m_net_component->is_local_player_host()) + freemode && freemode->m_net_component && ((CGameScriptHandlerNetComponent*)freemode->m_net_component)->is_local_player_host()) { for (int i = 0; i < *scr_globals::gsbd.at(818).at(44).as(); i++) { diff --git a/src/backend/looped/vehicle/allow_all_weapons.cpp b/src/backend/looped/vehicle/allow_all_weapons.cpp new file mode 100644 index 00000000..107c9d73 --- /dev/null +++ b/src/backend/looped/vehicle/allow_all_weapons.cpp @@ -0,0 +1,54 @@ +#include "backend/looped/looped.hpp" +#include "util/vehicle.hpp" + +#include +#include +#include + +#include "gta/weapons.hpp" + +namespace big +{ + void looped::vehicle_allow_all_weapons() + { + CVehicle* vehicle_ptr = (CVehicle*)g_pointers->m_gta.m_handle_to_ptr(self::veh); + + if (vehicle_ptr == nullptr) + return; + + rage::atArray one_handed_groups = + g_pointers->m_gta.m_driveby_metadata_mgr->m_drive_by_weapon_groups->m_drive_by_default->m_driveby_default_one_handed_weapon_group_names; + + if (g.vehicle.unlimited_weapons == false) + { + if (one_handed_groups.size() != 1) + { + rage::atArray one_handed_groups; + one_handed_groups.append(GROUP_PISTOL); + g_pointers->m_gta.m_driveby_metadata_mgr->m_drive_by_weapon_groups->m_drive_by_default->m_driveby_default_one_handed_weapon_group_names = one_handed_groups; + } + return; + } + + CVehicleModelInfo* vehicle_model_info = static_cast(vehicle_ptr->m_model_info); + + auto num_seats = vehicle_model_info->m_vehicle_layout->m_max_seats; + auto seat_info = vehicle_model_info->m_vehicle_layout->m_layout_metadata->m_seat_info; + auto defaults = g_pointers->m_gta.m_vehicle_layout_metadata_mgr->m_drive_by_seat_defaults; + if (seat_info->m_front_left->m_drive_by_info != defaults->m_driveby_standard_front_left) + seat_info->m_front_left->m_drive_by_info = defaults->m_driveby_standard_front_left; + if (num_seats > 1 && seat_info->m_front_right->m_drive_by_info != defaults->m_driveby_standard_front_right) + seat_info->m_front_right->m_drive_by_info = defaults->m_driveby_standard_front_right; + if (num_seats > 2 && seat_info->m_rear_left->m_drive_by_info != defaults->m_driveby_standard_rear_left) + seat_info->m_rear_left->m_drive_by_info = defaults->m_driveby_standard_rear_left; + if (num_seats > 3 && seat_info->m_rear_right->m_drive_by_info != defaults->m_driveby_standard_rear_right) + seat_info->m_rear_right->m_drive_by_info = defaults->m_driveby_standard_rear_right; + + if (g_pointers->m_gta.m_driveby_metadata_mgr->m_drive_by_weapon_groups->m_drive_by_default + ->m_driveby_default_one_handed_weapon_group_names.size() == 1) + { + one_handed_groups.append({GROUP_MG, GROUP_RIFLE, GROUP_SHOTGUN, GROUP_HEAVY, GROUP_SNIPER, GROUP_SMG}); + g_pointers->m_gta.m_driveby_metadata_mgr->m_drive_by_weapon_groups->m_drive_by_default->m_driveby_default_one_handed_weapon_group_names = one_handed_groups; + } + } +} \ No newline at end of file diff --git a/src/core/settings.hpp b/src/core/settings.hpp index 9248c925..c6d04b88 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -683,13 +683,12 @@ namespace big bool keep_vehicle_clean = false; bool vehinvisibility = false; bool localveh_visibility = false; - bool localped_visibility = true; bool keep_on_ground = false; bool no_collision = false; bool unlimited_weapons = false; bool siren_mute = false; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(vehicle, speedo_meter, fly, rainbow_paint, speed_unit, god_mode, proof_bullet, proof_fire, proof_collision, proof_melee, proof_explosion, proof_steam, proof_water, proof_mask, auto_drive_destination, auto_drive_style, auto_drive_speed, auto_turn_signals, boost_behavior, drive_on_water, horn_boost, instant_brake, block_homing, seatbelt, turn_signals, vehicle_jump, keep_vehicle_repaired, no_water_collision, disable_engine_auto_start, change_engine_state_immediately, keep_engine_running, keep_vehicle_clean, vehinvisibility, localveh_visibility, localped_visibility, keep_on_ground, no_collision, unlimited_weapons, siren_mute) + NLOHMANN_DEFINE_TYPE_INTRUSIVE(vehicle, speedo_meter, fly, rainbow_paint, speed_unit, god_mode, proof_bullet, proof_fire, proof_collision, proof_melee, proof_explosion, proof_steam, proof_water, proof_mask, auto_drive_destination, auto_drive_style, auto_drive_speed, auto_turn_signals, boost_behavior, drive_on_water, horn_boost, instant_brake, block_homing, seatbelt, turn_signals, vehicle_jump, keep_vehicle_repaired, no_water_collision, disable_engine_auto_start, change_engine_state_immediately, keep_engine_running, keep_vehicle_clean, vehinvisibility, localveh_visibility, keep_on_ground, no_collision, unlimited_weapons, siren_mute) } vehicle{}; struct weapons diff --git a/src/gta/net_object_mgr.hpp b/src/gta/net_object_mgr.hpp index 056ad82e..ec822fa0 100644 --- a/src/gta/net_object_mgr.hpp +++ b/src/gta/net_object_mgr.hpp @@ -1,7 +1,7 @@ #pragma once #include "../pointers.hpp" #include "enums.hpp" -#include "node_list.hpp" +#include "script/dataList.hpp" class CNetGamePlayer; diff --git a/src/gta/node_list.hpp b/src/gta/node_list.hpp deleted file mode 100644 index 352a6dcd..00000000 --- a/src/gta/node_list.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "fwddec.hpp" - -#include - -namespace rage -{ - template - class atDNode : public Base - { - public: - T m_data; - void* m_unk; - atDNode* m_next; - }; - - template - class atDList - { - public: - Node* m_head; - Node* m_tail; - }; -} diff --git a/src/gta/script_handler.hpp b/src/gta/script_handler.hpp index 59759ac4..59802369 100644 --- a/src/gta/script_handler.hpp +++ b/src/gta/script_handler.hpp @@ -1,19 +1,16 @@ #pragma once #include "fwddec.hpp" -#include "node_list.hpp" -#include "script_id.hpp" +#include "script/dataList.hpp" +#include "script/scriptIdBase.hpp" +#include "script/scriptResource.hpp" +#include "script/scriptHandler.hpp" +#include "script/scriptHandlerNetComponent.hpp" #include #pragma pack(push, 1) namespace rage { - class scriptResource - { - public: - virtual ~scriptResource() = default; - }; - class scriptResourceEntry { public: @@ -23,83 +20,6 @@ namespace rage scriptResourceEntry* m_next;// 0x18 }; - class scriptHandlerNetComponent - { - public: - virtual ~scriptHandlerNetComponent() = default; - - public: - scriptHandler* m_script_handler;// 0x08 - }; - - class scriptHandler - { - public: - class atDScriptObjectNode : public atDNode - { - }; - - public: - virtual ~scriptHandler() = default;// 0 (0x00) - - virtual bool _0x08() = 0;// 1 (0x08) - - virtual void _0x10() = 0;// 2 (0x10) - - virtual void cleanup_objects() = 0;// 3 (0x18) - - virtual scriptId* _0x20() = 0;// 4 (0x20) - - virtual scriptId* get_id() = 0;// 5 (0x28) - - // Returns whether the script handler belongs to a networked script. - virtual bool is_networked() = 0;// 6 (0x30) - - // Initializes the network component for the script handler. - virtual void init_net_component() = 0;// 7 (0x38) - - // Deletes the script handler's network component, if it exists. - virtual void reset_net_component() = 0;// 8 (0x40) - - // Destroys the script handler. - virtual bool destroy() = 0;// 9 (0x48) - - // Adds the object to the script handler's list of objects. - virtual void add_object(scriptHandlerObject*, bool is_network, bool is_network_and_scriptcheck) = 0;// 10 (0x50) - - // Something related to reservations. - virtual void _0x58(void*) = 0;// 11 (0x58) - - virtual void register_resource(scriptResource*, void*) = 0;// 12 (0x60) - - virtual void _0x68() = 0;// 13 (0x68) - - virtual void _0x70() = 0;// 14 (0x70) - - virtual void _0x78() = 0;// 15 (0x78) - - virtual void _0x80() = 0;// 16 (0x80) - - virtual void _0x88() = 0;// 17 (0x88) - - virtual void _0x90() = 0;// 18 (0x90) - - virtual void _0x98() = 0;// 19 (0x98) - public: - void* m_0x08; // 0x08 - void* m_0x10; // 0x10 - scrThread* m_script_thread; // 0x18 - atDList m_objects; // 0x20 - 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 - std::uint32_t m_0x60; // 0x5C - }; - class scriptHandlerMgr { public: diff --git a/src/gta/script_id.hpp b/src/gta/script_id.hpp deleted file mode 100644 index 7383b847..00000000 --- a/src/gta/script_id.hpp +++ /dev/null @@ -1,99 +0,0 @@ -#pragma once -#include "fwddec.hpp" -#include "joaat.hpp" - -#include - -#pragma pack(push, 1) -namespace rage -{ - class scriptIdBase - { - public: - virtual ~scriptIdBase() = default;// 0 (0x00) - - // Assumes the script thread's identity. - virtual void assume_thread_identity(scrThread*){};// 1 (0x08) - - // Returns whether the hash of the script id is valid. - virtual bool is_valid() - { - return false; - };// 2 (0x10) - - // Gets the hash of the script id. - virtual joaat_t* get_hash(joaat_t* out) - { - return 0; - };// 3 (0x18) - - // Gets an unknown value from the script id. - virtual std::uint32_t* get_hash2(std::uint32_t* out) - { - return 0; - };// 4 (0x20) - - // Gets the name of the script id. - virtual const char* get_name() - { - return nullptr; - };// 5 (0x28) - - // Serializes the script id from the buffer. - virtual void deserialize(datBitBuffer* buffer){};// 6 (0x30) - - // Serializes the script id to the buffer. - virtual void serialize(datBitBuffer* buffer){};// 7 (0x38) - - // Calculates some information with the position hash & instance id. - virtual std::uint32_t _0x40() - { - return 0; - };// 8 (0x40) - - // Calls _0x40 and returns it's value added to another value. - virtual std::uint32_t _0x48() - { - return 0; - };// 9 (0x48) - - // Logs some information about the script id. - virtual void log_information(netLoggingInterface* logger){};// 10 (0x50) - - // Copies the information of other to this object. - virtual void copy_data(scriptIdBase* other) - { - }// 11 (0x58) - - // Returns whether the other script id is equal. - virtual bool operator==(scriptIdBase*) - { - return false; - };// 12 (0x60) - - virtual bool _0x68(void*) - { - return false; - };// 13 (0x68) - }; - - class scriptId : public scriptIdBase - { - public: - joaat_t m_hash; // 0x08 - char m_name[0x20];// 0x0C - }; -} - -class CGameScriptId : public rage::scriptId -{ -public: - char m_padding[0x04]; // 0x2C - std::int32_t m_timestamp; // 0x30 - std::int32_t m_position_hash;// 0x34 - std::int32_t m_instance_id; // 0x38 - std::int32_t m_unk; // 0x3C -}; - -static_assert(sizeof(CGameScriptId) == 0x40); -#pragma pack(pop) diff --git a/src/gta/script_program.hpp b/src/gta/script_program.hpp index d8981ddf..1c82059a 100644 --- a/src/gta/script_program.hpp +++ b/src/gta/script_program.hpp @@ -2,7 +2,7 @@ #include "base.hpp" #include "fwddec.hpp" #include "joaat.hpp" -#include "script_id.hpp" +#include "script/scriptIdBase.hpp" #include diff --git a/src/gta/script_thread.hpp b/src/gta/script_thread.hpp index 42a5e9f8..ef9275e2 100644 --- a/src/gta/script_thread.hpp +++ b/src/gta/script_thread.hpp @@ -1,70 +1,11 @@ #pragma once #include "fwddec.hpp" #include "joaat.hpp" -#include "tls_context.hpp" #include class CGameScriptHandlerNetComponent; -namespace rage -{ - enum class eThreadState : std::uint32_t - { - idle, - running, - killed, - unk_3, - unk_4, - }; - - class scrThreadContext - { - public: - std::uint32_t m_thread_id; // 0x00 - joaat_t m_script_hash; // 0x04 - eThreadState m_state; // 0x08 - std::uint32_t m_instruction_pointer;// 0x0C - std::uint32_t m_frame_pointer; // 0x10 - std::uint32_t m_stack_pointer; // 0x14 - float m_timer_a; // 0x18 - float m_timer_b; // 0x1C - float m_timer_c; // 0x20 - char m_padding1[0x2C]; // 0x24 - std::uint32_t m_stack_size; // 0x50 - char m_padding2[0x54]; // 0x54 - }; - static_assert(sizeof(scrThreadContext) == 0xA8); - - class scrThread - { - public: - virtual ~scrThread() = default;// 0 (0x00) - virtual void reset(std::uint32_t script_hash, void* args, std::uint32_t arg_count) = 0; // 1 (0x08) - virtual eThreadState run() = 0; // 2 (0x10) - virtual eThreadState tick(std::uint32_t ops_to_execute) = 0; // 3 (0x18) - virtual void kill() = 0; // 4 (0x20) - - inline static scrThread* get() - { - 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 - CGameScriptHandlerNetComponent* m_net_component;// 0x11C - }; -} - class GtaThread : public rage::scrThread { public: diff --git a/src/gta/tls_context.hpp b/src/gta/tls_context.hpp deleted file mode 100644 index e2ae9218..00000000 --- a/src/gta/tls_context.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "fwddec.hpp" - -#include - -namespace rage -{ - class tlsContext - { - public: - char m_padding1[0xB8]; // 0x00 - sysMemAllocator* m_allocator; // 0xB8 - char m_padding2[0x788]; // 0xD0 - scrThread* m_script_thread; // 0x848 - bool m_is_script_thread_active;// 0x850 - - static tlsContext* get() - { - return *reinterpret_cast(__readgsqword(0x58)); - } - }; - static_assert(sizeof(tlsContext) == 0x858); -} diff --git a/src/gta/weapons.hpp b/src/gta/weapons.hpp index 7c5cffe7..25d7d2e1 100644 --- a/src/gta/weapons.hpp +++ b/src/gta/weapons.hpp @@ -21,6 +21,7 @@ enum WeaponGroup : Hash GROUP_PISTOL = RAGE_JOAAT("GROUP_PISTOL"), GROUP_RIFLE = RAGE_JOAAT("GROUP_RIFLE"), GROUP_MG = RAGE_JOAAT("GROUP_MG"), + GROUP_SMG = RAGE_JOAAT("GROUP_SMG"), GROUP_SHOTGUN = RAGE_JOAAT("GROUP_SHOTGUN"), GROUP_STUNGUN = RAGE_JOAAT("GROUP_STUNGUN"), GROUP_SNIPER = RAGE_JOAAT("GROUP_SNIPER"), diff --git a/src/gta_pointers.hpp b/src/gta_pointers.hpp index 83fda0d4..8b5086e2 100644 --- a/src/gta_pointers.hpp +++ b/src/gta_pointers.hpp @@ -9,6 +9,8 @@ class ChatData; class ScInfo; class GenericPool; class VehiclePool; +class CVehicleSeatMetadataMgr; +class CVehicleDriveByMetadataMgr; namespace rage { @@ -274,6 +276,9 @@ namespace big PVOID m_send_non_physical_player_data; void** m_presence_data{}; + + CVehicleSeatMetadataMgr* m_vehicle_layout_metadata_mgr{}; + CVehicleDriveByMetadataMgr* m_driveby_metadata_mgr{}; }; #pragma pack(pop) static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned"); diff --git a/src/gta_util.hpp b/src/gta_util.hpp index 715a91b8..29ae4b68 100644 --- a/src/gta_util.hpp +++ b/src/gta_util.hpp @@ -1,6 +1,6 @@ #pragma once #include "gta/script_thread.hpp" -#include "gta/tls_context.hpp" +#include "script/tlsContext.hpp" #include "pointers.hpp" #include diff --git a/src/hooking.cpp b/src/hooking.cpp index efc0bad2..7c2eed1f 100644 --- a/src/hooking.cpp +++ b/src/hooking.cpp @@ -108,8 +108,6 @@ namespace big detour_hook_helper::add("WVPMDN", g_pointers->m_gta.m_write_vehicle_proximity_migration_data_node); - detour_hook_helper::add("AWIV", g_pointers->m_gta.m_allow_weapons_in_vehicle); - detour_hook_helper::add("NHM", g_pointers->m_gta.m_netfilter_handle_message); detour_hook_helper::add("E0MBH", g_pointers->m_gta.m_error_message_box); diff --git a/src/hooking.hpp b/src/hooking.hpp index 48efa4dc..202e1910 100644 --- a/src/hooking.hpp +++ b/src/hooking.hpp @@ -148,7 +148,6 @@ namespace big static void write_vehicle_proximity_migration_data_node(rage::netObject* veh, CVehicleProximityMigrationDataNode* node); - static bool allow_weapons_in_vehicle(int64_t unk, int weaponinfo_group); static int netfilter_handle_message(__int64 filter, char* message, int flags); static void log_error_message_box(rage::joaat_t joaated_error_code, char a2); diff --git a/src/hooks/misc/allow_weapons_in_vehicle.cpp b/src/hooks/misc/allow_weapons_in_vehicle.cpp deleted file mode 100644 index e7811778..00000000 --- a/src/hooks/misc/allow_weapons_in_vehicle.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "hooking.hpp" -#include "gta/weapons.hpp" - -namespace big -{ - bool hooks::allow_weapons_in_vehicle(int64_t unk, int weaponinfo_group) - { - if (g.vehicle.unlimited_weapons) - { - if (weaponinfo_group == GROUP_THROWN) // Because the thrower can be used without bypassing, we let the game decide the return value, since this function has multiple xrefs, it may be necessary to return 0 at some point - return g_hooking->get_original()(unk, weaponinfo_group); - return true; - } - return g_hooking->get_original()(unk, weaponinfo_group); - } -} \ No newline at end of file diff --git a/src/hooks/protections/receive_net_message.cpp b/src/hooks/protections/receive_net_message.cpp index ee6c4741..535e8517 100644 --- a/src/hooks/protections/receive_net_message.cpp +++ b/src/hooks/protections/receive_net_message.cpp @@ -3,7 +3,7 @@ #include "backend/player_command.hpp" #include "core/data/packet_types.hpp" #include "gta/net_game_event.hpp" -#include "gta/script_id.hpp" +#include "script/scriptIdBase.hpp" #include "gta_util.hpp" #include "hooking.hpp" #include "lua/lua_manager.hpp" diff --git a/src/hooks/protections/received_array_update.cpp b/src/hooks/protections/received_array_update.cpp index 86d6a91f..8d2c53d8 100644 --- a/src/hooks/protections/received_array_update.cpp +++ b/src/hooks/protections/received_array_update.cpp @@ -22,7 +22,7 @@ namespace big { old_beast_index = *script_local(beast->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(6).as(); if (beast->m_net_component) - participant_id = beast->m_net_component->m_local_participant_index; + participant_id = ((CGameScriptHandlerNetComponent*)beast->m_net_component)->m_local_participant_index; } bool result = g_hooking->get_original()(array, sender, buffer, size, cycle); diff --git a/src/hooks/protections/received_event.cpp b/src/hooks/protections/received_event.cpp index 7fb1337a..320ad67f 100644 --- a/src/hooks/protections/received_event.cpp +++ b/src/hooks/protections/received_event.cpp @@ -1,7 +1,7 @@ #include "fiber_pool.hpp" #include "gta/enums.hpp" #include "gta/net_game_event.hpp" -#include "gta/script_id.hpp" +#include "script/scriptIdBase.hpp" #include "hooking.hpp" #include "util/math.hpp" #include "util/notify.hpp" diff --git a/src/hooks/protections/script_event_handler.cpp b/src/hooks/protections/script_event_handler.cpp index 2b2c71f3..15579c6b 100644 --- a/src/hooks/protections/script_event_handler.cpp +++ b/src/hooks/protections/script_event_handler.cpp @@ -383,7 +383,7 @@ namespace big { if (auto script = gta_util::find_script_thread(RAGE_JOAAT("freemode"))) { - if (script->m_net_component && script->m_net_component->m_host && script->m_net_component->m_host->m_net_game_player != player) + if (script->m_net_component && ((CGameScriptHandlerNetComponent*)script->m_net_component)->m_host && ((CGameScriptHandlerNetComponent*)script->m_net_component)->m_host->m_net_game_player != player) { g.reactions.trigger_business_raid.process(plyr); } @@ -396,7 +396,7 @@ namespace big // TODO: Breaks stuff if (auto script = gta_util::find_script_thread(RAGE_JOAAT("freemode"))) { - if (script->m_net_component && script->m_net_component->m_host && script->m_net_component->m_host->m_net_game_player != player) + if (script->m_net_component && ((CGameScriptHandlerNetComponent*)script->m_net_component)->m_host && ((CGameScriptHandlerNetComponent*)script->m_net_component)->m_host->m_net_game_player != player) { g.reactions.start_script.process(plyr); return true; diff --git a/src/hooks/toxic/broadcast_net_array.cpp b/src/hooks/toxic/broadcast_net_array.cpp index b18bf5ab..926368d6 100644 --- a/src/hooks/toxic/broadcast_net_array.cpp +++ b/src/hooks/toxic/broadcast_net_array.cpp @@ -58,7 +58,7 @@ namespace big .as(); *script_local(g.m_hunt_the_beast_thread->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(6).as() = - g.m_hunt_the_beast_thread->m_net_component->get_participant_index(target);// participant idx + ((CGameScriptHandlerNetComponent*)g.m_hunt_the_beast_thread->m_net_component)->get_participant_index(target);// participant idx *script_local(g.m_hunt_the_beast_thread->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(7).as() = target->m_player_id;// beast player idx *script_local(g.m_hunt_the_beast_thread->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(2).as() = INT_MAX;// stopwatch time diff --git a/src/logger/stack_trace.cpp b/src/logger/stack_trace.cpp index e36f4a15..ad6ac286 100644 --- a/src/logger/stack_trace.cpp +++ b/src/logger/stack_trace.cpp @@ -150,7 +150,7 @@ namespace big void stack_trace::dump_script_info() { - m_dump << "Currently executing script: " << rage::scrThread::get()->m_name << '\n'; + m_dump << "Currently executing script: " << rage::tlsContext::get()->m_script_thread->m_name << '\n'; m_dump << "Thread program counter (could be inaccurate): " << m_exception_info->ContextRecord->Rdi - m_exception_info->ContextRecord->Rsi << '\n'; } diff --git a/src/native_hooks/freemode.hpp b/src/native_hooks/freemode.hpp index 098989f8..2dabeacc 100644 --- a/src/native_hooks/freemode.hpp +++ b/src/native_hooks/freemode.hpp @@ -77,7 +77,7 @@ namespace big g_fiber_pool->queue_job([hash] { scripts::force_host(hash); if (auto script = gta_util::find_script_thread(hash); script && script->m_net_component) - script->m_net_component->block_host_migration(true); + ((CGameScriptHandlerNetComponent*)script->m_net_component)->block_host_migration(true); }); } diff --git a/src/pointers.cpp b/src/pointers.cpp index 52e9f962..a438734f 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -1371,6 +1371,17 @@ namespace big { g_pointers->m_gta.m_get_title_caption_error_message_box = ptr.add(1).rip().as(); } + }, + // Vehicle Metadata Manager. + { + "VEHMMGR", + "7C B8 48 8B 0D", + [](memory::handle ptr) + { + ptr = ptr.add(5).rip(); + g_pointers->m_gta.m_driveby_metadata_mgr = ptr.as(); + g_pointers->m_gta.m_vehicle_layout_metadata_mgr = ptr.add(0x20).as(); + } } >(); // don't leave a trailing comma at the end diff --git a/src/script_function.cpp b/src/script_function.cpp index 68b88e1c..7c68629f 100644 --- a/src/script_function.cpp +++ b/src/script_function.cpp @@ -106,10 +106,10 @@ namespace big populate_ip(); rage::scrThread* thread = (rage::scrThread*)new uint8_t[sizeof(rage::scrThread)]; - memcpy(thread, rage::scrThread::get(), sizeof(rage::scrThread)); + memcpy(thread, rage::tlsContext::get()->m_script_thread, sizeof(rage::scrThread)); void* stack = new uint64_t[25000]; - thread->m_stack = stack; + thread->m_stack = (rage::scrValue*)stack; thread->m_context.m_stack_size = 25000; thread->m_context.m_stack_pointer = 1; diff --git a/src/script_mgr.cpp b/src/script_mgr.cpp index 8d082c09..57dae5d9 100644 --- a/src/script_mgr.cpp +++ b/src/script_mgr.cpp @@ -2,7 +2,7 @@ #include "common.hpp" #include "gta/script_thread.hpp" -#include "gta/tls_context.hpp" +#include "script/tlsContext.hpp" #include "gta_util.hpp" #include "invoker.hpp" #include "pointers.hpp" diff --git a/src/services/creator_storage/creator_storage_service.cpp b/src/services/creator_storage/creator_storage_service.cpp index 8e73d728..57c3ebc5 100644 --- a/src/services/creator_storage/creator_storage_service.cpp +++ b/src/services/creator_storage/creator_storage_service.cpp @@ -2,7 +2,7 @@ #include "gta/joaat.hpp" #include "gta/sysMemAllocator.hpp" -#include "gta/tls_context.hpp" +#include "script/tlsContext.hpp" #include "natives.hpp" #include "pointers.hpp" #include "script.hpp" diff --git a/src/services/script_connection/script_connection.cpp b/src/services/script_connection/script_connection.cpp index ab431b38..45654b42 100644 --- a/src/services/script_connection/script_connection.cpp +++ b/src/services/script_connection/script_connection.cpp @@ -167,7 +167,7 @@ namespace big { if (m_thread && m_thread->m_net_component) { - for (int i = 0; !m_thread->m_net_component->is_local_player_host(); i++) + for (int i = 0; !((CGameScriptHandlerNetComponent*)m_thread->m_net_component)->is_local_player_host(); i++) { if (i > 200) return false; @@ -180,7 +180,7 @@ namespace big return false; } - m_thread->m_net_component->block_host_migration(true); + ((CGameScriptHandlerNetComponent*)m_thread->m_net_component)->block_host_migration(true); } return true; diff --git a/src/util/scripts.hpp b/src/util/scripts.hpp index 670fd0d1..7e79135f 100644 --- a/src/util/scripts.hpp +++ b/src/util/scripts.hpp @@ -62,7 +62,7 @@ namespace big::scripts { if (auto launcher = gta_util::find_script_thread(hash); launcher && launcher->m_net_component) { - for (int i = 0; !launcher->m_net_component->is_local_player_host(); i++) + for (int i = 0; !((CGameScriptHandlerNetComponent*)launcher->m_net_component)->is_local_player_host(); i++) { if (i > 200) return false; @@ -100,7 +100,7 @@ namespace big::scripts for (auto& [_, plyr] : g_player_service->players()) { - if (launcher->m_net_component->is_player_a_participant(plyr->get_net_game_player())) + if (((CGameScriptHandlerNetComponent*)launcher->m_net_component)->is_player_a_participant(plyr->get_net_game_player())) { if (*script_local(launcher->m_stack, 233).at(plyr->id(), 3).at(2).as() == state) { diff --git a/src/views/network/missions/cp_collection.hpp b/src/views/network/missions/cp_collection.hpp index 78f925f7..9d94b01e 100644 --- a/src/views/network/missions/cp_collection.hpp +++ b/src/views/network/missions/cp_collection.hpp @@ -24,7 +24,7 @@ namespace big components::button("Win Event", [] { if (auto checkpoints = gta_util::find_script_thread(RAGE_JOAAT("am_cp_collection"))) *script_local(checkpoints->m_stack, scr_locals::am_cp_collection::player_broadcast_idx) - .at(checkpoints->m_net_component->m_local_participant_index, 5) + .at(((CGameScriptHandlerNetComponent*)checkpoints->m_net_component)->m_local_participant_index, 5) .at(4) .as() = 999'999'999; diff --git a/src/views/network/view_network.cpp b/src/views/network/view_network.cpp index 569e1c90..5111eb0e 100644 --- a/src/views/network/view_network.cpp +++ b/src/views/network/view_network.cpp @@ -290,11 +290,11 @@ namespace big g_fiber_pool->queue_job([] { scripts::force_host(RAGE_JOAAT("freemode")); if (auto script = gta_util::find_script_thread(RAGE_JOAAT("freemode")); script && script->m_net_component) - script->m_net_component->block_host_migration(true); + ((CGameScriptHandlerNetComponent*)script->m_net_component)->block_host_migration(true); scripts::force_host(RAGE_JOAAT("fmmc_launcher")); if (auto script = gta_util::find_script_thread(RAGE_JOAAT("fmmc_launcher")); script && script->m_net_component) - script->m_net_component->block_host_migration(true); + ((CGameScriptHandlerNetComponent*)script->m_net_component)->block_host_migration(true); }); } if (ImGui::IsItemHovered())