# HG changeset patch # User unc0rr # Date 1451282789 -10800 # Node ID a9957113404a15ec9ca711977fd1beb5b34993fc # Parent fe46826de2912dac36b52a09f039ac3ae35060f8 Allow only one query per session diff -r fe46826de291 -r a9957113404a gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Mon Dec 28 08:43:38 2015 +0300 +++ b/gameServer/CoreTypes.hs Mon Dec 28 09:06:29 2015 +0300 @@ -126,32 +126,33 @@ data ClientInfo = ClientInfo { - clUID :: Unique, - sendChan :: ClientChan, - clientSocket :: Socket, - host :: B.ByteString, - connectTime :: UTCTime, - nick :: B.ByteString, - webPassword :: B.ByteString, - serverSalt :: B.ByteString, - logonPassed :: Bool, - isVisible :: Bool, + clUID :: !Unique, + sendChan :: !ClientChan, + clientSocket :: !Socket, + host :: !B.ByteString, + connectTime :: !UTCTime, + nick :: !B.ByteString, + webPassword :: !B.ByteString, + serverSalt :: !B.ByteString, + logonPassed :: !Bool, + isVisible :: !Bool, clientProto :: !Word16, pingsQueue :: !Word, - isMaster :: Bool, + isMaster :: !Bool, isReady :: !Bool, - isInGame :: Bool, - isAdministrator :: Bool, - isChecker :: Bool, - isContributor :: Bool, - isKickedFromServer :: Bool, - isJoinedMidGame :: Bool, + isInGame :: !Bool, + isAdministrator :: !Bool, + isChecker :: !Bool, + isContributor :: !Bool, + isKickedFromServer :: !Bool, + isJoinedMidGame :: !Bool, + hasAskedList :: !Bool, clientClan :: !(Maybe B.ByteString), - checkInfo :: Maybe CheckInfo, + checkInfo :: !(Maybe CheckInfo), eiLobbyChat, eiEM, - eiJoin :: EventsInfo, - teamsInGame :: Word + eiJoin :: !EventsInfo, + teamsInGame :: !Word } instance Eq ClientInfo where @@ -164,17 +165,17 @@ data TeamInfo = TeamInfo { - teamowner :: B.ByteString, - teamname :: B.ByteString, - teamcolor :: B.ByteString, - teamgrave :: B.ByteString, - teamfort :: B.ByteString, - teamvoicepack :: B.ByteString, - teamflag :: B.ByteString, - isOwnerRegistered :: Bool, - difficulty :: Int, - hhnum :: Int, - hedgehogs :: [HedgehogInfo] + teamowner :: !B.ByteString, + teamname :: !B.ByteString, + teamcolor :: !B.ByteString, + teamgrave :: !B.ByteString, + teamfort :: !B.ByteString, + teamvoicepack :: !B.ByteString, + teamflag :: !B.ByteString, + isOwnerRegistered :: !Bool, + difficulty :: !Int, + hhnum :: !Int, + hedgehogs :: ![HedgehogInfo] } deriving (Show, Read) @@ -214,26 +215,26 @@ data RoomInfo = RoomInfo { - masterID :: Maybe ClientIndex, - name :: B.ByteString, - password :: B.ByteString, - roomProto :: Word16, - teams :: [TeamInfo], - gameInfo :: Maybe GameInfo, + masterID :: !(Maybe ClientIndex), + name :: !B.ByteString, + password :: !B.ByteString, + roomProto :: !Word16, + teams :: ![TeamInfo], + gameInfo :: !(Maybe GameInfo), playersIn :: !Int, readyPlayers :: !Int, - isRestrictedJoins :: Bool, - isRestrictedTeams :: Bool, - isRegisteredOnly :: Bool, - isSpecial :: Bool, - defaultHedgehogsNumber :: Int, - teamsNumberLimit :: Int, - greeting :: B.ByteString, - voting :: Maybe Voting, + isRestrictedJoins :: !Bool, + isRestrictedTeams :: !Bool, + isRegisteredOnly :: !Bool, + isSpecial :: !Bool, + defaultHedgehogsNumber :: !Int, + teamsNumberLimit :: !Int, + greeting :: !B.ByteString, + voting :: !(Maybe Voting), roomBansList :: ![B.ByteString], - mapParams :: Map.Map B.ByteString B.ByteString, - params :: Map.Map B.ByteString [B.ByteString], - roomSaves :: Map.Map B.ByteString (Map.Map B.ByteString B.ByteString, Map.Map B.ByteString [B.ByteString]) + mapParams :: !(Map.Map B.ByteString B.ByteString), + params :: !(Map.Map B.ByteString [B.ByteString]), + roomSaves :: !(Map.Map B.ByteString (Map.Map B.ByteString B.ByteString, Map.Map B.ByteString [B.ByteString])) } newRoom :: RoomInfo diff -r fe46826de291 -r a9957113404a gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Mon Dec 28 08:43:38 2015 +0300 +++ b/gameServer/HWProtoLobbyState.hs Mon Dec 28 09:06:29 2015 +0300 @@ -34,7 +34,14 @@ handleCmd_lobby :: CmdHandler -handleCmd_lobby ["LIST"] = return [] +handleCmd_lobby ["LIST"] = do + (ci, irnc) <- ask + let cl = irnc `client` ci + rooms <- allRoomInfos + let roomsInfoList = concatMap (\r -> roomInfo (clientProto cl) (maybeNick . liftM (client irnc) $ masterID r) r) . filter (\r -> (roomProto r == clientProto cl)) + return $ if hasAskedList cl then [] else + [ ModifyClient (\c -> c{hasAskedList = True}) + , AnswerClients [sendChan cl] ("ROOMS" : roomsInfoList rooms)] handleCmd_lobby ["CHAT", msg] = do n <- clientNick diff -r fe46826de291 -r a9957113404a gameServer/NetRoutines.hs --- a/gameServer/NetRoutines.hs Mon Dec 28 08:43:38 2015 +0300 +++ b/gameServer/NetRoutines.hs Mon Dec 28 09:06:29 2015 +0300 @@ -72,6 +72,7 @@ False False False + False Nothing Nothing newEventsInfo