NSEntity: Add Destroy() which makes sure a sub-class is cleanly removed
from the game when possible.
This commit is contained in:
parent
f42263dbfe
commit
e4b7d55b3c
8 changed files with 30 additions and 14 deletions
|
@ -53,8 +53,7 @@ env_soundscape::SpawnKey(string strField, string strKey)
|
|||
m_iShader = Sound_Precache(strKey);
|
||||
|
||||
if (m_iShader == -1) {
|
||||
think = Util_Destroy;
|
||||
nextthink = time;
|
||||
Destroy();
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -93,10 +93,9 @@ game_counter::Trigger(entity act, int state)
|
|||
if (m_iCounted < m_iMaxCount)
|
||||
return;
|
||||
|
||||
if (spawnflags & GMCNT_REMOVE) {
|
||||
think = Util_Destroy;
|
||||
nextthink = time;
|
||||
} else if (spawnflags & GMCNT_RESET)
|
||||
if (spawnflags & GMCNT_REMOVE)
|
||||
Destroy();
|
||||
else if (spawnflags & GMCNT_RESET)
|
||||
Respawn();
|
||||
else
|
||||
m_iValue = 1;
|
||||
|
|
|
@ -81,4 +81,5 @@ class NSEntity:NSTrigger
|
|||
virtual void(vector) SetOrigin;
|
||||
virtual void(vector, vector) SetSize;
|
||||
virtual void(string, string) SpawnKey;
|
||||
nonvirtual void(void) Destroy;
|
||||
};
|
||||
|
|
|
@ -508,6 +508,27 @@ NSEntity::SpawnKey(string strKey, string strValue)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::Destroy
|
||||
|
||||
Call if the entity is to be removed the next possible frame.
|
||||
If you want an entity to be purged immediately, you'll have to jump
|
||||
through your own hoops. This however will be sufficient 99,99% of the time.
|
||||
============
|
||||
*/
|
||||
void
|
||||
NSEntity::Destroy(void)
|
||||
{
|
||||
think = Util_Destroy;
|
||||
|
||||
if (!time)
|
||||
nextthink = time + 0.01;
|
||||
else
|
||||
nextthink = time;
|
||||
};
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::NSEntity
|
||||
|
|
|
@ -115,8 +115,7 @@ func_illusionary::Init(void)
|
|||
|
||||
/* this entity is being controlled by the server, remove it */
|
||||
if (targetname) {
|
||||
think = Util_Destroy;
|
||||
nextthink = time + 0.01f; /* time may be 0.0 */
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,7 @@ func_ladder::Init(void)
|
|||
|
||||
/* this entity is being controlled by the server, remove it */
|
||||
if (targetname) {
|
||||
think = Util_Destroy;
|
||||
nextthink = time + 0.01f; /* time may be 0.0 */
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,8 +110,7 @@ func_wall::Init(void)
|
|||
|
||||
/* this entity is being controlled by the server, remove it */
|
||||
if (targetname) {
|
||||
think = Util_Destroy;
|
||||
nextthink = time + 0.01f; /* time may be 0.0 */
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,8 +173,7 @@ light_dynamic::Initialized(void)
|
|||
{
|
||||
/* we're meant to be a server controlled entity. cancel out and kill us ASAP */
|
||||
if (targetname) {
|
||||
think = Util_Destroy;
|
||||
nextthink = time + 0.1f;
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue