# HG changeset patch # User unc0rr # Date 1299267928 -10800 # Node ID 3572eaf1434001018c759977710bb9b5b4539463 # Parent 0c60ade27a0aaa09fd8bc6cf46fb0aa0f591a8a2 Add dbName parameter to .ini file, fix some warnings diff -r 0c60ade27a0a -r 3572eaf14340 gameServer/ClientIO.hs --- a/gameServer/ClientIO.hs Fri Mar 04 11:30:53 2011 +0300 +++ b/gameServer/ClientIO.hs Fri Mar 04 22:45:28 2011 +0300 @@ -38,7 +38,6 @@ where recieveWithBufferLoop recvBuf = do recvBS <- recv sock 4096 --- putStrLn $ show sock ++ " got smth: " ++ (show $ B.length recvBS) unless (B.null recvBS) $ do let (packets, newrecvBuf) = bs2Packets $ B.append recvBuf recvBS forM_ packets sendPacket diff -r 0c60ade27a0a -r 3572eaf14340 gameServer/ConfigFile.hs --- a/gameServer/ConfigFile.hs Fri Mar 04 11:30:53 2011 +0300 +++ b/gameServer/ConfigFile.hs Fri Mar 04 22:45:28 2011 +0300 @@ -11,6 +11,7 @@ cfg <- readConfig "hedgewars-server.ini" let si = serverInfo'{ dbHost = value "dbHost" cfg + , dbName = value "dbName" cfg , dbLogin = value "dbLogin" cfg , dbPassword = value "dbPassword" cfg , serverConfig = Just cfg diff -r 0c60ade27a0a -r 3572eaf14340 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Fri Mar 04 11:30:53 2011 +0300 +++ b/gameServer/CoreTypes.hs Fri Mar 04 22:45:28 2011 +0300 @@ -12,7 +12,6 @@ import Data.Unique import Control.Exception import Data.Typeable -import Data.TConfig ----------------------- import RoomsAndClients @@ -134,6 +133,7 @@ listenPort :: PortNumber, nextRoomID :: Int, dbHost :: B.ByteString, + dbName :: B.ByteString, dbLogin :: B.ByteString, dbPassword :: B.ByteString, lastLogins :: [(B.ByteString, (UTCTime, B.ByteString))], @@ -158,6 +158,7 @@ "" "" "" + "" [] False diff -r 0c60ade27a0a -r 3572eaf14340 gameServer/OfficialServer/DBInteraction.hs --- a/gameServer/OfficialServer/DBInteraction.hs Fri Mar 04 11:30:53 2011 +0300 +++ b/gameServer/OfficialServer/DBInteraction.hs Fri Mar 04 22:45:28 2011 +0300 @@ -27,7 +27,7 @@ localAddressList :: [B.ByteString] localAddressList = ["127.0.0.1", "0:0:0:0:0:0:0:1", "0:0:0:0:0:ffff:7f00:1"] ---fakeDbConnection :: forall b. (ServerInfo c)-> IO b +fakeDbConnection :: forall b c. ServerInfo c -> IO b fakeDbConnection si = forever $ do q <- readChan $ dbQueries si case q of @@ -89,7 +89,13 @@ maybeException (Just a) = return a maybeException Nothing = ioError (userError "Can't read") ---pipeDbConnection :: forall b. Map.Map ByteString (UTCTime, AccountInfo) -> (ServerInfo c) -> Int -> IO b +pipeDbConnection :: forall a c b. + (Num a, Ord a) => + Map.Map ByteString (UTCTime, AccountInfo) + -> ServerInfo c + -> a + -> IO b + pipeDbConnection accountsCache si errNum = do (updatedCache, newErrNum) <- Exception.handle (\(e :: Exception.IOException) -> warningM "Database" (show e) >> return (accountsCache, errNum + 1)) $ do @@ -100,6 +106,7 @@ hSetBuffering hOut LineBuffering B.hPutStrLn hIn $ dbHost si + B.hPutStrLn hIn $ dbName si B.hPutStrLn hIn $ dbLogin si B.hPutStrLn hIn $ dbPassword si (c, r) <- pipeDbConnectionLoop (dbQueries si) (coreChan si) hIn hOut accountsCache 0 @@ -109,6 +116,7 @@ threadDelay (3000000) pipeDbConnection updatedCache si newErrNum +dbConnectionLoop :: forall c b. ServerInfo c -> IO b dbConnectionLoop si = if (not . B.null $ dbHost si) then pipeDbConnection Map.empty si 0 diff -r 0c60ade27a0a -r 3572eaf14340 gameServer/OfficialServer/extdbinterface.hs --- a/gameServer/OfficialServer/extdbinterface.hs Fri Mar 04 11:30:53 2011 +0300 +++ b/gameServer/OfficialServer/extdbinterface.hs Fri Mar 04 22:45:28 2011 +0300 @@ -60,9 +60,10 @@ main = do dbHost <- getLine + dbName <- getLine dbLogin <- getLine dbPassword <- getLine - let mySQLConnectInfo = defaultMySQLConnectInfo {mysqlHost = dbHost, mysqlDatabase = "hedge_main", mysqlUser = dbLogin, mysqlPassword = dbPassword} + let mySQLConnectInfo = defaultMySQLConnectInfo {mysqlHost = dbHost, mysqlDatabase = dbName, mysqlUser = dbLogin, mysqlPassword = dbPassword} dbConnectionLoop mySQLConnectInfo diff -r 0c60ade27a0a -r 3572eaf14340 gameServer/hedgewars-server.hs --- a/gameServer/hedgewars-server.hs Fri Mar 04 11:30:53 2011 +0300 +++ b/gameServer/hedgewars-server.hs Fri Mar 04 22:45:28 2011 +0300 @@ -8,11 +8,6 @@ import qualified Control.Exception as E import System.Log.Logger import System.Process -import Data.TConfig -import Data.Maybe -#if defined(OFFICIAL_SERVER) -import Control.Monad -#endif ----------------------------------- import Opts import CoreTypes