Updated maven version to 2.0.

Added a dedicatedServer module.
Removed Visualiser module.
Removed mock module.
Removed network module.
Fixed weird exception non-handling that appeared for some reason.
This commit is contained in:
fjc40
2017-08-18 22:55:50 +12:00
parent 0d2be85d17
commit a9fde95b39
44 changed files with 63 additions and 2022 deletions
+2 -2
View File
@@ -4,13 +4,13 @@
<parent>
<groupId>seng302</groupId>
<artifactId>team-7</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0</version>
</parent>
<packaging>jar</packaging>
<name>racevisionGame</name>
<artifactId>racevisionGame</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0</version>
<dependencies>
<dependency>
@@ -79,7 +79,7 @@ public class Event {
*/
public Event(boolean singlePlayer) throws EventConstructionException {
String raceXMLFile = "mock/mockXML/raceThreePlayers.xml";//TEMP 3 player race - for demo on 18th august
String raceXMLFile = "mock/mockXML/raceTest.xml";
String boatsXMLFile = "mock/mockXML/boatTest.xml";
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
@@ -171,13 +171,6 @@ public class Event {
/**
* Sends the initial race data and then begins race simulation.
*/
public void start() {
}
/**
* Sends out each xml string, via the mock output
@@ -101,8 +101,6 @@ public class MockOutput implements RunnableWithFramePeriod {
Logger.getGlobal().log(Level.WARNING, "MockOutput.run() interrupted while putting message in queue.", e);
Thread.currentThread().interrupt();
return;
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -92,11 +92,8 @@ public class HeartBeatService implements RunnableWithFramePeriod {
while (!Thread.interrupted()) {
long currentFrameTime = System.currentTimeMillis();
try {
waitForFramePeriod(lastHeartbeatTime, currentFrameTime, heartbeatPeriod);
} catch (Exception e) {
e.printStackTrace();
}
waitForFramePeriod(lastHeartbeatTime, currentFrameTime, heartbeatPeriod);
lastHeartbeatTime = currentFrameTime;
try {
@@ -50,17 +50,9 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
public void run() {
race.initialiseBoats();
try {
countdown();
} catch (Exception e) {
e.printStackTrace();
}
countdown();
try {
raceLoop();
} catch (Exception e) {
e.printStackTrace();
}
raceLoop();
}
public void boolFalse(){
@@ -71,7 +63,7 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
/**
* Countdown timer until race starts.
*/
private void countdown() throws Exception {
private void countdown() {
long previousFrameTime = System.currentTimeMillis();
@@ -110,7 +102,7 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
/**
* Timer that runs for the duration of the race, until all boats finish.
*/
private void raceLoop() throws Exception {
private void raceLoop() {
long previousFrameTime = System.currentTimeMillis();
@@ -199,4 +191,4 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
// else if(e.getBearing().degrees() > 270) System.out.println("Port");
// else System.out.println("Behind");
}
}
}
@@ -93,11 +93,7 @@ public class MessageSerialiser implements RunnableWithFramePeriod {
long currentFrameTime = System.currentTimeMillis();
try {
waitForFramePeriod(previousFrameTime, currentFrameTime, 16);
} catch (Exception e) {
e.printStackTrace();
}
waitForFramePeriod(previousFrameTime, currentFrameTime, 16);
previousFrameTime = currentFrameTime;
@@ -20,8 +20,7 @@ public interface RunnableWithFramePeriod extends Runnable {
* @param currentFrameTime The timestamp of the current frame.
* @param minimumFramePeriod The minimum period the frame must be.
*/
default void waitForFramePeriod(long previousFrameTime, long currentFrameTime, long minimumFramePeriod) throws Exception {
default void waitForFramePeriod(long previousFrameTime, long currentFrameTime, long minimumFramePeriod) {
//This is the time elapsed, in milliseconds, since the last server "frame".
long framePeriod = currentFrameTime - previousFrameTime;
@@ -39,10 +38,10 @@ public interface RunnableWithFramePeriod extends Runnable {
} catch (InterruptedException e) {
//If we get interrupted, exit the function.
/*Logger.getGlobal().log(Level.SEVERE, "RunnableWithFramePeriod.waitForFramePeriod().sleep(framePeriod) was interrupted on thread: " + Thread.currentThread(), e);
//Logger.getGlobal().log(Level.WARNING, "RunnableWithFramePeriod.waitForFramePeriod().sleep(framePeriod) was interrupted on thread: " + Thread.currentThread(), e);
//Re-set the interrupt flag.
Thread.currentThread().interrupt();
return;*/
return;
}
@@ -49,7 +49,6 @@ public class HostController extends Controller {
public void hostGamePressed() throws IOException{
try {
this.game = new Event(false);
game.start();
connectSocket("localhost", 4942);
} catch (EventConstructionException e) {
Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e);
@@ -68,13 +68,7 @@ public class VisualiserRaceService implements RunnableWithFramePeriod {
while (!Thread.interrupted()) {
long currentFrameTime = System.currentTimeMillis();
try {
waitForFramePeriod(previousFrameTime, currentFrameTime, 16);
} catch (Exception e) {
e.printStackTrace();
}
waitForFramePeriod(previousFrameTime, currentFrameTime, 16);
previousFrameTime = currentFrameTime;
@@ -330,11 +330,8 @@ public class ServerConnection implements RunnableWithFramePeriod {
while (!Thread.interrupted()) {
long currentFrameTime = System.currentTimeMillis();
try {
waitForFramePeriod(previousFrameTime, currentFrameTime, 100);
} catch (Exception e) {
e.printStackTrace();
}
waitForFramePeriod(previousFrameTime, currentFrameTime, 100);
previousFrameTime = currentFrameTime;