From c05336e3e495aa452a412d92c15333d79abf737f Mon Sep 17 00:00:00 2001 From: asofold Date: Fri, 19 Oct 2012 19:05:09 +0200 Subject: [PATCH] Yawrate: add maximum penalty, corect use of minimum. --- .../neatmonster/nocheatplus/checks/combined/Combined.java | 6 ++++-- .../nocheatplus/checks/combined/CombinedConfig.java | 2 ++ src/fr/neatmonster/nocheatplus/config/ConfPaths.java | 1 + src/fr/neatmonster/nocheatplus/config/DefaultConfig.java | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/combined/Combined.java b/src/fr/neatmonster/nocheatplus/checks/combined/Combined.java index 807215a4..5ba0ecbf 100644 --- a/src/fr/neatmonster/nocheatplus/checks/combined/Combined.java +++ b/src/fr/neatmonster/nocheatplus/checks/combined/Combined.java @@ -83,12 +83,14 @@ public class Combined { if (total > threshold){ // Add time final float amount = ((total - threshold) / threshold * 1000f); - data.timeFreeze = Math.max(data.timeFreeze, (long) Math.max(cc.yawRatePenaltyFactor * ((float) now + amount) , cc.yawRatePenaltyMin)); + data.timeFreeze = Math.max(data.timeFreeze, now + (long) Math.min(Math.max(cc.yawRatePenaltyFactor * amount , cc.yawRatePenaltyMin), cc.yawRatePenaltyMax)); // TODO: balance (100 ... 200 ) ? if (cc.yawRateImprobable && Improbable.check(player, amount / 100f, now)) cancel = true; } - if (now < data.timeFreeze) cancel = true; + if (now < data.timeFreeze){ + cancel = true; + } return cancel; } diff --git a/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java b/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java index 0808f51f..83dc2461 100644 --- a/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/combined/CombinedConfig.java @@ -62,6 +62,7 @@ public class CombinedConfig extends ACheckConfig { public final boolean yawRateImprobable; public final float yawRatePenaltyFactor; public final int yawRatePenaltyMin; + public final int yawRatePenaltyMax; public CombinedConfig(final ConfigFile config) { super(config, ConfPaths.COMBINED); @@ -109,6 +110,7 @@ public class CombinedConfig extends ACheckConfig { yawRateImprobable = config.getBoolean(ConfPaths.COMBINED_YAWRATE_IMPROBABLE); yawRatePenaltyFactor = (float) config.getDouble(ConfPaths.COMBINED_YAWRATE_PENALTY_FACTOR); yawRatePenaltyMin = config.getInt(ConfPaths.COMBINED_YAWRATE_PENALTY_MIN); + yawRatePenaltyMax = config.getInt(ConfPaths.COMBINED_YAWRATE_PENALTY_MAX); } @Override diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index 6791b89e..3101b913 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -321,6 +321,7 @@ public abstract class ConfPaths { private static final String COMBINED_YAWRATE_PENALTY = COMBINED_YAWRATE + "penalty."; public static final String COMBINED_YAWRATE_PENALTY_FACTOR = COMBINED_YAWRATE_PENALTY + "factor"; public static final String COMBINED_YAWRATE_PENALTY_MIN = COMBINED_YAWRATE_PENALTY + "minimum"; + public static final String COMBINED_YAWRATE_PENALTY_MAX = COMBINED_YAWRATE_PENALTY + "maximum"; /* * 888'Y88 ,e, 888 d8 diff --git a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java index fde49880..a6ed8ea2 100644 --- a/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/src/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -247,6 +247,7 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.COMBINED_YAWRATE_RATE , 380); set(ConfPaths.COMBINED_YAWRATE_PENALTY_FACTOR, 1.0); set(ConfPaths.COMBINED_YAWRATE_PENALTY_MIN, 250); + set(ConfPaths.COMBINED_YAWRATE_PENALTY_MAX, 2000); set(ConfPaths.COMBINED_YAWRATE_IMPROBABLE, true); /*