Merge pull request #259 from Nextra/engine-fix
Engine: Fix bcompat and consistency for CHECK_ENTITY
This commit is contained in:
commit
b145b4c651
|
@ -269,38 +269,7 @@ static cell AMX_NATIVE_CALL PointContents(AMX *amx, cell *params)
|
||||||
static cell AMX_NATIVE_CALL trace_normal(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL trace_normal(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int iEnt = params[1];
|
int iEnt = params[1];
|
||||||
CHECK_ENTITY(iEnt);
|
if (iEnt > 0) {
|
||||||
|
|
||||||
cell *cStart = MF_GetAmxAddr(amx, params[2]);
|
|
||||||
cell *cEnd = MF_GetAmxAddr(amx, params[3]);
|
|
||||||
REAL fStartX = amx_ctof(cStart[0]);
|
|
||||||
REAL fStartY = amx_ctof(cStart[1]);
|
|
||||||
REAL fStartZ = amx_ctof(cStart[2]);
|
|
||||||
REAL fEndX = amx_ctof(cEnd[0]);
|
|
||||||
REAL fEndY = amx_ctof(cEnd[1]);
|
|
||||||
REAL fEndZ = amx_ctof(cEnd[2]);
|
|
||||||
|
|
||||||
cell *vRet = MF_GetAmxAddr(amx, params[4]);
|
|
||||||
|
|
||||||
Vector vStart = Vector(fStartX, fStartY, fStartZ);
|
|
||||||
Vector vEnd = Vector(fEndX, fEndY, fEndZ);
|
|
||||||
|
|
||||||
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iEnt), &g_tr);
|
|
||||||
|
|
||||||
vRet[0] = amx_ftoc(g_tr.vecPlaneNormal.x);
|
|
||||||
vRet[1] = amx_ftoc(g_tr.vecPlaneNormal.y);
|
|
||||||
vRet[2] = amx_ftoc(g_tr.vecPlaneNormal.z);
|
|
||||||
|
|
||||||
if (g_tr.flFraction >= 1.0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params)
|
|
||||||
{
|
|
||||||
int iEnt = params[1];
|
|
||||||
if (iEnt != -1) {
|
|
||||||
CHECK_ENTITY(iEnt);
|
CHECK_ENTITY(iEnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,10 +287,43 @@ static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params)
|
||||||
Vector vStart = Vector(fStartX, fStartY, fStartZ);
|
Vector vStart = Vector(fStartX, fStartY, fStartZ);
|
||||||
Vector vEnd = Vector(fEndX, fEndY, fEndZ);
|
Vector vEnd = Vector(fEndX, fEndY, fEndZ);
|
||||||
|
|
||||||
if (iEnt == -1)
|
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, iEnt > 0 ? INDEXENT2(iEnt) : NULL, &g_tr);
|
||||||
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &g_tr);
|
|
||||||
else
|
vRet[0] = amx_ftoc(g_tr.vecPlaneNormal.x);
|
||||||
|
vRet[1] = amx_ftoc(g_tr.vecPlaneNormal.y);
|
||||||
|
vRet[2] = amx_ftoc(g_tr.vecPlaneNormal.z);
|
||||||
|
|
||||||
|
if (g_tr.flFraction >= 1.0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
int iEnt = params[1];
|
||||||
|
if (iEnt > 0) {
|
||||||
|
CHECK_ENTITY(iEnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
cell *cStart = MF_GetAmxAddr(amx, params[2]);
|
||||||
|
cell *cEnd = MF_GetAmxAddr(amx, params[3]);
|
||||||
|
REAL fStartX = amx_ctof(cStart[0]);
|
||||||
|
REAL fStartY = amx_ctof(cStart[1]);
|
||||||
|
REAL fStartZ = amx_ctof(cStart[2]);
|
||||||
|
REAL fEndX = amx_ctof(cEnd[0]);
|
||||||
|
REAL fEndY = amx_ctof(cEnd[1]);
|
||||||
|
REAL fEndZ = amx_ctof(cEnd[2]);
|
||||||
|
|
||||||
|
cell *vRet = MF_GetAmxAddr(amx, params[4]);
|
||||||
|
|
||||||
|
Vector vStart = Vector(fStartX, fStartY, fStartZ);
|
||||||
|
Vector vEnd = Vector(fEndX, fEndY, fEndZ);
|
||||||
|
|
||||||
|
if (iEnt > 0)
|
||||||
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iEnt), &g_tr);
|
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iEnt), &g_tr);
|
||||||
|
else
|
||||||
|
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &g_tr);
|
||||||
|
|
||||||
edict_t *pHit = g_tr.pHit;
|
edict_t *pHit = g_tr.pHit;
|
||||||
|
|
||||||
|
@ -370,7 +372,6 @@ static cell AMX_NATIVE_CALL get_decal_index(AMX *amx, cell *params)
|
||||||
static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int iEnt = params[1];
|
int iEnt = params[1];
|
||||||
|
|
||||||
if (iEnt != -1) {
|
if (iEnt != -1) {
|
||||||
CHECK_ENTITY(iEnt);
|
CHECK_ENTITY(iEnt);
|
||||||
}
|
}
|
||||||
|
@ -636,7 +637,9 @@ static cell AMX_NATIVE_CALL playback_event(AMX *amx, cell *params)
|
||||||
int bparam1;
|
int bparam1;
|
||||||
int bparam2;
|
int bparam2;
|
||||||
flags = params[1];
|
flags = params[1];
|
||||||
|
if (params[2] > 0) {
|
||||||
CHECK_ENTITY(params[2]);
|
CHECK_ENTITY(params[2]);
|
||||||
|
}
|
||||||
pInvoker=INDEXENT2(params[2]);
|
pInvoker=INDEXENT2(params[2]);
|
||||||
eventindex=params[3];
|
eventindex=params[3];
|
||||||
delay=amx_ctof(params[4]);
|
delay=amx_ctof(params[4]);
|
||||||
|
@ -954,7 +957,7 @@ static cell AMX_NATIVE_CALL trace_forward(AMX *amx, cell *params)
|
||||||
cell *cAngles = MF_GetAmxAddr(amx, params[2]);
|
cell *cAngles = MF_GetAmxAddr(amx, params[2]);
|
||||||
REAL fGive = amx_ctof(params[3]);
|
REAL fGive = amx_ctof(params[3]);
|
||||||
int iIgnoreEnt = params[4];
|
int iIgnoreEnt = params[4];
|
||||||
if (iIgnoreEnt != -1) {
|
if (iIgnoreEnt > 0) {
|
||||||
CHECK_ENTITY(iIgnoreEnt);
|
CHECK_ENTITY(iIgnoreEnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,10 +999,10 @@ static cell AMX_NATIVE_CALL trace_forward(AMX *amx, cell *params)
|
||||||
REAL fUseZ = fStartZ + (REAL)inum;
|
REAL fUseZ = fStartZ + (REAL)inum;
|
||||||
Vector vStart = Vector(fStartX, fStartY, fUseZ);
|
Vector vStart = Vector(fStartX, fStartY, fUseZ);
|
||||||
Vector vEnd = Vector(fEndX, fEndY, fUseZ);
|
Vector vEnd = Vector(fEndX, fEndY, fUseZ);
|
||||||
if(iIgnoreEnt == -1)
|
if(iIgnoreEnt > 0)
|
||||||
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &tr);
|
|
||||||
else
|
|
||||||
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iIgnoreEnt), &tr);
|
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iIgnoreEnt), &tr);
|
||||||
|
else
|
||||||
|
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &tr);
|
||||||
fRetX = tr.vecEndPos.x;
|
fRetX = tr.vecEndPos.x;
|
||||||
fRetY = tr.vecEndPos.y;
|
fRetY = tr.vecEndPos.y;
|
||||||
fRetZ = tr.vecEndPos.z;
|
fRetZ = tr.vecEndPos.z;
|
||||||
|
|
|
@ -1338,7 +1338,9 @@ static cell AMX_NATIVE_CALL get_entity_pointer(AMX *amx, cell *params) // get_en
|
||||||
static cell AMX_NATIVE_CALL find_ent_in_sphere(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL find_ent_in_sphere(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int idx = params[1];
|
int idx = params[1];
|
||||||
|
if (idx > 0) {
|
||||||
CHECK_ENTITY_SIMPLE(idx);
|
CHECK_ENTITY_SIMPLE(idx);
|
||||||
|
}
|
||||||
|
|
||||||
edict_t *pEnt = INDEXENT2(idx);
|
edict_t *pEnt = INDEXENT2(idx);
|
||||||
cell *cAddr = MF_GetAmxAddr(amx, params[2]);
|
cell *cAddr = MF_GetAmxAddr(amx, params[2]);
|
||||||
|
@ -1360,7 +1362,9 @@ static cell AMX_NATIVE_CALL find_ent_in_sphere(AMX *amx, cell *params)
|
||||||
static cell AMX_NATIVE_CALL find_ent_by_class(AMX *amx, cell *params) /* 3 param */
|
static cell AMX_NATIVE_CALL find_ent_by_class(AMX *amx, cell *params) /* 3 param */
|
||||||
{
|
{
|
||||||
int idx = params[1];
|
int idx = params[1];
|
||||||
|
if (idx > 0) {
|
||||||
CHECK_ENTITY_SIMPLE(idx);
|
CHECK_ENTITY_SIMPLE(idx);
|
||||||
|
}
|
||||||
|
|
||||||
edict_t *pEnt = INDEXENT2(idx);
|
edict_t *pEnt = INDEXENT2(idx);
|
||||||
|
|
||||||
|
@ -1498,7 +1502,9 @@ static cell AMX_NATIVE_CALL find_ent_by_owner(AMX *amx, cell *params) // native
|
||||||
{
|
{
|
||||||
int iEnt = params[1];
|
int iEnt = params[1];
|
||||||
int oEnt = params[3];
|
int oEnt = params[3];
|
||||||
|
if (iEnt > 0) {
|
||||||
CHECK_ENTITY_SIMPLE(iEnt);
|
CHECK_ENTITY_SIMPLE(iEnt);
|
||||||
|
}
|
||||||
CHECK_ENTITY_SIMPLE(oEnt);
|
CHECK_ENTITY_SIMPLE(oEnt);
|
||||||
|
|
||||||
edict_t *pEnt = INDEXENT2(iEnt);
|
edict_t *pEnt = INDEXENT2(iEnt);
|
||||||
|
@ -1534,7 +1540,10 @@ static cell AMX_NATIVE_CALL get_grenade_id(AMX *amx, cell *params) /* 4 param *
|
||||||
int index = params[1];
|
int index = params[1];
|
||||||
const char *szModel;
|
const char *szModel;
|
||||||
|
|
||||||
|
if (params[4] > 0) {
|
||||||
CHECK_ENTITY_SIMPLE(params[4]);
|
CHECK_ENTITY_SIMPLE(params[4]);
|
||||||
|
}
|
||||||
|
|
||||||
CHECK_ENTITY(index);
|
CHECK_ENTITY(index);
|
||||||
|
|
||||||
edict_t* pentFind = INDEXENT2(params[4]);
|
edict_t* pentFind = INDEXENT2(params[4]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user