Skip to content

Commit 2c69046

Browse files
authored
Merge pull request #786 from Roeterdink/ImproveSyntaxCheck
Improve syntax check on timetable files
2 parents 9ebd050 + f2c5d2d commit 2c69046

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
@@ -7908,17 +7908,36 @@ public void ProcessTimetableStopCommands(TTTrainCommands thisCommand, int subrou
79087908
break;
79097909

79107910
case "callon":
7911-
if (thisStationStop != null) thisStationStop.CallOnAllowed = true;
7911+
if (thisStationStop == null)
7912+
{
7913+
Trace.TraceInformation("Cannot set CALLON without station stop time : train " + Name + " ( " + Number + " )");
7914+
}
7915+
else
7916+
{
7917+
thisStationStop.CallOnAllowed = true;
7918+
}
79127919
break;
79137920

79147921
case "hold":
7915-
if (thisStationStop != null)
7922+
if (thisStationStop == null)
7923+
{
7924+
Trace.TraceInformation("Cannot set HOLD without station stop time : train " + Name + " ( " + Number + " )");
7925+
}
7926+
else
7927+
{
79167928
thisStationStop.HoldSignal = thisStationStop.ExitSignal >= 0; // set holdstate only if exit signal is defined
7929+
}
79177930
break;
79187931

79197932
case "nohold":
7920-
if (thisStationStop != null)
7933+
if (thisStationStop == null)
7934+
{
7935+
Trace.TraceInformation("Cannot set NOHOLD without station stop time : train " + Name + " ( " + Number + " )");
7936+
}
7937+
else
7938+
{
79217939
thisStationStop.HoldSignal = false;
7940+
}
79227941
break;
79237942

79247943
case "forcehold":
@@ -8002,15 +8021,36 @@ public void ProcessTimetableStopCommands(TTTrainCommands thisCommand, int subrou
80028021
break;
80038022

80048023
case "nowaitsignal":
8005-
thisStationStop.NoWaitSignal = true;
8024+
if (thisStationStop == null)
8025+
{
8026+
Trace.TraceInformation("Cannot set NOWAITSIGNAL without station stop time : train " + Name + " ( " + Number + " )");
8027+
}
8028+
else
8029+
{
8030+
thisStationStop.NoWaitSignal = true;
8031+
}
80068032
break;
80078033

80088034
case "waitsignal":
8009-
thisStationStop.NoWaitSignal = false;
8035+
if (thisStationStop == null)
8036+
{
8037+
Trace.TraceInformation("Cannot set WAITSIGNAL without station stop time : train " + Name + " ( " + Number + " )");
8038+
}
8039+
else
8040+
{
8041+
thisStationStop.NoWaitSignal = false;
8042+
}
80108043
break;
80118044

80128045
case "noclaim":
8013-
thisStationStop.NoClaimAllowed = true;
8046+
if (thisStationStop == null)
8047+
{
8048+
Trace.TraceInformation("Cannot set NOCLAIM without station stop time : train " + Name + " ( " + Number + " )");
8049+
}
8050+
else
8051+
{
8052+
thisStationStop.NoClaimAllowed = true;
8053+
}
80148054
break;
80158055

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

0 commit comments

Comments
 (0)