# HG changeset patch # User unc0rr # Date 1273168417 0 # Node ID 288fcbdb77b69a40243e3edd9eaf1110d2cb92bc # Parent 4e4f88a7bdf20b51f59c1c6001a025fc966be0b0 Make server build again (it's still useless though) diff -r 4e4f88a7bdf2 -r 288fcbdb77b6 gameServer/Actions.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) = diff -r 4e4f88a7bdf2 -r 288fcbdb77b6 gameServer/RoomsAndClients.hs --- 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