Store replays for further analysis
authorunc0rr
Sat, 24 Sep 2011 21:14:51 +0400
changeset 6012 6bac93097da3
parent 6011 519f8a58c021
child 6013 4c24f064851e
Store replays for further analysis
gameServer/Actions.hs
gameServer/HWProtoInRoomState.hs
--- a/gameServer/Actions.hs	Sat Sep 24 22:16:49 2011 +0400
+++ b/gameServer/Actions.hs	Sat Sep 24 21:14:51 2011 +0400
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE CPP, OverloadedStrings #-}
 module Actions where
 
 import Control.Concurrent
@@ -507,9 +507,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
--- a/gameServer/HWProtoInRoomState.hs	Sat Sep 24 22:16:49 2011 +0400
+++ b/gameServer/HWProtoInRoomState.hs	Sat Sep 24 21:14:51 2011 +0400
@@ -166,16 +166,19 @@
         ]
 
 handleCmd_inRoom ["START_GAME"] = do
+    (ci, rnc) <- ask
     cl <- thisClient
     rm <- thisRoom
     chans <- roomClientsChans
+    
+    let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm
 
     if isMaster cl && playersIn rm == readyPlayers rm && not (isJust $ gameInfo rm) then
         if enoughClans rm then
             return [
                 ModifyRoom
                     (\r -> r{
-                        gameInfo = Just $ newGameInfo False
+                        gameInfo = Just $ newGameInfo allPlayersRegistered
                         }
                     ),
                 AnswerClients chans ["RUN_GAME"]
@@ -207,8 +210,9 @@
     chans <- roomClientsChans
 
     if isMaster cl && (isJust $ gameInfo rm) then
-        return $ 
-            ModifyRoom
+        return $
+            SaveReplay
+            : ModifyRoom
                 (\r -> r{
                     gameInfo = Nothing,
                     readyPlayers = 0