1.1 --- a/extensions/sdktools/vnatives.cpp Mon Oct 22 02:54:27 2007 +0000
1.2 +++ b/extensions/sdktools/vnatives.cpp Mon Oct 22 03:27:22 2007 +0000
1.3 @@ -113,24 +113,6 @@
1.4 return false;
1.5 }
1.6
1.7 -class CTraceFilterSimple : public CTraceFilterEntitiesOnly
1.8 -{
1.9 -public:
1.10 - CTraceFilterSimple(const IHandleEntity *passentity): m_pPassEnt(passentity)
1.11 - {
1.12 - }
1.13 - virtual bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask)
1.14 - {
1.15 - if (pServerEntity == m_pPassEnt)
1.16 - {
1.17 - return false;
1.18 - }
1.19 - return true;
1.20 - }
1.21 -private:
1.22 - const IHandleEntity *m_pPassEnt;
1.23 -};
1.24 -
1.25 static cell_t RemovePlayerItem(IPluginContext *pContext, const cell_t *params)
1.26 {
1.27 static ValveCall *pCall = NULL;
1.28 @@ -803,7 +785,7 @@
1.29 return (ret) ? 1 : 0;
1.30 }
1.31
1.32 -static cell_t GetClientAimTarget(IPluginContext *pContext, const cell_t *params)
1.33 +static cell_t sm_GetClientAimTarget(IPluginContext *pContext, const cell_t *params)
1.34 {
1.35 int client = params[1];
1.36 IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
1.37 @@ -817,62 +799,7 @@
1.38 return pContext->ThrowNativeError("Client %d is not in game", client);
1.39 }
1.40
1.41 - edict_t *pEdict = pPlayer->GetEdict();
1.42 - CBaseEntity *pEntity = pEdict->GetUnknown() ? pEdict->GetUnknown()->GetBaseEntity() : NULL;
1.43 -
1.44 - if (pEntity == NULL)
1.45 - {
1.46 - return -1;
1.47 - }
1.48 -
1.49 - Vector eye_position;
1.50 - QAngle eye_angles;
1.51 -
1.52 - /* Get the private information we need */
1.53 - serverClients->ClientEarPosition(pEdict, &eye_position);
1.54 - if (!GetEyeAngles(pEntity, &eye_angles))
1.55 - {
1.56 - return -2;
1.57 - }
1.58 -
1.59 - Vector aim_dir;
1.60 - AngleVectors(eye_angles, &aim_dir);
1.61 - VectorNormalize(aim_dir);
1.62 -
1.63 - Vector vec_end = eye_position + aim_dir * 8000;
1.64 -
1.65 - Ray_t ray;
1.66 - ray.Init(eye_position, vec_end);
1.67 -
1.68 - trace_t tr;
1.69 - CTraceFilterSimple simple(pEdict->GetIServerEntity());
1.70 -
1.71 - enginetrace->TraceRay(ray, MASK_SOLID|CONTENTS_DEBRIS|CONTENTS_HITBOX, &simple, &tr);
1.72 -
1.73 - if (tr.fraction == 1.0f || tr.m_pEnt == NULL)
1.74 - {
1.75 - return -1;
1.76 - }
1.77 -
1.78 - edict_t *pTarget = gameents->BaseEntityToEdict(tr.m_pEnt);
1.79 - if (pTarget == NULL)
1.80 - {
1.81 - return -1;
1.82 - }
1.83 -
1.84 - int ent_index = engine->IndexOfEdict(pTarget);
1.85 -
1.86 - IGamePlayer *pTargetPlayer = playerhelpers->GetGamePlayer(ent_index);
1.87 - if (pTargetPlayer != NULL && !pTargetPlayer->IsInGame())
1.88 - {
1.89 - return -1;
1.90 - }
1.91 - else if (params[2] && pTargetPlayer == NULL)
1.92 - {
1.93 - return -1;
1.94 - }
1.95 -
1.96 - return ent_index;
1.97 + return GetClientAimTarget(pPlayer->GetEdict(), params[2] ? true : false);
1.98 }
1.99
1.100 sp_nativeinfo_t g_Natives[] =
1.101 @@ -898,6 +825,6 @@
1.102 {"DispatchKeyValue", DispatchKeyValue},
1.103 {"DispatchKeyValueFloat", DispatchKeyValueFloat},
1.104 {"DispatchKeyValueVector", DispatchKeyValueVector},
1.105 - {"GetClientAimTarget", GetClientAimTarget},
1.106 + {"GetClientAimTarget", sm_GetClientAimTarget},
1.107 {NULL, NULL},
1.108 };