gameServer/Utils.hs
changeset 10017 de822cd3df3a
parent 9837 fa94ee96f006
child 10059 015ed10e7e66
equal deleted inserted replaced
10015:4feced261c68 10017:de822cd3df3a
   114 
   114 
   115 readInt_ :: (Num a) => B.ByteString -> a
   115 readInt_ :: (Num a) => B.ByteString -> a
   116 readInt_ str =
   116 readInt_ str =
   117   case B.readInt str of
   117   case B.readInt str of
   118        Just (i, t) | B.null t -> fromIntegral i
   118        Just (i, t) | B.null t -> fromIntegral i
   119        _                      -> 0 
   119        _                      -> 0
   120 
   120 
   121 cutHost :: B.ByteString -> B.ByteString
   121 cutHost :: B.ByteString -> B.ByteString
   122 cutHost = B.intercalate "." .  flip (++) ["*","*"] . List.take 2 . B.split '.'
   122 cutHost = B.intercalate "." .  flip (++) ["*","*"] . List.take 2 . B.split '.'
   123 
   123 
   124 caseInsensitiveCompare :: B.ByteString -> B.ByteString -> Bool
   124 caseInsensitiveCompare :: B.ByteString -> B.ByteString -> Bool
   126 
   126 
   127 upperCase :: B.ByteString -> B.ByteString
   127 upperCase :: B.ByteString -> B.ByteString
   128 upperCase = UTF8.fromString . map Char.toUpper . UTF8.toString
   128 upperCase = UTF8.fromString . map Char.toUpper . UTF8.toString
   129 
   129 
   130 roomInfo :: Word16 -> B.ByteString -> RoomInfo -> [B.ByteString]
   130 roomInfo :: Word16 -> B.ByteString -> RoomInfo -> [B.ByteString]
   131 roomInfo p n r 
   131 roomInfo p n r
   132     | p < 46 = [
   132     | p < 46 = [
   133         showB $ isJust $ gameInfo r,
   133         showB $ isJust $ gameInfo r,
   134         name r,
   134         name r,
   135         showB $ playersIn r,
   135         showB $ playersIn r,
   136         showB $ length $ teams r,
   136         showB $ length $ teams r,