Skip to content

Commit

Permalink
Fix control point progress recovery NPE
Browse files Browse the repository at this point in the history
Signed-off-by: Pugzy <[email protected]>
  • Loading branch information
Pugzy authored and Electroid committed Jun 4, 2021
1 parent 405f5f7 commit 66455cd
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -479,20 +480,22 @@ 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) {
this.controllingTeam = null;
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
Expand All @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 66455cd

Please sign in to comment.