--- 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
--- 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
--- 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
--- 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
--- 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
--- 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