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:
@@ -72,8 +72,6 @@ public class Event {
|
|||||||
*/
|
*/
|
||||||
public Event(boolean singlePlayer) throws EventConstructionException {
|
public Event(boolean singlePlayer) throws EventConstructionException {
|
||||||
|
|
||||||
singlePlayer = false;//TEMP
|
|
||||||
|
|
||||||
String raceXMLFile = "mock/mockXML/raceTest.xml";
|
String raceXMLFile = "mock/mockXML/raceTest.xml";
|
||||||
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
||||||
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ public class MockRace extends Race {
|
|||||||
|
|
||||||
this.updateEstimatedTime(boat);
|
this.updateEstimatedTime(boat);
|
||||||
}
|
}
|
||||||
checkPosition(boat, totalElapsedMilliseconds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newOptimalVMG(MockBoat boat) {
|
private void newOptimalVMG(MockBoat boat) {
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
CompoundMark currentCompoundMark = this.compoundMarkMap.get(cornerID);
|
CompoundMark currentCompoundMark = this.compoundMarkMap.get(cornerID);
|
||||||
|
|
||||||
//Sets the rounding type of this compound mark
|
//Sets the rounding type of this compound mark
|
||||||
currentCompoundMark.setRoundingType(RoundingType.valueOf(cornerRounding));
|
currentCompoundMark.setRoundingType(RoundingType.getValueOf(cornerRounding));
|
||||||
|
|
||||||
//Create a leg from these two adjacent compound marks.
|
//Create a leg from these two adjacent compound marks.
|
||||||
Leg leg = new Leg(legName, lastCompoundMark, currentCompoundMark, i - 1);
|
Leg leg = new Leg(legName, lastCompoundMark, currentCompoundMark, i - 1);
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public class Boat {
|
|||||||
/**
|
/**
|
||||||
* The time at which the boat is estimated to reach the next mark, in milliseconds since unix epoch.
|
* The time at which the boat is estimated to reach the next mark, in milliseconds since unix epoch.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
private ZonedDateTime estimatedTimeAtNextMark;
|
private ZonedDateTime estimatedTimeAtNextMark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,6 +107,8 @@ public class Boat {
|
|||||||
|
|
||||||
this.bearing = Bearing.fromDegrees(0d);
|
this.bearing = Bearing.fromDegrees(0d);
|
||||||
|
|
||||||
|
setCurrentPosition(new GPSCoordinate(0, 0));
|
||||||
|
|
||||||
this.status = BoatStatusEnum.UNDEFINED;
|
this.status = BoatStatusEnum.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +368,7 @@ public class Boat {
|
|||||||
* Returns the time at which the boat should reach the next mark.
|
* Returns the time at which the boat should reach the next mark.
|
||||||
* @return Time at which the boat should reach next mark.
|
* @return Time at which the boat should reach next mark.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public ZonedDateTime getEstimatedTimeAtNextMark() {
|
public ZonedDateTime getEstimatedTimeAtNextMark() {
|
||||||
return estimatedTimeAtNextMark;
|
return estimatedTimeAtNextMark;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,13 +342,7 @@ public abstract class Race {
|
|||||||
return lastFps;
|
return lastFps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the legs of this race
|
|
||||||
* @return list of legs
|
|
||||||
*/
|
|
||||||
public List<Leg> getLegs() {
|
|
||||||
return legs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increments the FPS counter, and adds timePeriod milliseconds to our FPS reset timer.
|
* Increments the FPS counter, and adds timePeriod milliseconds to our FPS reset timer.
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class HostController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public void hostGamePressed() throws IOException{
|
public void hostGamePressed() throws IOException{
|
||||||
try {
|
try {
|
||||||
Event game = new Event(true);
|
Event game = new Event(false);
|
||||||
game.start();
|
game.start();
|
||||||
connectSocket("localhost", 4942);
|
connectSocket("localhost", 4942);
|
||||||
} catch (EventConstructionException e) {
|
} catch (EventConstructionException e) {
|
||||||
|
|||||||
@@ -317,40 +317,36 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
*/
|
*/
|
||||||
private void drawBoat(VisualiserBoat boat) {
|
private void drawBoat(VisualiserBoat boat) {
|
||||||
|
|
||||||
//The position may be null if we haven't received any BoatLocation messages yet.
|
if (boat.isClientBoat()) {
|
||||||
if (boat.getCurrentPosition() != null) {
|
drawClientBoat(boat);
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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
|
* draws a transparent line around the course that shows the paths boats must travel
|
||||||
*/
|
*/
|
||||||
public void drawRaceLine(){
|
public void drawRaceLine(){
|
||||||
List<Leg> legs = this.visualiserRace.getLegs();
|
List<Leg> legs = this.visualiserRace.getVisualiserRaceState().getLegs();
|
||||||
GPSCoordinate legStartPoint = legs.get(0).getStartCompoundMark().getAverageGPSCoordinate();
|
GPSCoordinate legStartPoint = legs.get(0).getStartCompoundMark().getAverageGPSCoordinate();
|
||||||
GPSCoordinate nextStartPoint;
|
GPSCoordinate nextStartPoint;
|
||||||
for (int i = 0; i < legs.size() -1; i++) {
|
for (int i = 0; i < legs.size() -1; i++) {
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
<Yacht SourceID="126"/>
|
<Yacht SourceID="126"/>
|
||||||
</Participants>
|
</Participants>
|
||||||
<CompoundMarkSequence>
|
<CompoundMarkSequence>
|
||||||
<Corner CompoundMarkID="1" SeqID="1"/>
|
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3" />
|
||||||
<Corner CompoundMarkID="2" SeqID="2"/>
|
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" />
|
||||||
<Corner CompoundMarkID="4" SeqID="3"/>
|
<Corner SeqID="3" CompoundMarkID="4" Rounding="Port" ZoneSize="3" />
|
||||||
<Corner CompoundMarkID="3" SeqID="4"/>
|
<Corner SeqID="4" CompoundMarkID="3" Rounding="Starboard" ZoneSize="3" />
|
||||||
<Corner CompoundMarkID="4" SeqID="5"/>
|
<Corner SeqID="5" CompoundMarkID="4" Rounding="Port" ZoneSize="3" />
|
||||||
<Corner CompoundMarkID="5" SeqID="6"/>
|
<Corner SeqID="6" CompoundMarkID="5" Rounding="SP" ZoneSize="3"/>
|
||||||
</CompoundMarkSequence>
|
</CompoundMarkSequence>
|
||||||
<Course>
|
<Course>
|
||||||
<CompoundMark CompoundMarkID="1" Name="Start Line">
|
<CompoundMark CompoundMarkID="1" Name="Start Line">
|
||||||
|
|||||||
Reference in New Issue
Block a user