From 03e309314d430f195f8f0d9cbe4d8d84c551ea46 Mon Sep 17 00:00:00 2001 Message-Id: <03e309314d430f195f8f0d9cbe4d8d84c551ea46.1714615605.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 24 Mar 2013 01:43:29 +0000 Subject: [PATCH] atoms.lisp: Call `player-turn-begin' from the main loop. Organization: Straylight/Edgeware From: Mark Wooding This will prevent huge recursion when multiple robots play each other. Also, make sure that the first player is told at the beginning of the game. --- atoms.lisp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/atoms.lisp b/atoms.lisp index 60c6470..915c53e 100644 --- a/atoms.lisp +++ b/atoms.lisp @@ -312,7 +312,7 @@ (defmethod game-next-player (game) (when (member (player-state player) '(:starting :playing)) (setf (game-player-index game) j (player-state player) :ready) - (player-turn-begin game player) + (glib:idle-add (lambda () (player-turn-begin game player) nil)) (changed game :start-turn :player player) (return)))))) @@ -386,7 +386,8 @@ (defmethod restart-game ((game atom-game) &key grid players) (setf (player-score player) 0 (player-state player) (if (zerop i) :ready :starting)))) (setf (game-player-index game) 0) - (changed game :refresh)) + (changed game :refresh) + (glib:idle-add (lambda () (player-turn-begin game (aref players 0)) nil))) ;;;-------------------------------------------------------------------------- ;;; Snapshots and undo. -- [mdw]