Merged changes from sourcemod-1.1 branch.
Merged changes from sourcemod-1.1 branch.
1.1 --- a/core/EventManager.cpp Thu Jan 22 15:20:45 2009 -0600
1.2 +++ b/core/EventManager.cpp Wed Jan 28 00:00:19 2009 -0600
1.3 @@ -377,21 +377,21 @@
1.4
1.5 if (pForward)
1.6 {
1.7 - EventInfo info = { pEvent, NULL };
1.8 + EventInfo info(pEvent, NULL);
1.9 + HandleSecurity sec(NULL, g_pCoreIdent);
1.10 + Handle_t hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
1.11
1.12 - Handle_t hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
1.13 pForward->PushCell(hndl);
1.14 pForward->PushString(name);
1.15 pForward->PushCell(bDontBroadcast);
1.16 pForward->Execute(&res, NULL);
1.17
1.18 - HandleSecurity sec(NULL, g_pCoreIdent);
1.19 g_HandleSys.FreeHandle(hndl, &sec);
1.20 }
1.21
1.22 if (pHook->postCopy)
1.23 {
1.24 - pHook->pEventCopy = gameevents->DuplicateEvent(pEvent);
1.25 + m_EventCopies.push(gameevents->DuplicateEvent(pEvent));
1.26 }
1.27
1.28 if (res)
1.29 @@ -407,8 +407,8 @@
1.30 /* IGameEventManager2::FireEvent post hook */
1.31 bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
1.32 {
1.33 - IGameEvent *pEventCopy = NULL;
1.34 EventHook *pHook;
1.35 + EventInfo info;
1.36 IChangeableForward *pForward;
1.37 const char *name;
1.38 Handle_t hndl = 0;
1.39 @@ -427,10 +427,10 @@
1.40
1.41 if (pForward)
1.42 {
1.43 - EventInfo info = { pHook->pEventCopy, NULL };
1.44 -
1.45 if (pHook->postCopy)
1.46 {
1.47 + info.pEvent = m_EventCopies.front();
1.48 + info.pOwner = NULL;
1.49 hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
1.50
1.51 pForward->PushCell(hndl);
1.52 @@ -449,8 +449,8 @@
1.53 g_HandleSys.FreeHandle(hndl, &sec);
1.54
1.55 /* Free event structure */
1.56 - gameevents->FreeEvent(pEventCopy);
1.57 - pHook->pEventCopy = NULL;
1.58 + gameevents->FreeEvent(info.pEvent);
1.59 + m_EventCopies.pop();
1.60 }
1.61 }
1.62 }
2.1 --- a/core/EventManager.h Thu Jan 22 15:20:45 2009 -0600
2.2 +++ b/core/EventManager.h Wed Jan 28 00:00:19 2009 -0600
2.3 @@ -45,6 +45,12 @@
2.4
2.5 struct EventInfo
2.6 {
2.7 + EventInfo()
2.8 + {
2.9 + }
2.10 + EventInfo(IGameEvent *ev, IdentityToken_t *owner) : pEvent(ev), pOwner(owner)
2.11 + {
2.12 + }
2.13 IGameEvent *pEvent;
2.14 IdentityToken_t *pOwner;
2.15 };
2.16 @@ -56,13 +62,11 @@
2.17 pPreHook = NULL;
2.18 pPostHook = NULL;
2.19 postCopy = false;
2.20 - pEventCopy = NULL;
2.21 refCount = 0;
2.22 }
2.23 IChangeableForward *pPreHook;
2.24 IChangeableForward *pPostHook;
2.25 bool postCopy;
2.26 - IGameEvent *pEventCopy;
2.27 unsigned int refCount;
2.28 };
2.29
2.30 @@ -121,6 +125,7 @@
2.31 Trie *m_EventHooks;
2.32 CStack<EventInfo *> m_FreeEvents;
2.33 CStack<const char *> m_EventNames;
2.34 + CStack<IGameEvent *> m_EventCopies;
2.35 };
2.36
2.37 extern EventManager g_EventManager;