gameServer/Utils.hs
branchsdl2transition
changeset 9798 f2b18754742f
parent 9753 9579596cf471
child 9837 fa94ee96f006
equal deleted inserted replaced
9711:7d0329f37181 9798:f2b18754742f
   123 caseInsensitiveCompare a b = upperCase a == upperCase b
   123 caseInsensitiveCompare a b = upperCase a == upperCase b
   124 
   124 
   125 upperCase :: B.ByteString -> B.ByteString
   125 upperCase :: B.ByteString -> B.ByteString
   126 upperCase = UTF8.fromString . map Char.toUpper . UTF8.toString
   126 upperCase = UTF8.fromString . map Char.toUpper . UTF8.toString
   127 
   127 
   128 roomInfo :: B.ByteString -> RoomInfo -> [B.ByteString]
   128 roomInfo :: Word16 -> B.ByteString -> RoomInfo -> [B.ByteString]
   129 roomInfo n r = [
   129 roomInfo p n r 
       
   130     | p < 46 = [
   130         showB $ isJust $ gameInfo r,
   131         showB $ isJust $ gameInfo r,
   131         name r,
   132         name r,
   132         showB $ playersIn r,
   133         showB $ playersIn r,
   133         showB $ length $ teams r,
   134         showB $ length $ teams r,
   134         n,
   135         n,
   135         Map.findWithDefault "+rnd+" "MAP" (mapParams r),
   136         Map.findWithDefault "+rnd+" "MAP" (mapParams r),
   136         head (Map.findWithDefault ["Default"] "SCHEME" (params r)),
   137         head (Map.findWithDefault ["Default"] "SCHEME" (params r)),
   137         head (Map.findWithDefault ["Default"] "AMMO" (params r))
   138         head (Map.findWithDefault ["Default"] "AMMO" (params r))
   138         ]
   139         ]
   139 
   140     | otherwise = [
       
   141         showB $ isJust $ gameInfo r,
       
   142         name r,
       
   143         showB $ playersIn r,
       
   144         showB $ length $ teams r,
       
   145         n,
       
   146         Map.findWithDefault "+rnd+" "MAP" (mapParams r),
       
   147         head (Map.findWithDefault ["Normal"] "SCRIPT" (params r)),
       
   148         head (Map.findWithDefault ["Default"] "SCHEME" (params r)),
       
   149         head (Map.findWithDefault ["Default"] "AMMO" (params r))
       
   150         ]
   140 
   151 
   141 answerFullConfigParams ::
   152 answerFullConfigParams ::
   142             ClientInfo
   153             ClientInfo
   143             -> Map.Map B.ByteString B.ByteString
   154             -> Map.Map B.ByteString B.ByteString
   144             -> Map.Map B.ByteString [B.ByteString]
   155             -> Map.Map B.ByteString [B.ByteString]
   167             AnswerClients [clChan] ["HH_NUM", teamname team, showB $ hhnum team]]
   178             AnswerClients [clChan] ["HH_NUM", teamname team, showB $ hhnum team]]
   168 
   179 
   169 
   180 
   170 loc :: B.ByteString -> B.ByteString
   181 loc :: B.ByteString -> B.ByteString
   171 loc = id
   182 loc = id
       
   183 
       
   184 maybeNick :: Maybe ClientInfo -> B.ByteString
       
   185 maybeNick = fromMaybe "[empty]" . liftM nick