@@ -296,6 +296,7 @@ public TimetablePool(BinaryReader inf, Simulator simulatorref)
296
296
PoolDetails newPool = new PoolDetails ( ) ;
297
297
newPool . StoragePath = new Train . TCSubpathRoute ( inf ) ;
298
298
newPool . StoragePathTraveller = new Traveller ( simulatorref . TSectionDat , simulatorref . TDB . TrackDB . TrackNodes , inf ) ;
299
+ newPool . StoragePathReverseTraveller = new Traveller ( simulatorref . TSectionDat , simulatorref . TDB . TrackDB . TrackNodes , inf ) ;
299
300
newPool . StorageName = inf . ReadString ( ) ;
300
301
301
302
newPool . AccessPaths = new List < Train . TCSubpathRoute > ( ) ;
@@ -362,6 +363,7 @@ virtual public void Save(BinaryWriter outf)
362
363
{
363
364
thisStorage . StoragePath . Save ( outf ) ;
364
365
thisStorage . StoragePathTraveller . Save ( outf ) ;
366
+ thisStorage . StoragePathReverseTraveller . Save ( outf ) ;
365
367
outf . Write ( thisStorage . StorageName ) ;
366
368
367
369
outf . Write ( thisStorage . AccessPaths . Count ) ;
@@ -525,10 +527,16 @@ public PoolDetails ExtractStorage(TimetableReader fileContents, Simulator simula
525
527
{
526
528
Train . TCRoutePath fullRoute = new Train . TCRoutePath ( newPath , - 2 , 1 , simulatorref . Signals , - 1 , simulatorref . Settings ) ;
527
529
530
+ // front traveller
528
531
newPool . StoragePath = new Train . TCSubpathRoute ( fullRoute . TCRouteSubpaths [ 0 ] ) ;
529
532
newPool . StoragePathTraveller = new Traveller ( simulatorref . TSectionDat , simulatorref . TDB . TrackDB . TrackNodes , newPath ) ;
530
- Traveller dummy = new Traveller ( newPool . StoragePathTraveller ) ;
531
- dummy . Move ( simulatorref . Signals . TrackCircuitList [ newPool . StoragePath [ 0 ] . TCSectionIndex ] . Length - newPool . StoragePathTraveller . TrackNodeOffset - 1.0f ) ;
533
+
534
+ // rear traveller (for moving tables)
535
+ AIPathNode lastNode = newPath . Nodes . Last ( ) ;
536
+ Traveller . TravellerDirection newDirection = newPool . StoragePathTraveller . Direction == Traveller . TravellerDirection . Forward ? Traveller . TravellerDirection . Backward : Traveller . TravellerDirection . Forward ;
537
+ newPool . StoragePathReverseTraveller = new Traveller ( simulatorref . TSectionDat , simulatorref . TDB . TrackDB . TrackNodes ,
538
+ lastNode . Location . TileX , lastNode . Location . TileZ , lastNode . Location . Location . X , lastNode . Location . Location . Z , newDirection ) ;
539
+
532
540
newPool . StorageName = String . Copy ( storagePathName ) ;
533
541
534
542
// if last element is end of track, remove it from path
@@ -1166,17 +1174,39 @@ public float CalculateStorageLength(PoolDetails reqStorage, TTTrain train)
1166
1174
float remLength = 0 ;
1167
1175
1168
1176
// same direction : use rear of train position
1169
- if ( occSectionDirection == storageSectionDirection )
1177
+ // for turntable pools, path is defined in opposite direction
1178
+
1179
+ if ( GetType ( ) == typeof ( TimetableTurntablePool ) )
1170
1180
{
1171
- occSectionIndex = train . PresentPosition [ 1 ] . TCSectionIndex ;
1172
- TrackCircuitSection occSection = train . signalRef . TrackCircuitList [ occSectionIndex ] ;
1173
- remLength = occSection . Length - train . PresentPosition [ 1 ] . TCOffset ;
1181
+ // use rear of train position
1182
+ if ( occSectionDirection == storageSectionDirection )
1183
+ {
1184
+ occSectionIndex = train . PresentPosition [ 1 ] . TCSectionIndex ;
1185
+ TrackCircuitSection occSection = train . signalRef . TrackCircuitList [ occSectionIndex ] ;
1186
+ remLength = train . PresentPosition [ 1 ] . TCOffset ;
1187
+ }
1188
+ else
1189
+ // use front of train position
1190
+ {
1191
+ TrackCircuitSection occSection = train . signalRef . TrackCircuitList [ occSectionIndex ] ;
1192
+ remLength = occSection . Length - train . PresentPosition [ 0 ] . TCOffset ;
1193
+ }
1174
1194
}
1175
1195
else
1176
- // opposite direction : use front of train position
1177
1196
{
1178
- TrackCircuitSection occSection = train . signalRef . TrackCircuitList [ occSectionIndex ] ;
1179
- remLength = train . PresentPosition [ 0 ] . TCOffset ;
1197
+ // use rear of train position
1198
+ if ( occSectionDirection == storageSectionDirection )
1199
+ {
1200
+ occSectionIndex = train . PresentPosition [ 1 ] . TCSectionIndex ;
1201
+ TrackCircuitSection occSection = train . signalRef . TrackCircuitList [ occSectionIndex ] ;
1202
+ remLength = occSection . Length - train . PresentPosition [ 1 ] . TCOffset ;
1203
+ }
1204
+ else
1205
+ // use front of train position
1206
+ {
1207
+ TrackCircuitSection occSection = train . signalRef . TrackCircuitList [ occSectionIndex ] ;
1208
+ remLength = train . PresentPosition [ 0 ] . TCOffset ;
1209
+ }
1180
1210
}
1181
1211
1182
1212
for ( int iSection = reqStorage . StoragePath . Count - 1 ; iSection >= 0 && reqStorage . StoragePath [ iSection ] . TCSectionIndex != occSectionIndex ; iSection -- )
0 commit comments