1212// -----------------------------------------------------------------------------
1313// Macros
1414// -----------------------------------------------------------------------------
15- // This creates a static manager (only visible in file that uses this macro)
16- // and an inline function that returns a pointer to the manager. That way we
17- // avoid multiple definitions
15+ // This creates a static manager and an inline function that returns a pointer
16+ // to the manager. Must be used in a *.cpp file!
1817#define DEFINE_MANAGER_ACCESSOR (name ) \
1918 static CListenerManager s_##name; \
2019 inline CListenerManager* Get##name##ListenerManager() \
2120 { return &s_##name; }
2221
2322// Calls all listeners of the given manager
24- #define CALL_LISTENERS (manager, ...) \
25- for (int i = 0 ; i < s_##manager.m_vecCallables.Count(); i++) \
23+ #define CALL_LISTENERS (name, ...) \
24+ extern CListenerManager* Get##name##ListenerManager(); \
25+ for (int i = 0 ; i < Get##name##ListenerManager()->m_vecCallables.Count(); i++) \
2626 { \
2727 BEGIN_BOOST_PY () \
28- CALL_PY_FUNC (s_##manager. m_vecCallables [i].ptr (), ##__VA_ARGS__); \
29- END_BOOST_PY_NORET () \
28+ CALL_PY_FUNC (Get##name## ListenerManager ()-> m_vecCallables [i].ptr (), ##__VA_ARGS__); \
29+ END_BOOST_PY_NORET () \
3030 }
3131
3232
@@ -43,20 +43,4 @@ class CListenerManager
4343 CUtlVector<object> m_vecCallables;
4444};
4545
46- // Create manager accessor functions
47- DEFINE_MANAGER_ACCESSOR (ClientActive)
48- DEFINE_MANAGER_ACCESSOR(ClientConnect)
49- DEFINE_MANAGER_ACCESSOR(ClientDisconnect)
50- DEFINE_MANAGER_ACCESSOR(ClientFullyConnect)
51- DEFINE_MANAGER_ACCESSOR(ClientPutInServer)
52- DEFINE_MANAGER_ACCESSOR(ClientSettingsChanged)
53- DEFINE_MANAGER_ACCESSOR(LevelInit)
54- DEFINE_MANAGER_ACCESSOR(LevelShutdown)
55- DEFINE_MANAGER_ACCESSOR(NetworkidValidated)
56- DEFINE_MANAGER_ACCESSOR(OnEdictAllocated)
57- DEFINE_MANAGER_ACCESSOR(OnEdictFreed)
58- DEFINE_MANAGER_ACCESSOR(OnQueryCvarValueFinished)
59- DEFINE_MANAGER_ACCESSOR(ServerActivate)
60- DEFINE_MANAGER_ACCESSOR(Tick)
61-
6246#endif // _LISTENERMANAGER_H
0 commit comments