Skip to content

Commit

Permalink
fix: issues with PathwayRequeseter
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Oct 23, 2023
1 parent c4ba18d commit 6f7273c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void initOwn() {

if (!container.validEnds.isEmpty()) {
inner.add(GuiElements.createEnumElement(end, e -> {
container.end = container.validStarts.get(e);
container.end = container.validEnds.get(e);
}, container.end != null ? container.end.equals(new Point()) ? 0
: container.validEnds.indexOf(container.end) : 0));
} else {
Expand Down Expand Up @@ -122,4 +122,4 @@ private void sendToServer() {
OpenSignalsMain.network.sendTo(player, buffer);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ public static boolean arePointsValidStartAndEnd(final PosIdentifier identifier,
return grid.isValidStart(start) && grid.isValidEnd(end);
}

public static SignalBoxNode getNodeFromGrid(final PosIdentifier identifier, final Point point) {
if (identifier.world.isClientSide)
return new SignalBoxNode();
PathwayHolder grid;
synchronized (ALL_GRIDS) {
grid = ALL_GRIDS.get(identifier);
}
if (grid == null)
return new SignalBoxNode();
return grid.getNode(point);
}

public static boolean requesetInterSignalBoxPathway(final PosIdentifier startBox,
final Point start, final Point end) {
if (startBox.world.isClientSide)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<Point> getAllInConnections() {

public SignalBoxNode getNode(final Point point) {
checkTileWasLoaded();
return modeGrid.get(point);
return modeGrid.getOrDefault(point, new SignalBoxNode());
}

public List<ModeIdentifier> getGreenSignals() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ public void saveWrapper(final NBTWrapper wrapper) {

public void requestPathway() {
final PosIdentifier identifier = new PosIdentifier(linkedSignalBox, level);
if (!SignalBoxHandler.requestPathway(identifier, pathway.getKey(), pathway.getValue())) {
SignalBoxHandler.addNextPathway(identifier, pathway.getKey(), pathway.getValue());
if (SignalBoxHandler.getNodeFromGrid(identifier, pathway.getValue())
.containsOutConnection()) {
SignalBoxHandler.requesetInterSignalBoxPathway(identifier, pathway.getKey(),
pathway.getValue());
} else {
if (!SignalBoxHandler.requestPathway(identifier, pathway.getKey(),
pathway.getValue())) {
SignalBoxHandler.addNextPathway(identifier, pathway.getKey(), pathway.getValue());
}
}
}

Expand Down

0 comments on commit 6f7273c

Please sign in to comment.