gameServer/OfficialServer/extdbinterface.hs
changeset 2869 93cc73dcc421
parent 2348 b39d826e1ccd
child 2918 24d6dc579b47
--- a/gameServer/OfficialServer/extdbinterface.hs	Thu Feb 25 18:34:30 2010 +0000
+++ b/gameServer/OfficialServer/extdbinterface.hs	Thu Feb 25 18:34:36 2010 +0000
@@ -14,54 +14,54 @@
 
 
 dbQueryAccount =
-	"select users.pass, users_roles.rid from users left join users_roles on users.uid = users_roles.uid where users.name = ?"
+    "SELECT users.pass, users_roles.rid FROM users LEFT JOIN users_roles ON users.uid = users_roles.uid WHERE users.name = ?"
 
 dbQueryStats =
-	"UPDATE gameserver_stats SET players = ?, rooms = ?, last_update = UNIX_TIMESTAMP()"
+    "UPDATE gameserver_stats SET players = ?, rooms = ?, last_update = UNIX_TIMESTAMP()"
 
 dbInteractionLoop dbConn = forever $ do
-	q <- (getLine >>= return . read)
-	hPutStrLn stderr $ show q
-	
-	case q of
-		CheckAccount clUid clNick _ -> do
-				statement <- prepare dbConn dbQueryAccount
-				execute statement [SqlString $ clNick]
-				passAndRole <- fetchRow statement
-				finish statement
-				let response =
-					if isJust passAndRole then
-						(
-							clUid,
-							HasAccount
-								(fromSql $ head $ fromJust $ passAndRole)
-								((fromSql $ last $ fromJust $ passAndRole) == (Just (3 :: Int)))
-						)
-					else
-						(clUid, Guest)
-				putStrLn (show response)
-				hFlush stdout
+    q <- (getLine >>= return . read)
+    hPutStrLn stderr $ show q
+    
+    case q of
+        CheckAccount clUid clNick _ -> do
+                statement <- prepare dbConn dbQueryAccount
+                execute statement [SqlString $ clNick]
+                passAndRole <- fetchRow statement
+                finish statement
+                let response =
+                    if isJust passAndRole then
+                        (
+                            clUid,
+                            HasAccount
+                                (fromSql $ head $ fromJust $ passAndRole)
+                                ((fromSql $ last $ fromJust $ passAndRole) == (Just (3 :: Int)))
+                        )
+                    else
+                        (clUid, Guest)
+                putStrLn (show response)
+                hFlush stdout
 
-		SendStats clients rooms ->
-				run dbConn dbQueryStats [SqlInt32 $ fromIntegral clients, SqlInt32 $ fromIntegral rooms] >> return ()
+        SendStats clients rooms ->
+                run dbConn dbQueryStats [SqlInt32 $ fromIntegral clients, SqlInt32 $ fromIntegral rooms] >> return ()
 
 
 dbConnectionLoop mySQLConnectionInfo =
-	Control.Exception.handle (\(_ :: IOException) -> return ()) $ handleSqlError $
-		bracket
-			(connectMySQL mySQLConnectionInfo)
-			(disconnect)
-			(dbInteractionLoop)
+    Control.Exception.handle (\(_ :: IOException) -> return ()) $ handleSqlError $
+        bracket
+            (connectMySQL mySQLConnectionInfo)
+            (disconnect)
+            (dbInteractionLoop)
 
 
 processRequest :: DBQuery -> IO String
 processRequest (CheckAccount clUid clNick clHost) = return $ show (clUid, Guest)
 
 main = do
-		dbHost <- getLine
-		dbLogin <- getLine
-		dbPassword <- getLine
+        dbHost <- getLine
+        dbLogin <- getLine
+        dbPassword <- getLine
 
-		let mySQLConnectInfo = defaultMySQLConnectInfo {mysqlHost = dbHost, mysqlDatabase = "hedge_main", mysqlUser = dbLogin, mysqlPassword = dbPassword}
+        let mySQLConnectInfo = defaultMySQLConnectInfo {mysqlHost = dbHost, mysqlDatabase = "hedge_main", mysqlUser = dbLogin, mysqlPassword = dbPassword}
 
-		dbConnectionLoop mySQLConnectInfo
+        dbConnectionLoop mySQLConnectInfo