CancelCreatedEvent actually does what it is supposed to do now...

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40693
This commit is contained in:
Scott Ehlert 2007-04-12 19:49:49 +00:00
parent 9542cf5113
commit 7b74745ceb
3 changed files with 15 additions and 0 deletions

View File

@ -317,6 +317,18 @@ void EventManager::FireEvent(EventInfo *pInfo, int flags, bool bDontBroadcast)
m_FreeEvents.push(pInfo);
}
void EventManager::CancelCreatedEvent(EventInfo *pInfo)
{
/* Free event from IGameEventManager2 */
gameevents->FreeEvent(pInfo->pEvent);
/* IGameEvent is free at this point, so no one owns this */
pInfo->pOwner = NULL;
/* Add EventInfo struct to free event stack */
m_FreeEvents.push(pInfo);
}
/* IGameEventManager2::FireEvent hook */
bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
{

View File

@ -98,6 +98,7 @@ public:
EventHookError UnhookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post);
EventInfo *CreateEvent(IPluginContext *pContext, const char *name);
void FireEvent(EventInfo *pInfo, int flags=0, bool bDontBroadcast=false);
void CancelCreatedEvent(EventInfo *pInfo);
private: // IGameEventManager2 hooks
bool OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast);
bool OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast);

View File

@ -126,6 +126,8 @@ static cell_t sm_CancelCreatedEvent(IPluginContext *pContext, const cell_t *para
return pContext->ThrowNativeError("Game event \"%s\" could not be canceled because it was not created by this plugin", pInfo->pEvent->GetName());
}
g_EventManager.CancelCreatedEvent(pInfo);
/* Free handle on game event */
HandleSecurity sec = {pContext->GetIdentity(), g_pCoreIdent};
g_HandleSys.FreeHandle(hndl, &sec);