Fixed null pointer exception when a boat finishes the race.
Boats now default to have position (0, 0). Added mark rounding data to single player race.xml
This commit is contained in:
@@ -317,40 +317,36 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
*/
|
||||
private void drawBoat(VisualiserBoat boat) {
|
||||
|
||||
//The position may be null if we haven't received any BoatLocation messages yet.
|
||||
if (boat.getCurrentPosition() != null) {
|
||||
|
||||
if (boat.isClientBoat()) {
|
||||
drawClientBoat(boat);
|
||||
}
|
||||
|
||||
//Convert position to graph coordinate.
|
||||
GraphCoordinate pos = this.map.convertGPS(boat.getCurrentPosition());
|
||||
|
||||
//The x coordinates of each vertex of the boat.
|
||||
double[] x = {
|
||||
pos.getX() - 6,
|
||||
pos.getX(),
|
||||
pos.getX() + 6 };
|
||||
|
||||
//The y coordinates of each vertex of the boat.
|
||||
double[] y = {
|
||||
pos.getY() + 12,
|
||||
pos.getY() - 12,
|
||||
pos.getY() + 12 };
|
||||
|
||||
//The above shape is essentially a triangle 12px wide, and 24px long.
|
||||
|
||||
//Draw the boat.
|
||||
gc.setFill(boat.getColor());
|
||||
|
||||
gc.save();
|
||||
rotate(boat.getBearing().degrees(), pos.getX(), pos.getY());
|
||||
gc.fillPolygon(x, y, 3);
|
||||
gc.restore();
|
||||
|
||||
if (boat.isClientBoat()) {
|
||||
drawClientBoat(boat);
|
||||
}
|
||||
|
||||
//Convert position to graph coordinate.
|
||||
GraphCoordinate pos = this.map.convertGPS(boat.getCurrentPosition());
|
||||
|
||||
//The x coordinates of each vertex of the boat.
|
||||
double[] x = {
|
||||
pos.getX() - 6,
|
||||
pos.getX(),
|
||||
pos.getX() + 6 };
|
||||
|
||||
//The y coordinates of each vertex of the boat.
|
||||
double[] y = {
|
||||
pos.getY() + 12,
|
||||
pos.getY() - 12,
|
||||
pos.getY() + 12 };
|
||||
|
||||
//The above shape is essentially a triangle 12px wide, and 24px long.
|
||||
|
||||
//Draw the boat.
|
||||
gc.setFill(boat.getColor());
|
||||
|
||||
gc.save();
|
||||
rotate(boat.getBearing().degrees(), pos.getX(), pos.getY());
|
||||
gc.fillPolygon(x, y, 3);
|
||||
gc.restore();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,7 +517,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
* draws a transparent line around the course that shows the paths boats must travel
|
||||
*/
|
||||
public void drawRaceLine(){
|
||||
List<Leg> legs = this.visualiserRace.getLegs();
|
||||
List<Leg> legs = this.visualiserRace.getVisualiserRaceState().getLegs();
|
||||
GPSCoordinate legStartPoint = legs.get(0).getStartCompoundMark().getAverageGPSCoordinate();
|
||||
GPSCoordinate nextStartPoint;
|
||||
for (int i = 0; i < legs.size() -1; i++) {
|
||||
|
||||
Reference in New Issue
Block a user