Visualiser:

Fixed the issue where a boat's time since last mark started counting from when the race screen loaded.
It now starts counting when the race actually starts.
main
fjc40 9 years ago
parent e5ae2543f8
commit 234748d056

@ -185,9 +185,7 @@ public class StreamedRace implements Runnable {
System.setProperty("javafx.animation.fullspeed", "true");
for (Boat boat : startingBoats) {
boat.setStarted(true);
}
new AnimationTimer() {
@ -199,18 +197,27 @@ public class StreamedRace implements Runnable {
public void handle(long arg0) {
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
//Check if the race has actually started.
if (visualiserInput.getRaceStatus().isStarted()) {
//Set all boats to started.
for (Boat boat : startingBoats) {
if (boat != null && !boat.isFinished()) {
updatePosition(boat);
checkPosition(boat, totalTimeElapsed);
}
boat.setStarted(true);
}
}
for (Boat boat : startingBoats) {
if (boat != null && !boat.isFinished()) {
updatePosition(boat);
checkPosition(boat, totalTimeElapsed);
}
for (Marker mark: boatMarkers){
if (mark != null){
updateMarker(mark);
}
}
for (Marker mark: boatMarkers){
if (mark != null){
updateMarker(mark);
}
}
if (visualiserInput.getRaceStatus().isFinished()) {
controller.finishRace(startingBoats);

@ -328,6 +328,12 @@ public class ResizableRaceCanvas extends ResizableCanvas {
if (Duration.between(boat.getTimeSinceLastMark(), raceClock.getTime()).getSeconds() < 0) {
boat.setTimeSinceLastMark(raceClock.getTime());
}
//If the race hasn't started, we set the time since last mark to the current time, to ensure we don't start counting until the race actually starts.
if (boat.isStarted() == false) {
boat.setTimeSinceLastMark(raceClock.getTime());
}
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getFormattedEstTime(), boat.getTimeSinceLastMark());
//TODO this needs to be fixed.
drawTrack(boat, boatColours.get(sourceID));

Loading…
Cancel
Save