NSIO: Prevent firing an output when no activator is set

This commit is contained in:
Marco Cawthorne 2023-09-27 00:14:44 -07:00
parent d7ddfc1c87
commit 9518a23f03
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
3 changed files with 17 additions and 4 deletions

View File

@ -36,6 +36,8 @@ public:
/** Call to trigger the NSOutput's target. */
virtual void TriggerOutput(void);
virtual void ScheduleOutput(entity);
/** Internal use only. */
virtual void Init(void);
/** Internal use only. */

View File

@ -31,6 +31,14 @@ NSOutput::TriggerOutput(void)
m_iCount--;
}
void
NSOutput::ScheduleOutput(entity activatorEnt)
{
m_eActivator = activatorEnt;
think = TriggerOutput;
nextthink = time + m_flDelay;
}
void
NSOutput::Init(void)
{
@ -44,6 +52,8 @@ NSOutput::Respawn(void)
{
/* gotta reset our counter */
m_iCount = m_iOldCount;
nextthink = 0.0f;
think = __NULL__;
}
void

View File

@ -101,7 +101,10 @@ NSIO::Spawned(void)
void
NSIO::UseOutput(entity act, string outname)
{
if (!outname)
if (!outname || outname == "")
return;
if (!act)
return;
for (entity f = world; (f = find(f, ::targetname, outname));) {
@ -112,9 +115,7 @@ NSIO::UseOutput(entity act, string outname)
return;
}
op.m_eActivator = act;
op.think = NSOutput::TriggerOutput;
op.nextthink = time + op.m_flDelay;
op.ScheduleOutput(act);
}
}