Fixed traceresults and trace hooks..

This commit is contained in:
Steve Dudenhoeffer 2004-09-15 18:40:18 +00:00
parent 0ea68c81dc
commit 1485014229
4 changed files with 53 additions and 52 deletions

View File

@ -1,5 +1,7 @@
#include "fakemeta_amxx.h"
TraceResult *gfm_tr;
/*enum
{
TR_AllSolid,
@ -16,60 +18,59 @@
static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
{
cell *cPtr = &params[1];
int type = params[2];
TraceResult *tr = (TraceResult*)((void *)cPtr);
int type = params[1];
//TraceResult *tr = (TraceResult*)((void *)cPtr);
if (*params / sizeof(cell) < 3)
if (*params / sizeof(cell) < 2)
return 0; //TODO: Error
cell *ptr = MF_GetAmxAddr(amx, params[3]);
cell *ptr = MF_GetAmxAddr(amx, params[2]);
edict_t *e = 0;
switch (type)
{
case TR_AllSolid:
{
tr->fAllSolid = *ptr;
gfm_tr->fAllSolid = *ptr;
return 1;
break;
}
case TR_StartSolid:
{
return tr->fStartSolid;
return gfm_tr->fStartSolid;
break;
}
case TR_InWater:
{
tr->fInWater = *ptr;
gfm_tr->fInWater = *ptr;
return 1;
break;
}
case TR_flFraction:
{
tr->flFraction = amx_ctof(*ptr);
gfm_tr->flFraction = amx_ctof(*ptr);
return 1;
break;
}
case TR_vecEndPos:
{
tr->vecEndPos.x = amx_ctof(ptr[0]);
tr->vecEndPos.y = amx_ctof(ptr[1]);
tr->vecEndPos.z = amx_ctof(ptr[2]);
gfm_tr->vecEndPos.x = amx_ctof(ptr[0]);
gfm_tr->vecEndPos.y = amx_ctof(ptr[1]);
gfm_tr->vecEndPos.z = amx_ctof(ptr[2]);
return 1;
break;
}
case TR_flPlaneDist:
{
tr->flPlaneDist = amx_ctof(*ptr);
gfm_tr->flPlaneDist = amx_ctof(*ptr);
return 1;
break;
}
case TR_vecPlaneNormal:
{
tr->vecPlaneNormal.x = amx_ctof(ptr[0]);
tr->vecPlaneNormal.y = amx_ctof(ptr[1]);
tr->vecPlaneNormal.z = amx_ctof(ptr[2]);
gfm_tr->vecPlaneNormal.x = amx_ctof(ptr[0]);
gfm_tr->vecPlaneNormal.y = amx_ctof(ptr[1]);
gfm_tr->vecPlaneNormal.z = amx_ctof(ptr[2]);
return 1;
break;
}
@ -78,13 +79,13 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
e = INDEXENT(*ptr);
if (!e || FNullEnt(e))
return 0; //TODO: return error
tr->pHit = e;
gfm_tr->pHit = e;
return 1;
break;
}
case TR_iHitgroup:
{
tr->iHitgroup = *ptr;
gfm_tr->iHitgroup = *ptr;
return 1;
break;
}
@ -98,68 +99,66 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_tr(AMX *amx, cell *params)
{
cell *cPtr = &params[1];
int type = params[2];
TraceResult *tr = (TraceResult*)((void *)cPtr);
int type = params[1];
cell *ptr = 0;
switch (type)
{
case TR_AllSolid:
{
return tr->fAllSolid;
return gfm_tr->fAllSolid;
break;
}
case TR_StartSolid:
{
return tr->fStartSolid;
return gfm_tr->fStartSolid;
break;
}
case TR_InWater:
{
return tr->fInWater;
return gfm_tr->fInWater;
break;
}
case TR_flFraction:
{
ptr = MF_GetAmxAddr(amx, params[3]);
*ptr = amx_ftoc(tr->flFraction);
ptr = MF_GetAmxAddr(amx, params[2]);
*ptr = amx_ftoc(gfm_tr->flFraction);
return 1;
break;
}
case TR_vecEndPos:
{
ptr = MF_GetAmxAddr(amx, params[3]);
ptr[0] = amx_ftoc(tr->vecEndPos.x);
ptr[1] = amx_ftoc(tr->vecEndPos.y);
ptr[2] = amx_ftoc(tr->vecEndPos.z);
ptr = MF_GetAmxAddr(amx, params[2]);
ptr[0] = amx_ftoc(gfm_tr->vecEndPos.x);
ptr[1] = amx_ftoc(gfm_tr->vecEndPos.y);
ptr[2] = amx_ftoc(gfm_tr->vecEndPos.z);
return 1;
break;
}
case TR_flPlaneDist:
{
ptr = MF_GetAmxAddr(amx, params[3]);
*ptr = amx_ftoc(tr->flPlaneDist);
ptr = MF_GetAmxAddr(amx, params[2]);
*ptr = amx_ftoc(gfm_tr->flPlaneDist);
return 1;
break;
}
case TR_vecPlaneNormal:
{
ptr = MF_GetAmxAddr(amx, params[3]);
ptr[0] = amx_ftoc(tr->vecPlaneNormal.x);
ptr[1] = amx_ftoc(tr->vecPlaneNormal.y);
ptr[2] = amx_ftoc(tr->vecPlaneNormal.z);
ptr = MF_GetAmxAddr(amx, params[2]);
ptr[0] = amx_ftoc(gfm_tr->vecPlaneNormal.x);
ptr[1] = amx_ftoc(gfm_tr->vecPlaneNormal.y);
ptr[2] = amx_ftoc(gfm_tr->vecPlaneNormal.z);
return 1;
break;
}
case TR_pHit:
{
return ENTINDEX(tr->pHit);
return ENTINDEX(gfm_tr->pHit);
break;
}
case TR_iHitgroup:
{
return tr->iHitgroup;
return gfm_tr->iHitgroup;
break;
}
default:

View File

@ -1,6 +1,8 @@
#ifndef _INCLUDE_TR_H
#define _INCLUDE_TR_H
extern TraceResult *gfm_tr;
enum
{
TR_AllSolid,

View File

@ -92,22 +92,22 @@ void SetModel_post(edict_t *e, const char *m)
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
{
TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr); //from fun module - prevents crash? - t(+)rget/freecode
cell vec1[3] = {amx_ftoc(v1[0]), amx_ftoc(v1[1]), amx_ftoc(v1[2])};
cell vec2[3] = {amx_ftoc(v2[0]), amx_ftoc(v2[1]), amx_ftoc(v2[2])};
cell retvec1 = MF_PrepareCellArray(vec1, 3);
cell retvec2 = MF_PrepareCellArray(vec2, 3);
FM_ENG_HANDLE(FM_TraceLine, (Engine[FM_TraceLine].at(i), retvec1, retvec2, fNoMonsters, ENTINDEX(pentToSkip), (cell)ptr));
/*
TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr); //from fun module - prevents crash? - t(+)rget/freecode // well i guess that's what you get for listening, isnt it? =/
*/
gfm_tr=ptr;
PREPARE_VECTOR(v1);
PREPARE_VECTOR(v2);
FM_ENG_HANDLE(FM_TraceLine, (Engine[FM_TraceLine].at(i), p_v1, p_v2, fNoMonsters, ENTINDEX(pentToSkip) /*, (cell)ptr*/));
RETURN_META(mswi(lastFmRes));
}
void TraceLine_post(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
{
cell vec1[3] = {amx_ftoc(v1[0]), amx_ftoc(v1[1]), amx_ftoc(v1[2])};
cell vec2[3] = {amx_ftoc(v2[0]), amx_ftoc(v2[1]), amx_ftoc(v2[2])};
cell retvec1 = MF_PrepareCellArray(vec1, 3);
cell retvec2 = MF_PrepareCellArray(vec2, 3);
FM_ENG_HANDLE(FM_TraceLine, (Engine[FM_TraceLine].at(i), retvec1, retvec2, fNoMonsters, ENTINDEX(pentToSkip), (cell)ptr));
gfm_tr=ptr;
PREPARE_VECTOR(v1);
PREPARE_VECTOR(v2);
FM_ENG_HANDLE_POST(FM_TraceLine, (EnginePost[FM_TraceLine].at(i), p_v1, p_v2, fNoMonsters, ENTINDEX(pentToSkip)/*, (cell)ptr*/));
RETURN_META(MRES_IGNORED);
}
@ -590,7 +590,7 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
ENGHOOK(EmitAmbientSound);
break;
case FM_TraceLine:
fId = MF_RegisterSPForwardByName(amx, funcname, FP_ARRAY, FP_ARRAY, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
fId = MF_RegisterSPForwardByName(amx, funcname, FP_ARRAY, FP_ARRAY, FP_CELL, FP_CELL, FP_DONE);
ENGHOOK(TraceLine);
break;
case FM_TraceToss:

View File

@ -40,5 +40,5 @@ native dllfunc(type,{Float,Sql,Result,_}:...);
//only use this with functions that pass a Trace
// get: zero extra params - return int, one extra param = byref float or vector
// set: use anything
native get_tr(Trace:tr, TraceResult:tr_member, {Float,_}:...);
native set_tr(Trace:tr, TraceResult:tr_member, {Float,_}:...);
native get_tr(TraceResult:tr_member, {Float,_}:...);
native set_tr(TraceResult:tr_member, {Float,_}:...);