Fixed the Yacht clas so it now works.

Lists and Maps are instantiated as they should be in GameState which were creating NullPointers
Introduced ServerLog to server to client threads for bug reporting
Introduced some print statements to test the game state updating upon receiving key presses

tags: #story[989] #refactor #fix
This commit is contained in:
William Muir
2017-07-22 16:32:05 +12:00
parent 913e5fee7b
commit a0005064ac
4 changed files with 237 additions and 14 deletions
@@ -2,7 +2,6 @@ package seng302.gameServer;
import java.util.Random;
import seng302.client.ClientPacketParser;
import seng302.models.Player;
import seng302.models.Yacht;
import seng302.models.stream.packets.PacketType;
@@ -22,6 +21,8 @@ import seng302.utilities.GeoPoint;
* Created by wmu16 on 13/07/17.
*/
public class ServerToClientThread extends Thread {
private static final Integer LOG_LEVEL = 1;
private static final Integer MAX_ID_ATTEMPTS = 10;
private InputStream is;
@@ -51,6 +52,13 @@ public class ServerToClientThread extends Thread {
GameState.addYacht(sourceId, new Yacht("Kappa", "Kap", new GeoPoint(0.0, 0.0), 0.0));
}
static void serverLog(String message, int logLevel){
if(logLevel <= LOG_LEVEL){
System.out.println("[SERVER] " + message);
}
}
public void run() {
int sync1;
int sync2;
@@ -100,6 +108,7 @@ public class ServerToClientThread extends Thread {
}
}
} catch (Exception e) {
serverLog("ERROR OCCURED, CLOSING SERVER CONNETION: " + socket.getRemoteSocketAddress().toString(), 1);
closeSocket();
return;
}