From 30a90a62037767fc26bb92df00c26fcbbfeeabc5 Mon Sep 17 00:00:00 2001 From: Timo van Veen Date: Mon, 30 Oct 2023 19:50:58 +0100 Subject: [PATCH] Fix crash on invalid schedule regex (e.g. "station \\E1\\Q") --- .../trains/schedule/ScheduleRuntime.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/trains/schedule/ScheduleRuntime.java b/src/main/java/com/simibubi/create/content/trains/schedule/ScheduleRuntime.java index 58dcbee64..85521e83a 100644 --- a/src/main/java/com/simibubi/create/content/trains/schedule/ScheduleRuntime.java +++ b/src/main/java/com/simibubi/create/content/trains/schedule/ScheduleRuntime.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Objects; +import java.util.regex.PatternSyntaxException; import com.simibubi.create.AllItems; import com.simibubi.create.content.trains.display.GlobalTrainDisplayData.TrainDeparturePrediction; @@ -183,13 +184,16 @@ public class ScheduleRuntime { cooldown = INTERVAL; return null; } - - for (GlobalStation globalStation : train.graph.getPoints(EdgePointType.STATION)) { - if (!globalStation.name.matches(regex)) - continue; - anyMatch = true; - validStations.add(globalStation); - } + + try { + for (GlobalStation globalStation : train.graph.getPoints(EdgePointType.STATION)) { + if (!globalStation.name.matches(regex)) + continue; + anyMatch = true; + validStations.add(globalStation); + } + } catch (PatternSyntaxException ignored) {} + DiscoveredPath best = train.navigation.findPathTo(validStations, Double.MAX_VALUE); if (best == null) { if (anyMatch)