# HG changeset patch # User unc0rr # Date 1235420102 0 # Node ID 1fb61a53a2c2ce2a1e480ab0e586b9faf53bf55c # Parent 025348f05b9fe44ce96bf60e58ed4c2b12b97f5e Add options for database access diff -r 025348f05b9f -r 1fb61a53a2c2 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Mon Feb 23 19:01:36 2009 +0000 +++ b/gameServer/CoreTypes.hs Mon Feb 23 20:15:02 2009 +0000 @@ -113,10 +113,12 @@ { isDedicated :: Bool, serverMessage :: String, - adminPassword :: String, listenPort :: PortNumber, loginsNumber :: Int, nextRoomID :: Int, + dbHost :: String, + dbLogin :: String, + dbPassword :: String, stats :: TMVar StatisticsInfo --dbQueries :: TChan DBQuery } @@ -128,10 +130,12 @@ ServerInfo True "
" - "" 46631 0 0 + "" + "" + "" ) data CoreMessage = diff -r 025348f05b9f -r 1fb61a53a2c2 gameServer/Opts.hs --- a/gameServer/Opts.hs Mon Feb 23 19:01:36 2009 +0000 +++ b/gameServer/Opts.hs Mon Feb 23 20:15:02 2009 +0000 @@ -14,10 +14,17 @@ options = [ Option ['p'] ["port"] (ReqArg readListenPort "PORT") "listen on PORT", Option ['d'] ["dedicated"] (ReqArg readDedicated "BOOL") "start as dedicated (True or False)", - Option [] ["password"] (ReqArg readPassword "STRING") "admin password" + Option [] ["db-login"] (ReqArg readDbLogin "STRING") "database access login", + Option [] ["db-password"] (ReqArg readDbPassword "STRING") "database access password", + Option [] ["db-host"] (ReqArg readDbHost "STRING") "database host" ] -readListenPort, readDedicated, readPassword :: String -> ServerInfo -> ServerInfo +readListenPort, + readDedicated, + readDbLogin, + readDbPassword, + readDbHost :: String -> ServerInfo -> ServerInfo + readListenPort str opts = opts{listenPort = readPort} where readPort = fromInteger $ fromMaybe 46631 (maybeRead str :: Maybe Integer) @@ -26,7 +33,9 @@ where readDedicated = fromMaybe True (maybeRead str :: Maybe Bool) -readPassword str opts = opts{adminPassword = str} +readDbLogin str opts = opts{dbLogin = str} +readDbPassword str opts = opts{dbPassword = str} +readDbHost str opts = opts{dbHost = str} getOpts :: ServerInfo -> IO ServerInfo getOpts opts = do