# HG changeset patch # User unc0rr # Date 1344885429 -14400 # Node ID 833a0c34fafc3881f8f8b6461a9f678823cfae68 # Parent 87e5838103ffc1c4d5f78fe2366bf562d4ef9d76 Room bans. They're more simple, than the global ones: if you ban someone, he is banned by ip in this room for the rest of the room lifetime. Not tested. diff -r 87e5838103ff -r 833a0c34fafc QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Mon Aug 13 23:04:42 2012 +0400 +++ b/QTfrontend/ui/widget/chatwidget.cpp Mon Aug 13 23:17:09 2012 +0400 @@ -922,7 +922,7 @@ if(b) { chatNicks->insertAction(0, acKick); -// chatNicks->insertAction(0, acBan); + chatNicks->insertAction(0, acBan); } } diff -r 87e5838103ff -r 833a0c34fafc gameServer/Actions.hs --- a/gameServer/Actions.hs Mon Aug 13 23:04:42 2012 +0400 +++ b/gameServer/Actions.hs Mon Aug 13 23:17:09 2012 +0400 @@ -469,9 +469,9 @@ processAction BanList = do ch <- client's sendChan - bans <- gets (bans . serverInfo) + bans <- gets (B.pack . unlines . map show . bans . serverInfo) processAction $ - AnswerClients [ch] ["BANLIST", B.pack $ show bans] + AnswerClients [ch] ["BANLIST", bans] diff -r 87e5838103ff -r 833a0c34fafc gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Mon Aug 13 23:04:42 2012 +0400 +++ b/gameServer/CoreTypes.hs Mon Aug 13 23:17:09 2012 +0400 @@ -94,6 +94,7 @@ readyPlayers :: !Int, isRestrictedJoins :: Bool, isRestrictedTeams :: Bool, + roomBansList :: [B.ByteString], mapParams :: Map.Map B.ByteString B.ByteString, params :: Map.Map B.ByteString [B.ByteString] } @@ -111,6 +112,7 @@ 0 False False + [] ( Map.fromList $ Prelude.zipWith (,) ["MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"] diff -r 87e5838103ff -r 833a0c34fafc gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Mon Aug 13 23:04:42 2012 +0400 +++ b/gameServer/HWProtoInRoomState.hs Mon Aug 13 23:17:09 2012 +0400 @@ -278,6 +278,14 @@ where engineMsg cl = toEngineMsg $ B.concat ["b", nick cl, "(team): ", msg, "\x20\x20"] +handleCmd_inRoom ["BAN", banNick] = do + (_, rnc) <- ask + maybeClientId <- clientByNick banNick + let banId = fromJust maybeClientId + master <- liftM isMaster thisClient + return [ModifyRoom (\r -> r{roomBansList = (host $ rnc `client` banId) : roomBansList r}) | master && isJust maybeClientId] + + handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17) handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"] diff -r 87e5838103ff -r 833a0c34fafc gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Mon Aug 13 23:04:42 2012 +0400 +++ b/gameServer/HWProtoLobbyState.hs Mon Aug 13 23:17:09 2012 +0400 @@ -70,11 +70,14 @@ let jRoomClients = map (client irnc) $ roomClients irnc jRI let nicks = map nick jRoomClients let chans = map sendChan (cl : jRoomClients) + let isBanned = host cl `elem` roomBansList jRoom return $ if isNothing maybeRI || not sameProto then [Warning "No such room"] else if isRestrictedJoins jRoom then [Warning "Joining restricted"] + else if isBanned then + [Warning "You are banned in this room"] else if roomPassword /= password jRoom then [NoticeMessage WrongPassword] else @@ -183,7 +186,7 @@ handleCmd_lobby ["RESTART_SERVER"] = do cl <- thisClient - return [RestartServer] + return [RestartServer | isAdministrator cl] handleCmd_lobby _ = return [ProtocolError "Incorrect command (state: in lobby)"]