1.1 --- a/extensions/sdktools/output.cpp Thu Jul 09 17:51:12 2009 -0400
1.2 +++ b/extensions/sdktools/output.cpp Fri Jul 24 12:34:31 2009 +1200
1.3 @@ -205,20 +205,12 @@
1.4 // attempt to directly lookup a hook using the pOutput pointer
1.5 OutputNameStruct *pOutputName = NULL;
1.6
1.7 - edict_t *pEdict = gameents->BaseEntityToEdict(pCaller);
1.8 -
1.9 - /* TODO: Add support for entities without an edict */
1.10 - if (pEdict == NULL)
1.11 - {
1.12 - return;
1.13 - }
1.14 -
1.15 bool fastLookup = false;
1.16
1.17 // Fast lookup failed - check the slow way for hooks that havn't fired yet
1.18 if ((fastLookup = EntityOutputs->Retrieve(sOutput, (void **)&pOutputName)) == false)
1.19 {
1.20 - const char *classname = pEdict->GetClassName();
1.21 + const char *classname = GetEntityClassname(pCaller);
1.22 const char *outputname = FindOutputName(pOutput, pCaller);
1.23
1.24 pOutputName = FindOutputPointer(classname, outputname, false);
1.25 @@ -249,37 +241,31 @@
1.26
1.27 hook->in_use = true;
1.28
1.29 - int serial = pEdict->m_NetworkSerialNumber;
1.30 + cell_t ref = gamehelpers->EntityToReference(pCaller);
1.31
1.32 - if (serial != hook->entity_filter && hook->entity_index == IndexOfEdict(pEdict))
1.33 + if (hook->entity_ref != -1
1.34 + && gamehelpers->ReferenceToIndex(hook->entity_ref) == gamehelpers->ReferenceToIndex(ref)
1.35 + && ref != hook->entity_ref)
1.36 {
1.37 - // same entity index but different serial number. Entity has changed, kill the hook.
1.38 + // same entity index but different reference. Entity has changed, kill the hook.
1.39 _iter = pOutputName->hooks.erase(_iter);
1.40 CleanUpHook(hook);
1.41
1.42 continue;
1.43 }
1.44
1.45 - if (hook->entity_filter == -1 || hook->entity_filter == serial) // Global classname hook
1.46 + if (hook->entity_ref == -1 || hook->entity_ref == ref) // Global classname hook
1.47 {
1.48 //fire the forward to hook->pf
1.49 hook->pf->PushString(pOutputName->Name);
1.50 - hook->pf->PushCell(IndexOfEdict(pEdict));
1.51 -
1.52 - edict_t *pEdictActivator = gameents->BaseEntityToEdict(pActivator);
1.53 - if (!pEdictActivator)
1.54 - {
1.55 - hook->pf->PushCell(-1);
1.56 - }
1.57 - else
1.58 - {
1.59 - hook->pf->PushCell(IndexOfEdict(pEdictActivator));
1.60 - }
1.61 + hook->pf->PushCell(gamehelpers->ReferenceToBCompatRef(ref));
1.62 + hook->pf->PushCell(gamehelpers->EntityToBCompatRef(pActivator));
1.63 +
1.64 //hook->pf->PushCell(handle);
1.65 hook->pf->PushFloat(fDelay);
1.66 hook->pf->Execute(NULL);
1.67
1.68 - if ((hook->entity_filter != -1) && hook->only_once)
1.69 + if ((hook->entity_ref != -1) && hook->only_once)
1.70 {
1.71 _iter = pOutputName->hooks.erase(_iter);
1.72 CleanUpHook(hook);
1.73 @@ -454,36 +440,15 @@
1.74 return NULL;
1.75 }
1.76
1.77 -// Thanks SM core
1.78 -edict_t *EntityOutputManager::BaseHandleToEdict(CBaseHandle &hndl)
1.79 +const char *EntityOutputManager::GetEntityClassname(CBaseEntity *pEntity)
1.80 {
1.81 - if (!hndl.IsValid())
1.82 + static int offset = -1;
1.83 + if (offset == -1)
1.84 {
1.85 - return NULL;
1.86 + datamap_t *pMap = gamehelpers->GetDataMap(pEntity);
1.87 + typedescription_t *pDesc = gamehelpers->FindInDataMap(pMap, "m_iClassname");
1.88 + offset = pDesc->fieldOffset[TD_OFFSET_NORMAL];
1.89 }
1.90
1.91 - int index = hndl.GetEntryIndex();
1.92 -
1.93 - edict_t *pStoredEdict;
1.94 -
1.95 - pStoredEdict = PEntityOfEntIndex(index);
1.96 -
1.97 - if (pStoredEdict == NULL)
1.98 - {
1.99 - return NULL;
1.100 - }
1.101 -
1.102 - IServerEntity *pSE = pStoredEdict->GetIServerEntity();
1.103 -
1.104 - if (pSE == NULL)
1.105 - {
1.106 - return NULL;
1.107 - }
1.108 -
1.109 - if (pSE->GetRefEHandle() != hndl)
1.110 - {
1.111 - return NULL;
1.112 - }
1.113 -
1.114 - return pStoredEdict;
1.115 -}
1.116 + return (const char *)(((unsigned char *)pEntity) + offset);
1.117 +}
1.118 \ No newline at end of file