Wait till we finish drawing and watching to commit state

This commit is contained in:
Joseph Ferano 2026-09-05 11:17:34 +07:00
parent a2f53900f9
commit 0732d473b7

View File

@ -84,17 +84,15 @@
(let [config (:config @game-config)]
(try
(doseq [buf @buffered-objs] (snapshot! buf))
(swap! game-state #(update config %))
(catch Throwable t
(doseq [buf @buffered-objs]
(restore! buf))
(report-exception! t)))
(rl/with-drawing!
(try
(draw config @game-state)
(w/watch! (watch-fn config @game-state))
(catch Throwable t
(report-exception! t)))))))
(let [updated-state (update config @game-state)]
(rl/with-drawing!
(draw config updated-state)
(w/watch! (watch-fn config updated-state))
(swap! game-state updated-state)
(catch Throwable t
(doseq [buf @buffered-objs]
(restore! buf))
(report-exception! t))))))))
(try
(when unload
(doseq [[_ tex] @texture-cache]