Removed flags from FireEvent()

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40718
This commit is contained in:
Scott Ehlert 2007-04-30 22:03:28 +00:00
parent 1b5bcc4836
commit 473e1d4135
4 changed files with 5 additions and 31 deletions

View File

@ -25,7 +25,7 @@ SH_DECL_HOOK2(IGameEventManager2, FireEvent, SH_NOATTRIB, 0, bool, IGameEvent *,
const ParamType GAMEEVENT_PARAMS[] = {Param_Cell, Param_String, Param_Cell}; const ParamType GAMEEVENT_PARAMS[] = {Param_Cell, Param_String, Param_Cell};
typedef List<EventHook *> EventHookList; typedef List<EventHook *> EventHookList;
EventManager::EventManager() : m_EventType(0), m_NotifyPlugins(true) EventManager::EventManager() : m_EventType(0)
{ {
/* Create an event lookup trie */ /* Create an event lookup trie */
m_EventHooks = sm_trie_create(); m_EventHooks = sm_trie_create();
@ -302,11 +302,8 @@ EventInfo *EventManager::CreateEvent(IPluginContext *pContext, const char *name)
return NULL; return NULL;
} }
void EventManager::FireEvent(EventInfo *pInfo, int flags, bool bDontBroadcast) void EventManager::FireEvent(EventInfo *pInfo, bool bDontBroadcast)
{ {
/* Should SourceMod plugins be notified of this event? */
m_NotifyPlugins = (flags & EVENT_PASSTHRU_ALL) ? true : false;
/* Actually fire event now */ /* Actually fire event now */
gameevents->FireEvent(pInfo->pEvent, bDontBroadcast); gameevents->FireEvent(pInfo->pEvent, bDontBroadcast);
@ -337,11 +334,6 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
const char *name; const char *name;
cell_t res = Pl_Continue; cell_t res = Pl_Continue;
if (!m_NotifyPlugins)
{
RETURN_META_VALUE(MRES_IGNORED, true);
}
/* Get the event name, we're going to need this for passing to post hooks */ /* Get the event name, we're going to need this for passing to post hooks */
name = pEvent->GetName(); name = pEvent->GetName();
@ -389,14 +381,6 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
const char *name; const char *name;
Handle_t hndl = 0; Handle_t hndl = 0;
if (!m_NotifyPlugins)
{
/* Reset plugin notification state */
m_NotifyPlugins = true;
RETURN_META_VALUE(MRES_IGNORED, true);
}
name = m_EventNames.front(); name = m_EventNames.front();
if (sm_trie_retrieve(m_EventHooks, name, reinterpret_cast<void **>(&pHook))) if (sm_trie_retrieve(m_EventHooks, name, reinterpret_cast<void **>(&pHook)))

View File

@ -26,9 +26,6 @@
using namespace SourceHook; using namespace SourceHook;
//#define EVENT_PASSTHRU (1<<0)
#define EVENT_PASSTHRU_ALL (1<<1)
struct EventInfo struct EventInfo
{ {
IGameEvent *pEvent; IGameEvent *pEvent;
@ -97,14 +94,13 @@ public:
EventHookError HookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post); EventHookError HookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post);
EventHookError UnhookEvent(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);
void FireEvent(EventInfo *pInfo, int flags=0, bool bDontBroadcast=false); void FireEvent(EventInfo *pInfo, bool bDontBroadcast=false);
void CancelCreatedEvent(EventInfo *pInfo); void CancelCreatedEvent(EventInfo *pInfo);
private: // IGameEventManager2 hooks private: // IGameEventManager2 hooks
bool OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast); bool OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast);
bool OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast); bool OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast);
private: private:
HandleType_t m_EventType; HandleType_t m_EventType;
bool m_NotifyPlugins;
Trie *m_EventHooks; Trie *m_EventHooks;
CStack<EventInfo *> m_FreeEvents; CStack<EventInfo *> m_FreeEvents;
CStack<const char *> m_EventNames; CStack<const char *> m_EventNames;

View File

@ -99,7 +99,7 @@ static cell_t sm_FireEvent(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Game event \"%s\" could not be fired because it was not created by this plugin", pInfo->pEvent->GetName()); return pContext->ThrowNativeError("Game event \"%s\" could not be fired because it was not created by this plugin", pInfo->pEvent->GetName());
} }
g_EventManager.FireEvent(pInfo, params[2], params[3] ? true : false); g_EventManager.FireEvent(pInfo, params[2] ? true : false);
/* Free handle on game event */ /* Free handle on game event */
HandleSecurity sec = {pContext->GetIdentity(), g_pCoreIdent}; HandleSecurity sec = {pContext->GetIdentity(), g_pCoreIdent};

View File

@ -18,11 +18,6 @@
#endif #endif
#define _events_included #define _events_included
/**
* Flags for firing game events
*/
#define EVENT_PASSTHRU_ALL (1<<1) /**< Event will pass through other SourceMM plugins AND SourceMod */
/** /**
* Event hook modes determining how hooking should be handled * Event hook modes determining how hooking should be handled
*/ */
@ -94,12 +89,11 @@ native Handle:CreateEvent(const String:name[]);
* Fires a game event. * Fires a game event.
* *
* @param event Handle to the event. * @param event Handle to the event.
* @param flags Optional bitstring flags. See EVENT_* constants for more details.
* @param dontBroadcast Optional boolean that determines if event should be broadcast to clients. * @param dontBroadcast Optional boolean that determines if event should be broadcast to clients.
* @noreturn * @noreturn
* @error Invalid or corrupt Handle. * @error Invalid or corrupt Handle.
*/ */
native FireEvent(Handle:event, flags=0, bool:dontBroadcast=false); native FireEvent(Handle:event, bool:dontBroadcast=false);
/** /**
* Cancels a previously created game event that has not been fired. * Cancels a previously created game event that has not been fired.