Fix filtering
authorunc0rr
Thu, 13 Aug 2009 08:54:20 +0000
changeset 2310 581e59f123a2
parent 2309 1c106b0d36da
child 2311 977ee15c3c1f
Fix filtering
gameServer/Utils.hs
--- a/gameServer/Utils.hs	Wed Aug 12 15:32:29 2009 +0000
+++ b/gameServer/Utils.hs	Thu Aug 13 08:54:20 2009 +0000
@@ -7,6 +7,7 @@
 import qualified Data.Map as Map
 import qualified Data.IntMap as IntMap
 import qualified Data.Set as Set
+import Data.ByteString.Internal (w2c)
 import Numeric
 import Network.Socket
 import System.IO
@@ -29,9 +30,9 @@
 toEngineMsg msg = Base64.encode (fromIntegral (length msg) : (UTF8.encode msg))
 
 fromEngineMsg :: String -> Maybe String
-fromEngineMsg msg = Base64.decode msg >>= return . UTF8.decode >>= removeLength
+fromEngineMsg msg = Base64.decode msg >>= removeLength >>= return . (map w2c)
 	where
-		removeLength (x:xs) = if length xs == ord x then Just xs else Nothing
+		removeLength (x:xs) = if length xs == fromIntegral x then Just xs else Nothing
 		removeLength _ = Nothing
 
 isLegalNetCommand :: String -> Bool