/** * @deprecated Use instead: score(float). * @param factor * @return */ public final float getScore(final float factor) { return score(factor); }
/** * Get a weighted sum score, weight for bucket i: w(i) = factor^i. * @param factor * @return */ public final float score(final float factor) { return sliceScore(0, buckets.length, factor); }
/** * Update and add (updates reference and update time). * @param now * @param amount */ public final void add(final long now, final float amount) { update(now); buckets[0] += amount; }
/** * Update and then reduce all given ActionFrequency instances by the given * amount, without capping the result. * * @param amount * The amount to subtract. * @param freqs */ public static void subtract(final long time, final float amount, final ActionFrequency... freqs) { for (int i = 0; i < freqs.length; i++) { final ActionFrequency freq = freqs[i]; freq.update(time); freq.setBucket(0, freq.bucketScore(0) - amount); } }
public FightData(final FightConfig config){ speedBuckets = new ActionFrequency(config.speedBuckets, config.speedBucketDur); // Start with full fast-heal buffer. fastHealBuffer = config.fastHealBuffer; }
/** * Reset tick and tick stats to 0 (!). */ public static void reset() { tick = 0; timeLast = 0; for (int i = 0; i < lagMaxTicks; i++) { tickDurations[i] = 0; tickDurationsSq[i] = 0; } for (int i = 0; i < spikeDurations.length; i++) { spikes[i].clear(0); } }
/** * @deprecated Use instead: score(float). * @param factor * @return */ public final float getScore(final int bucket) { return bucketScore(bucket); }
/** * Clear accounting data. */ public void clearAccounting() { vDistAcc.clear(); }
public void add(float value){ if (counts[0] >= bucketCapacity){ shift(); } counts[0] ++; buckets[0] += value; }
/** * Reduce the morepackets frequency counters by the given amount, capped at * a minimum of 0. * * @param amount */ public void reducePlayerMorePacketsData(final float amount) { ActionFrequency.reduce(System.currentTimeMillis(), amount, morePacketsFreq, morePacketsBurstFreq); }
/** * Feed the check but no violations processing (convenience method). * @param player * @param weight * @param now * @param pData */ public static final void feed(final Player player, final float weight, final long now, final IPlayerData pData){ pData.getGenericInstance(CombinedData.class).improbableCount.add(now, weight); }
/** * Get heavy lag spikes of the last hour (> 450 ms supposedly, first * duration bigger than 150 ms). * * @return the heavy lag spikes * @deprecated What is heavy :) ? */ public static final int getHeavyLagSpikes() { spikes[1].update(System.currentTimeMillis()); return (int) spikes[1].score(1f); }
public NetData(final NetConfig config) { flyingFrequencyAll = new ActionFrequency(config.flyingFrequencySeconds, 1000L); flyingFrequencyRedundantFreq = new ActionFrequency(config.flyingFrequencyRedundantSeconds, 1000L); if (config.packetFrequencySeconds <= 2) { packetFrequency = new ActionFrequency(config.packetFrequencySeconds * 3, 333); } else { packetFrequency = new ActionFrequency(config.packetFrequencySeconds * 2, 500); } }
/** * Get score from start on, with factor. * @param start This is included. * @param factor * @return */ public final float trailingScore(final int start, float factor) { return sliceScore(start, buckets.length, factor); }
/** * Get total number of lag spikes counted at all. This is the number of lag * spikes with a duration above spikeDuations[0] which should be 150 ms. * This is the score of spikes[0]. * * @return the number of lag spikes */ public static final int getNumberOfLagSpikes() { spikes[0].update(System.currentTimeMillis()); return (int) spikes[0].score(1f); }
public BlockBreakData(final BlockBreakConfig cc) { setStats(); fastBreakPenalties = new ActionFrequency(cc.fastBreakBuckets, cc.fastBreakBucketDur); frequencyBuckets = new ActionFrequency(cc.frequencyBuckets, cc.frequencyBucketDur); wrongBlockVL = new ActionFrequency(6, 20000); }
/** * Get score of first end buckets, with factor. * @param end Number of buckets including start. The end is not included. * @param factor * @return */ public final float leadingScore(final int end, float factor) { return sliceScore(0, end, factor); }
private ActionFrequency getActionFrequency(String worldName, int buckets, long durBucket, boolean perWorldCount){ if (!perWorldCount) worldName = ""; ActionFrequency freq = counts.get(worldName); if (freq == null) freq = new ActionFrequency(buckets, durBucket); counts.put(worldName, freq); return freq; }