mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 06:24:29 +01:00
Payload Overload
- Potential fix for players getting kicked while merging very large track networks
This commit is contained in:
parent
9ab3b77294
commit
157077b0ef
@ -54,22 +54,26 @@ public class TrackGraphSync {
|
||||
public void nodeAdded(TrackGraph graph, TrackNode node) {
|
||||
flushGraphPacket(graph);
|
||||
currentGraphSyncPacket.addedNodes.put(node.getNetId(), Pair.of(node.getLocation(), node.getNormal()));
|
||||
currentPayload++;
|
||||
}
|
||||
|
||||
public void edgeAdded(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) {
|
||||
flushGraphPacket(graph);
|
||||
currentGraphSyncPacket.addedEdges
|
||||
.add(Pair.of(Couple.create(node1.getNetId(), node2.getNetId()), edge.getTurn()));
|
||||
currentPayload++;
|
||||
}
|
||||
|
||||
public void pointAdded(TrackGraph graph, TrackEdgePoint point) {
|
||||
flushGraphPacket(graph);
|
||||
currentGraphSyncPacket.addedEdgePoints.add(point);
|
||||
currentPayload++;
|
||||
}
|
||||
|
||||
public void pointRemoved(TrackGraph graph, TrackEdgePoint point) {
|
||||
flushGraphPacket(graph);
|
||||
currentGraphSyncPacket.removedEdgePoints.add(point.getId());
|
||||
currentPayload++;
|
||||
}
|
||||
|
||||
public void nodeRemoved(TrackGraph graph, TrackNode node) {
|
||||
@ -120,12 +124,14 @@ public class TrackGraphSync {
|
||||
public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) {
|
||||
flushGraphPacket(graph);
|
||||
currentGraphSyncPacket.syncEdgeData(node1, node2, edge);
|
||||
currentPayload++;
|
||||
}
|
||||
|
||||
public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge, TrackEdge edge2) {
|
||||
flushGraphPacket(graph);
|
||||
currentGraphSyncPacket.syncEdgeData(node1, node2, edge);
|
||||
currentGraphSyncPacket.syncEdgeData(node2, node1, edge2);
|
||||
currentPayload++;
|
||||
}
|
||||
|
||||
public void sendFullGraphTo(TrackGraph graph, ServerPlayer player) {
|
||||
@ -190,6 +196,7 @@ public class TrackGraphSync {
|
||||
//
|
||||
|
||||
private TrackGraphSyncPacket currentGraphSyncPacket;
|
||||
private int currentPayload;
|
||||
|
||||
private void flushGraphPacket() {
|
||||
flushGraphPacket(null, 0);
|
||||
@ -201,14 +208,17 @@ public class TrackGraphSync {
|
||||
|
||||
private void flushGraphPacket(@Nullable UUID graphId, int netId) {
|
||||
if (currentGraphSyncPacket != null) {
|
||||
if (currentGraphSyncPacket.graphId.equals(graphId))
|
||||
if (currentGraphSyncPacket.graphId.equals(graphId) && currentPayload < 1000)
|
||||
return;
|
||||
queuedPackets.add(currentGraphSyncPacket);
|
||||
currentGraphSyncPacket = null;
|
||||
currentPayload = 0;
|
||||
}
|
||||
|
||||
if (graphId != null)
|
||||
if (graphId != null) {
|
||||
currentGraphSyncPacket = new TrackGraphSyncPacket(graphId, netId);
|
||||
currentPayload = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user