From 81e43b51d7049a40b49d826d09bdc3828b1c7bb3 Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Sat, 19 Aug 2023 07:02:26 -0400 Subject: [PATCH] Fixes Idle Kick to replace the globals that freemode.c4 uses to determine idle time. (#1979) --- src/backend/looped/tunables/no_idle_kick.cpp | 42 ++++---------------- src/core/scr_globals.hpp | 2 + 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/src/backend/looped/tunables/no_idle_kick.cpp b/src/backend/looped/tunables/no_idle_kick.cpp index 4ebdc436..d57d0776 100644 --- a/src/backend/looped/tunables/no_idle_kick.cpp +++ b/src/backend/looped/tunables/no_idle_kick.cpp @@ -1,5 +1,6 @@ #include "backend/looped_command.hpp" #include "services/tunables/tunables_service.hpp" +#include "core/scr_globals.hpp" namespace big { @@ -7,49 +8,20 @@ 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 { - if (!m_ready_to_use) + for (int i = 0; i < 4; i++) { - 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; - } + *scr_globals::tuneables.at(87).at(i).as() = 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]; - } + *scr_globals::tuneables.at(87).as() = *g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING1")); + *scr_globals::tuneables.at(87).at(1).as() = *g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING2")); + *scr_globals::tuneables.at(87).at(2).as() = *g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING3")); + *scr_globals::tuneables.at(87).at(3).as() = *g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_KICK")); } }; diff --git a/src/core/scr_globals.hpp b/src/core/scr_globals.hpp index f311e05d..a8077741 100644 --- a/src/core/scr_globals.hpp +++ b/src/core/scr_globals.hpp @@ -37,6 +37,8 @@ namespace big::scr_globals static inline const script_global spawn_global(2694613); static inline const script_global offradar_time(2672524); + + static inline const script_global tuneables(262145); } namespace big::scr_locals