Don't rewrite server ini file too often
authorunc0rr
Thu, 20 Feb 2014 01:32:37 +0400
changeset 10148 a599593e1dc2
parent 10147 9a772dc5dfbe
child 10149 017ca6054845
Don't rewrite server ini file too often
gameServer/Actions.hs
--- a/gameServer/Actions.hs	Thu Feb 20 00:28:49 2014 +0400
+++ b/gameServer/Actions.hs	Thu Feb 20 01:32:37 2014 +0400
@@ -608,11 +608,11 @@
     clNick <- client's nick
     clHost <- client's host
     si <- gets serverInfo
-    let validBans = filter (checkNotExpired clTime) $ bans si
+    let (validBans, expiredBans) = L.partition (checkNotExpired clTime) $ bans si
     let ban = L.find (checkBan byIP clHost clNick) $ validBans
     mapM_ processAction $
-        ModifyServerInfo (\s -> s{bans = validBans})
-        : [ByeClient (getBanReason $ fromJust ban) | isJust ban]
+        [ModifyServerInfo (\s -> s{bans = validBans}) | not $ null expiredBans]
+        ++ [ByeClient (getBanReason $ fromJust ban) | isJust ban]
     where
         checkNotExpired testTime (BanByIP _ _ time) = testTime `diffUTCTime` time <= 0
         checkNotExpired testTime (BanByNick _ _ time) = testTime `diffUTCTime` time <= 0