//----------------------------------------------------------------------------- // Returns an IntHandle from the given Edict instance. //----------------------------------------------------------------------------- bool IntHandleFromEdict( edict_t *pEdict, unsigned int& output ) { CBaseHandle hBaseHandle; if (!BaseHandleFromEdict(pEdict, hBaseHandle)) return false; return IntHandleFromBaseHandle(hBaseHandle, output); }
//----------------------------------------------------------------------------- // Returns an index from the given IntHandle. //----------------------------------------------------------------------------- bool IndexFromIntHandle( unsigned int iEntityHandle, unsigned int& output ) { if (iEntityHandle == (int) INVALID_EHANDLE_INDEX) return false; CBaseHandle hBaseHandle(iEntityHandle); unsigned int iEntityIndex; if (!IndexFromBaseHandle(hBaseHandle, iEntityIndex)) return false; edict_t* pEdict; if (!EdictFromIndex(iEntityIndex, pEdict)) return false; CBaseHandle hTestHandle; if (!BaseHandleFromEdict(pEdict, hTestHandle)) return false; if (!hTestHandle.IsValid() || hBaseHandle.GetSerialNumber() != hTestHandle.GetSerialNumber()) return false; output = iEntityIndex; return true; }