From ca418d788738edd0ff18c4e7713d13e54ed780d4 Mon Sep 17 00:00:00 2001 From: asofold Date: Sat, 1 Sep 2012 20:57:47 +0200 Subject: [PATCH] Adjust noPwnageVL: use a queue that expires gradually with time instead of one single VL entry. Blends in nice with globalchat, if captcha is off and ban actions removed (nopwnage just kicks then). --- .../nocheatplus/checks/chat/ChatConfig.java | 3 +++ .../nocheatplus/checks/chat/ChatData.java | 5 +++-- .../nocheatplus/checks/chat/NoPwnage.java | 15 +++++++++------ .../neatmonster/nocheatplus/config/ConfPaths.java | 3 +++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java b/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java index c2f7a8eb..c3dd5a42 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java @@ -82,6 +82,7 @@ public class ChatConfig implements CheckConfig { public final boolean noPwnageCheck; public final List noPwnageExclusions; public final int noPwnageLevel; + public final float noPwnageVLFactor; public final boolean noPwnageBannedCheck; public final long noPwnageBannedTimeout; @@ -161,6 +162,8 @@ public class ChatConfig implements CheckConfig { noPwnageCheck = data.getBoolean(ConfPaths.CHAT_NOPWNAGE_CHECK); noPwnageExclusions = data.getStringList(ConfPaths.CHAT_NOPWNAGE_EXCLUSIONS); noPwnageLevel = data.getInt(ConfPaths.CHAT_NOPWNAGE_LEVEL); + // VL decreasing factor, hidden option. + noPwnageVLFactor = (float) data.getDouble(ConfPaths.CHAT_NOPWNAGE_VL_FACTOR, 0.95); noPwnageBannedCheck = data.getBoolean(ConfPaths.CHAT_NOPWNAGE_BANNED_CHECK); noPwnageBannedTimeout = data.getLong(ConfPaths.CHAT_NOPWNAGE_BANNED_TIMEOUT); diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/ChatData.java b/src/fr/neatmonster/nocheatplus/checks/chat/ChatData.java index b0633fd5..06db9dbb 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/ChatData.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/ChatData.java @@ -51,7 +51,7 @@ public class ChatData implements CheckData { public double captchaVL; public double colorVL; public double globalChatVL; - public double noPwnageVL; + public ActionFrequency noPwnageVL = new ActionFrequency(10, 3000); // Data of the globalchat check. public final ActionFrequency globalChatFrequency = new ActionFrequency(10, 3000); @@ -75,7 +75,8 @@ public class ChatData implements CheckData { public synchronized void clearNoPwnageData() { noPwnageCaptchTries = noPwnageReloginWarnings = 0; captchaVL = 0D; - // colorVL, noPwnageVL <- are spared to avoid problems with spam + captcha success. + // colorVL <- is spared to avoid problems with spam + captcha success. + // noPwnageVL <- Is handled by the ActionFrequency forgtting mechanism, currently (call clear otherwise). noPwnageJoinTime = noPwnageLastMessageTime = noPwnageLastMovedTime = noPwnageLastWarningTime = noPwnageLeaveTime = noPwnageReloginWarningTime = 0L; noPwnageGeneratedCaptcha = noPwnageLastMessage = ""; } diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/NoPwnage.java b/src/fr/neatmonster/nocheatplus/checks/chat/NoPwnage.java index 2cf7ddf3..be9bfa4b 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/NoPwnage.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/NoPwnage.java @@ -134,6 +134,9 @@ public class NoPwnage extends Check implements ICaptcha{ return false; final long now = System.currentTimeMillis(); + + // Forget expired VL. + data.noPwnageVL.update(now); if (shouldCheckCaptcha(cc, data)) { checkCaptcha(player, message, cc, data, isMainThread); @@ -198,15 +201,15 @@ public class NoPwnage extends Check implements ICaptcha{ player.getName()))); // Increment the violation level. - data.noPwnageVL += suspicion / 10D; + data.noPwnageVL.add(now, (float) (suspicion / 10D)); // Find out if we need to kick the player or not. - cancel = executeActionsThreadSafe(player, data.noPwnageVL, suspicion / 10D, cc.noPwnageActions, + cancel = executeActionsThreadSafe(player, cc.noPwnageVLFactor, suspicion / 10D, cc.noPwnageActions, isMainThread); } - else - // Reduce the violation level. - data.noPwnageVL *= 0.95D; +// else +// // Reduce the violation level. <- Done automatically by queue. +// data.noPwnageVL *= 0.95D; // Store the message and some other data. data.noPwnageLastMessage = message; @@ -300,7 +303,7 @@ public class NoPwnage extends Check implements ICaptcha{ data.noPwnageReloginWarnings++; } else if (now - data.noPwnageReloginWarningTime < cc.noPwnageReloginWarningTimeout) // Find out if we need to ban the player or not. - cancel = executeActionsThreadSafe(player, data.noPwnageVL, data.noPwnageVL, cc.noPwnageActions, true); + cancel = executeActionsThreadSafe(player, (double) data.noPwnageVL.getScore(cc.noPwnageVLFactor), 0D, cc.noPwnageActions, true); } // Store his joining time. diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index cedd0137..813e8ad1 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -201,6 +201,9 @@ public abstract class ConfPaths { public static final String CHAT_NOPWNAGE_SPEED_CHECK = CHAT_NOPWNAGE_SPEED + "active"; public static final String CHAT_NOPWNAGE_SPEED_TIMEOUT = CHAT_NOPWNAGE_SPEED + "timeout"; public static final String CHAT_NOPWNAGE_SPEED_WEIGHT = CHAT_NOPWNAGE_SPEED + "weight"; + + public static final String CHAT_NOPWNAGE_VL = CHAT_NOPWNAGE + "vl."; + public static final String CHAT_NOPWNAGE_VL_FACTOR = CHAT_NOPWNAGE_VL + "factor"; private static final String CHAT_NOPWNAGE_WARN = CHAT_NOPWNAGE + "warn."; public static final String CHAT_NOPWNAGE_WARN_LEVEL = CHAT_NOPWNAGE_WARN + "level";