From c259ff55d90543457bfd790aa0201f128ca21cd9 Mon Sep 17 00:00:00 2001 From: howdoiusekeyboard <90883505+howdoiusekeyboard@users.noreply.github.com> Date: Sun, 17 Jul 2022 02:07:26 +0530 Subject: [PATCH] Improve and optimise session local_time (#345) Local time has a transition to revert back to global session time when used in online. Full credits to @tupoy-ya --- .../src/backend/looped/session/local_time.cpp | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/BigBaseV2/src/backend/looped/session/local_time.cpp b/BigBaseV2/src/backend/looped/session/local_time.cpp index fdc07650..2427c23d 100644 --- a/BigBaseV2/src/backend/looped/session/local_time.cpp +++ b/BigBaseV2/src/backend/looped/session/local_time.cpp @@ -3,22 +3,24 @@ namespace big { - static bool lastOverride = true; + static bool toggled = true; void looped::session_local_time() { - if (lastOverride && !g->session.override_time) - { - NETWORK::NETWORK_GET_GLOBAL_MULTIPLAYER_CLOCK(&g->session.custom_time.hour, &g->session.custom_time.minute, &g->session.custom_time.second); - NETWORK::NETWORK_OVERRIDE_CLOCK_TIME(g->session.custom_time.hour, g->session.custom_time.minute, g->session.custom_time.second); - NETWORK::NETWORK_CLEAR_CLOCK_TIME_OVERRIDE(); - lastOverride = false; - } - if (g->session.override_time) { + if (toggled) + { + NETWORK::NETWORK_GET_GLOBAL_MULTIPLAYER_CLOCK(&g->session.custom_time.hour, &g->session.custom_time.minute, &g->session.custom_time.second); + toggled = false; + } + NETWORK::NETWORK_OVERRIDE_CLOCK_TIME(g->session.custom_time.hour, g->session.custom_time.minute, g->session.custom_time.second); - lastOverride = true; + } + else + { + NETWORK::NETWORK_CLEAR_CLOCK_TIME_OVERRIDE(); + toggled = true; } } -} \ No newline at end of file +}