IGameEventManager2::FireEvent post hook */
| 452 | |
| 453 | /* IGameEventManager2::FireEvent post hook */ |
| 454 | bool 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 | } |
nothing calls this directly
no test coverage detected