From 539b74990eab7e3a06fd497ba3eed90af8378fe2 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Thu, 22 Aug 2019 17:47:45 +0200 Subject: [PATCH] Fix race condition issue in move handling by first recording new game state before sending it to players --- src/Automaton.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Automaton.hs b/src/Automaton.hs index cc84a9c..9d9fc84 100644 --- a/src/Automaton.hs +++ b/src/Automaton.hs @@ -67,12 +67,12 @@ receive (Session.Playing gameKey) played@(Message.Play {}) = do case result of Left message -> sendError message Right newGame -> do - Messaging.notifyPlayers newGame logs case KoiKoi.step newGame of KoiKoi.Over -> do App.debug $ "Game " ++ show gameKey ++ " ended" App.update_ $ Server.endGame gameKey _ -> App.update_ $ Server.update gameKey (const newGame) + Messaging.notifyPlayers newGame logs receive (Session.Playing gameKey) Message.Quit = do games <- (Data.get <$> App.server :: App.T (Map Game.Key Game.T))