diff --git a/robocode.api/src/main/java/robocode/Event.java b/robocode.api/src/main/java/robocode/Event.java index 5c27c4999..54aec7003 100644 --- a/robocode.api/src/main/java/robocode/Event.java +++ b/robocode.api/src/main/java/robocode/Event.java @@ -170,6 +170,13 @@ private void setTimeHidden(long time) { */ // This method must be invisible on Robot API private void setPriorityHidden(int newPriority) { + // System events have a fixed priority (e.g. 100) that is outside the 0-99 range allowed for + // robot-defined events. The priority of a system event must not be changed, and the 0-99 rule + // must not be enforced for them, as that would clamp their priority and emit misleading + // warnings on the robot console. + if (isCriticalEvent()) { + return; + } if (newPriority < 0) { Logger.printlnToRobotsConsole("SYSTEM: Priority must be between 0 and 99"); Logger.printlnToRobotsConsole("SYSTEM: Priority for " + this.getClass().getName() + " will be 0"); diff --git a/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java b/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java index 54d826ac3..f628558b7 100644 --- a/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java +++ b/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java @@ -510,6 +510,7 @@ public void setEventPriority(String eventClass, int priority) { } if (HiddenAccess.isCriticalEvent(event)) { robotProxy.println("SYSTEM: You may not change the priority of a system event."); + return; } HiddenAccess.setEventPriority(event, priority); }