From c824f54c3d6089213f3ab1dae75e5f93743fe953 Mon Sep 17 00:00:00 2001 From: asofold Date: Fri, 9 Nov 2012 10:28:57 +0100 Subject: [PATCH] ExecutionHistory: Do not add entries for actions that always execute. --- .../nocheatplus/players/ExecutionHistory.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/players/ExecutionHistory.java b/src/fr/neatmonster/nocheatplus/players/ExecutionHistory.java index a7f38ed7..81af89a6 100644 --- a/src/fr/neatmonster/nocheatplus/players/ExecutionHistory.java +++ b/src/fr/neatmonster/nocheatplus/players/ExecutionHistory.java @@ -149,20 +149,22 @@ public class ExecutionHistory { entries = new HashMap(); } - /** - * Returns true, if the action should be executed, because all time criteria have been met. Will add a entry with - * the time to a list which will influence further requests, so only use once and remember the result. - * - * @param violationData - * the violation data - * @param action - * the action - * @param time - * a time IN SECONDS - * @return true, if the action is to be executed. - */ - public boolean executeAction(final ViolationData violationData, final Action action, final long time) { - + /** + * Returns true, if the action should be executed, because all time criteria + * have been met. Will add a entry with the time to a list which will + * influence further requests, so only use once and remember the result. + * If the action is to be executed always, it will not be added to the history. + * @param violationData + * the violation data + * @param action + * the action + * @param time + * a time IN SECONDS + * @return true, if the action is to be executed. + */ + public boolean executeAction(final ViolationData violationData, final Action action, final long time) + { + if (action.executesAlways()) return true; ExecutionHistoryEntry entry = entries.get(action); if (entry == null) { entry = new ExecutionHistoryEntry(60); @@ -190,7 +192,9 @@ public class ExecutionHistory { * @param time * @return */ - public boolean wouldExecute(final ViolationData violationData, final Action action, final long time) { + public boolean wouldExecute(final ViolationData violationData, final Action action, final long time) + { + if (action.executesAlways()) return true; ExecutionHistoryEntry entry = entries.get(action); if (entry == null) { return action.delay <= 0;