MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / OnFireEvent

Method OnFireEvent

core/EventManager.cpp:385–451  ·  view source on GitHub ↗

IGameEventManager2::FireEvent hook */

Source from the content-addressed store, hash-verified

383
384/* IGameEventManager2::FireEvent hook */
385bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
386{
387 EventHook *pHook;
388 IChangeableForward *pForward;
389 const char *name;
390 cell_t res = Pl_Continue;
391 bool broadcast = bDontBroadcast;
392
393 /* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */
394 if (!pEvent)
395 {
396 RETURN_META_VALUE(MRES_IGNORED, false);
397 }
398
399 name = pEvent->GetName();
400
401 if (m_EventHooks.retrieve(name, &pHook))
402 {
403 /* Push the event onto the event stack. The reference count is increased to make sure
404 * the structure is not garbage collected in between now and the post hook.
405 */
406 pHook->refCount++;
407 m_EventStack.push(pHook);
408
409 pForward = pHook->pPreHook;
410
411 if (pForward)
412 {
413 EventInfo info(pEvent, NULL);
414 HandleSecurity sec(NULL, g_pCoreIdent);
415 Handle_t hndl = handlesys->CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
416
417 info.bDontBroadcast = bDontBroadcast;
418
419 EventForwardFilter filter(&info);
420
421 pForward->PushCell(hndl);
422 pForward->PushString(name);
423 pForward->PushCell(bDontBroadcast);
424 pForward->Execute(&res, &filter);
425
426 broadcast = info.bDontBroadcast;
427
428 handlesys->FreeHandle(hndl, &sec);
429 }
430
431 if (pHook->postCopy)
432 {
433 m_EventCopies.push(gameevents->DuplicateEvent(pEvent));
434 }
435
436 if (res >= Pl_Handled)
437 {
438 gameevents->FreeEvent(pEvent);
439 RETURN_META_VALUE(MRES_SUPERCEDE, false);
440 }
441 }
442 else

Callers

nothing calls this directly

Calls 8

PushCellMethod · 0.80
PushStringMethod · 0.80
FreeHandleMethod · 0.80
GetNameMethod · 0.45
retrieveMethod · 0.45
pushMethod · 0.45
CreateHandleMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected