fix: fixed PauseSegment and DisconnectSegment, and added logging to all segments
This commit is contained in:
parent
2380012d35
commit
96f131e50c
@ -22,7 +22,7 @@ public class DisconnectSegment implements Segment {
|
||||
public void processRequests(Packet packet, List<Event> carrier, AtomicBoolean abort) {
|
||||
Logger.trace("DisconnectSegment received {} requests.", packet.size());
|
||||
if (packet.containsRequestOfType(RequestType.DisconnectRequest)) {
|
||||
Logger.debug("Player {} sent DisconnectRequest", packet.getOrigin().type);
|
||||
Logger.debug("Player of Type {} sent DisconnectRequest", packet.getOrigin().type);
|
||||
parent.connection.removePlayer(packet.getOrigin());
|
||||
|
||||
if (packet.getOrigin().type != ParticipantType.Spectator) {
|
||||
@ -33,7 +33,7 @@ public class DisconnectSegment implements Segment {
|
||||
parent.generateWin(parent.connection.getPlayer2());
|
||||
}
|
||||
}
|
||||
}
|
||||
packet.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,13 @@ public class GameStateSegment implements Segment {
|
||||
public void processRequests(Packet packet, List<Event> carrier, AtomicBoolean abort) {
|
||||
Logger.trace("GameStateSegment received {} requests.", packet.size());
|
||||
var result = game.checkRequestsAndApply(packet.toArray(new Request[0]));
|
||||
Logger.trace("GameLogic gener");
|
||||
Logger.trace("GameLogic generated {} events", result.map(List::size).orElse(0));
|
||||
if (result.isPresent()) {
|
||||
Logger.trace("Result from GameLogic is present. Adding requests to carrier.");
|
||||
carrier.addAll(result.get());
|
||||
packet.clear();
|
||||
} else {
|
||||
Logger.debug("Result from GameLogic is invalid. Triggering error.");
|
||||
abort.set(true);
|
||||
}
|
||||
}
|
||||
|
@ -97,10 +97,8 @@ public class PauseSegment implements Segment {
|
||||
RequestType.MoveRequest,
|
||||
RequestType.ExchangeInfinityStoneRequest,
|
||||
RequestType.UseInfinityStoneRequest,
|
||||
RequestType.EndRoundRequest,
|
||||
RequestType.PauseStopRequest,
|
||||
RequestType.PauseStartRequest);
|
||||
|
||||
RequestType.EndRoundRequest);
|
||||
}
|
||||
packet.removeRequestsOfTypes(RequestType.PauseStopRequest, RequestType.PauseStartRequest);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package uulm.teamname.marvelous.server.lobby.pipelining;
|
||||
|
||||
import org.tinylog.Logger;
|
||||
import uulm.teamname.marvelous.gamelibrary.events.Event;
|
||||
import uulm.teamname.marvelous.gamelibrary.gamelogic.GameInstance;
|
||||
import uulm.teamname.marvelous.gamelibrary.requests.RequestBuilder;
|
||||
@ -19,9 +20,11 @@ public class RequestGameStateSegment implements Segment {
|
||||
|
||||
@Override
|
||||
public void processRequests(Packet packet, List<Event> carrier, AtomicBoolean abort) {
|
||||
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());
|
||||
}
|
||||
packet.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user