mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-21 11:01:36 +00:00
- added NULL pointer checks to AActor::RemoveInventory to prevent items that destroy their owner in their use state from crashing the engine.
This commit is contained in:
parent
84f8c299ce
commit
13e98c301a
1 changed files with 12 additions and 9 deletions
|
@ -575,20 +575,23 @@ void AActor::AddInventory (AInventory *item)
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
void AActor::RemoveInventory (AInventory *item)
|
void AActor::RemoveInventory(AInventory *item)
|
||||||
{
|
{
|
||||||
AInventory *inv, **invp;
|
AInventory *inv, **invp;
|
||||||
|
|
||||||
invp = &item->Owner->Inventory;
|
if (item != NULL && item->Owner != NULL) // can happen if the owner was destroyed by some action from an item's use state.
|
||||||
for (inv = *invp; inv != NULL; invp = &inv->Inventory, inv = *invp)
|
|
||||||
{
|
{
|
||||||
if (inv == item)
|
invp = &item->Owner->Inventory;
|
||||||
|
for (inv = *invp; inv != NULL; invp = &inv->Inventory, inv = *invp)
|
||||||
{
|
{
|
||||||
*invp = item->Inventory;
|
if (inv == item)
|
||||||
item->DetachFromOwner ();
|
{
|
||||||
item->Owner = NULL;
|
*invp = item->Inventory;
|
||||||
item->Inventory = NULL;
|
item->DetachFromOwner();
|
||||||
break;
|
item->Owner = NULL;
|
||||||
|
item->Inventory = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue