[Bleeding] Account for lag in blockbreak.fastbreak.

This commit is contained in:
asofold 2013-01-04 14:21:08 +01:00
parent b85cd17688
commit 581cdef7bb

View File

@ -11,6 +11,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData; import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.permissions.Permissions; import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.BlockProperties; import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/* /*
* MM""""""""`M dP M#"""""""'M dP * MM""""""""`M dP M#"""""""'M dP
@ -75,24 +76,31 @@ public class FastBreak extends Check {
// // Ignore those for now. // // Ignore those for now.
// } // }
// else // else
if (elapsedTime + cc.fastBreakDelay < breakingTime){ if (elapsedTime + cc.fastBreakDelay < breakingTime){
// lag or cheat or Minecraft. // lag or cheat or Minecraft.
final long missingTime = breakingTime - elapsedTime; // Count in server side lag, if desired.
final float lag = cc.lag ? TickTask.getLag(breakingTime, true) : 1f;
final long missingTime = breakingTime - (long) (lag * elapsedTime);
// Add as penalty if (missingTime > 0){
data.fastBreakPenalties.add(now, (float) missingTime); // Add as penalty
data.fastBreakPenalties.add(now, (float) missingTime);
// Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
if (data.fastBreakPenalties.score(cc.fastBreakBucketFactor) > cc.fastBreakGrace){
// TODO: maybe add one absolute penalty time for big amounts to stop breaking until then // Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
final double vlAdded = (double) missingTime / 1000.0; if (data.fastBreakPenalties.score(cc.fastBreakBucketFactor) > cc.fastBreakGrace){
data.fastBreakVL += vlAdded; // TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
final ViolationData vd = new ViolationData(this, player, data.fastBreakVL, vlAdded, cc.fastBreakActions); final double vlAdded = (double) missingTime / 1000.0;
if (vd.needsParameters()) vd.setParameter(ParameterName.BLOCK_ID, "" + id); data.fastBreakVL += vlAdded;
cancel = executeActions(vd); final ViolationData vd = new ViolationData(this, player, data.fastBreakVL, vlAdded, cc.fastBreakActions);
if (vd.needsParameters()) vd.setParameter(ParameterName.BLOCK_ID, "" + id);
cancel = executeActions(vd);
}
// else: still within contention limits.
} }
// else: still within contention limits.
} }
else if (breakingTime > cc.fastBreakDelay){ else if (breakingTime > cc.fastBreakDelay){
// Fast breaking does not decrease violation level. // Fast breaking does not decrease violation level.