Cut dependency on yaml for non-official server builds
authorunC0Rr
Sat, 24 Nov 2018 20:55:42 +0300
changeset 14292 9f0d81213d65
parent 14291 7a7c090f96f6
child 14293 21e719e35f43
Cut dependency on yaml for non-official server builds
gameServer/Actions.hs
gameServer/Utils.hs
--- a/gameServer/Actions.hs	Fri Nov 23 21:38:34 2018 -0500
+++ b/gameServer/Actions.hs	Sat Nov 24 20:55:42 2018 +0300
@@ -43,10 +43,10 @@
 import Text.Regex.TDFA
 import qualified Text.Regex.TDFA as TDFA
 import qualified Text.Regex.TDFA.ByteString as TDFAB
-import qualified Data.Yaml as YAML
 -----------------------------
 #if defined(OFFICIAL_SERVER)
 import OfficialServer.GameReplayStore
+import qualified Data.Yaml as YAML
 #endif
 import CoreTypes
 import Utils
@@ -820,14 +820,6 @@
     uid <- client's clUID
     io $ writeChan (dbQueries si) $ GetReplayName ci (hashUnique uid) rname
 
-#else
-processAction SaveReplay = return ()
-processAction CheckRecord = return ()
-processAction (CheckFailed _) = return ()
-processAction (CheckSuccess _) = return ()
-processAction (QueryReplay _) = processAction $ Warning $ loc "This server does not support replays!"
-#endif
-
 processAction (ShowReplay rname) = do
     c <- client's sendChan
     cl <- client's id
@@ -860,6 +852,17 @@
 processAction (LoadRoom rname) = do
     Right (g, rs) <- io $ YAML.decodeFileEither (B.unpack rname)
     processAction $ ModifyRoom $ \r -> r{greeting = g, roomSaves = rs}
+	
+#else
+processAction SaveReplay = return ()
+processAction CheckRecord = return ()
+processAction (CheckFailed _) = return ()
+processAction (CheckSuccess _) = return ()
+processAction (QueryReplay _) = processAction $ Warning $ loc "This server does not support replays!"
+processAction (ShowReplay rname) = return ()
+processAction (SaveRoom rname) = return ()
+processAction (LoadRoom rname) = return ()
+#endif
 
 processAction Cleanup = do
     jm <- gets joinsMonitor
--- a/gameServer/Utils.hs	Fri Nov 23 21:38:34 2018 -0500
+++ b/gameServer/Utils.hs	Sat Nov 24 20:55:42 2018 +0300
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  \-}
 
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings,CPP #-}
 module Utils where
 
 import Data.Char
@@ -32,8 +32,10 @@
 import qualified Data.ByteString.Char8 as B
 import qualified Data.ByteString.UTF8 as UTF8
 import Data.Maybe
+#if defined(OFFICIAL_SERVER)
 import qualified Data.Aeson.Types as Aeson
 import qualified Data.Text as Text
+#endif
 -------------------------------------------------
 import CoreTypes
 
@@ -259,6 +261,7 @@
 isRegistered :: ClientInfo -> Bool
 isRegistered = (<) 0 . B.length . webPassword
 
+#if defined(OFFICIAL_SERVER)
 instance Aeson.ToJSON B.ByteString where
   toJSON = Aeson.toJSON . B.unpack
 
@@ -270,4 +273,4 @@
   
 instance Aeson.FromJSONKey B.ByteString where
   fromJSONKey = Aeson.FromJSONKeyTextParser (return . B.pack . Text.unpack)
-  
+#endif