[Bleeding] Account for server side lag in fight.speed.

This commit is contained in:
asofold 2013-01-04 14:49:11 +01:00
parent adf91b88d6
commit 202a3ec0c9

View File

@ -50,14 +50,24 @@ public class Speed extends Check {
// Add to frequency. // Add to frequency.
data.speedBuckets.add(now, 1f); data.speedBuckets.add(now, 1f);
// Medium term (normalized to one second). // Medium term (normalized to one second), account for server side lag.
final float total = data.speedBuckets.score(cc.speedBucketFactor) * 1000f / (float) (cc.speedBucketDur * cc.speedBuckets); final long fullTime = cc.speedBucketDur * cc.speedBuckets;
final float fullLag = cc.lag ? TickTask.getLag(fullTime, true) : 1f;
final float total = data.speedBuckets.score(cc.speedBucketFactor) * 1000f / (fullLag * fullTime);
// Short term. // Short term.
final int tick = TickTask.getTick(); final int tick = TickTask.getTick();
if (tick - data.speedShortTermTick < cc.speedShortTermTicks){ if (tick - data.speedShortTermTick < cc.speedShortTermTicks){
// Within range, add. // Account for server side lag.
data.speedShortTermCount ++; if (!cc.lag || TickTask.getLag(50L * (tick - data.speedShortTermTick), true) < 1.5f){
// Within range, add.
data.speedShortTermCount ++;
}
else{
// Too much lag, reset.
data.speedShortTermTick = tick;
data.speedShortTermCount = 1;
}
} }
else{ else{
data.speedShortTermTick = tick; data.speedShortTermTick = tick;