Skip to content

Commit f2c5d2d

Browse files
committed
Improve syntax check on timetable files
1 parent 3ffb9bc commit f2c5d2d

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

Source/Orts.Simulation/Simulation/Timetables/ProcessTimetable.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ public List<TTTrain> ProcessTimetable(string[] arguments, CancellationToken canc
257257
{
258258
Trace.TraceInformation("Player trains " + reqPlayerTrain.Name + " defined without engine, engine assumed to be attached later");
259259
}
260+
else if (reqPlayerTrain.FormedOf >= 0)
261+
{
262+
Trace.TraceInformation("Player trains " + reqPlayerTrain.Name + " defined without engine, train is assumed to be formed out of other train");
263+
}
260264
else
261265
{
262266
throw new InvalidDataException("Can't find player locomotive in " + reqPlayerTrain.Name);

Source/Orts.Simulation/Simulation/Timetables/TTTrain.cs

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7874,17 +7874,36 @@ public void ProcessTimetableStopCommands(TTTrainCommands thisCommand, int subrou
78747874
break;
78757875

78767876
case "callon":
7877-
if (thisStationStop != null) thisStationStop.CallOnAllowed = true;
7877+
if (thisStationStop == null)
7878+
{
7879+
Trace.TraceInformation("Cannot set CALLON without station stop time : train " + Name + " ( " + Number + " )");
7880+
}
7881+
else
7882+
{
7883+
thisStationStop.CallOnAllowed = true;
7884+
}
78787885
break;
78797886

78807887
case "hold":
7881-
if (thisStationStop != null)
7888+
if (thisStationStop == null)
7889+
{
7890+
Trace.TraceInformation("Cannot set HOLD without station stop time : train " + Name + " ( " + Number + " )");
7891+
}
7892+
else
7893+
{
78827894
thisStationStop.HoldSignal = thisStationStop.ExitSignal >= 0; // set holdstate only if exit signal is defined
7895+
}
78837896
break;
78847897

78857898
case "nohold":
7886-
if (thisStationStop != null)
7899+
if (thisStationStop == null)
7900+
{
7901+
Trace.TraceInformation("Cannot set NOHOLD without station stop time : train " + Name + " ( " + Number + " )");
7902+
}
7903+
else
7904+
{
78877905
thisStationStop.HoldSignal = false;
7906+
}
78887907
break;
78897908

78907909
case "forcehold":
@@ -7968,15 +7987,36 @@ public void ProcessTimetableStopCommands(TTTrainCommands thisCommand, int subrou
79687987
break;
79697988

79707989
case "nowaitsignal":
7971-
thisStationStop.NoWaitSignal = true;
7990+
if (thisStationStop == null)
7991+
{
7992+
Trace.TraceInformation("Cannot set NOWAITSIGNAL without station stop time : train " + Name + " ( " + Number + " )");
7993+
}
7994+
else
7995+
{
7996+
thisStationStop.NoWaitSignal = true;
7997+
}
79727998
break;
79737999

79748000
case "waitsignal":
7975-
thisStationStop.NoWaitSignal = false;
8001+
if (thisStationStop == null)
8002+
{
8003+
Trace.TraceInformation("Cannot set WAITSIGNAL without station stop time : train " + Name + " ( " + Number + " )");
8004+
}
8005+
else
8006+
{
8007+
thisStationStop.NoWaitSignal = false;
8008+
}
79768009
break;
79778010

79788011
case "noclaim":
7979-
thisStationStop.NoClaimAllowed = true;
8012+
if (thisStationStop == null)
8013+
{
8014+
Trace.TraceInformation("Cannot set NOCLAIM without station stop time : train " + Name + " ( " + Number + " )");
8015+
}
8016+
else
8017+
{
8018+
thisStationStop.NoClaimAllowed = true;
8019+
}
79808020
break;
79818021

79828022
// no action for terminal (processed in create station stop)

0 commit comments

Comments
 (0)