From 9518a23f0320a7a60a771080ab328e17d3ab0614 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Wed, 27 Sep 2023 00:14:44 -0700 Subject: [PATCH] NSIO: Prevent firing an output when no activator is set --- src/server/NSOutput.h | 2 ++ src/server/NSOutput.qc | 10 ++++++++++ src/shared/NSIO.qc | 9 +++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/server/NSOutput.h b/src/server/NSOutput.h index a6e39786..32fe7437 100644 --- a/src/server/NSOutput.h +++ b/src/server/NSOutput.h @@ -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. */ diff --git a/src/server/NSOutput.qc b/src/server/NSOutput.qc index 4be25994..56cde759 100644 --- a/src/server/NSOutput.qc +++ b/src/server/NSOutput.qc @@ -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 diff --git a/src/shared/NSIO.qc b/src/shared/NSIO.qc index d65e406c..badd15f3 100644 --- a/src/shared/NSIO.qc +++ b/src/shared/NSIO.qc @@ -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); } }