chiark / gitweb /
atoms.lisp: Call `player-turn-begin' from the main loop.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 24 Mar 2013 01:43:29 +0000 (01:43 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 24 Mar 2013 01:43:29 +0000 (01:43 +0000)
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

index 60c6470e51c7e1d77c44ff0c0b9ed29007e4e072..915c53e21aef3461f4cc5fd613ca81299c1a30ec 100644 (file)
@@ -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.