From b7606f4edd0350b2ddd2f4c14ba368e7c1a80099 Mon Sep 17 00:00:00 2001 From: Pugzy Date: Fri, 4 Jun 2021 21:36:02 +0100 Subject: [PATCH] Fix control point progress recovery NPE Signed-off-by: Pugzy --- .../tc/oc/pgm/controlpoint/ControlPoint.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java index 2ca5d7cb63..08db8c6a80 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java @@ -463,11 +463,12 @@ private void dominate(Competitor dominantTeam, Duration dominantTime) { return null; } else { final Duration remainder = duration.minus(this.capturingTime); - this.capturingTime = duration.ZERO; + this.capturingTime = Duration.ZERO; return remainder; } } - // Progress to a new owner + + /** Progress to a new owner */ private void capture(Duration dominantTime) { dominantTime = addCaptureTime(dominantTime); if (dominantTime != null) { // Point is captured @@ -479,7 +480,8 @@ private void capture(Duration dominantTime) { } } } - // Progress towards the neutral state + + /** Progress towards the neutral state */ private void uncapture(Competitor dominantTeam, Duration dominantTime) { dominantTime = addCaptureTime(dominantTime); if (dominantTime != null) { @@ -487,12 +489,13 @@ private void uncapture(Competitor dominantTeam, Duration dominantTime) { this.dominate(dominantTeam, dominantTime); } } - // Point being pulled back to current state (There is a lead on the point) + + /** Point being pulled back to current state (There is a lead on the point) */ private void recover(Competitor dominantTeam, Duration dominantTime) { dominantTime = subtractCaptureTime( Duration.ofMillis((long) (definition.getRecoveryRate() * dominantTime.toMillis()))); - if (dominantTeam != null) { + if (dominantTime != null) { this.capturingTeam = null; if (dominantTeam != this.controllingTeam) { // If the dominant team is not the controller, recurse with the remaining time @@ -503,7 +506,8 @@ private void recover(Competitor dominantTeam, Duration dominantTime) { } } } - // Point is being decayed back to its current state (No lead on point) + + /** Point is being decayed back to its current state (No lead on point) */ private void decay(Duration dominantTime) { dominantTime = subtractCaptureTime( @@ -513,7 +517,7 @@ private void decay(Duration dominantTime) { } } - // Point is being decayed back to neutral (No lead on point) + /** Point is being decayed back to neutral (No lead on point) */ private void ownedDecay(Duration dominantTime) { dominantTime = addCaptureTime(