diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java index f162cd2b..60164b30 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MorePackets.java @@ -60,7 +60,7 @@ public class MorePackets extends Check { } // Check for a violation of the set limits. - final double violation = NetStatic.morePacketsCheck(data.morePacketsFreq, time, 1f, cc.morePacketsEPSMax, cc.morePacketsEPSIdeal, data.morePacketsBurstFreq, cc.morePacketsBurstPackets, cc.morePacketsBurstEPM); + final double violation = NetStatic.morePacketsCheck(data.morePacketsFreq, time, 1f, cc.morePacketsEPSMax, cc.morePacketsEPSIdeal, data.morePacketsBurstFreq, cc.morePacketsBurstPackets, cc.morePacketsBurstDirect, cc.morePacketsBurstEPM); // Process violation result. if (violation > 0.0) { diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java index 6d3ff182..b627aef3 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java @@ -81,6 +81,7 @@ public class MovingConfig extends ACheckConfig { /** The maximum number of packets per second that we accept. */ public final float morePacketsEPSMax; public final float morePacketsBurstPackets; + public final double morePacketsBurstDirect; public final double morePacketsBurstEPM; public final ActionList morePacketsActions; @@ -175,7 +176,8 @@ public class MovingConfig extends ACheckConfig { morePacketsCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK); morePacketsEPSIdeal = config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL); morePacketsEPSMax = Math.max(morePacketsEPSIdeal, config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSMAX)); - morePacketsBurstPackets = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_PACKETS); + morePacketsBurstPackets = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM); + morePacketsBurstDirect = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT); morePacketsBurstEPM = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM); morePacketsActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java index 4b1a3483..68c4a41a 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -507,6 +507,7 @@ public abstract class ConfPaths { public static final String MOVING_MOREPACKETS_EPSMAX = MOVING_MOREPACKETS + "epsmax"; private static final String MOVING_MOREPACKETS_BURST = MOVING_MOREPACKETS + "burst."; public static final String MOVING_MOREPACKETS_BURST_PACKETS = MOVING_MOREPACKETS_BURST + "packets"; + public static final String MOVING_MOREPACKETS_BURST_DIRECT = MOVING_MOREPACKETS_BURST + "directviolation"; public static final String MOVING_MOREPACKETS_BURST_EPM = MOVING_MOREPACKETS_BURST + "epmviolation"; public static final String MOVING_MOREPACKETS_ACTIONS = MOVING_MOREPACKETS + "actions"; diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java index 1c8b1f86..a854bea8 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -358,7 +358,8 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL, 20); set(ConfPaths.MOVING_MOREPACKETS_EPSMAX, 22); set(ConfPaths.MOVING_MOREPACKETS_BURST_PACKETS, 40); - set(ConfPaths.MOVING_MOREPACKETS_BURST_EPM, 30); + set(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT, 30); + set(ConfPaths.MOVING_MOREPACKETS_BURST_EPM, 120); set(ConfPaths.MOVING_MOREPACKETS_ACTIONS, "cancel vl>10 log:morepackets:0:2:if cancel vl>100 log:morepackets:0:2:if cancel cmd:kickpackets"); set(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK, true); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/net/NetStatic.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/net/NetStatic.java index 0780e259..540d9213 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/net/NetStatic.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/net/NetStatic.java @@ -35,7 +35,7 @@ public class NetStatic { * @param burstEPM Events per minute to trigger a burst violation. * @return The violation amount, i.e. "count above limit", 0.0 if no violation. */ - public static double morePacketsCheck(final ActionFrequency packetFreq, final long time, final float packets, final float maxPackets, final float idealPackets, final ActionFrequency burstFreq, final float burstPackets, final double burstEPM) { + public static double morePacketsCheck(final ActionFrequency packetFreq, final long time, final float packets, final float maxPackets, final float idealPackets, final ActionFrequency burstFreq, final float burstPackets, final double burstDirect, final double burstEPM) { // Pull down stuff. final long winDur = packetFreq.bucketDuration(); final int winNum = packetFreq.numberOfBuckets(); @@ -90,7 +90,9 @@ public class NetStatic { double violation = (double) fullCount - (double) (maxPackets * winNum * winDur / 1000f); final float burst = packetFreq.bucketScore(0); if (burst > burstPackets) { - burstFreq.add(time, 1f); // TODO: Remove float packets or do this properly. + // TODO: Account for "just now lag", i.e. time until first occupied one > 0. + burstFreq.add(time, 1f); // TODO: Remove float packets or do this properly. + violation = Math.max(violation, burst - burstDirect); violation = Math.max(violation, burstEPM * (double) (burstFreq.bucketDuration() * burstFreq.numberOfBuckets()) / 60000.0 - (double) burstFreq.score(0f)); } return Math.max(0.0, violation);