Fix desync between fade out/in and level loading when game is lagging.
This commit is contained in:
parent
78ce020fcb
commit
eeb95785c7
4 changed files with 33 additions and 18 deletions
|
@ -7,6 +7,7 @@
|
|||
script?
|
||||
run-script
|
||||
script-cancel!
|
||||
yield
|
||||
wait
|
||||
forever
|
||||
tween)
|
||||
|
@ -102,9 +103,8 @@
|
|||
(current-scheduler scheduler))
|
||||
(thunk)))
|
||||
handler)))
|
||||
(define (handler k delay)
|
||||
(when delay
|
||||
(scheduler-add! scheduler (lambda () (run k)) delay)))
|
||||
(define (handler k proc)
|
||||
(proc (lambda () (run k))))
|
||||
(when (script-pending? script)
|
||||
(let ((parent (current-script)))
|
||||
(when parent
|
||||
|
@ -112,20 +112,20 @@
|
|||
(run
|
||||
(lambda ()
|
||||
(set-script-state! script 'running)
|
||||
((script-cont script))
|
||||
;; Nasty hack: For some reason, falling through the prompt
|
||||
;; thunk messes up the Scheme stack, resulting in an invalid
|
||||
;; ref.cast somewhere. So, we *never* fall through. Instead,
|
||||
;; we create a continuation that gets thrown away.
|
||||
(abort-to-prompt %script-tag #f)))))
|
||||
((script-cont script))))))
|
||||
|
||||
(define (run-script thunk)
|
||||
(let ((script (make-script thunk)))
|
||||
(script-run! script)
|
||||
script))
|
||||
|
||||
(define (yield proc)
|
||||
(abort-to-prompt %script-tag proc))
|
||||
|
||||
(define (wait delay)
|
||||
(abort-to-prompt %script-tag delay))
|
||||
(yield
|
||||
(lambda (thunk)
|
||||
(scheduler-add! (current-scheduler) thunk delay))))
|
||||
|
||||
(define-syntax-rule (forever body ...)
|
||||
(let loop ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue