# HG changeset patch # User unc0rr # Date 1451328672 -10800 # Node ID 4b5c7a5c49fd9b45775fe72568e2315f07e33a78 # Parent 0ae2e4c13bd1798ca1d2f266157240cb43590046 Defer kicking to the time when everything is in consistent state diff -r 0ae2e4c13bd1 -r 4b5c7a5c49fd gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Mon Dec 28 21:21:02 2015 +0300 +++ b/gameServer/CoreTypes.hs Mon Dec 28 21:51:12 2015 +0300 @@ -152,7 +152,8 @@ eiLobbyChat, eiEM, eiJoin :: !EventsInfo, - teamsInGame :: !Word + teamsInGame :: !Word, + pendingActions :: ![Action] } instance Eq ClientInfo where diff -r 0ae2e4c13bd1 -r 4b5c7a5c49fd gameServer/FloodDetection.hs --- a/gameServer/FloodDetection.hs Mon Dec 28 21:21:02 2015 +0300 +++ b/gameServer/FloodDetection.hs Mon Dec 28 21:51:12 2015 +0300 @@ -49,7 +49,7 @@ chat1 = [Warning $ loc "Warning! Chat flood protection activated"] chat2 = [ByeClient $ loc "Excess flood"] em1 = [Warning $ loc "Game messages flood detected - 1"] - em2 = [Warning $ loc "Game messages flood detected - 2"] + em2 = [ByeClient $ loc "Excess flood"] join1 = [Warning $ loc "Warning! Joins flood protection activated"] join2 = [ByeClient $ loc "Excess flood"] @@ -69,7 +69,9 @@ else [] - return $ (ModifyClient . transformField e . const $ (numPerEntry, curTime) : nei) : actions + return $ [ModifyClient . transformField e . const $ (numPerEntry, curTime) : nei + , ModifyClient (\c -> c{pendingActions = actions}) -- append? prepend? just replacing for now + ] updateInfo = return [ ModifyClient $ transformField e diff -r 0ae2e4c13bd1 -r 4b5c7a5c49fd gameServer/HWProtoCore.hs --- a/gameServer/HWProtoCore.hs Mon Dec 28 21:21:02 2015 +0300 +++ b/gameServer/HWProtoCore.hs Mon Dec 28 21:51:12 2015 +0300 @@ -94,9 +94,12 @@ h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"] h "REGISTERED_ONLY" _ = do cl <- thisClient - return [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s}) + return $ if isAdministrator cl then + [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s}) , AnswerClients [sendChan cl] ["CHAT", "[server]", "'Registered only' state toggled"] ] + else + [] 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 0ae2e4c13bd1 -r 4b5c7a5c49fd gameServer/NetRoutines.hs --- a/gameServer/NetRoutines.hs Mon Dec 28 21:21:02 2015 +0300 +++ b/gameServer/NetRoutines.hs Mon Dec 28 21:51:12 2015 +0300 @@ -79,6 +79,7 @@ newEventsInfo newEventsInfo 0 + [] ) writeChan chan $ Accept newClient diff -r 0ae2e4c13bd1 -r 4b5c7a5c49fd gameServer/ServerCore.hs --- a/gameServer/ServerCore.hs Mon Dec 28 21:21:02 2015 +0300 +++ b/gameServer/ServerCore.hs Mon Dec 28 21:51:12 2015 +0300 @@ -23,7 +23,7 @@ import System.Log.Logger import Control.Monad.Reader import Control.Monad.State.Strict -import Data.Set as Set +import Data.Set as Set hiding (null) import Data.Unique import Data.Maybe -------------------------------------- @@ -55,6 +55,10 @@ unless (ci `Set.member` removed) $ do modify (\s -> s{clientIndex = Just ci}) processAction $ ReactCmd cmd + pa <- client's pendingActions + when (not $ null pa) $ do + mapM_ processAction pa + processAction $ ModifyClient $ \c -> c{pendingActions = []} Remove ci -> processAction (DeleteClient ci)