Skip to content

Commit

Permalink
Fix game_player_equip crashing when given a null activator
Browse files Browse the repository at this point in the history
Resolves #189
  • Loading branch information
SamVanheer committed Feb 2, 2023
1 parent c20feca commit 6b649da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Updated source file encoding to UTF-8 [#183](https://github.com/SamVanheer/halflife-updated/issues/183) (Thanks anchurcn)
* Renamed `CWorld::Instance` to `CWorld::World` to avoid conflicting with `CBaseEntity::Instance` function name
* Added `-flifetime-dse=1` flag to Linux Makefile to disable compiler optimization that removed entity memory zero-initialization, resulting in the game crashing when any entity touches the world [#187](https://github.com/SamVanheer/halflife-updated/issues/187)(Thanks FreeSlave)
* Fixed game_player_equip crashing when given a null activator [#189](https://github.com/SamVanheer/halflife-updated/issues/189)

### New features

Expand Down
9 changes: 3 additions & 6 deletions dlls/maprules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,15 +834,12 @@ void CGamePlayerEquip::Touch(CBaseEntity* pOther)

void CGamePlayerEquip::EquipPlayer(CBaseEntity* pEntity)
{
CBasePlayer* pPlayer = NULL;

if (pEntity->IsPlayer())
if (!pEntity || !pEntity->IsPlayer())
{
pPlayer = (CBasePlayer*)pEntity;
return;
}

if (!pPlayer)
return;
CBasePlayer* pPlayer = (CBasePlayer*)pEntity;

for (int i = 0; i < MAX_EQUIP; i++)
{
Expand Down

0 comments on commit 6b649da

Please sign in to comment.