gameServer/Actions.hs
changeset 6101 5a4ea2c7b9df
parent 6068 e18713ecf1e0
child 6191 190a8e5d9956
--- a/gameServer/Actions.hs	Sat Oct 08 16:45:52 2011 +0200
+++ b/gameServer/Actions.hs	Sat Oct 08 16:54:56 2011 +0200
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE CPP, OverloadedStrings #-}
 module Actions where
 
 import Control.Concurrent
@@ -17,16 +17,17 @@
 import Data.Unique
 import Control.Arrow
 import Control.Exception
-import OfficialServer.GameReplayStore
 import System.Process
 import Network.Socket
 -----------------------------
+import OfficialServer.GameReplayStore
 import CoreTypes
 import Utils
 import ClientIO
 import ServerState
 import Consts
 import ConfigFile
+import EngineInteraction
 
 data Action =
     AnswerClients ![ClientChan] ![B.ByteString]
@@ -206,7 +207,7 @@
     (Just ci) <- gets clientIndex
     ri <- clientRoomA
     rnc <- gets roomsClients
-    (gameProgress, playersNum) <- io $ room'sM rnc (gameinprogress &&& playersIn) ri
+    (gameProgress, playersNum) <- io $ room'sM rnc ((isJust . gameInfo) &&& playersIn) ri
     ready <- client's isReady
     master <- client's isMaster
 --    client <- client's id
@@ -298,7 +299,7 @@
 processAction (RemoveTeam teamName) = do
     rnc <- gets roomsClients
     ri <- clientRoomA
-    inGame <- io $ room'sM rnc gameinprogress ri
+    inGame <- io $ room'sM rnc (isJust . gameInfo) ri
     chans <- othersChans
     if not $ inGame then
             mapM_ processAction [
@@ -310,8 +311,10 @@
                 AnswerClients chans ["EM", rmTeamMsg],
                 ModifyRoom (\r -> r{
                     teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r,
-                    leftTeams = teamName : leftTeams r,
-                    roundMsgs = roundMsgs r Seq.|> rmTeamMsg
+                        gameInfo = liftM (\g -> g{
+                        leftTeams = teamName : leftTeams g,
+                        roundMsgs = roundMsgs g Seq.|> rmTeamMsg
+                        }) $ gameInfo r
                     })
                 ]
     where
@@ -505,9 +508,13 @@
             return ()
         processAction $ ModifyServerInfo (\s -> s{shutdownPending = True})
 
+#if defined(OFFICIAL_SERVER)
 processAction SaveReplay = do
     ri <- clientRoomA
     rnc <- gets roomsClients
     io $ do
         r <- room'sM rnc id ri
         saveReplay r
+#else
+processAction SaveReplay = return ()
+#endif