mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Tweaking to server loop making it send packets at 5Hz
Commented out some smoothing code in BoatGroup that was dependend on FPS screwing with movement
This commit is contained in:
@@ -19,6 +19,7 @@ public class MainServerThread implements Runnable, PacketBufferDelegate, ClientC
|
||||
|
||||
private static final int PORT = 4942;
|
||||
private static final Integer MAX_NUM_PLAYERS = 3;
|
||||
private static final Integer UPDATES_PER_SECOND = 5;
|
||||
private static final int LOG_LEVEL = 1;
|
||||
|
||||
private Thread thread;
|
||||
@@ -57,7 +58,7 @@ public class MainServerThread implements Runnable, PacketBufferDelegate, ClientC
|
||||
//You should handle interrupts in some way, so that the thread won't keep on forever if you exit the app.
|
||||
while (!thread.isInterrupted()) {
|
||||
try {
|
||||
Thread.sleep(1000 / 60); //60 times per second we should calculate the game state
|
||||
Thread.sleep(1000 / UPDATES_PER_SECOND); //60 times per second we should calculate the game state
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -77,7 +78,6 @@ public class MainServerThread implements Runnable, PacketBufferDelegate, ClientC
|
||||
else if (GameState.getCurrentStage() == GameStages.FINISHED) {
|
||||
|
||||
}
|
||||
updateClients();
|
||||
|
||||
while (!packetBuffer.isEmpty()){
|
||||
try {
|
||||
|
||||
@@ -184,7 +184,7 @@ public class ServerToClientThread implements Runnable {
|
||||
// } catch (IOException e) {
|
||||
// System.out.println("IO error in server thread upon writing to output stream");
|
||||
// }
|
||||
sendBoatLocationPackets();
|
||||
// sendBoatLocationPackets();
|
||||
updateClient = false;
|
||||
}
|
||||
|
||||
@@ -251,6 +251,7 @@ public class ServerToClientThread implements Runnable {
|
||||
}
|
||||
|
||||
public void updateClient() {
|
||||
sendBoatLocationPackets();
|
||||
updateClient = true;
|
||||
}
|
||||
|
||||
@@ -347,7 +348,15 @@ public class ServerToClientThread implements Runnable {
|
||||
ArrayList<Yacht> yachts = new ArrayList<>(GameState.getYachts().values());
|
||||
for (Yacht yacht: yachts){
|
||||
// System.out.println("[SERVER] Lat: " + yacht.getLocation().getLat() + " Lon: " + yacht.getLocation().getLng());
|
||||
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceId, getSeqNo(), yacht.getLocation().getLat(), yacht.getLocation().getLng(), yacht.getHeading(), (long) yacht.getVelocity());
|
||||
BoatLocationMessage boatLocationMessage =
|
||||
new BoatLocationMessage(
|
||||
sourceId,
|
||||
getSeqNo(),
|
||||
yacht.getLocation().getLat(),
|
||||
yacht.getLocation().getLng(),
|
||||
yacht.getHeading(),
|
||||
(long) yacht.getVelocity());
|
||||
|
||||
sendMessage(boatLocationMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user