ncItem: unset m_nextItem and owner fields in OnRemoveEntity, exit out of PreFrame when freed
This commit is contained in:
parent
e60556e124
commit
143e247cf3
2 changed files with 11 additions and 3 deletions
|
@ -118,6 +118,8 @@ public:
|
|||
virtual bool IsWeapon(void);
|
||||
virtual bool InInventory(void);
|
||||
|
||||
virtual void OnRemoveEntity(void);
|
||||
|
||||
private:
|
||||
/** Called to signal that the owner added this weapon to their inventory. */
|
||||
virtual void _AddedCallback(void);
|
||||
|
|
|
@ -607,7 +607,7 @@ ncItem::PredictPreFrame(void)
|
|||
m_nextItem = (ncItem)findentity(world, ::entnum, chain_entnum);
|
||||
|
||||
if (wasfreed(m_nextItem)) {
|
||||
m_nextItem = __NULL__;
|
||||
return;
|
||||
}
|
||||
|
||||
if (owner == __NULL__ && owner_entnum) {
|
||||
|
@ -617,8 +617,8 @@ ncItem::PredictPreFrame(void)
|
|||
_AddedCallback();
|
||||
|
||||
/* we may have been removed in _AddedCallback */
|
||||
if (wasfreed(this)) {
|
||||
owner = __NULL__;
|
||||
if (this && wasfreed(this)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -657,6 +657,12 @@ ncItem::PredictPostFrame(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ncItem::OnRemoveEntity(void)
|
||||
{
|
||||
m_nextItem = owner = 0;
|
||||
}
|
||||
|
||||
void
|
||||
ncItem::AddedToInventory(void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue