From 523e3d042d6a3173e1332d1915080e474501409c Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Mon, 30 Apr 2007 22:53:27 +0000 Subject: [PATCH] Added paramater to CreateEvent to determine whether or not creation should be forced even if nothing is hooking/listening to the event. --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40719 --- core/EventManager.cpp | 4 ++-- core/EventManager.h | 2 +- core/smn_events.cpp | 2 +- plugins/include/events.inc | 7 +++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/EventManager.cpp b/core/EventManager.cpp index db97f207..b0c08460 100644 --- a/core/EventManager.cpp +++ b/core/EventManager.cpp @@ -277,10 +277,10 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun return EventHookErr_Okay; } -EventInfo *EventManager::CreateEvent(IPluginContext *pContext, const char *name) +EventInfo *EventManager::CreateEvent(IPluginContext *pContext, const char *name, bool force) { EventInfo *pInfo; - IGameEvent *pEvent = gameevents->CreateEvent(name, true); + IGameEvent *pEvent = gameevents->CreateEvent(name, force); if (pEvent) { diff --git a/core/EventManager.h b/core/EventManager.h index 0c796284..90dee518 100644 --- a/core/EventManager.h +++ b/core/EventManager.h @@ -93,7 +93,7 @@ public: public: EventHookError HookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post); EventHookError UnhookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post); - EventInfo *CreateEvent(IPluginContext *pContext, const char *name); + EventInfo *CreateEvent(IPluginContext *pContext, const char *name, bool force=false); void FireEvent(EventInfo *pInfo, bool bDontBroadcast=false); void CancelCreatedEvent(EventInfo *pInfo); private: // IGameEventManager2 hooks diff --git a/core/smn_events.cpp b/core/smn_events.cpp index 95a2648d..679c4efe 100644 --- a/core/smn_events.cpp +++ b/core/smn_events.cpp @@ -71,7 +71,7 @@ static cell_t sm_CreateEvent(IPluginContext *pContext, const cell_t *params) pContext->LocalToString(params[1], &name); - pInfo = g_EventManager.CreateEvent(pContext, name); + pInfo = g_EventManager.CreateEvent(pContext, name, params[2] ? true : false); if (pInfo) { diff --git a/plugins/include/events.inc b/plugins/include/events.inc index 34088948..d1fd81d9 100644 --- a/plugins/include/events.inc +++ b/plugins/include/events.inc @@ -81,9 +81,12 @@ native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=E * Creates a game event to be fired later. * * @param name Name of event. - * @return Handle to event or INVALID_HANDLE if event doesn't exist. + * @param force If set to true, this forces the event to be created even if it's not being hooked. + * Note that this will not force it if the event doesn't exist at all. + * @return Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't + being hooked (unless force is true). */ -native Handle:CreateEvent(const String:name[]); +native Handle:CreateEvent(const String:name[], bool:force=false); /** * Fires a game event.