Skip to content

Commit

Permalink
Merge pull request #2 from FreezeEngine/MoreFixes
Browse files Browse the repository at this point in the history
Event dispatching performance issue fix
  • Loading branch information
marioCST authored Aug 23, 2024
2 parents d1a57d3 + bd18c90 commit bb9db4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/api/eventing/EventManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ class IEventManager {
public:
template <typename T>
bool dispatch(T& ev) requires std::derived_from<T, Event> {
std::sort(listeners.begin(), listeners.end(), [](std::pair<uint32_t, EventListener> const& left,
std::pair<uint32_t, EventListener> 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) {
Expand All @@ -33,6 +28,10 @@ class IEventManager {
void listen(Listener* ptr, EventListenerFunc listener, int priority = 0, bool callWhileInactive = false) requires std::derived_from<T, Event> {
mutex.lock();
listeners.push_back({ T::hash, EventListener{ listener, ptr, callWhileInactive, priority } });
std::sort(listeners.begin(), listeners.end(), [](std::pair<uint32_t, EventListener> const& left,
std::pair<uint32_t, EventListener> const& right) {
return left.second.priority > right.second.priority;
});
mutex.unlock();
}

Expand Down
2 changes: 0 additions & 2 deletions src/client/feature/module/impl/visual/NoHurtCam.h
Original file line number Diff line number Diff line change
@@ -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:
};

0 comments on commit bb9db4f

Please sign in to comment.