merge
authorunc0rr
Wed, 07 Nov 2012 23:08:02 +0400
changeset 8005 6d47a4f47e10
parent 8002 8113afd3858f (diff)
parent 8003 7d8bce524daf (current diff)
child 8007 b07ce9dfc6bb
merge
--- a/gameServer/CoreTypes.hs	Wed Nov 07 14:02:10 2012 -0500
+++ b/gameServer/CoreTypes.hs	Wed Nov 07 23:08:02 2012 +0400
@@ -100,7 +100,7 @@
         readyPlayers :: !Int,
         isRestrictedJoins :: Bool,
         isRestrictedTeams :: Bool,
-        roomBansList :: [B.ByteString],
+        roomBansList :: ![B.ByteString],
         mapParams :: Map.Map B.ByteString B.ByteString,
         params :: Map.Map B.ByteString [B.ByteString]
     }
--- a/gameServer/HWProtoInRoomState.hs	Wed Nov 07 14:02:10 2012 -0500
+++ b/gameServer/HWProtoInRoomState.hs	Wed Nov 07 23:08:02 2012 +0400
@@ -8,6 +8,7 @@
 import qualified Data.ByteString.Char8 as B
 import Control.Monad
 import Control.Monad.Reader
+import Control.DeepSeq
 --------------------------------------
 import CoreTypes
 import Actions
@@ -300,11 +301,18 @@
         engineMsg cl = toEngineMsg $ B.concat ["b", nick cl, "(team): ", msg, "\x20\x20"]
 
 handleCmd_inRoom ["BAN", banNick] = do
-    (_, rnc) <- ask
+    (thisClientId, rnc) <- ask
     maybeClientId <- clientByNick banNick
+    master <- liftM isMaster thisClient
     let banId = fromJust maybeClientId
-    master <- liftM isMaster thisClient
-    return [ModifyRoom (\r -> r{roomBansList = (host $ rnc `client` banId) : roomBansList r}) | master && isJust maybeClientId]
+    let sameRoom = clientRoom rnc thisClientId == clientRoom rnc banId
+    if master && isJust maybeClientId && (banId /= thisClientId) && sameRoom then
+        return [
+                ModifyRoom (\r -> r{roomBansList = let h = host $ rnc `client` banId in h `deepseq` h : roomBansList r})
+              , KickRoomClient banId
+            ]
+        else
+        return []
 
 
 handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)