diff --git a/game/shared/GameEventListener.h b/game/shared/GameEventListener.h index 3371b3b2..a2fbb640 100644 --- a/game/shared/GameEventListener.h +++ b/game/shared/GameEventListener.h @@ -12,6 +12,7 @@ #endif #include "igameevents.h" +extern IGameEventManager2 *gameeventmanager; // A safer method than inheriting straight from IGameEventListener2. // Avoids requiring the user to remove themselves as listeners in @@ -22,10 +23,12 @@ class CGameEventListener : public IGameEventListener2 public: CGameEventListener() : m_bRegisteredForEvents(false) { + m_nDebugID = EVENT_DEBUG_ID_INIT; } ~CGameEventListener() { + m_nDebugID = EVENT_DEBUG_ID_SHUTDOWN; StopListeningForAllEvents(); } @@ -47,16 +50,20 @@ public: // remove me from list if ( m_bRegisteredForEvents ) { - gameeventmanager->RemoveListener( this ); + if ( gameeventmanager ) + gameeventmanager->RemoveListener( this ); + m_bRegisteredForEvents = false; } } // Intentionally abstract virtual void FireGameEvent( IGameEvent *event ) = 0; - + int m_nDebugID; + virtual int GetEventDebugID( void ) { return m_nDebugID; } + private: - + // Have we registered for any events? bool m_bRegisteredForEvents; };