Add options for database access
authorunc0rr
Mon, 23 Feb 2009 20:15:02 +0000
changeset 1832 1fb61a53a2c2
parent 1831 025348f05b9f
child 1833 e901ec5644b4
Add options for database access
gameServer/CoreTypes.hs
gameServer/Opts.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
 		"<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
-		""
 		46631
 		0
 		0
+		""
+		""
+		""
 	)
 
 data CoreMessage =
--- 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