Skip to content
Snippets Groups Projects
Commit 5c208cd9 authored by Stefano Grisendi's avatar Stefano Grisendi
Browse files

bugfix with more bugs

parent 90e3681b
No related branches found
No related tags found
No related merge requests found
...@@ -72,6 +72,7 @@ public class ServerController { ...@@ -72,6 +72,7 @@ public class ServerController {
if(lobby.getPlayersID().contains(id)){ if(lobby.getPlayersID().contains(id)){
ArrayList<Connection> connections = getConnections(lobby); ArrayList<Connection> connections = getConnections(lobby);
cLobbyLeave command = new cLobbyLeave(leaveLobby(id, lobby.getID())); cLobbyLeave command = new cLobbyLeave(leaveLobby(id, lobby.getID()));
leaveLobby(id, lobby.getID());
for(Connection c : connections){ for(Connection c : connections){
c.sendTCP(command); c.sendTCP(command);
} }
......
...@@ -25,14 +25,16 @@ public class cLobbyLeave extends Command{ ...@@ -25,14 +25,16 @@ public class cLobbyLeave extends Command{
playerId = (int) receivedData.get(1); playerId = (int) receivedData.get(1);
Lobby lobby = net.getLobby(lobbyId); Lobby lobby = net.getLobby(lobbyId);
data = net.leaveLobby(playerId, lobbyId); //Find new lobby without player
System.out.printf("Request from Player w. ID: %d to leave Lobby w. ID: %d \n", playerId, lobbyId); System.out.printf("Request from Player w. ID: %d to leave Lobby w. ID: %d \n", playerId, lobbyId);
for (Connection c : net.getConnections(lobby)) { for (Connection c : net.getConnections(lobby)) {
c.sendTCP(this); if (c.getID() != playerId) c.sendTCP(this); //send new lobby to other players
} }
net.leaveLobby(playerId, lobbyId); data = new Lobby(-1); //Send empty lobby to the player who left
connection.sendTCP(this);
net.getPlayer(playerId).setIsPlayerReady(false); net.getPlayer(playerId).setIsPlayerReady(false);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment