mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-14 08:16:42 +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
1 changed files with 12 additions and 2 deletions
|
@ -54,22 +54,26 @@ public class TrackGraphSync {
|
||||||
public void nodeAdded(TrackGraph graph, TrackNode node) {
|
public void nodeAdded(TrackGraph graph, TrackNode node) {
|
||||||
flushGraphPacket(graph);
|
flushGraphPacket(graph);
|
||||||
currentGraphSyncPacket.addedNodes.put(node.getNetId(), Pair.of(node.getLocation(), node.getNormal()));
|
currentGraphSyncPacket.addedNodes.put(node.getNetId(), Pair.of(node.getLocation(), node.getNormal()));
|
||||||
|
currentPayload++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void edgeAdded(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) {
|
public void edgeAdded(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) {
|
||||||
flushGraphPacket(graph);
|
flushGraphPacket(graph);
|
||||||
currentGraphSyncPacket.addedEdges
|
currentGraphSyncPacket.addedEdges
|
||||||
.add(Pair.of(Couple.create(node1.getNetId(), node2.getNetId()), edge.getTurn()));
|
.add(Pair.of(Couple.create(node1.getNetId(), node2.getNetId()), edge.getTurn()));
|
||||||
|
currentPayload++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pointAdded(TrackGraph graph, TrackEdgePoint point) {
|
public void pointAdded(TrackGraph graph, TrackEdgePoint point) {
|
||||||
flushGraphPacket(graph);
|
flushGraphPacket(graph);
|
||||||
currentGraphSyncPacket.addedEdgePoints.add(point);
|
currentGraphSyncPacket.addedEdgePoints.add(point);
|
||||||
|
currentPayload++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pointRemoved(TrackGraph graph, TrackEdgePoint point) {
|
public void pointRemoved(TrackGraph graph, TrackEdgePoint point) {
|
||||||
flushGraphPacket(graph);
|
flushGraphPacket(graph);
|
||||||
currentGraphSyncPacket.removedEdgePoints.add(point.getId());
|
currentGraphSyncPacket.removedEdgePoints.add(point.getId());
|
||||||
|
currentPayload++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nodeRemoved(TrackGraph graph, TrackNode node) {
|
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) {
|
public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge) {
|
||||||
flushGraphPacket(graph);
|
flushGraphPacket(graph);
|
||||||
currentGraphSyncPacket.syncEdgeData(node1, node2, edge);
|
currentGraphSyncPacket.syncEdgeData(node1, node2, edge);
|
||||||
|
currentPayload++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge, TrackEdge edge2) {
|
public void edgeDataChanged(TrackGraph graph, TrackNode node1, TrackNode node2, TrackEdge edge, TrackEdge edge2) {
|
||||||
flushGraphPacket(graph);
|
flushGraphPacket(graph);
|
||||||
currentGraphSyncPacket.syncEdgeData(node1, node2, edge);
|
currentGraphSyncPacket.syncEdgeData(node1, node2, edge);
|
||||||
currentGraphSyncPacket.syncEdgeData(node2, node1, edge2);
|
currentGraphSyncPacket.syncEdgeData(node2, node1, edge2);
|
||||||
|
currentPayload++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendFullGraphTo(TrackGraph graph, ServerPlayer player) {
|
public void sendFullGraphTo(TrackGraph graph, ServerPlayer player) {
|
||||||
|
@ -190,6 +196,7 @@ public class TrackGraphSync {
|
||||||
//
|
//
|
||||||
|
|
||||||
private TrackGraphSyncPacket currentGraphSyncPacket;
|
private TrackGraphSyncPacket currentGraphSyncPacket;
|
||||||
|
private int currentPayload;
|
||||||
|
|
||||||
private void flushGraphPacket() {
|
private void flushGraphPacket() {
|
||||||
flushGraphPacket(null, 0);
|
flushGraphPacket(null, 0);
|
||||||
|
@ -201,14 +208,17 @@ public class TrackGraphSync {
|
||||||
|
|
||||||
private void flushGraphPacket(@Nullable UUID graphId, int netId) {
|
private void flushGraphPacket(@Nullable UUID graphId, int netId) {
|
||||||
if (currentGraphSyncPacket != null) {
|
if (currentGraphSyncPacket != null) {
|
||||||
if (currentGraphSyncPacket.graphId.equals(graphId))
|
if (currentGraphSyncPacket.graphId.equals(graphId) && currentPayload < 1000)
|
||||||
return;
|
return;
|
||||||
queuedPackets.add(currentGraphSyncPacket);
|
queuedPackets.add(currentGraphSyncPacket);
|
||||||
currentGraphSyncPacket = null;
|
currentGraphSyncPacket = null;
|
||||||
|
currentPayload = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (graphId != null)
|
if (graphId != null) {
|
||||||
currentGraphSyncPacket = new TrackGraphSyncPacket(graphId, netId);
|
currentGraphSyncPacket = new TrackGraphSyncPacket(graphId, netId);
|
||||||
|
currentPayload = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue