gameServer/HWProtoInRoomState.hs
branchwebgl
changeset 8330 aaefa587e277
parent 8247 d7cf4a9ce685
child 8444 75db7bb8dce8
equal deleted inserted replaced
8116:d24257910f8d 8330:aaefa587e277
    54         clChan <- thisClientChans
    54         clChan <- thisClientChans
    55         othChans <- roomOthersChans
    55         othChans <- roomOthersChans
    56         roomChans <- roomClientsChans
    56         roomChans <- roomClientsChans
    57         cl <- thisClient
    57         cl <- thisClient
    58         teamColor <-
    58         teamColor <-
    59             if clientProto cl < 42 then 
    59             if clientProto cl < 42 then
    60                 return color
    60                 return color
    61                 else
    61                 else
    62                 liftM (head . (L.\\) (map B.singleton ['0'..]) . map teamcolor . teams) thisRoom
    62                 liftM (head . (L.\\) (map B.singleton ['0'..]) . map teamcolor . teams) thisRoom
    63         let newTeam = clNick `seq` TeamInfo ci clNick tName teamColor grave fort voicepack flag dif (newTeamHHNum rm) (hhsList hhsInfo)
    63         let newTeam = clNick `seq` TeamInfo ci clNick tName teamColor grave fort voicepack flag dif (newTeamHHNum rm) (hhsList hhsInfo)
    64         return $
    64         return $
   262             [ProtocolError "Not room master"]
   262             [ProtocolError "Not room master"]
   263         else
   263         else
   264             [ModifyRoom (\r -> r{isRestrictedTeams = not $ isRestrictedTeams r})]
   264             [ModifyRoom (\r -> r{isRestrictedTeams = not $ isRestrictedTeams r})]
   265 
   265 
   266 
   266 
       
   267 handleCmd_inRoom ["TOGGLE_REGISTERED_ONLY"] = do
       
   268     cl <- thisClient
       
   269     return $
       
   270         if not $ isMaster cl then
       
   271             [ProtocolError "Not room master"]
       
   272         else
       
   273             [ModifyRoom (\r -> r{isRegisteredOnly = not $ isRegisteredOnly r})]
       
   274 
   267 handleCmd_inRoom ["ROOM_NAME", newName] = do
   275 handleCmd_inRoom ["ROOM_NAME", newName] = do
   268     cl <- thisClient
   276     cl <- thisClient
   269     rs <- allRoomInfos
   277     rs <- allRoomInfos
   270     rm <- thisRoom
   278     rm <- thisRoom
   271     chans <- sameProtoChans
   279     chans <- sameProtoChans
   291     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
   299     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
   292     return
   300     return
   293         [KickRoomClient kickId | master && isJust maybeClientId && (kickId /= thisClientId) && sameRoom]
   301         [KickRoomClient kickId | master && isJust maybeClientId && (kickId /= thisClientId) && sameRoom]
   294 
   302 
   295 
   303 
       
   304 handleCmd_inRoom ["DELEGATE", newAdmin] = do
       
   305     (thisClientId, rnc) <- ask
       
   306     maybeClientId <- clientByNick newAdmin
       
   307     master <- liftM isMaster thisClient
       
   308     let newAdminId = fromJust maybeClientId
       
   309     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc newAdminId
       
   310     return
       
   311         [ChangeMaster (Just newAdminId) | master && isJust maybeClientId && (newAdminId /= thisClientId) && sameRoom]
       
   312 
       
   313 
   296 handleCmd_inRoom ["TEAMCHAT", msg] = do
   314 handleCmd_inRoom ["TEAMCHAT", msg] = do
   297     cl <- thisClient
   315     cl <- thisClient
   298     chans <- roomSameClanChans
   316     chans <- roomSameClanChans
   299     return [AnswerClients chans ["EM", engineMsg cl]]
   317     return [AnswerClients chans ["EM", engineMsg cl]]
   300     where
   318     where
   306     master <- liftM isMaster thisClient
   324     master <- liftM isMaster thisClient
   307     let banId = fromJust maybeClientId
   325     let banId = fromJust maybeClientId
   308     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc banId
   326     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc banId
   309     if master && isJust maybeClientId && (banId /= thisClientId) && sameRoom then
   327     if master && isJust maybeClientId && (banId /= thisClientId) && sameRoom then
   310         return [
   328         return [
   311                 ModifyRoom (\r -> r{roomBansList = let h = host $ rnc `client` banId in h `deepseq` h : roomBansList r})
   329 --                ModifyRoom (\r -> r{roomBansList = let h = host $ rnc `client` banId in h `deepseq` h : roomBansList r})
   312               , KickRoomClient banId
   330                 KickRoomClient banId
   313             ]
   331             ]
   314         else
   332         else
   315         return []
   333         return []
   316 
   334 
   317 
   335