1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Add Elapsed and Remaining properties to routine.
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
Sandu Liviu Catalin 2021-11-10 17:30:21 +02:00
parent 0213ffe632
commit 6419fc0f4d
2 changed files with 29 additions and 1 deletions

View File

@ -549,6 +549,8 @@ void Register_Routine(HSQUIRRELVM vm)
.Prop(_SC("Inactive"), &Routine::GetInactive) .Prop(_SC("Inactive"), &Routine::GetInactive)
.Prop(_SC("Persistent"), &Routine::GetPersistent, &Routine::SetPersistent) .Prop(_SC("Persistent"), &Routine::GetPersistent, &Routine::SetPersistent)
.Prop(_SC("Yields"), &Routine::GetYields, &Routine::SetYields) .Prop(_SC("Yields"), &Routine::GetYields, &Routine::SetYields)
.Prop(_SC("Elapsed"), &Routine::GetElapsed)
.Prop(_SC("Remaining"), &Routine::GetRemaining)
.Prop(_SC("Terminated"), &Routine::GetTerminated) .Prop(_SC("Terminated"), &Routine::GetTerminated)
.Prop(_SC("Arguments"), &Routine::GetArguments) .Prop(_SC("Arguments"), &Routine::GetArguments)
// Member Methods // Member Methods

View File

@ -408,7 +408,6 @@ public:
} }
// Unable to find such routine // Unable to find such routine
STHROWF("Unable to fetch a routine with tag ({}). No such routine", tag.mPtr); 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 // Should not reach this point but if it did, we have to return something
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic push #pragma clang diagnostic push
@ -418,6 +417,7 @@ public:
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif
SQ_UNREACHABLE
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -804,6 +804,32 @@ public:
return (m_Slot == SQMOD_MAX_ROUTINES); 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. * Retrieve the number of arguments to be forwarded.
*/ */