Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix control point progress recovery NPE #886

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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