Skip to content

Commit

Permalink
Fix a crash with set_tr/2 when -1 is passed in TR_pHit + allow worlds…
Browse files Browse the repository at this point in the history
…pawn (0) in set_tr/2 (#601)

* Fix a crash with set_ptr2 when -1 is passed in TR_pHit

* Allow wordspawn in set_tr|2(TR_pHit, ...)
  • Loading branch information
Arkshine committed Sep 28, 2018
1 parent 05bd01c commit d867a95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions modules/fakemeta/fm_tr.cpp
Expand Up @@ -27,7 +27,6 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
}

cell *ptr = MF_GetAmxAddr(amx, params[2]);
edict_t *e;

switch (type)
{
Expand Down Expand Up @@ -85,12 +84,13 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
}
case TR_pHit:
{
e = TypeConversion.id_to_edict(*ptr);
if (*ptr != -1 && FNullEnt(e))
return 0; //TODO: return error
gfm_tr->pHit = e;
const auto pEdict = TypeConversion.id_to_edict(*ptr);
if (pEdict == nullptr)
{
return 0;
}
gfm_tr->pHit = pEdict;
return 1;
break;
}
case TR_iHitgroup:
{
Expand Down
11 changes: 6 additions & 5 deletions modules/fakemeta/fm_tr2.cpp
Expand Up @@ -98,12 +98,13 @@ static cell AMX_NATIVE_CALL set_tr2(AMX *amx, cell *params)
}
case TR_pHit:
{
edict_t *e = TypeConversion.id_to_edict(*ptr);
if (*ptr != -1 && FNullEnt(e))
return 0; //TODO: return error
tr->pHit = e;
const auto pEdict = TypeConversion.id_to_edict(*ptr);
if (pEdict == nullptr)
{
return 0;
}
tr->pHit = pEdict;
return 1;
break;
}
case TR_iHitgroup:
{
Expand Down

0 comments on commit d867a95

Please sign in to comment.