From 5b52c57a561c6f89585cdf933d078e054e4965c2 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Wed, 27 Sep 2023 00:25:25 -0700 Subject: [PATCH] NSIO: new method CheckOutput(string), which will see if a given Output is ready to fire again. --- src/server/NSOutput.qc | 2 ++ src/shared/NSIO.h | 4 ++++ src/shared/NSIO.qc | 13 +++++++++++++ 3 files changed, 19 insertions(+) diff --git a/src/server/NSOutput.qc b/src/server/NSOutput.qc index 56cde759..128280cf 100644 --- a/src/server/NSOutput.qc +++ b/src/server/NSOutput.qc @@ -29,6 +29,8 @@ NSOutput::TriggerOutput(void) /* we're not -1 (infinite) and we've still got one use to deduct */ if (m_iCount > 0) m_iCount--; + + nextthink = 0.0f; } void diff --git a/src/shared/NSIO.h b/src/shared/NSIO.h index 434b6cff..8ebbb2ef 100644 --- a/src/shared/NSIO.h +++ b/src/shared/NSIO.h @@ -92,6 +92,10 @@ public: Input/Output specification. */ nonvirtual string CreateOutput(string); + /** Returns whether the Output is ready, or has done firing - not currently scheduled to fire, etc. + Input is the identifier of an output. */ + nonvirtual bool CheckOutput(string); + /* save game related methods */ /** Saves a floating point key/value pair to a filehandle. */ nonvirtual void SaveFloat(float,string,float); diff --git a/src/shared/NSIO.qc b/src/shared/NSIO.qc index badd15f3..f7924c25 100644 --- a/src/shared/NSIO.qc +++ b/src/shared/NSIO.qc @@ -164,6 +164,19 @@ NSIO::CreateOutput(string outmsg) return outname; } +bool +NSIO::CheckOutput(string strOut) +{ + for (entity f = world; (f = find(f, ::targetname, strOut));) { + NSOutput op = (NSOutput)f; + + if (op.nextthink != 0.0f) + return false; + } + + return true; +} + string NSIO::PrepareOutput(string strOut, string strValue) {