From e0a7e4542f494368133dddd3bdc92ed89476f6ea Mon Sep 17 00:00:00 2001 From: FreezeEngine Date: Fri, 23 Aug 2024 04:29:37 +0300 Subject: [PATCH 1/2] Cleanup --- src/client/feature/module/impl/visual/NoHurtCam.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/client/feature/module/impl/visual/NoHurtCam.h b/src/client/feature/module/impl/visual/NoHurtCam.h index f07a523e..61d85ce9 100644 --- a/src/client/feature/module/impl/visual/NoHurtCam.h +++ b/src/client/feature/module/impl/visual/NoHurtCam.h @@ -1,11 +1,9 @@ #pragma once #include "../../Module.h" -#include "client/event/impl/GammaEvent.h" class NoHurtCam : public Module { public: NoHurtCam(); void onBobHurt(Event& ev); -private: }; \ No newline at end of file From bd18c9088dd194a5707fab2603067d352ca3db4a Mon Sep 17 00:00:00 2001 From: FreezeEngine Date: Fri, 23 Aug 2024 04:30:45 +0300 Subject: [PATCH 2/2] Event dispatching performance fix --- src/api/eventing/EventManager.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/api/eventing/EventManager.h b/src/api/eventing/EventManager.h index c2984b1f..5aaf73dd 100644 --- a/src/api/eventing/EventManager.h +++ b/src/api/eventing/EventManager.h @@ -7,11 +7,6 @@ class IEventManager { public: template bool dispatch(T& ev) requires std::derived_from { - std::sort(listeners.begin(), listeners.end(), [](std::pair const& left, - std::pair const& right) { - return left.second.priority > right.second.priority; - }); - for (auto& pair : listeners) { if (pair.first == T::hash) { if (pair.second.listener->shouldListen() || pair.second.callWhileInactive) { @@ -33,6 +28,10 @@ class IEventManager { void listen(Listener* ptr, EventListenerFunc listener, int priority = 0, bool callWhileInactive = false) requires std::derived_from { mutex.lock(); listeners.push_back({ T::hash, EventListener{ listener, ptr, callWhileInactive, priority } }); + std::sort(listeners.begin(), listeners.end(), [](std::pair const& left, + std::pair const& right) { + return left.second.priority > right.second.priority; + }); mutex.unlock(); }