Fix crash when old room admin becomes new room admin
authorunc0rr
Sun, 03 Apr 2011 16:31:40 +0400
changeset 5092 28e0a6d2d09a
parent 5091 288dcbda3b77
child 5093 7eb35faa7f7a
Fix crash when old room admin becomes new room admin
gameServer/Actions.hs
--- a/gameServer/Actions.hs	Sun Apr 03 13:34:04 2011 +0400
+++ b/gameServer/Actions.hs	Sun Apr 03 16:31:40 2011 +0400
@@ -219,9 +219,10 @@
         moveClientToLobby rnc ci
 
 processAction ChangeMaster = do
+    (Just ci) <- gets clientIndex
     ri <- clientRoomA
     rnc <- gets roomsClients
-    newMasterId <- liftM head . io $ roomClientsIndicesM rnc ri
+    newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri
     newMaster <- io $ client'sM rnc id newMasterId
     let newRoomName = nick newMaster
     mapM_ processAction [
@@ -407,7 +408,7 @@
         [
             AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion]
             , CheckBanned
-            , AddIP2Bans (host cl) "Reconnected too fast" (addUTCTime 10 $ connectTime cl)
+--            , AddIP2Bans (host cl) "Reconnected too fast" (addUTCTime 10 $ connectTime cl)
         ]