@@ -1160,7 +1160,7 @@ public bool PreProcessRoutes(CancellationToken cancellation)
1160
1160
{
1161
1161
// read route
1162
1162
bool pathValid = true ;
1163
- AIPath newPath = LoadPath ( thisRoute , out pathValid ) ;
1163
+ LoadPath ( thisRoute , out pathValid ) ;
1164
1164
if ( ! pathValid ) allPathsLoaded = false ;
1165
1165
if ( cancellation . IsCancellationRequested )
1166
1166
return ( false ) ;
@@ -1187,23 +1187,23 @@ public AIPath LoadPath(string pathstring, out bool validPath)
1187
1187
if ( String . IsNullOrEmpty ( pathExtension ) )
1188
1188
formedpathFilefull = Path . ChangeExtension ( formedpathFilefull , "pat" ) ;
1189
1189
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 ) )
1199
1191
{
1192
+ // try to load binary path if required
1193
+ bool binaryloaded = false ;
1200
1194
string formedpathFilefullBinary = Path . Combine ( Path . GetDirectoryName ( formedpathFilefull ) , "OpenRails" ) ;
1201
1195
formedpathFilefullBinary = Path . Combine ( formedpathFilefullBinary , Path . GetFileNameWithoutExtension ( formedpathFilefull ) ) ;
1202
1196
formedpathFilefullBinary = Path . ChangeExtension ( formedpathFilefullBinary , "or-binpat" ) ;
1203
1197
1204
- if ( BinaryPaths )
1198
+ if ( BinaryPaths && File . Exists ( formedpathFilefullBinary ) )
1205
1199
{
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
1207
1207
{
1208
1208
try
1209
1209
{
@@ -1213,7 +1213,7 @@ public AIPath LoadPath(string pathstring, out bool validPath)
1213
1213
1214
1214
if ( outPath . Nodes != null )
1215
1215
{
1216
- Paths . Add ( formedpathFilefull , new AIPath ( outPath ) ) ;
1216
+ Paths . Add ( formedpathFilefull , outPath ) ;
1217
1217
binaryloaded = true ;
1218
1218
}
1219
1219
}
@@ -1235,7 +1235,7 @@ public AIPath LoadPath(string pathstring, out bool validPath)
1235
1235
{
1236
1236
try
1237
1237
{
1238
- Paths . Add ( formedpathFilefull , new AIPath ( outPath ) ) ;
1238
+ Paths . Add ( formedpathFilefull , outPath ) ;
1239
1239
}
1240
1240
catch ( Exception e )
1241
1241
{
0 commit comments