- Fix UNBAN bug
authorunc0rr
Sat, 01 Dec 2012 00:37:23 +0400
changeset 8156 3ccc61102b58
parent 8155 0bccee1d31da
child 8157 695f1eef72c8
- Fix UNBAN bug - Rework BANLIST message format
gameServer/Actions.hs
gameServer/HWProtoLobbyState.hs
--- a/gameServer/Actions.hs	Fri Nov 30 18:46:25 2012 +0400
+++ b/gameServer/Actions.hs	Sat Dec 01 00:37:23 2012 +0400
@@ -512,13 +512,17 @@
         AddNick2Bans n msg (addUTCTime seconds currentTime)
 
 processAction BanList = do
+    time <- io $ getCurrentTime
     ch <- client's sendChan
-    b <- gets (B.pack . unlines . map show . bans . serverInfo)
+    b <- gets (B.intercalate "\n" . concatMap (ban2Str time) . bans . serverInfo)
     processAction $
         AnswerClients [ch] ["BANLIST", b]
+    where
+        ban2Str time (BanByIP b r t) = ["I", b, r, B.pack . show $ t `diffUTCTime` time]
+        ban2Str time (BanByNick b r t) = ["N", b, r, B.pack . show $ t `diffUTCTime` time]
 
 processAction (Unban entry) = do
-    processAction $ ModifyServerInfo (\s -> s{bans = filter f $ bans s})
+    processAction $ ModifyServerInfo (\s -> s{bans = filter (not . f) $ bans s})
     where
         f (BanByIP bip _ _) = bip == entry
         f (BanByNick bn _ _) = bn == entry
--- a/gameServer/HWProtoLobbyState.hs	Fri Nov 30 18:46:25 2012 +0400
+++ b/gameServer/HWProtoLobbyState.hs	Sat Dec 01 00:37:23 2012 +0400
@@ -150,11 +150,11 @@
     return [KickClient $ fromJust kickId | isAdministrator cl && isJust kickId && fromJust kickId /= ci]
 
 
-handleCmd_lobby ["BAN", banNick, reason] = do
+handleCmd_lobby ["BAN", banNick, reason, duration] = do
     (ci, _) <- ask
     cl <- thisClient
     banId <- clientByNick banNick
-    return [BanClient 60 reason (fromJust banId) | isAdministrator cl && isJust banId && fromJust banId /= ci]
+    return [BanClient (readInt_ duration) reason (fromJust banId) | isAdministrator cl && isJust banId && fromJust banId /= ci]
 
 handleCmd_lobby ["BANIP", ip, reason, duration] = do
     cl <- thisClient