From 3e65e02eda4a63c62fce896dbf515358f9d2c47b Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Sat, 16 Sep 2023 11:49:18 -0400 Subject: [PATCH] Various fixes (#2135) --- src/backend/looped/self/toggle_passive.cpp | 9 ++-- src/backend/looped/tunables/no_idle_kick.cpp | 45 ++++++++++++++++++-- src/core/scr_globals.hpp | 6 +-- src/views/vehicle/spawn/view_pv.cpp | 30 +++++++++++++ 4 files changed, 78 insertions(+), 12 deletions(-) diff --git a/src/backend/looped/self/toggle_passive.cpp b/src/backend/looped/self/toggle_passive.cpp index e85b1adf..c2532906 100644 --- a/src/backend/looped/self/toggle_passive.cpp +++ b/src/backend/looped/self/toggle_passive.cpp @@ -4,6 +4,7 @@ #include "script_global.hpp" #include "script/globals/GPBD_FM_3.hpp" #include "gta_util.hpp" +#include "services/tunables/tunables_service.hpp" namespace big { @@ -21,15 +22,15 @@ namespace big g_notification_service->push_warning("Disabled passive mode", "Disabled passive mode because you started mission / joined CEO/MC"); return; } - *scr_globals::tuneables.at(27371).as() = 0; // End Passive Time = 0s - *script_global(1574582).as() = true; + *g_tunables_service->get_tunable(-29732167) = 0; // End Passive Time = 0s + *scr_globals::passive.as() = TRUE; } virtual void on_disable() override { - *script_global(1574582).as() = false; + *scr_globals::passive.as() = FALSE; NETWORK::SET_LOCAL_PLAYER_AS_GHOST(false, false); - *scr_globals::tuneables.at(27371).as() = 30000; + *g_tunables_service->get_tunable(-29732167) = 30000; PED::SET_PED_CONFIG_FLAG(self::ped, 342, false); // Disable NotAllowedToJackAnyPlayers PED::SET_PED_CONFIG_FLAG(self::ped, 122, false); // Disable DisableMelee PLAYER::SET_PLAYER_VEHICLE_DEFENSE_MODIFIER(self::ped, 1.f); diff --git a/src/backend/looped/tunables/no_idle_kick.cpp b/src/backend/looped/tunables/no_idle_kick.cpp index 7e19ae96..99534bf2 100644 --- a/src/backend/looped/tunables/no_idle_kick.cpp +++ b/src/backend/looped/tunables/no_idle_kick.cpp @@ -9,12 +9,49 @@ namespace big { using looped_command::looped_command; + std::array m_tunables = {nullptr}; + std::array m_restore; + bool m_ready_to_use; + virtual void on_tick() override { - *scr_globals::session_info.at(1155).as() = -1; - *scr_globals::session_info.at(1171).as() = -1; - CAM::INVALIDATE_IDLE_CAM(); - CAM::INVALIDATE_CINEMATIC_VEHICLE_IDLE_MODE(); + if (!m_ready_to_use) + { + m_tunables[0] = g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING1")); + m_tunables[1] = g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING2")); + m_tunables[2] = g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING3")); + m_tunables[3] = g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_KICK")); + m_tunables[4] = g_tunables_service->get_tunable(RAGE_JOAAT("ConstrainedKick_Warning1")); + m_tunables[5] = g_tunables_service->get_tunable(RAGE_JOAAT("ConstrainedKick_Warning2")); + m_tunables[6] = g_tunables_service->get_tunable(RAGE_JOAAT("ConstrainedKick_Warning3")); + m_tunables[7] = g_tunables_service->get_tunable(RAGE_JOAAT("ConstrainedKick_Kick")); + + // create backup of tunables + m_ready_to_use = true; + for (int i = 0; i < m_restore.size(); ++i) + { + if (m_ready_to_use = m_tunables[i]; !m_ready_to_use) + break; + m_restore[i] = *m_tunables[i]; + } + } + else + { + for (const auto& tunable : m_tunables) + { + if (tunable) + *tunable = INT_MAX; + } + } + } + + virtual void on_disable() override + { + for (int i = 0; m_ready_to_use && i < m_restore.size(); ++i) + { + if (m_tunables[i]) + *m_tunables[i] = m_restore[i]; + } } }; diff --git a/src/core/scr_globals.hpp b/src/core/scr_globals.hpp index ee1c9579..ba8bcf37 100644 --- a/src/core/scr_globals.hpp +++ b/src/core/scr_globals.hpp @@ -39,10 +39,6 @@ namespace big::scr_globals static inline const script_global spawn_global(2694613); - static inline const script_global session_info(1654054); - - static inline const script_global tuneables(262145); - static inline const script_global dance_state(1950837); static inline const script_global mobile(20483); @@ -59,6 +55,8 @@ namespace big::scr_globals static inline const script_global session6(2694534); static inline const script_global gooch(1890378); + + static inline const script_global passive(1574582); } namespace big::scr_locals diff --git a/src/views/vehicle/spawn/view_pv.cpp b/src/views/vehicle/spawn/view_pv.cpp index 251ec148..76274fef 100644 --- a/src/views/vehicle/spawn/view_pv.cpp +++ b/src/views/vehicle/spawn/view_pv.cpp @@ -8,6 +8,32 @@ namespace big { + bool is_blacklist_vehicle(Hash vehicle_hash) + { + switch (vehicle_hash) + { + case RAGE_JOAAT("avenger"): + case RAGE_JOAAT("avenger3"): + case RAGE_JOAAT("hauler2"): + case RAGE_JOAAT("phantom3"): + case RAGE_JOAAT("trailersmall2"): + case RAGE_JOAAT("khanjali"): + case RAGE_JOAAT("chernobog"): + case RAGE_JOAAT("riot2"): + case RAGE_JOAAT("thruster"): + case RAGE_JOAAT("brickade2"): + case RAGE_JOAAT("manchez3"): + case RAGE_JOAAT("terbyte"): + case RAGE_JOAAT("speedo4"): + case RAGE_JOAAT("mule4"): + case RAGE_JOAAT("pounder2"): + case RAGE_JOAAT("rcbandito"): + case RAGE_JOAAT("minitank"): + return true; + } + return false; + } + void view::pv() { ImGui::SetWindowSize({0.f, (float)*g_pointers->m_gta.m_resolution_y}, ImGuiCond_Always); @@ -112,6 +138,10 @@ namespace big if ((selected_class == -1 || class_arr[selected_class] == vehicle_class) && (display_name.find(lower_search) != std::string::npos || display_manufacturer.find(lower_search) != std::string::npos)) { + if (!g.clone_pv.spawn_clone && is_blacklist_vehicle(personal_veh->get_hash())) + { + continue; + } indexes_to_use.insert(personal_veh->get_id()); } }