core/HalfLife2.cpp
changeset 2596 4fb11ed1e6bc
parent 2583 d3b2571c378b
child 2628 541e48653064
     1.1 --- a/core/HalfLife2.cpp	Sat Feb 21 11:29:28 2009 +1300
     1.2 +++ b/core/HalfLife2.cpp	Sun Feb 22 14:38:05 2009 +1300
     1.3 @@ -576,3 +576,59 @@
     1.4  		player->Kick(info.buffer);
     1.5  	}
     1.6  }
     1.7 +
     1.8 +edict_t *CHalfLife2::EdictOfIndex(int index)
     1.9 +{
    1.10 +	return ::PEntityOfEntIndex(index);
    1.11 +}
    1.12 +
    1.13 +int CHalfLife2::IndexOfEdict(edict_t *pEnt)
    1.14 +{
    1.15 +	return ::IndexOfEdict(pEnt);
    1.16 +}
    1.17 +
    1.18 +edict_t *CHalfLife2::GetHandleEntity(CBaseHandle &hndl)
    1.19 +{
    1.20 +	if (!hndl.IsValid())
    1.21 +	{
    1.22 +		return NULL;
    1.23 +	}
    1.24 +
    1.25 +	int index = hndl.GetEntryIndex();
    1.26 +
    1.27 +	edict_t *pStoredEdict;
    1.28 +	CBaseEntity *pStoredEntity;
    1.29 +
    1.30 +	pStoredEdict = GetEntity(index, &pStoredEntity);
    1.31 +
    1.32 +	if (pStoredEdict == NULL || pStoredEntity == NULL)
    1.33 +	{
    1.34 +		return NULL;
    1.35 +	}
    1.36 +
    1.37 +	IServerEntity *pSE = pStoredEdict->GetIServerEntity();
    1.38 +
    1.39 +	if (pSE == NULL)
    1.40 +	{
    1.41 +		return NULL;
    1.42 +	}
    1.43 +
    1.44 +	if (pSE->GetRefEHandle() != hndl)
    1.45 +	{
    1.46 +		return NULL;
    1.47 +	}
    1.48 +
    1.49 +	return pStoredEdict;
    1.50 +}
    1.51 +
    1.52 +void CHalfLife2::SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt)
    1.53 +{
    1.54 +	IServerEntity *pEntOther = pEnt->GetIServerEntity();
    1.55 +
    1.56 +	if (pEntOther == NULL)
    1.57 +	{
    1.58 +		return;
    1.59 +	}
    1.60 +
    1.61 +	hndl.Set(pEntOther);
    1.62 +}