diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/RequestGameStateSegment.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/RequestGameStateSegment.java index c7cdcb8..fc9d4a1 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/RequestGameStateSegment.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/RequestGameStateSegment.java @@ -2,7 +2,9 @@ package uulm.teamname.marvelous.server.lobby.pipelining; import org.tinylog.Logger; import uulm.teamname.marvelous.gamelibrary.events.Event; +import uulm.teamname.marvelous.gamelibrary.events.EventBuilder; import uulm.teamname.marvelous.gamelibrary.gamelogic.GameInstance; +import uulm.teamname.marvelous.gamelibrary.messages.server.EventMessage; import uulm.teamname.marvelous.gamelibrary.requests.RequestBuilder; import uulm.teamname.marvelous.gamelibrary.requests.RequestType; import uulm.teamname.marvelous.server.lobby.Lobby; @@ -28,7 +30,10 @@ public class RequestGameStateSegment implements Segment { Logger.trace("RequestGameStateSegment received {} requests", packet.size()); if (packet.containsRequestOfType(RequestType.Req)) { Logger.trace("Req event found. Returning Gamestate, and clearing entire RequestList"); - carrier.add(game.getGameStateEvent()); + var gamestateEventMessage = new EventMessage(); + gamestateEventMessage.messages = new Event[] {game.getGameStateEvent()}; + packet.getOrigin().sendMessage(gamestateEventMessage); + carrier.clear(); packet.clear(); } } diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java index 1eca31c..0c5aec4 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnection.java @@ -49,17 +49,18 @@ public class LobbyConnection implements Runnable { } public void addParticipant(Participant participant) { - if (this.state == LobbyConnectionState.Started) { + if (this.state == LobbyConnectionState.Started || this.player1.state == ParticipantState.Playing) { + Logger.trace("Set client state to playing"); participant.getClient().state = ClientState.Playing; + participant.state = ParticipantState.Playing; } if(participant.type == ParticipantType.Spectator) { + Logger.trace("Adding spectator"); spectators.add(participant); return; - } - - if(participant.type == ParticipantType.PlayerOne) { + } else if(participant.type == ParticipantType.PlayerOne) { player1 = participant; - }else { + } else { player2 = participant; } } diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/netconnector/ClientState.java b/Server/src/main/java/uulm/teamname/marvelous/server/netconnector/ClientState.java index b58b6df..cee5962 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/netconnector/ClientState.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/netconnector/ClientState.java @@ -4,5 +4,6 @@ public enum ClientState { Blank, Ready, Assigned, - Reconnect, Playing + Reconnect, + Playing }