mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-29 08:05:46 +03:00
Allow null player pointer in CreateWeaponBox (#899)
This commit is contained in:
parent
556406009f
commit
d135a67bb7
@ -1295,7 +1295,7 @@ LINK_HOOK_CHAIN(CWeaponBox *, CreateWeaponBox, (CBasePlayerItem *pItem, CBasePla
|
|||||||
CWeaponBox *EXT_FUNC __API_HOOK(CreateWeaponBox)(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo)
|
CWeaponBox *EXT_FUNC __API_HOOK(CreateWeaponBox)(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo)
|
||||||
{
|
{
|
||||||
// create a box to pack the stuff into.
|
// create a box to pack the stuff into.
|
||||||
CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create("weaponbox", origin, angles, ENT(pPlayerOwner->pev));
|
CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create("weaponbox", origin, angles, pPlayerOwner ? ENT(pPlayerOwner->pev) : nullptr);
|
||||||
|
|
||||||
if (pWeaponBox)
|
if (pWeaponBox)
|
||||||
{
|
{
|
||||||
@ -1309,7 +1309,7 @@ CWeaponBox *EXT_FUNC __API_HOOK(CreateWeaponBox)(CBasePlayerItem *pItem, CBasePl
|
|||||||
|
|
||||||
// pack the ammo
|
// pack the ammo
|
||||||
bool exhaustibleAmmo = (pItem->iFlags() & ITEM_FLAG_EXHAUSTIBLE) == ITEM_FLAG_EXHAUSTIBLE;
|
bool exhaustibleAmmo = (pItem->iFlags() & ITEM_FLAG_EXHAUSTIBLE) == ITEM_FLAG_EXHAUSTIBLE;
|
||||||
if (exhaustibleAmmo || packAmmo)
|
if ((exhaustibleAmmo || packAmmo) && pPlayerOwner)
|
||||||
{
|
{
|
||||||
#ifndef REGAMEDLL_ADD
|
#ifndef REGAMEDLL_ADD
|
||||||
pWeaponBox->PackAmmo(MAKE_STRING(pItem->pszAmmo1()), pPlayerOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()]);
|
pWeaponBox->PackAmmo(MAKE_STRING(pItem->pszAmmo1()), pPlayerOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()]);
|
||||||
|
Loading…
Reference in New Issue
Block a user