# HG changeset patch # User unc0rr # Date 1427832849 -10800 # Node ID ed7717f659ae3fcf1248909770b482c6e897d17e # Parent 941b5ab9e5a6043ea9b4d195b0616da2f64a1f91 - Fix ping timeouts after incorrect "/vote" commands (protocol violation) - Add "/info" command - Add "/maxteams" command to specify desired maximum number of teams in your room diff -r 941b5ab9e5a6 -r ed7717f659ae gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Tue Mar 31 23:01:53 2015 +0300 +++ b/gameServer/CoreTypes.hs Tue Mar 31 23:14:09 2015 +0300 @@ -226,6 +226,7 @@ isRegisteredOnly :: Bool, isSpecial :: Bool, defaultHedgehogsNumber :: Int, + teamsNumberLimit :: Int, greeting :: B.ByteString, voting :: Maybe Voting, roomBansList :: ![B.ByteString], @@ -250,6 +251,7 @@ False False 4 + 8 "" Nothing [] diff -r 941b5ab9e5a6 -r ed7717f659ae gameServer/HWProtoCore.hs --- a/gameServer/HWProtoCore.hs Tue Mar 31 23:01:53 2015 +0300 +++ b/gameServer/HWProtoCore.hs Tue Mar 31 23:14:09 2015 +0300 @@ -71,12 +71,14 @@ h "WATCH" f = return [QueryReplay f] h "FIX" _ = handleCmd ["FIX"] h "UNFIX" _ = handleCmd ["UNFIX"] - h "GREETING" msg = handleCmd ["GREETING", msg] + h "GREETING" msg | not $ B.null msg = handleCmd ["GREETING", msg] h "CALLVOTE" msg | B.null msg = handleCmd ["CALLVOTE"] | otherwise = let (c, p) = extractParameters msg in if B.null p then handleCmd ["CALLVOTE", c] else handleCmd ["CALLVOTE", c, p] - h "VOTE" msg = handleCmd ["VOTE", upperCase msg] - h "FORCE" msg = handleCmd ["VOTE", upperCase msg, "FORCE"] + h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg] + h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"] + h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n] + h "INFO" n | not $ B.null n = handleCmd ["INFO", n] h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]] extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b) diff -r 941b5ab9e5a6 -r ed7717f659ae gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Tue Mar 31 23:01:53 2015 +0300 +++ b/gameServer/HWProtoInRoomState.hs Tue Mar 31 23:14:09 2015 +0300 @@ -125,7 +125,7 @@ defaultHedgehogsNumber rm let newTeam = clNick `seq` TeamInfo clNick tName teamColor grave fort voicepack flag isRegistered dif hhNum (hhsList hhsInfo) return $ - if not . null . drop (maxTeams rm - 1) $ roomTeams then + if not . null . drop (teamsNumberLimit rm) $ roomTeams then [Warning $ loc "too many teams"] else if canAddNumber roomTeams <= 0 then [Warning $ loc "too many hedgehogs"] @@ -389,6 +389,15 @@ s <- roomClientsChans return [AnswerClients s ["CHAT", n, B.unwords $ "/rnd" : rs], Random s rs] + +handleCmd_inRoom ["MAXTEAMS", n] = roomAdminOnly $ do + cl <- thisClient + let m = readInt_ n + if m < 2 || m > 8 then + return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "/maxteams: specify number from 2 to 8"]] + else + return [ModifyRoom (\r -> r{teamsNumberLimit = m})] + handleCmd_inRoom ["FIX"] = serverAdminOnly $ return [ModifyRoom (\r -> r{isSpecial = True})]