Skip to content

Commit

Permalink
remove dangerous code
Browse files Browse the repository at this point in the history
  • Loading branch information
0us committed Nov 7, 2019
1 parent 75a5190 commit c2ae84b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
6 changes: 1 addition & 5 deletions server/src/main/java/no/ntnu/trostespel/GameServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void updateClients() {

private void broadcastUpdate() {
try {
sender.broadcast(Connections.getInstance().getConnections(), getTickcounter());
sender.broadcast(Connections.getInstance().getConnections(), tickCounter.get());
} catch (InterruptedException e) {
// Server is running too slow
e.printStackTrace();
Expand Down Expand Up @@ -147,8 +147,4 @@ private void notifyObservers(long tick) {
tickable.onTick(tick);
}
}

private static long getTickcounter() {
return tickCounter.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public PlayerUpdater(GameState gameState, long pid) {
this.pid = pid;
}

private void putProjectile ( long k, MovableState v){
private void putProjectile(long k, MovableState v) {
gameState.getProjectilesStateUpdates().add(v);
gameState.getProjectiles().put(k, v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public GameDataSender() {
* Does the update tasks for the server.
*/
public void broadcast(List<Connection> connections, long tick) throws InterruptedException {
/*if (completedCount.get() != 0) {
throw new InterruptedException("Game data broadcast was interrupted");
// TODO: Change approach; this can potentially deadlock if one connection hangs
}*/
// Send GameState to all clients
nextGameState = gameStateMaster.getGameState();
nextGameState.setTick(tick);
// TODO: 15.10.2019 Add concurrency protection, since we will be modifying connecitons on the fly.
Expand All @@ -68,7 +63,6 @@ private Runnable send(Connection connection, String json) {
json.getBytes().length,
connection.getAddress(),
connection.getPort());

packet.setData(json.getBytes());
try {
DatagramSocket socket = connection.getClientSocket();
Expand Down

0 comments on commit c2ae84b

Please sign in to comment.