# HG changeset patch # User unc0rr # Date 1238698148 0 # Node ID e71c24f114838259b298de1c85529d2f6ee2d458 # Parent 7e6cc8da1c586bcb33a16211d8d118dd064b025b Fix server crash (properly follow client's state) diff -r 7e6cc8da1c58 -r e71c24f11483 gameServer/Actions.hs --- a/gameServer/Actions.hs Sat Mar 28 10:42:00 2009 +0000 +++ b/gameServer/Actions.hs Thu Apr 02 18:49:08 2009 +0000 @@ -112,8 +112,11 @@ processAction (clID, serverInfo, clients, rooms) (ByeClient msg) = do (_, _, newClients, newRooms) <- - processAction (clID, serverInfo, clients, rooms) + if roomID client /= 0 then + processAction (clID, serverInfo, clients, rooms) (if isMaster client then RemoveRoom else RemoveClientTeams clID) + else + return (clID, serverInfo, clients, rooms) mapM_ (processAction (clID, serverInfo, newClients, newRooms)) $ answerOthersQuit ++ answerInformRoom writeChan (sendChan $ clients ! clID) ["BYE", msg] @@ -125,11 +128,10 @@ playersIDs = IntSet.delete clID (playersIDs r), playersIn = (playersIn r) - 1, readyPlayers = if isReady client then readyPlayers r - 1 else readyPlayers r - }) rID newRooms + }) (roomID $ newClients ! clID) newRooms ) where client = clients ! clID - rID = roomID client clientNick = nick client answerInformRoom = if roomID client /= 0 then @@ -340,10 +342,10 @@ let newLogins = takeWhile (\(_ , time) -> (connectTime client) `diffUTCTime` time <= 20) $ lastLogins serverInfo - if isJust $ host client `Prelude.lookup` newLogins then - processAction (clID, serverInfo{lastLogins = newLogins}, updatedClients, rooms) $ ByeClient "Reconnected too fast" - else - return (clID, serverInfo{lastLogins = (host client, connectTime client) : newLogins}, updatedClients, rooms) +-- if isJust $ host client `Prelude.lookup` newLogins then +-- processAction (clID, serverInfo{lastLogins = newLogins}, updatedClients, rooms) $ ByeClient "Reconnected too fast" +-- else + return (clID, serverInfo{lastLogins = (host client, connectTime client) : newLogins}, updatedClients, rooms) processAction (clID, serverInfo, clients, rooms) PingAll = do