Make server build again (it's still useless though)
authorunc0rr
Thu, 06 May 2010 17:53:37 +0000
changeset 3436 288fcbdb77b6
parent 3435 4e4f88a7bdf2
child 3437 858105ae769c
Make server build again (it's still useless though)
gameServer/Actions.hs
gameServer/RoomsAndClients.hs
--- a/gameServer/Actions.hs	Thu May 06 17:39:08 2010 +0000
+++ b/gameServer/Actions.hs	Thu May 06 17:53:37 2010 +0000
@@ -95,21 +95,22 @@
     infoM "Clients" (show ci ++ " quits: " ++ msg)
 
     ri <- clientRoomM rnc ci
-    when (ri /= lobbyId)
+    when (ri /= lobbyId) $ do
         processAction (ci, serverInfo, rnc) $ RoomRemoveThisClient ("quit: " ++ msg)
+        return ()
 
-    mapM_ (processAction (ci, serverInfo, rnc)) $ answerOthersQuit ++ answerInformRoom
-    writeChan (sendChan $ clients ! clID) ["BYE", msg]
-    return (
-            0,
-            serverInfo,
-            delete clID newClients,
-            adjust (\r -> r{
-                    playersIDs = IntSet.delete clID (playersIDs r),
-                    playersIn = (playersIn r) - 1,
-                    readyPlayers = if isReady client then readyPlayers r - 1 else readyPlayers r
-                    }) (roomID $ newClients ! clID) newRooms
-            )
+    --mapM_ (processAction (ci, serverInfo, rnc)) $ answerOthersQuit ++ answerInformRoom
+    --writeChan (sendChan $ clients ! clID) ["BYE", msg]
+    modifyRoom rnc (\r -> r{
+                    --playersIDs = IntSet.delete ci (playersIDs r)
+                    playersIn = (playersIn r) - 1
+                    --readyPlayers = if isReady client then readyPlayers r - 1 else readyPlayers r
+                    }) ri
+    removeClient rnc ci
+    
+    return (ci, serverInfo)
+    
+{-
     where
         client = clients ! clID
         clientNick = nick client
@@ -128,7 +129,8 @@
                 else
                     [AnswerAll ["LOBBY:LEFT", clientNick]]
             else
-                []
+            [] 
+-}
 {-
 
 processAction (clID, serverInfo, rnc) (ModifyClient func) =
--- a/gameServer/RoomsAndClients.hs	Thu May 06 17:39:08 2010 +0000
+++ b/gameServer/RoomsAndClients.hs	Thu May 06 17:53:37 2010 +0000
@@ -8,10 +8,13 @@
     addClient,
     removeRoom,
     removeClient,
+    modifyRoom,
+    modifyClient,
     lobbyId,
     moveClientToLobby,
     moveClientToRoom,
     clientRoom,
+    clientRoomM,
     client,
     allClients,
     withRoomsAndClients,
@@ -106,6 +109,12 @@
     removeElem clients ci
 
 
+modifyRoom :: MRoomsAndClients r c -> (r -> r) -> RoomIndex -> IO ()
+modifyRoom (MRoomsAndClients (rooms, _)) f (RoomIndex ri) = modifyElem rooms (\r -> r{room' = f $ room' r}) ri
+
+modifyClient :: MRoomsAndClients r c -> (c -> c) -> ClientIndex -> IO ()
+modifyClient (MRoomsAndClients (_, clients)) f (ClientIndex ci) = modifyElem clients (\c -> c{client' = f $ client' c}) ci
+
 moveClientInRooms :: MRoomsAndClients r c -> RoomIndex -> RoomIndex -> ClientIndex -> IO ()
 moveClientInRooms (MRoomsAndClients (rooms, clients)) (RoomIndex riFrom) rt@(RoomIndex riTo) cl@(ClientIndex ci) = do
     modifyElem rooms (roomRemoveClient cl) riFrom