Minor bug fixes.

Server will now only save incoming connections if in lobbying mode as it should
Commented out boat status printing

tags: #story[1047]
This commit is contained in:
Michael Rausch
2017-07-27 14:15:55 +12:00
parent 1d9dd76356
commit 25d8c8f9c4
2 changed files with 14 additions and 8 deletions
@@ -136,13 +136,7 @@ public class GameState implements Runnable {
break; break;
} }
System.out.println("-----------------------"); // printBoatStatus(playerYacht);
System.out.println("Sails are in: " + playerYacht.getSailIn());
System.out.println("Heading: " + playerYacht.getHeading());
System.out.println("Velocity: " + playerYacht.getVelocityMMS() / 1000);
System.out.println("Lat: " + playerYacht.getLocation().getLat());
System.out.println("Lng: " + playerYacht.getLocation().getLng());
System.out.println("-----------------------\n");
} }
public static void update() { public static void update() {
@@ -186,4 +180,14 @@ public class GameState implements Runnable {
} }
} }
} }
private static void printBoatStatus(Yacht playerYacht) {
System.out.println("-----------------------");
System.out.println("Sails are in: " + playerYacht.getSailIn());
System.out.println("Heading: " + playerYacht.getHeading());
System.out.println("Velocity: " + playerYacht.getVelocityMMS() / 1000);
System.out.println("Lat: " + playerYacht.getLocation().getLat());
System.out.println("Lng: " + playerYacht.getLocation().getLng());
System.out.println("-----------------------\n");
}
} }
@@ -27,9 +27,11 @@ public class ServerListenThread extends Thread{
private void acceptConnection() { private void acceptConnection() {
try { try {
Socket thisClient = serverSocket.accept(); Socket thisClient = serverSocket.accept();
if (thisClient != null){ if (thisClient != null && GameState.getCurrentStage().equals(GameStages.LOBBYING)) {
ServerToClientThread thisConnection = new ServerToClientThread(thisClient); ServerToClientThread thisConnection = new ServerToClientThread(thisClient);
delegate.clientConnected(thisConnection); delegate.clientConnected(thisConnection);
} else {
thisClient.close();
} }
} catch (IOException e) { } catch (IOException e) {
e.getMessage(); e.getMessage();