Merge pull request #259 from Nextra/engine-fix

Engine: Fix bcompat and consistency for CHECK_ENTITY
This commit is contained in:
Vincent Herbet 2015-07-13 15:45:10 +02:00
commit b145b4c651
2 changed files with 29 additions and 17 deletions

View File

@ -269,7 +269,9 @@ 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) {
CHECK_ENTITY(iEnt);
}
cell *cStart = MF_GetAmxAddr(amx, params[2]); cell *cStart = MF_GetAmxAddr(amx, params[2]);
cell *cEnd = MF_GetAmxAddr(amx, params[3]); cell *cEnd = MF_GetAmxAddr(amx, params[3]);
@ -285,7 +287,7 @@ static cell AMX_NATIVE_CALL trace_normal(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);
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iEnt), &g_tr); TRACE_LINE(vStart, vEnd, dont_ignore_monsters, iEnt > 0 ? INDEXENT2(iEnt) : NULL, &g_tr);
vRet[0] = amx_ftoc(g_tr.vecPlaneNormal.x); vRet[0] = amx_ftoc(g_tr.vecPlaneNormal.x);
vRet[1] = amx_ftoc(g_tr.vecPlaneNormal.y); vRet[1] = amx_ftoc(g_tr.vecPlaneNormal.y);
@ -300,7 +302,7 @@ static cell AMX_NATIVE_CALL trace_normal(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params) static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params)
{ {
int iEnt = params[1]; int iEnt = params[1];
if (iEnt != -1) { if (iEnt > 0) {
CHECK_ENTITY(iEnt); CHECK_ENTITY(iEnt);
} }
@ -318,10 +320,10 @@ 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) if (iEnt > 0)
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &g_tr);
else
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];
CHECK_ENTITY(params[2]); if (params[2] > 0) {
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); TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iIgnoreEnt), &tr);
else else
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iIgnoreEnt), &tr); 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;

View File

@ -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];
CHECK_ENTITY_SIMPLE(idx); if (idx > 0) {
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];
CHECK_ENTITY_SIMPLE(idx); if (idx > 0) {
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];
CHECK_ENTITY_SIMPLE(iEnt); if (iEnt > 0) {
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;
CHECK_ENTITY_SIMPLE(params[4]); if (params[4] > 0) {
CHECK_ENTITY_SIMPLE(params[4]);
}
CHECK_ENTITY(index); CHECK_ENTITY(index);
edict_t* pentFind = INDEXENT2(params[4]); edict_t* pentFind = INDEXENT2(params[4]);