Eh. n/m. Even when I did 1 shl, didn't seem right, and anyway, it isn't much of a mask if there are 16 categories and we use 10, of which those are the most common.
module EngineInteraction whereimport qualified Data.Set as Setimport qualified Data.List as Listimport Control.Monadimport qualified Codec.Binary.Base64 as Base64import qualified Data.ByteString.Char8 as Bimport qualified Data.ByteString as BW-------------import CoreTypestoEngineMsg :: B.ByteString -> B.ByteStringtoEngineMsg msg = B.pack $ Base64.encode (fromIntegral (BW.length msg) : BW.unpack msg)fromEngineMsg :: B.ByteString -> Maybe B.ByteStringfromEngineMsg msg = liftM BW.pack (Base64.decode (B.unpack msg) >>= removeLength) where removeLength (x:xs) = if length xs == fromIntegral x then Just xs else Nothing removeLength _ = NothingcheckNetCmd :: B.ByteString -> (Bool, Bool)checkNetCmd msg = check decoded where decoded = fromEngineMsg msg check Nothing = (False, False) check (Just ms) | B.length ms > 0 = let m = B.head ms in (m `Set.member` legalMessages, m == '+') | otherwise = (False, False) legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtghbc12345" ++ slotMessages slotMessages = "\128\129\130\131\132\133\134\135\136\137\138"gameInfo2Replay :: GameInfo -> B.ByteStringgameInfo2Replay GameInfo{roundMsgs = rm, teamsAtStart = teams, giMapParams = params1, giParams = params2} = undefined