Fixed disconnection issues. Fix is only temporary until a consistent interface for disconnections exists.

#bug #implement
This commit is contained in:
Calum
2017-08-17 14:10:38 +12:00
parent 0276911b88
commit 3639e0d3ce
5 changed files with 9 additions and 14 deletions
@@ -423,7 +423,6 @@ public class GameState implements Runnable {
private void checkForLegProgression(ServerYacht yacht) { private void checkForLegProgression(ServerYacht yacht) {
Integer currentMarkSeqID = yacht.getCurrentMarkSeqID(); Integer currentMarkSeqID = yacht.getCurrentMarkSeqID();
CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID); CompoundMark currentMark = markOrder.getCurrentMark(currentMarkSeqID);
// System.out.println(yacht.getCurrentMarkSeqID());
Boolean hasProgressed; Boolean hasProgressed;
if (currentMarkSeqID == 0) { if (currentMarkSeqID == 0) {
@@ -192,7 +192,6 @@ public class ServerToClientThread implements Runnable, Observer {
long computedCrc = checksum.getValue(); long computedCrc = checksum.getValue();
long packetCrc = Message.bytesToLong(getBytes(4)); long packetCrc = Message.bytesToLong(getBytes(4));
if (computedCrc == packetCrc) { if (computedCrc == packetCrc) {
//System.out.println("RECEIVED A PACKET");
switch (PacketType.assignPacketType(type, payload)) { switch (PacketType.assignPacketType(type, payload)) {
case BOAT_ACTION: case BOAT_ACTION:
BoatAction actionType = ServerPacketParser BoatAction actionType = ServerPacketParser
@@ -229,7 +228,11 @@ public class ServerToClientThread implements Runnable, Observer {
} }
//@TODO calculate lat/lng values //@TODO calculate lat/lng values
xml.setRegatta(new Regatta("Party Parrot Test Server", "Bermuda Test Course", 57.6679590, 11.8503233)); xml.setRegatta(
new Regatta(
"Party Parrot Test Server", "Bermuda Test Course",
57.6679590, 11.8503233)
);
xml.setRace(race); xml.setRace(race);
XMLMessage xmlMessage; XMLMessage xmlMessage;
@@ -289,8 +292,7 @@ public class ServerToClientThread implements Runnable, Observer {
try { try {
os.write(message.getBuffer()); os.write(message.getBuffer());
} catch (SocketException e) { } catch (SocketException e) {
//serverLog("Player " + sourceId + " side socket disconnected", 1); logger.warn("Player " + sourceId + " side socket disconnected", 1);
return;
} catch (IOException e) { } catch (IOException e) {
logger.warn("Message send failed", 1); logger.warn("Message send failed", 1);
} }
@@ -410,7 +410,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
List<Text> vboxEntries = new ArrayList<>(); List<Text> vboxEntries = new ArrayList<>();
for (int i = 0; i < yachts.size(); i++) { for (int i = 0; i < yachts.size(); i++) {
// System.out.println("yacht == null " + String.valueOf(yacht == null));
if (yachts.get(i).getBoatStatus() == 3) { // 3 is finish status if (yachts.get(i).getBoatStatus() == 3) { // 3 is finish status
Text textToAdd = new Text(i + 1 + ". " + Text textToAdd = new Text(i + 1 + ". " +
yachts.get(i).getShortName() + " (Finished)"); yachts.get(i).getShortName() + " (Finished)");
@@ -49,17 +49,13 @@ public class Marker extends Group {
*/ */
public void addArrows(MarkArrowFactory.RoundingSide roundingSide, double entryAngle, public void addArrows(MarkArrowFactory.RoundingSide roundingSide, double entryAngle,
double exitAngle) { double exitAngle) {
//Change Color.GRAY to this.colour to revert all gray arrows.
enterArrows.add( enterArrows.add(
MarkArrowFactory.constructEntryArrow(roundingSide, entryAngle, exitAngle, colour) MarkArrowFactory.constructEntryArrow(roundingSide, entryAngle, exitAngle, Color.GRAY)
); );
exitArrows.add( exitArrows.add(
MarkArrowFactory.constructExitArrow(roundingSide, exitAngle, colour) MarkArrowFactory.constructExitArrow(roundingSide, exitAngle, Color.GRAY)
); );
// Platform.runLater(() -> {
// this.getChildren().add(enterArrows.get(enterArrows.size()-1));
// this.getChildren().add(exitArrows.get(exitArrows.size()-1));
// });
} }
/** /**
@@ -140,7 +140,6 @@ public class GeoUtilityTest {
// for (int i = 0; i < 100000; i++) { // for (int i = 0; i < 100000; i++) {
// assertTrue(GeoUtility.isPointInTriangle(v1, v2, v3, p1)); // assertTrue(GeoUtility.isPointInTriangle(v1, v2, v3, p1));
// } // }
// System.out.println((System.nanoTime() - startTime) / 1000000000.0);
// test for different orders of vertices, which should not affect the result // test for different orders of vertices, which should not affect the result
assertTrue(GeoUtility.isPointInTriangle(v2, v1, v3, p1)); assertTrue(GeoUtility.isPointInTriangle(v2, v1, v3, p1));