Skip to content

Commit efc2ccc

Browse files
authored
Fix CreateWeaponBox crash on undefined owner (#366)
* Fix CreateWeaponBox crash on undefined owner * Fixed NULLENT constants in include files
1 parent 44a9b37 commit efc2ccc

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ native rg_find_ent_by_class(start_index, const classname[], const bool:useHashTa
443443
/*
444444
* Finds an entity in the world using Counter-Strike's custom FindEntityByString wrapper, matching by owner.
445445
*
446-
* @param start_index Entity index to start searching from. AMX_NULLENT (-1) to start from the first entity
446+
* @param start_index Entity index to start searching from. NULLENT (-1) to start from the first entity
447447
* @param classname Classname to search for
448448
*
449449
* @return true if found, false otherwise
@@ -532,7 +532,7 @@ native rg_remove_all_items(const index, const bool:removeSuit = false);
532532
* @param index Client index
533533
* @param item_name Item classname, if no name, the active item classname
534534
*
535-
* @return Entity index of weaponbox, AMX_NULLENT (-1) otherwise
535+
* @return Entity index of weaponbox, NULLENT (-1) otherwise
536536
*
537537
*/
538538
native rg_drop_item(const index, const item_name[]);
@@ -718,7 +718,7 @@ native rg_instant_reload_weapons(const index, const weapon = 0);
718718
* @param origin The origin of the bomb where it will be planted.
719719
* @param angles The angles of the planted bomb.
720720
*
721-
* @return Index of bomb entity or AMX_NULLENT (-1) otherwise
721+
* @return Index of bomb entity or NULLENT (-1) otherwise
722722
*/
723723
native rg_plant_bomb(const index, Float:vecOrigin[3], Float:vecAngles[3] = {0.0,0.0,0.0});
724724

@@ -994,7 +994,7 @@ native bool:rg_get_can_hear_player(const listener, const sender);
994994
*
995995
* @param index Entity id
996996
*
997-
* @return Index of head gib entity or AMX_NULLENT (-1) otherwise
997+
* @return Index of head gib entity or NULLENT (-1) otherwise
998998
*/
999999
native rg_spawn_head_gib(const index);
10001000

@@ -1020,23 +1020,23 @@ native rg_spawn_random_gibs(const index, const cGibs, const bool:bHuman = true);
10201020
* @param iTeam Grenade team, see TEAM_* constants
10211021
* @param usEvent Event index related to grenade (returned value of precache_event)
10221022
*
1023-
* @return Entity index on success, AMX_NULLENT (-1) otherwise
1023+
* @return Entity index on success, NULLENT (-1) otherwise
10241024
*/
10251025
native rg_spawn_grenade(WeaponIdType:weaponId, pevOwner, Float:vecSrc[3], Float:vecThrow[3], Float:time, TeamName:iTeam, usEvent = 0);
10261026

10271027
/*
10281028
* Spawn a weaponbox entity with its properties
10291029
*
10301030
* @param pItem Weapon entity index to attach
1031-
* @param pPlayerOwner Player index to remove pItem entity (0 = no weapon owner)
1031+
* @param pPlayerOwner Player index to remove pItem entity (NULLENT = no weapon owner)
10321032
* @param modelName Model name ("models/w_*.mdl")
10331033
* @param origin Weaponbox origin position
10341034
* @param angles Weaponbox angles
10351035
* @param velocity Weaponbox initial velocity vector
10361036
* @param lifeTime Time to stay in world (< 0.0 = use mp_item_staytime cvar value)
10371037
* @param packAmmo Set if ammo should be removed from weapon owner
10381038
*
1039-
* @return Weaponbox ent index on success, AMX_NULLENT (-1) otherwise
1039+
* @return Weaponbox ent index on success, NULLENT (-1) otherwise
10401040
*/
10411041
native rg_create_weaponbox(const pItem, const pPlayerOwner, const modelName[], Float:origin[3], Float:angles[3], Float:velocity[3], Float:lifeTime, bool:packAmmo);
10421042

reapi/src/hook_callback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ CWeaponBox *CreateWeaponBox(IReGameHook_CreateWeaponBox *chain, CBasePlayerItem
13191319
return indexOfPDataAmx(chain->callNext(getPrivate<CBasePlayerItem>(_pItem), getPrivate<CBasePlayer>(_pPlayerOwner), _modelName, vecOriginCopy, vecAnglesCopy, vecVelocityCopy, _lifeTime, _packAmmo));
13201320
};
13211321

1322-
return getPrivate<CWeaponBox>(callForward<size_t>(RG_CreateWeaponBox, original, indexOfEdictAmx(pItem->pev), indexOfEdictAmx(pPlayerOwner->pev), modelName, getAmxVector(vecOriginCopy), getAmxVector(vecAnglesCopy), getAmxVector(vecVelocityCopy), lifeTime, packAmmo));
1322+
return getPrivate<CWeaponBox>(callForward<size_t>(RG_CreateWeaponBox, original, indexOfPDataAmx(pItem), indexOfPDataAmx(pPlayerOwner), modelName, getAmxVector(vecOriginCopy), getAmxVector(vecAnglesCopy), getAmxVector(vecVelocityCopy), lifeTime, packAmmo));
13231323
}
13241324

13251325
CGib *SpawnHeadGib(IReGameHook_SpawnHeadGib *chain, entvars_t *pevVictim)

reapi/src/natives/natives_misc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,7 @@ cell AMX_NATIVE_CALL rg_spawn_grenade(AMX* amx, cell* params)
26912691
* Spawn a weaponbox entity with its properties
26922692
*
26932693
* @param pItem Weapon entity index to attach
2694-
* @param pPlayerOwner Player index to remove pItem entity (0 = no weapon owner)
2694+
* @param pPlayerOwner Player index to remove pItem entity (AMX_NULLENT = no weapon owner)
26952695
* @param modelName Model name ("models/w_*.mdl")
26962696
* @param origin Weaponbox origin position
26972697
* @param angles Weaponbox angles
@@ -2716,7 +2716,7 @@ cell AMX_NATIVE_CALL rg_create_weaponbox(AMX* amx, cell* params)
27162716

27172717
CBasePlayer *pPlayer = nullptr;
27182718

2719-
if (params[arg_player] != 0)
2719+
if (params[arg_player] > 0)
27202720
{
27212721
CHECK_ISPLAYER(arg_player);
27222722

0 commit comments

Comments
 (0)