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

Method OnFireEvent_Post

core/EventManager.cpp:454–516  ·  view source on GitHub ↗

IGameEventManager2::FireEvent post hook */

Source from the content-addressed store, hash-verified

452
453/* IGameEventManager2::FireEvent post hook */
454bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
455{
456 EventHook *pHook;
457 EventInfo info;
458 IChangeableForward *pForward;
459 Handle_t hndl = 0;
460
461 /* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */
462 if (!pEvent)
463 {
464 RETURN_META_VALUE(MRES_IGNORED, false);
465 }
466
467 pHook = m_EventStack.front();
468
469 if (pHook != NULL)
470 {
471 pForward = pHook->pPostHook;
472
473 if (pForward)
474 {
475 if (pHook->postCopy)
476 {
477 info.bDontBroadcast = bDontBroadcast;
478 info.pEvent = m_EventCopies.front();
479 info.pOwner = NULL;
480 hndl = handlesys->CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
481
482 pForward->PushCell(hndl);
483 } else {
484 pForward->PushCell(BAD_HANDLE);
485 }
486
487 pForward->PushString(pHook->name.c_str());
488 pForward->PushCell(bDontBroadcast);
489 pForward->Execute(NULL);
490
491 if (pHook->postCopy)
492 {
493 /* Free handle */
494 HandleSecurity sec(NULL, g_pCoreIdent);
495 handlesys->FreeHandle(hndl, &sec);
496
497 /* Free event structure */
498 gameevents->FreeEvent(info.pEvent);
499 m_EventCopies.pop();
500 }
501 }
502
503 /* Decrement reference count, check if a delayed delete is needed */
504 if (--pHook->refCount == 0)
505 {
506 assert(pHook->pPostHook == NULL);
507 assert(pHook->pPreHook == NULL);
508 m_EventHooks.remove(pHook->name.c_str());
509 delete pHook;
510 }
511 }

Callers

nothing calls this directly

Calls 8

PushCellMethod · 0.80
PushStringMethod · 0.80
FreeHandleMethod · 0.80
popMethod · 0.80
CreateHandleMethod · 0.45
c_strMethod · 0.45
ExecuteMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected