# HG changeset patch # User unc0rr # Date 1235421269 0 # Node ID 71cb978dc85f2ebf40301d2b2489dc6bb0f33834 # Parent e901ec5644b49e79a5df917aaf82ffb53e14de6a Add working check for www account existance diff -r e901ec5644b4 -r 71cb978dc85f gameServer/Actions.hs --- a/gameServer/Actions.hs Mon Feb 23 20:25:07 2009 +0000 +++ b/gameServer/Actions.hs Mon Feb 23 20:34:29 2009 +0000 @@ -28,6 +28,7 @@ | ModifyClient (ClientInfo -> ClientInfo) | ModifyRoom (RoomInfo -> RoomInfo) | AddRoom String String + | CheckRegistered | Dump type CmdHandler = Int -> Clients -> Rooms -> [String] -> [Action] @@ -241,6 +242,12 @@ rmTeamMsg = toEngineMsg $ 'F' : teamName +processAction (clID, serverInfo, clients, rooms) (CheckRegistered) = do + writeChan (dbQueries serverInfo) $ HasRegistered $ nick client + return (clID, serverInfo, clients, rooms) + where + client = clients ! clID + processAction (clID, serverInfo, clients, rooms) (Dump) = do writeChan (sendChan $ clients ! clID) ["DUMP", show serverInfo, showTree clients, showTree rooms] return (clID, serverInfo, clients, rooms) diff -r e901ec5644b4 -r 71cb978dc85f gameServer/HWProtoNEState.hs --- a/gameServer/HWProtoNEState.hs Mon Feb 23 20:25:07 2009 +0000 +++ b/gameServer/HWProtoNEState.hs Mon Feb 23 20:34:29 2009 +0000 @@ -17,6 +17,7 @@ [] else (RoomAddThisClient 0) + : CheckRegistered : answerLobbyNicks -- ++ (answerServerMessage client clients) where diff -r e901ec5644b4 -r 71cb978dc85f gameServer/OfficialServer/DBInteraction.hs --- a/gameServer/OfficialServer/DBInteraction.hs Mon Feb 23 20:25:07 2009 +0000 +++ b/gameServer/OfficialServer/DBInteraction.hs Mon Feb 23 20:34:29 2009 +0000 @@ -10,13 +10,19 @@ import Control.Concurrent import Control.Exception import Monad +import Maybe ------------------------ import CoreTypes dbInteractionLoop queries dbConn = do q <- readChan queries case q of - HasRegistered queryStr -> putStrLn queryStr + HasRegistered name -> do + statement <- prepare dbConn "SELECT uid FROM users WHERE name=?" + execute statement [SqlString name] + uid <- fetchRow statement + finish statement + putStrLn (show $ isJust uid) CheckPassword queryStr -> putStrLn queryStr dbInteractionLoop queries dbConn