File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const log = require ( '../util/log' ) ;
2+ const Timer = require ( '../util/timer' ) ;
23
34/**
45 * Recycle bin for empty stackFrame objects
@@ -405,6 +406,7 @@ class Thread {
405406 * pause this thread
406407 */
407408 pause ( ) {
409+ this . pauseTime = Timer . nowObj . now ( ) ;
408410 this . originalStatus = this . status ;
409411 this . status = Thread . STATUS_PAUSED ;
410412 if ( this . timer ) this . timer . pause ( ) ;
@@ -414,7 +416,20 @@ class Thread {
414416 * unpause this thread
415417 */
416418 play ( ) {
419+ const dt = Timer . nowObj . now ( ) - this . pauseTime ;
417420 this . status = this . originalStatus ;
421+
422+ // reference the SA/TurboWarp pause addon for this
423+ // we need to update compat & execution context timers when unpausing
424+ const stackFrame = this . peekStackFrame ( ) ;
425+ if ( stackFrame && stackFrame . executionContext && stackFrame . executionContext . timer ) {
426+ stackFrame . executionContext . timer . startTime += dt ;
427+ }
428+
429+ if ( this . compatibilityStackFrame && this . compatibilityStackFrame . timer ) {
430+ this . compatibilityStackFrame . timer . startTime += dt ;
431+ }
432+
418433 if ( this . timer ) this . timer . play ( ) ;
419434 }
420435
You can’t perform that action at this time.
0 commit comments