1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-12 07:47:12 +01:00

Minor changes in tasks.

This commit is contained in:
Sandu Liviu Catalin 2016-11-17 23:09:35 +02:00
parent 659f522efa
commit 7ab1084955
2 changed files with 9 additions and 11 deletions

View File

@ -89,14 +89,12 @@ Tasks::Interval Tasks::Task::Execute()
// Validate the result // Validate the result
if (SQ_FAILED(res)) if (SQ_FAILED(res))
{ {
// Destroy ourself on error Terminate(); // Destroy ourself on error
Terminate();
} }
// Decrease the number of iterations if necessary // Decrease the number of iterations if necessary
if (mIterations && (--mIterations) == 0) if (mIterations && (--mIterations) == 0)
{ {
// This routine reached the end of it's life Terminate(); // This routine reached the end of it's life
Terminate();
} }
// Return the current interval // Return the current interval
return mInterval; return mInterval;
@ -129,7 +127,7 @@ void Tasks::Process()
// Have we completed the routine interval? // Have we completed the routine interval?
if ((*itr) <= 0) if ((*itr) <= 0)
{ {
// Reset the elapsed time // Execute and reset the elapsed time
(*itr) = s_Tasks[itr - s_Intervals].Execute(); (*itr) = s_Tasks[itr - s_Intervals].Execute();
} }
} }
@ -230,9 +228,9 @@ SQInteger Tasks::Create(Int32 id, Int32 type, HSQUIRRELVM vm)
// See if too many arguments were specified // See if too many arguments were specified
if (top > 12) /* 4 base + 8 parameters = 12 */ if (top > 12) /* 4 base + 8 parameters = 12 */
{ {
return sq_throwerror(vm, "Too many parameter specified"); return sq_throwerror(vm, "Too many parameters specified");
} }
// Was there a callback specified? // Was there was a callback specified?
else if (top <= 1) else if (top <= 1)
{ {
return sq_throwerror(vm, "Missing task callback"); return sq_throwerror(vm, "Missing task callback");
@ -318,7 +316,7 @@ SQInteger Tasks::Create(Int32 id, Int32 type, HSQUIRRELVM vm)
// Alright, at this point we can initialize the slot // Alright, at this point we can initialize the slot
task.Init(func, inst, intrv, itr, id, type); task.Init(func, inst, intrv, itr, id, type);
// Now initialize the interval // Now initialize the timer
s_Intervals[slot] = intrv; s_Intervals[slot] = intrv;
// Push the tag instance on the stack // Push the tag instance on the stack
sq_pushobject(vm, task.mSelf); sq_pushobject(vm, task.mSelf);

View File

@ -94,9 +94,9 @@ private:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string. * Used by the script engine to convert an instance of this type to a string.
*/ */
CSStr ToString() const const String & ToString() const
{ {
return ToStrF("%lld", static_cast< Int64 >(mInterval)); return mTag;
} }
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
@ -250,7 +250,7 @@ private:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Retrieve a certain argument. * Retrieve a certain argument.
*/ */
LightObj GetArgument(SQInteger arg) const const Argument & GetArgument(SQInteger arg) const
{ {
constexpr Uint32 argvn = (sizeof(mArgv) / sizeof(mArgv[0])); constexpr Uint32 argvn = (sizeof(mArgv) / sizeof(mArgv[0]));
// Cast the index to the proper value // Cast the index to the proper value