diff --git a/module/Core/Routine.cpp b/module/Core/Routine.cpp index 9b1a383c..ac5847d5 100644 --- a/module/Core/Routine.cpp +++ b/module/Core/Routine.cpp @@ -549,6 +549,8 @@ void Register_Routine(HSQUIRRELVM vm) .Prop(_SC("Inactive"), &Routine::GetInactive) .Prop(_SC("Persistent"), &Routine::GetPersistent, &Routine::SetPersistent) .Prop(_SC("Yields"), &Routine::GetYields, &Routine::SetYields) + .Prop(_SC("Elapsed"), &Routine::GetElapsed) + .Prop(_SC("Remaining"), &Routine::GetRemaining) .Prop(_SC("Terminated"), &Routine::GetTerminated) .Prop(_SC("Arguments"), &Routine::GetArguments) // Member Methods diff --git a/module/Core/Routine.hpp b/module/Core/Routine.hpp index e2300577..241d46c9 100644 --- a/module/Core/Routine.hpp +++ b/module/Core/Routine.hpp @@ -408,7 +408,6 @@ public: } // Unable to find such routine STHROWF("Unable to fetch a routine with tag ({}). No such routine", tag.mPtr); - SQ_UNREACHABLE // Should not reach this point but if it did, we have to return something #ifdef __clang__ #pragma clang diagnostic push @@ -418,6 +417,7 @@ public: #ifdef __clang__ #pragma clang diagnostic pop #endif + SQ_UNREACHABLE } /* -------------------------------------------------------------------------------------------- @@ -804,6 +804,32 @@ public: return (m_Slot == SQMOD_MAX_ROUTINES); } + /* -------------------------------------------------------------------------------------------- + * Retrieve the time elapsed since the routine was created or invoked. + */ + SQMOD_NODISCARD SQInteger GetElapsed() const + { + if (m_Slot >= SQMOD_MAX_ROUTINES) + { + STHROWF("This instance does not reference a valid routine"); + } + // We know it's valid so let's return it + return s_Instances[m_Slot].mInterval - s_Intervals[m_Slot]; + } + + /* -------------------------------------------------------------------------------------------- + * Retrieve the time remaining until the routine is invoked. + */ + SQMOD_NODISCARD SQInteger GetRemaining() const + { + if (m_Slot >= SQMOD_MAX_ROUTINES) + { + STHROWF("This instance does not reference a valid routine"); + } + // We know it's valid so let's return it + return s_Intervals[m_Slot]; + } + /* -------------------------------------------------------------------------------------------- * Retrieve the number of arguments to be forwarded. */