extensions/sdktools/trnatives.cpp
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/extensions/sdktools/trnatives.cpp	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,577 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod SDKTools Extension
     1.8 - * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     1.9 - * =============================================================================
    1.10 - *
    1.11 - * This program is free software; you can redistribute it and/or modify it under
    1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 - * Free Software Foundation.
    1.14 - * 
    1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 - * details.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License along with
    1.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 - *
    1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 - * or <http://www.sourcemod.net/license.php>.
    1.31 - *
    1.32 - * Version: $Id$
    1.33 - */
    1.34 -
    1.35 -#include "extension.h"
    1.36 -#include <worldsize.h>
    1.37 -
    1.38 -class CSMTraceFilter : public CTraceFilter
    1.39 -{
    1.40 -public:
    1.41 -	bool ShouldHitEntity(IHandleEntity *pEntity, int contentsMask)
    1.42 -	{
    1.43 -		cell_t res = 1;
    1.44 -		edict_t *pEdict = gameents->BaseEntityToEdict(reinterpret_cast<CBaseEntity *>(pEntity));
    1.45 -		m_pFunc->PushCell(engine->IndexOfEdict(pEdict));
    1.46 -		m_pFunc->PushCell(contentsMask);
    1.47 -		m_pFunc->PushCell(m_Data);
    1.48 -		m_pFunc->Execute(&res);
    1.49 -
    1.50 -		return (res) ? true : false;
    1.51 -	}
    1.52 -	void SetFunctionPtr(IPluginFunction *pFunc, cell_t data)
    1.53 -	{
    1.54 -		m_pFunc = pFunc;
    1.55 -		m_Data = data;
    1.56 -	}
    1.57 -private:
    1.58 -	IPluginFunction *m_pFunc;
    1.59 -	cell_t m_Data;
    1.60 -};
    1.61 -
    1.62 -/* Used for the global trace version */
    1.63 -Ray_t g_Ray;
    1.64 -trace_t g_Trace;
    1.65 -Vector g_StartVec;
    1.66 -Vector g_EndVec;
    1.67 -Vector g_HullMins;
    1.68 -Vector g_HullMaxs;
    1.69 -QAngle g_DirAngles;
    1.70 -CTraceFilterHitAll g_HitAllFilter;
    1.71 -CSMTraceFilter g_SMTraceFilter;
    1.72 -
    1.73 -enum
    1.74 -{
    1.75 -	RayType_EndPoint,
    1.76 -	RayType_Infinite
    1.77 -};
    1.78 -
    1.79 -static cell_t smn_TRTraceRay(IPluginContext *pContext, const cell_t *params)
    1.80 -{
    1.81 -	cell_t *startaddr, *endaddr;
    1.82 -	pContext->LocalToPhysAddr(params[1], &startaddr);
    1.83 -	pContext->LocalToPhysAddr(params[2], &endaddr);
    1.84 -
    1.85 -	g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
    1.86 -
    1.87 -	switch (params[4])
    1.88 -	{
    1.89 -	case RayType_EndPoint:
    1.90 -		{
    1.91 -			g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
    1.92 -			break;
    1.93 -		}
    1.94 -	case RayType_Infinite:
    1.95 -		{
    1.96 -			g_DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
    1.97 -			AngleVectors(g_DirAngles, &g_EndVec);
    1.98 -
    1.99 -			/* Make it unitary and get the ending point */
   1.100 -			g_EndVec.NormalizeInPlace();
   1.101 -			g_EndVec = g_StartVec + g_EndVec * MAX_TRACE_LENGTH;
   1.102 -			break;
   1.103 -		}
   1.104 -	}
   1.105 -
   1.106 -	g_Ray.Init(g_StartVec, g_EndVec);
   1.107 -	enginetrace->TraceRay(g_Ray, params[3], &g_HitAllFilter, &g_Trace);
   1.108 -
   1.109 -	return 1;
   1.110 -}
   1.111 -
   1.112 -static cell_t smn_TRTraceHull(IPluginContext *pContext, const cell_t *params)
   1.113 -{
   1.114 -	cell_t *startaddr, *endaddr, *mins, *maxs;
   1.115 -	pContext->LocalToPhysAddr(params[1], &startaddr);
   1.116 -	pContext->LocalToPhysAddr(params[2], &endaddr);
   1.117 -	pContext->LocalToPhysAddr(params[3], &mins);
   1.118 -	pContext->LocalToPhysAddr(params[4], &maxs);
   1.119 -
   1.120 -	g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
   1.121 -	g_HullMins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
   1.122 -	g_HullMaxs.Init(sp_ctof(maxs[0]), sp_ctof(maxs[1]), sp_ctof(maxs[2]));
   1.123 -	g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.124 -
   1.125 -	g_Ray.Init(g_StartVec, g_EndVec, g_HullMins, g_HullMaxs);
   1.126 -	enginetrace->TraceRay(g_Ray, params[5], &g_HitAllFilter, &g_Trace);
   1.127 -
   1.128 -	return 1;
   1.129 -}
   1.130 -
   1.131 -static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *params)
   1.132 -{
   1.133 -	cell_t *startaddr, *endaddr;
   1.134 -	IPluginFunction *pFunc;
   1.135 -	cell_t data;
   1.136 -
   1.137 -	pFunc = pContext->GetFunctionById(params[5]);
   1.138 -	if (!pFunc)
   1.139 -	{
   1.140 -		return pContext->ThrowNativeError("Invalid function id (%X)", params[5]);
   1.141 -	}
   1.142 -
   1.143 -	if (params[0] >= 6)
   1.144 -	{
   1.145 -		data = params[6];
   1.146 -	}
   1.147 -	else
   1.148 -	{
   1.149 -		data = 0;
   1.150 -	}
   1.151 -
   1.152 -	g_SMTraceFilter.SetFunctionPtr(pFunc, data);
   1.153 -	pContext->LocalToPhysAddr(params[1], &startaddr);
   1.154 -	pContext->LocalToPhysAddr(params[2], &endaddr);
   1.155 -
   1.156 -	g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
   1.157 -
   1.158 -	switch (params[4])
   1.159 -	{
   1.160 -	case RayType_EndPoint:
   1.161 -		{
   1.162 -			g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.163 -			break;
   1.164 -		}
   1.165 -	case RayType_Infinite:
   1.166 -		{
   1.167 -			g_DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.168 -			AngleVectors(g_DirAngles, &g_EndVec);
   1.169 -
   1.170 -			/* Make it unitary and get the ending point */
   1.171 -			g_EndVec.NormalizeInPlace();
   1.172 -			g_EndVec = g_StartVec + g_EndVec * MAX_TRACE_LENGTH;
   1.173 -			break;
   1.174 -		}
   1.175 -	}
   1.176 -
   1.177 -	g_Ray.Init(g_StartVec, g_EndVec);
   1.178 -	enginetrace->TraceRay(g_Ray, params[3], &g_SMTraceFilter, &g_Trace);
   1.179 -
   1.180 -	return 1;
   1.181 -}
   1.182 -
   1.183 -static cell_t smn_TRTraceHullFilter(IPluginContext *pContext, const cell_t *params)
   1.184 -{
   1.185 -	cell_t data;
   1.186 -	IPluginFunction *pFunc;
   1.187 -	cell_t *startaddr, *endaddr, *mins, *maxs;
   1.188 -
   1.189 -	pFunc = pContext->GetFunctionById(params[6]);
   1.190 -	if (!pFunc)
   1.191 -	{
   1.192 -		return pContext->ThrowNativeError("Invalid function id (%X)", params[5]);
   1.193 -	}
   1.194 -
   1.195 -	data = params[7];
   1.196 -
   1.197 -	g_SMTraceFilter.SetFunctionPtr(pFunc, data);
   1.198 -	pContext->LocalToPhysAddr(params[1], &startaddr);
   1.199 -	pContext->LocalToPhysAddr(params[2], &endaddr);
   1.200 -	pContext->LocalToPhysAddr(params[3], &mins);
   1.201 -	pContext->LocalToPhysAddr(params[4], &maxs);
   1.202 -
   1.203 -	g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
   1.204 -	g_HullMins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
   1.205 -	g_HullMaxs.Init(sp_ctof(maxs[0]), sp_ctof(maxs[1]), sp_ctof(maxs[2]));
   1.206 -	g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.207 -
   1.208 -	g_Ray.Init(g_StartVec, g_EndVec, g_HullMins, g_HullMaxs);
   1.209 -	enginetrace->TraceRay(g_Ray, params[5], &g_SMTraceFilter, &g_Trace);
   1.210 -
   1.211 -	return 1;
   1.212 -}
   1.213 -
   1.214 -
   1.215 -static cell_t smn_TRTraceRayEx(IPluginContext *pContext, const cell_t *params)
   1.216 -{
   1.217 -	cell_t *startaddr, *endaddr;
   1.218 -	pContext->LocalToPhysAddr(params[1], &startaddr);
   1.219 -	pContext->LocalToPhysAddr(params[2], &endaddr);
   1.220 -
   1.221 -	Vector StartVec, EndVec;
   1.222 -	Ray_t ray;
   1.223 -
   1.224 -	StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
   1.225 -
   1.226 -	switch (params[4])
   1.227 -	{
   1.228 -	case RayType_EndPoint:
   1.229 -		{
   1.230 -			EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.231 -			break;
   1.232 -		}
   1.233 -	case RayType_Infinite:
   1.234 -		{
   1.235 -			QAngle DirAngles;
   1.236 -			DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.237 -			AngleVectors(DirAngles, &EndVec);
   1.238 -
   1.239 -			/* Make it unitary and get the ending point */
   1.240 -			EndVec.NormalizeInPlace();
   1.241 -			EndVec = StartVec + EndVec * MAX_TRACE_LENGTH;
   1.242 -			break;
   1.243 -		}
   1.244 -	}
   1.245 -
   1.246 -	trace_t *tr = new trace_t;
   1.247 -	ray.Init(StartVec, EndVec);
   1.248 -	enginetrace->TraceRay(ray, params[3], &g_HitAllFilter, tr);
   1.249 -
   1.250 -	HandleError herr;
   1.251 -	Handle_t hndl;
   1.252 -	if (!(hndl=handlesys->CreateHandle(g_TraceHandle, tr, pContext->GetIdentity(), myself->GetIdentity(), &herr)))
   1.253 -	{
   1.254 -		delete tr;
   1.255 -		return pContext->ThrowNativeError("Unable to create a new trace handle (error %d)", herr);
   1.256 -	}
   1.257 -
   1.258 -	return hndl;
   1.259 -}
   1.260 -
   1.261 -static cell_t smn_TRTraceHullEx(IPluginContext *pContext, const cell_t *params)
   1.262 -{
   1.263 -	cell_t *startaddr, *endaddr, *mins, *maxs;
   1.264 -	pContext->LocalToPhysAddr(params[1], &startaddr);
   1.265 -	pContext->LocalToPhysAddr(params[2], &endaddr);
   1.266 -	pContext->LocalToPhysAddr(params[3], &mins);
   1.267 -	pContext->LocalToPhysAddr(params[4], &maxs);
   1.268 -
   1.269 -	Ray_t ray;
   1.270 -	Vector StartVec, EndVec, vmins, vmaxs;
   1.271 -
   1.272 -	StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
   1.273 -	vmins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
   1.274 -	vmaxs.Init(sp_ctof(maxs[0]), sp_ctof(maxs[1]), sp_ctof(maxs[2]));
   1.275 -	EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.276 -
   1.277 -	ray.Init(StartVec, EndVec, vmins, vmaxs);
   1.278 -
   1.279 -	trace_t *tr = new trace_t;
   1.280 -	enginetrace->TraceRay(ray, params[5], &g_HitAllFilter, tr);
   1.281 -
   1.282 -	HandleError herr;
   1.283 -	Handle_t hndl;
   1.284 -	if (!(hndl=handlesys->CreateHandle(g_TraceHandle, tr, pContext->GetIdentity(), myself->GetIdentity(), &herr)))
   1.285 -	{
   1.286 -		delete tr;
   1.287 -		return pContext->ThrowNativeError("Unable to create a new trace handle (error %d)", herr);
   1.288 -	}
   1.289 -
   1.290 -	return hndl;
   1.291 -}
   1.292 -
   1.293 -static cell_t smn_TRTraceRayFilterEx(IPluginContext *pContext, const cell_t *params)
   1.294 -{
   1.295 -	IPluginFunction *pFunc;
   1.296 -	cell_t *startaddr, *endaddr;
   1.297 -	cell_t data;
   1.298 -
   1.299 -	pFunc = pContext->GetFunctionById(params[5]);
   1.300 -	if (!pFunc)
   1.301 -	{
   1.302 -		return pContext->ThrowNativeError("Invalid function id (%X)", params[5]);
   1.303 -	}
   1.304 -	pContext->LocalToPhysAddr(params[1], &startaddr);
   1.305 -	pContext->LocalToPhysAddr(params[2], &endaddr);
   1.306 -
   1.307 -	Vector StartVec, EndVec;
   1.308 -	CSMTraceFilter smfilter;
   1.309 -	Ray_t ray;
   1.310 -
   1.311 -	if (params[0] >= 6)
   1.312 -	{
   1.313 -		data = params[6];
   1.314 -	}
   1.315 -	else
   1.316 -	{
   1.317 -		data = 0;
   1.318 -	}
   1.319 -
   1.320 -	smfilter.SetFunctionPtr(pFunc, data);
   1.321 -	StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
   1.322 -
   1.323 -	switch (params[4])
   1.324 -	{
   1.325 -	case RayType_EndPoint:
   1.326 -		{
   1.327 -			EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.328 -			break;
   1.329 -		}
   1.330 -	case RayType_Infinite:
   1.331 -		{
   1.332 -			QAngle DirAngles;
   1.333 -			DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.334 -			AngleVectors(DirAngles, &EndVec);
   1.335 -
   1.336 -			/* Make it unitary and get the ending point */
   1.337 -			EndVec.NormalizeInPlace();
   1.338 -			EndVec = StartVec + EndVec * MAX_TRACE_LENGTH;
   1.339 -			break;
   1.340 -		}
   1.341 -	}
   1.342 -
   1.343 -	trace_t *tr = new trace_t;
   1.344 -	ray.Init(StartVec, EndVec);
   1.345 -	enginetrace->TraceRay(ray, params[3], &smfilter, tr);
   1.346 -
   1.347 -	HandleError herr;
   1.348 -	Handle_t hndl;
   1.349 -	if (!(hndl=handlesys->CreateHandle(g_TraceHandle, tr, pContext->GetIdentity(), myself->GetIdentity(), &herr)))
   1.350 -	{
   1.351 -		delete tr;
   1.352 -		return pContext->ThrowNativeError("Unable to create a new trace handle (error %d)", herr);
   1.353 -	}
   1.354 -
   1.355 -	return hndl;
   1.356 -}
   1.357 -
   1.358 -static cell_t smn_TRTraceHullFilterEx(IPluginContext *pContext, const cell_t *params)
   1.359 -{
   1.360 -	IPluginFunction *pFunc;
   1.361 -	cell_t *startaddr, *endaddr, *mins, *maxs;
   1.362 -	cell_t data;
   1.363 -
   1.364 -	pFunc = pContext->GetFunctionById(params[6]);
   1.365 -	if (!pFunc)
   1.366 -	{
   1.367 -		return pContext->ThrowNativeError("Invalid function id (%X)", params[5]);
   1.368 -	}
   1.369 -	pContext->LocalToPhysAddr(params[1], &startaddr);
   1.370 -	pContext->LocalToPhysAddr(params[2], &endaddr);
   1.371 -	pContext->LocalToPhysAddr(params[3], &mins);
   1.372 -	pContext->LocalToPhysAddr(params[4], &maxs);
   1.373 -
   1.374 -	Vector StartVec, EndVec, vmins, vmaxs;
   1.375 -	CSMTraceFilter smfilter;
   1.376 -	Ray_t ray;
   1.377 -
   1.378 -	data = params[7];
   1.379 -
   1.380 -	smfilter.SetFunctionPtr(pFunc, data);
   1.381 -	StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
   1.382 -	vmins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
   1.383 -	vmaxs.Init(sp_ctof(maxs[0]), sp_ctof(maxs[1]), sp_ctof(maxs[2]));
   1.384 -	EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
   1.385 -
   1.386 -	ray.Init(StartVec, EndVec, vmins, vmaxs);
   1.387 -
   1.388 -	trace_t *tr = new trace_t;
   1.389 -	enginetrace->TraceRay(ray, params[5], &smfilter, tr);
   1.390 -
   1.391 -	HandleError herr;
   1.392 -	Handle_t hndl;
   1.393 -	if (!(hndl=handlesys->CreateHandle(g_TraceHandle, tr, pContext->GetIdentity(), myself->GetIdentity(), &herr)))
   1.394 -	{
   1.395 -		delete tr;
   1.396 -		return pContext->ThrowNativeError("Unable to create a new trace handle (error %d)", herr);
   1.397 -	}
   1.398 -
   1.399 -	return hndl;
   1.400 -}
   1.401 -
   1.402 -static cell_t smn_TRGetFraction(IPluginContext *pContext, const cell_t *params)
   1.403 -{
   1.404 -	trace_t *tr;
   1.405 -	HandleError err;
   1.406 -	HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
   1.407 -
   1.408 -	if (params[1] == BAD_HANDLE)
   1.409 -	{
   1.410 -		tr = &g_Trace;
   1.411 -	} else if ((err = handlesys->ReadHandle(params[1], g_TraceHandle, &sec, (void **)&tr)) != HandleError_None) {
   1.412 -		return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
   1.413 -	}
   1.414 -
   1.415 -	return sp_ftoc(tr->fraction);
   1.416 -}
   1.417 -
   1.418 -static cell_t smn_TRGetPlaneNormal(IPluginContext *pContext, const cell_t *params)
   1.419 -{
   1.420 -	trace_t *tr;
   1.421 -	HandleError err;
   1.422 -	HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
   1.423 -
   1.424 -	if (params[1] == BAD_HANDLE)
   1.425 -	{
   1.426 -		tr = &g_Trace;
   1.427 -	} else if ((err = handlesys->ReadHandle(params[1], g_TraceHandle, &sec, (void **)&tr)) != HandleError_None) {
   1.428 -		return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
   1.429 -	}
   1.430 -
   1.431 -	Vector *normal = &tr->plane.normal;
   1.432 -
   1.433 -	cell_t *r;
   1.434 -	pContext->LocalToPhysAddr(params[2], &r);
   1.435 -	r[0] = sp_ftoc(normal->x);
   1.436 -	r[1] = sp_ftoc(normal->y);
   1.437 -	r[2] = sp_ftoc(normal->z);
   1.438 -
   1.439 -	return 1;
   1.440 -}
   1.441 -
   1.442 -
   1.443 -static cell_t smn_TRGetEndPosition(IPluginContext *pContext, const cell_t *params)
   1.444 -{
   1.445 -	trace_t *tr;
   1.446 -	HandleError err;
   1.447 -	HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
   1.448 -
   1.449 -	if (params[2] == BAD_HANDLE)
   1.450 -	{
   1.451 -		tr = &g_Trace;
   1.452 -	} else if ((err = handlesys->ReadHandle(params[2], g_TraceHandle, &sec, (void **)&tr)) != HandleError_None) {
   1.453 -		return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[2], err);
   1.454 -	}
   1.455 -
   1.456 -	cell_t *addr;
   1.457 -	pContext->LocalToPhysAddr(params[1], &addr);
   1.458 -
   1.459 -	addr[0] = sp_ftoc(tr->endpos.x);
   1.460 -	addr[1] = sp_ftoc(tr->endpos.y);
   1.461 -	addr[2] = sp_ftoc(tr->endpos.z);
   1.462 -
   1.463 -	return 1;
   1.464 -}
   1.465 -
   1.466 -static cell_t smn_TRDidHit(IPluginContext *pContext, const cell_t *params)
   1.467 -{
   1.468 -	trace_t *tr;
   1.469 -	HandleError err;
   1.470 -	HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
   1.471 -
   1.472 -	if (params[1] == BAD_HANDLE)
   1.473 -	{
   1.474 -		tr = &g_Trace;
   1.475 -	} else if ((err = handlesys->ReadHandle(params[1], g_TraceHandle, &sec, (void **)&tr)) != HandleError_None) {
   1.476 -		return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
   1.477 -	}
   1.478 -
   1.479 -	return tr->DidHit() ? 1 : 0;
   1.480 -}
   1.481 -
   1.482 -static cell_t smn_TRGetHitGroup(IPluginContext *pContext, const cell_t *params)
   1.483 -{
   1.484 -	trace_t *tr;
   1.485 -	HandleError err;
   1.486 -	HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
   1.487 -
   1.488 -	if (params[1] == BAD_HANDLE)
   1.489 -	{
   1.490 -		tr = &g_Trace;
   1.491 -	} else if ((err = handlesys->ReadHandle(params[1], g_TraceHandle, &sec, (void **)&tr)) != HandleError_None) {
   1.492 -		return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
   1.493 -	}
   1.494 -
   1.495 -	return tr->hitgroup;
   1.496 -}
   1.497 -
   1.498 -static cell_t smn_TRGetEntityIndex(IPluginContext *pContext, const cell_t *params)
   1.499 -{
   1.500 -	trace_t *tr;
   1.501 -	HandleError err;
   1.502 -	HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
   1.503 -
   1.504 -	if (params[1] == BAD_HANDLE)
   1.505 -	{
   1.506 -		tr = &g_Trace;
   1.507 -	} else if ((err = handlesys->ReadHandle(params[1], g_TraceHandle, &sec, (void **)&tr)) != HandleError_None) {
   1.508 -		return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
   1.509 -	}
   1.510 -
   1.511 -	edict_t *pEdict = gameents->BaseEntityToEdict(tr->m_pEnt);
   1.512 -	return engine->IndexOfEdict(pEdict);
   1.513 -}
   1.514 -
   1.515 -static cell_t smn_TRGetPointContents(IPluginContext *pContext, const cell_t *params)
   1.516 -{
   1.517 -	cell_t *vec, *ent;
   1.518 -	IHandleEntity *hentity;
   1.519 -	Vector pos;
   1.520 -	int mask;
   1.521 -
   1.522 -	pContext->LocalToPhysAddr(params[1], &vec);
   1.523 -	pContext->LocalToPhysAddr(params[2], &ent);
   1.524 -
   1.525 -	pos.x = sp_ctof(vec[0]);
   1.526 -	pos.y = sp_ctof(vec[1]);
   1.527 -	pos.z = sp_ctof(vec[2]);
   1.528 -
   1.529 -	if (*ent == -1)
   1.530 -	{
   1.531 -		mask = enginetrace->GetPointContents(pos);
   1.532 -	} else {
   1.533 -		mask = enginetrace->GetPointContents(pos, &hentity);
   1.534 -		edict_t *pEdict = gameents->BaseEntityToEdict(reinterpret_cast<CBaseEntity *>(hentity));
   1.535 -		*ent = engine->IndexOfEdict(pEdict);
   1.536 -	}
   1.537 -
   1.538 -	return mask;
   1.539 -}
   1.540 -
   1.541 -static cell_t smn_TRGetPointContentsEnt(IPluginContext *pContext, const cell_t *params)
   1.542 -{
   1.543 -	edict_t *pEdict = engine->PEntityOfEntIndex(params[1]);
   1.544 -	if (!pEdict || pEdict->IsFree())
   1.545 -	{
   1.546 -		return pContext->ThrowNativeError("Entity %d is invalid", params[1]);
   1.547 -	}
   1.548 -
   1.549 -	cell_t *addr;
   1.550 -	Vector pos;
   1.551 -
   1.552 -	pContext->LocalToPhysAddr(params[2], &addr);
   1.553 -
   1.554 -	pos.x = sp_ctof(addr[0]);
   1.555 -	pos.y = sp_ctof(addr[1]);
   1.556 -	pos.z = sp_ctof(addr[2]);
   1.557 -
   1.558 -	return enginetrace->GetPointContents_Collideable(pEdict->GetCollideable(), pos);
   1.559 -}
   1.560 -
   1.561 -sp_nativeinfo_t g_TRNatives[] = 
   1.562 -{
   1.563 -	{"TR_TraceRay",				smn_TRTraceRay},
   1.564 -	{"TR_TraceHull",			smn_TRTraceHull},
   1.565 -	{"TR_TraceRayEx",			smn_TRTraceRayEx},
   1.566 -	{"TR_TraceHullEx",			smn_TRTraceHullEx},
   1.567 -	{"TR_GetFraction",			smn_TRGetFraction},
   1.568 -	{"TR_GetEndPosition",		smn_TRGetEndPosition},
   1.569 -	{"TR_GetEntityIndex",		smn_TRGetEntityIndex},
   1.570 -	{"TR_DidHit",				smn_TRDidHit},
   1.571 -	{"TR_GetHitGroup",			smn_TRGetHitGroup},
   1.572 -	{"TR_GetPointContents",		smn_TRGetPointContents},
   1.573 -	{"TR_GetPointContentsEnt",	smn_TRGetPointContentsEnt},
   1.574 -	{"TR_TraceRayFilter",		smn_TRTraceRayFilter},
   1.575 -	{"TR_TraceRayFilterEx",		smn_TRTraceRayFilterEx},
   1.576 -	{"TR_TraceHullFilter",		smn_TRTraceHullFilter},
   1.577 -	{"TR_TraceHullFilterEx",	smn_TRTraceHullFilterEx},
   1.578 -	{"TR_GetPlaneNormal",		smn_TRGetPlaneNormal},
   1.579 -	{NULL,						NULL}
   1.580 -};