gameServer/HWProtoInRoomState.hs
changeset 8002 8113afd3858f
parent 7986 53b1da5ee7f4
child 8189 328f429c3ecc
equal deleted inserted replaced
8000:cd007c1780e7 8002:8113afd3858f
     6 import Data.List as L
     6 import Data.List as L
     7 import Data.Maybe
     7 import Data.Maybe
     8 import qualified Data.ByteString.Char8 as B
     8 import qualified Data.ByteString.Char8 as B
     9 import Control.Monad
     9 import Control.Monad
    10 import Control.Monad.Reader
    10 import Control.Monad.Reader
       
    11 import Control.DeepSeq
    11 --------------------------------------
    12 --------------------------------------
    12 import CoreTypes
    13 import CoreTypes
    13 import Actions
    14 import Actions
    14 import Utils
    15 import Utils
    15 import HandlerUtils
    16 import HandlerUtils
   298     return [AnswerClients chans ["EM", engineMsg cl]]
   299     return [AnswerClients chans ["EM", engineMsg cl]]
   299     where
   300     where
   300         engineMsg cl = toEngineMsg $ B.concat ["b", nick cl, "(team): ", msg, "\x20\x20"]
   301         engineMsg cl = toEngineMsg $ B.concat ["b", nick cl, "(team): ", msg, "\x20\x20"]
   301 
   302 
   302 handleCmd_inRoom ["BAN", banNick] = do
   303 handleCmd_inRoom ["BAN", banNick] = do
   303     (_, rnc) <- ask
   304     (thisClientId, rnc) <- ask
   304     maybeClientId <- clientByNick banNick
   305     maybeClientId <- clientByNick banNick
       
   306     master <- liftM isMaster thisClient
   305     let banId = fromJust maybeClientId
   307     let banId = fromJust maybeClientId
   306     master <- liftM isMaster thisClient
   308     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc banId
   307     return [ModifyRoom (\r -> r{roomBansList = (host $ rnc `client` banId) : roomBansList r}) | master && isJust maybeClientId]
   309     if master && isJust maybeClientId && (banId /= thisClientId) && sameRoom then
       
   310         return [
       
   311                 ModifyRoom (\r -> r{roomBansList = let h = host $ rnc `client` banId in h `deepseq` h : roomBansList r})
       
   312               , KickRoomClient banId
       
   313             ]
       
   314         else
       
   315         return []
   308 
   316 
   309 
   317 
   310 handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)
   318 handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)
   311 
   319 
   312 handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"]
   320 handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"]