From 469850098a453670710387283e1bb1e81404fc8e Mon Sep 17 00:00:00 2001 From: Johann <76482511+Primexz@users.noreply.github.com> Date: Tue, 31 Jan 2023 00:19:05 +0100 Subject: [PATCH] fix(self): fix auto tp to waypoint (#919) --- src/backend/backend.cpp | 1 - src/backend/looped/looped.hpp | 1 - src/backend/looped/system/auto_tp.cpp | 28 ------------------- .../looped/system/auto_tp_to_waypoint.cpp | 24 ++++++++++++++++ src/views/self/view_teleport.cpp | 3 +- 5 files changed, 25 insertions(+), 32 deletions(-) delete mode 100644 src/backend/looped/system/auto_tp.cpp create mode 100644 src/backend/looped/system/auto_tp_to_waypoint.cpp diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp index 073791f9..6b051ea6 100644 --- a/src/backend/backend.cpp +++ b/src/backend/backend.cpp @@ -22,7 +22,6 @@ namespace big looped::system_desync_kick_protection(); looped::system_spoofing(); looped::system_mission_creator(); - looped::system_auto_tp(); for (auto command : g_looped_commands) if (command->is_enabled()) diff --git a/src/backend/looped/looped.hpp b/src/backend/looped/looped.hpp index 117ef0dc..753bebb6 100644 --- a/src/backend/looped/looped.hpp +++ b/src/backend/looped/looped.hpp @@ -41,7 +41,6 @@ namespace big static void system_desync_kick_protection(); static void system_spoofing(); static void system_mission_creator(); - static void system_auto_tp(); static void vehicle_auto_drive(); static void vehicle_boost_behavior(); diff --git a/src/backend/looped/system/auto_tp.cpp b/src/backend/looped/system/auto_tp.cpp deleted file mode 100644 index 11ae711f..00000000 --- a/src/backend/looped/system/auto_tp.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "backend/looped/looped.hpp" -#include "fiber_pool.hpp" -#include "natives.hpp" -#include "script.hpp" -#include "pointers.hpp" - -namespace big -{ - bool bLastAutoTP = false; - void looped::system_auto_tp() - { - bool temp_disable_tp = (!*g_pointers->m_is_session_started) && CUTSCENE::IS_CUTSCENE_ACTIVE(); - - if ((!g.self.auto_tp || temp_disable_tp) && bLastAutoTP) - { - MISC::USING_MISSION_CREATOR(false); - MISC::ALLOW_MISSION_CREATOR_WARP(false); - } - - if (g.self.auto_tp && !temp_disable_tp) - { - MISC::USING_MISSION_CREATOR(true); - MISC::ALLOW_MISSION_CREATOR_WARP(true); - } - - bLastAutoTP = g.self.auto_tp; - } -} \ No newline at end of file diff --git a/src/backend/looped/system/auto_tp_to_waypoint.cpp b/src/backend/looped/system/auto_tp_to_waypoint.cpp new file mode 100644 index 00000000..5923a738 --- /dev/null +++ b/src/backend/looped/system/auto_tp_to_waypoint.cpp @@ -0,0 +1,24 @@ +#include "natives.hpp" +#include "backend/looped_command.hpp" +#include "util/teleport.hpp" + +namespace big +{ + class auto_tp_to_waypoint : looped_command + { + using looped_command::looped_command; + + virtual void on_tick() override + { + //this is a hack to prevent the warning notify.. + if (!teleport::to_blip((int)BlipIcons::Waypoint)) + return; + + bool temp_disable_tp = (!*g_pointers->m_is_session_started) && CUTSCENE::IS_CUTSCENE_ACTIVE(); + if (!temp_disable_tp) + teleport::to_waypoint(); + } + }; + + auto_tp_to_waypoint g_auto_tp_to_waypoint("autotptowp", "Auto-Teleport To Waypoint", "Automatically teleports you to a waypoint as soon as you set one.", g.self.auto_tp); +} diff --git a/src/views/self/view_teleport.cpp b/src/views/self/view_teleport.cpp index 4510f609..dfc8ac6e 100644 --- a/src/views/self/view_teleport.cpp +++ b/src/views/self/view_teleport.cpp @@ -14,8 +14,7 @@ namespace big components::command_button<"waypointtp">({}, "Waypoint"); ImGui::SameLine(); components::command_button<"objectivetp">({}, "Objective"); - - ImGui::Checkbox("Auto-Teleport To Waypoint", &g.self.auto_tp); + components::command_checkbox<"autotptowp">(); ImGui::Text("Vehicles:"); components::command_button<"lastvehtp">();