From 31ec99ef912d090ef5c6bed04380ea2c1fcaa18b Mon Sep 17 00:00:00 2001 From: dystopm Date: Fri, 26 Sep 2025 12:40:50 -0300 Subject: [PATCH 1/2] Fix CreateWeaponBox crash on undefined owner --- reapi/src/hook_callback.cpp | 2 +- reapi/src/natives/natives_misc.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index fdb723e4..7d03f922 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1319,7 +1319,7 @@ CWeaponBox *CreateWeaponBox(IReGameHook_CreateWeaponBox *chain, CBasePlayerItem return indexOfPDataAmx(chain->callNext(getPrivate(_pItem), getPrivate(_pPlayerOwner), _modelName, vecOriginCopy, vecAnglesCopy, vecVelocityCopy, _lifeTime, _packAmmo)); }; - return getPrivate(callForward(RG_CreateWeaponBox, original, indexOfEdictAmx(pItem->pev), indexOfEdictAmx(pPlayerOwner->pev), modelName, getAmxVector(vecOriginCopy), getAmxVector(vecAnglesCopy), getAmxVector(vecVelocityCopy), lifeTime, packAmmo)); + return getPrivate(callForward(RG_CreateWeaponBox, original, indexOfPDataAmx(pItem), indexOfPDataAmx(pPlayerOwner), modelName, getAmxVector(vecOriginCopy), getAmxVector(vecAnglesCopy), getAmxVector(vecVelocityCopy), lifeTime, packAmmo)); } CGib *SpawnHeadGib(IReGameHook_SpawnHeadGib *chain, entvars_t *pevVictim) diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index de49e9e0..f0da730f 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -2691,7 +2691,7 @@ cell AMX_NATIVE_CALL rg_spawn_grenade(AMX* amx, cell* params) * Spawn a weaponbox entity with its properties * * @param pItem Weapon entity index to attach -* @param pPlayerOwner Player index to remove pItem entity (0 = no weapon owner) +* @param pPlayerOwner Player index to remove pItem entity (AMX_NULLENT = no weapon owner) * @param modelName Model name ("models/w_*.mdl") * @param origin Weaponbox origin position * @param angles Weaponbox angles @@ -2716,7 +2716,7 @@ cell AMX_NATIVE_CALL rg_create_weaponbox(AMX* amx, cell* params) CBasePlayer *pPlayer = nullptr; - if (params[arg_player] != 0) + if (params[arg_player] > 0) { CHECK_ISPLAYER(arg_player); From 92e0cad4ae786fafb20080bd7e72470a888aa4bd Mon Sep 17 00:00:00 2001 From: dystopm Date: Sun, 28 Sep 2025 15:03:26 -0300 Subject: [PATCH 2/2] Fixed NULLENT constants in include files --- .../amxmodx/scripting/include/reapi_gamedll.inc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 4a891573..15b4218d 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -443,7 +443,7 @@ native rg_find_ent_by_class(start_index, const classname[], const bool:useHashTa /* * Finds an entity in the world using Counter-Strike's custom FindEntityByString wrapper, matching by owner. * -* @param start_index Entity index to start searching from. AMX_NULLENT (-1) to start from the first entity +* @param start_index Entity index to start searching from. NULLENT (-1) to start from the first entity * @param classname Classname to search for * * @return true if found, false otherwise @@ -532,7 +532,7 @@ native rg_remove_all_items(const index, const bool:removeSuit = false); * @param index Client index * @param item_name Item classname, if no name, the active item classname * -* @return Entity index of weaponbox, AMX_NULLENT (-1) otherwise +* @return Entity index of weaponbox, NULLENT (-1) otherwise * */ native rg_drop_item(const index, const item_name[]); @@ -718,7 +718,7 @@ native rg_instant_reload_weapons(const index, const weapon = 0); * @param origin The origin of the bomb where it will be planted. * @param angles The angles of the planted bomb. * -* @return Index of bomb entity or AMX_NULLENT (-1) otherwise +* @return Index of bomb entity or NULLENT (-1) otherwise */ native rg_plant_bomb(const index, Float:vecOrigin[3], Float:vecAngles[3] = {0.0,0.0,0.0}); @@ -994,7 +994,7 @@ native bool:rg_get_can_hear_player(const listener, const sender); * * @param index Entity id * -* @return Index of head gib entity or AMX_NULLENT (-1) otherwise +* @return Index of head gib entity or NULLENT (-1) otherwise */ native rg_spawn_head_gib(const index); @@ -1020,7 +1020,7 @@ native rg_spawn_random_gibs(const index, const cGibs, const bool:bHuman = true); * @param iTeam Grenade team, see TEAM_* constants * @param usEvent Event index related to grenade (returned value of precache_event) * -* @return Entity index on success, AMX_NULLENT (-1) otherwise +* @return Entity index on success, NULLENT (-1) otherwise */ native rg_spawn_grenade(WeaponIdType:weaponId, pevOwner, Float:vecSrc[3], Float:vecThrow[3], Float:time, TeamName:iTeam, usEvent = 0); @@ -1028,7 +1028,7 @@ native rg_spawn_grenade(WeaponIdType:weaponId, pevOwner, Float:vecSrc[3], Float: * Spawn a weaponbox entity with its properties * * @param pItem Weapon entity index to attach -* @param pPlayerOwner Player index to remove pItem entity (0 = no weapon owner) +* @param pPlayerOwner Player index to remove pItem entity (NULLENT = no weapon owner) * @param modelName Model name ("models/w_*.mdl") * @param origin Weaponbox origin position * @param angles Weaponbox angles @@ -1036,7 +1036,7 @@ native rg_spawn_grenade(WeaponIdType:weaponId, pevOwner, Float:vecSrc[3], Float: * @param lifeTime Time to stay in world (< 0.0 = use mp_item_staytime cvar value) * @param packAmmo Set if ammo should be removed from weapon owner * -* @return Weaponbox ent index on success, AMX_NULLENT (-1) otherwise +* @return Weaponbox ent index on success, NULLENT (-1) otherwise */ native rg_create_weaponbox(const pItem, const pPlayerOwner, const modelName[], Float:origin[3], Float:angles[3], Float:velocity[3], Float:lifeTime, bool:packAmmo);