From b44aa534dcfdb2f8c1c13841f326ff01d09401a5 Mon Sep 17 00:00:00 2001 From: Edo Date: Fri, 10 Mar 2023 23:22:00 +0000 Subject: [PATCH] [Command]: Update (#826) --- src/Components/Modules/Command.cpp | 47 +++++++++++++++++++++++------- src/Components/Modules/Command.hpp | 2 ++ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index 43f03b8e..fca3a947 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -174,6 +174,41 @@ namespace Components } } + bool Command::IsSendingNotifiesDisabled() + { + static std::optional flag; + + if (!flag.has_value()) + { + flag.emplace(Flags::HasFlag("disable-notifies")); + } + + return flag.value(); + } + + const std::vector& Command::GetExceptions() + { + static const auto exceptions = []() -> std::vector + { + std::vector values = + { + "cmd", + "exec", + "map", + }; + + if (IsSendingNotifiesDisabled()) + { + values.emplace_back("vstr"); + values.emplace_back("wait"); + } + + return values; + }(); + + return exceptions; + } + bool Command::CL_ShouldSendNotify_Hk(const char* cmd) { if (!cmd) @@ -181,18 +216,10 @@ namespace Components return false; } - static std::array exceptions = - { - "cmd", - "exec", - "map", - "vstr", - "wait", - }; - + const auto& exceptions = GetExceptions(); for (const auto& entry : exceptions) { - if (!_stricmp(cmd, entry)) + if (!_stricmp(cmd, entry.data())) { return false; } diff --git a/src/Components/Modules/Command.hpp b/src/Components/Modules/Command.hpp index 401685b0..e060b456 100644 --- a/src/Components/Modules/Command.hpp +++ b/src/Components/Modules/Command.hpp @@ -73,6 +73,8 @@ namespace Components static void MainCallback(); static void MainCallbackSV(); + static bool IsSendingNotifiesDisabled(); + static const std::vector& GetExceptions(); static bool CL_ShouldSendNotify_Hk(const char* cmd); }; }