@@ -1160,7 +1160,7 @@ public bool PreProcessRoutes(CancellationToken cancellation)
11601160 {
11611161 // read route
11621162 bool pathValid = true ;
1163- AIPath newPath = LoadPath ( thisRoute , out pathValid ) ;
1163+ LoadPath ( thisRoute , out pathValid ) ;
11641164 if ( ! pathValid ) allPathsLoaded = false ;
11651165 if ( cancellation . IsCancellationRequested )
11661166 return ( false ) ;
@@ -1187,23 +1187,23 @@ public AIPath LoadPath(string pathstring, out bool validPath)
11871187 if ( String . IsNullOrEmpty ( pathExtension ) )
11881188 formedpathFilefull = Path . ChangeExtension ( formedpathFilefull , "pat" ) ;
11891189
1190- // try to load binary path if required
1191- bool binaryloaded = false ;
1192- AIPath outPath = null ;
1193-
1194- if ( Paths . ContainsKey ( formedpathFilefull ) )
1195- {
1196- outPath = new AIPath ( Paths [ formedpathFilefull ] ) ;
1197- }
1198- else
1190+ if ( ! Paths . TryGetValue ( formedpathFilefull , out var outPath ) )
11991191 {
1192+ // try to load binary path if required
1193+ bool binaryloaded = false ;
12001194 string formedpathFilefullBinary = Path . Combine ( Path . GetDirectoryName ( formedpathFilefull ) , "OpenRails" ) ;
12011195 formedpathFilefullBinary = Path . Combine ( formedpathFilefullBinary , Path . GetFileNameWithoutExtension ( formedpathFilefull ) ) ;
12021196 formedpathFilefullBinary = Path . ChangeExtension ( formedpathFilefullBinary , "or-binpat" ) ;
12031197
1204- if ( BinaryPaths )
1198+ if ( BinaryPaths && File . Exists ( formedpathFilefullBinary ) )
12051199 {
1206- if ( File . Exists ( formedpathFilefullBinary ) )
1200+ var binaryLastWriteTime = File . GetLastWriteTime ( formedpathFilefullBinary ) ;
1201+ if ( binaryLastWriteTime < simulator . TDB . LastWriteTime ||
1202+ File . Exists ( formedpathFilefull ) && binaryLastWriteTime < File . GetLastWriteTime ( formedpathFilefull ) )
1203+ {
1204+ File . Delete ( formedpathFilefullBinary ) ;
1205+ }
1206+ else
12071207 {
12081208 try
12091209 {
@@ -1213,7 +1213,7 @@ public AIPath LoadPath(string pathstring, out bool validPath)
12131213
12141214 if ( outPath . Nodes != null )
12151215 {
1216- Paths . Add ( formedpathFilefull , new AIPath ( outPath ) ) ;
1216+ Paths . Add ( formedpathFilefull , outPath ) ;
12171217 binaryloaded = true ;
12181218 }
12191219 }
@@ -1235,7 +1235,7 @@ public AIPath LoadPath(string pathstring, out bool validPath)
12351235 {
12361236 try
12371237 {
1238- Paths . Add ( formedpathFilefull , new AIPath ( outPath ) ) ;
1238+ Paths . Add ( formedpathFilefull , outPath ) ;
12391239 }
12401240 catch ( Exception e )
12411241 {
0 commit comments