--- a/gameServer/Actions.hs Wed Aug 28 23:11:05 2013 +0400
+++ b/gameServer/Actions.hs Wed Aug 28 23:44:27 2013 +0400
@@ -421,16 +421,16 @@
processAction (ProcessAccountInfo info) = do
case info of
- HasAccount passwd isAdmin -> do
+ HasAccount passwd isAdmin isContr -> do
b <- isBanned
c <- client's isChecker
- when (not b) $ (if c then checkerLogin else playerLogin) passwd isAdmin
+ when (not b) $ (if c then checkerLogin else playerLogin) passwd isAdmin isContr
Guest -> do
b <- isBanned
c <- client's isChecker
when (not b) $
if c then
- checkerLogin "" False
+ checkerLogin "" False False
else
processAction JoinLobby
Admin -> do
@@ -441,30 +441,36 @@
isBanned = do
processAction $ CheckBanned False
liftM B.null $ client's nick
- checkerLogin _ False = processAction $ ByeClient $ loc "No checker rights"
- checkerLogin p True = do
+ checkerLogin _ False _ = processAction $ ByeClient $ loc "No checker rights"
+ checkerLogin p True _ = do
wp <- client's webPassword
processAction $
if wp == p then ModifyClient $ \c -> c{logonPassed = True} else ByeClient $ loc "Authentication failed"
- playerLogin p a = do
+ playerLogin p a contr = do
chan <- client's sendChan
- mapM_ processAction [AnswerClients [chan] ["ASKPASSWORD"], ModifyClient (\c -> c{webPassword = p, isAdministrator = a})]
+ mapM_ processAction [
+ AnswerClients [chan] ["ASKPASSWORD"]
+ , ModifyClient (\c -> c{webPassword = p, isAdministrator = a, isContributor = contr})
+ ]
processAction JoinLobby = do
chan <- client's sendChan
clientNick <- client's nick
isAuthenticated <- liftM (not . B.null) $ client's webPassword
isAdmin <- client's isAdministrator
+ isContr <- client's isContributor
loggedInClients <- liftM (Prelude.filter isVisible) $! allClientsS
let (lobbyNicks, clientsChans) = unzip . L.map (nick &&& sendChan) $ loggedInClients
let authenticatedNicks = L.map nick . L.filter (not . B.null . webPassword) $ loggedInClients
let adminsNicks = L.map nick . L.filter isAdministrator $ loggedInClients
- let clFlags = B.concat . L.concat $ [["u" | isAuthenticated], ["a" | isAdmin]]
+ let contrNicks = L.map nick . L.filter isContributor $ loggedInClients
+ let clFlags = B.concat . L.concat $ [["u" | isAuthenticated], ["a" | isAdmin], ["c" | isContr]]
mapM_ processAction . concat $ [
[AnswerClients clientsChans ["LOBBY:JOINED", clientNick]]
, [AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)]
, [AnswerClients [chan] ("CLIENT_FLAGS" : "+u" : authenticatedNicks) | not $ null authenticatedNicks]
, [AnswerClients [chan] ("CLIENT_FLAGS" : "+a" : adminsNicks) | not $ null adminsNicks]
+ , [AnswerClients [chan] ("CLIENT_FLAGS" : "+c" : contrNicks) | not $ null contrNicks]
, [AnswerClients (chan : clientsChans) ["CLIENT_FLAGS", B.concat["+" , clFlags], clientNick] | not $ B.null clFlags]
, [ModifyClient (\cl -> cl{logonPassed = True, isVisible = True})]
, [SendServerMessage]
@@ -611,6 +617,7 @@
where
st irnc = (length $ allRooms irnc, length $ allClients irnc)
+
processAction RestartServer = do
sp <- gets (shutdownPending . serverInfo)
when (not sp) $ do
@@ -624,6 +631,7 @@
return ()
processAction $ ModifyServerInfo (\s -> s{shutdownPending = True})
+
processAction Stats = do
cls <- allClientsS
rms <- allRoomsS
--- a/gameServer/CoreTypes.hs Wed Aug 28 23:11:05 2013 +0400
+++ b/gameServer/CoreTypes.hs Wed Aug 28 23:44:27 2013 +0400
@@ -106,6 +106,7 @@
isInGame :: Bool,
isAdministrator :: Bool,
isChecker :: Bool,
+ isContributor :: Bool,
isKickedFromServer :: Bool,
isJoinedMidGame :: Bool,
clientClan :: !(Maybe B.ByteString),
@@ -254,7 +255,7 @@
[]
data AccountInfo =
- HasAccount B.ByteString Bool
+ HasAccount B.ByteString Bool Bool
| Guest
| Admin
deriving (Show, Read)
--- a/gameServer/NetRoutines.hs Wed Aug 28 23:11:05 2013 +0400
+++ b/gameServer/NetRoutines.hs Wed Aug 28 23:44:27 2013 +0400
@@ -45,6 +45,7 @@
False
False
False
+ False
Nothing
Nothing
0
--- a/gameServer/OfficialServer/extdbinterface.hs Wed Aug 28 23:11:05 2013 +0400
+++ b/gameServer/OfficialServer/extdbinterface.hs Wed Aug 28 23:44:27 2013 +0400
@@ -17,7 +17,10 @@
dbQueryAccount =
- "SELECT users.pass, users_roles.rid FROM users LEFT JOIN users_roles ON (users.uid = users_roles.uid AND users_roles.rid = 3) WHERE users.name = ?"
+ "SELECT users.pass, \
+ \ (SELECT COUNT(users_roles.rid) FROM users_roles WHERE users.uid = users_roles.uid AND users_roles.rid = 3), \
+ \ (SELECT COUNT(users_roles.rid) FROM users_roles WHERE users.uid = users_roles.uid AND users_roles.rid = 13) \
+ \ FROM users WHERE users.name = ?"
dbQueryStats =
"INSERT INTO gameserver_stats (players, rooms, last_update) VALUES (?, ?, UNIX_TIMESTAMP())"
@@ -35,16 +38,17 @@
CheckAccount clId clUid clNick _ -> do
statement <- prepare dbConn dbQueryAccount
execute statement [SqlByteString clNick]
- passAndRole <- fetchRow statement
+ result <- fetchRow statement
finish statement
let response =
- if isJust passAndRole then
+ if isJust result then let [pass, adm, contr] = fromJust $ result
(
clId,
clUid,
HasAccount
- (fromSql . head . fromJust $ passAndRole)
- (fromSql (last . fromJust $ passAndRole) == Just (3 :: Int))
+ (fromSql pass)
+ (fromSql adm == Just (1 :: Int))
+ (fromSql contr == Just (1 :: Int))
)
else
(clId, clUid, Guest)