File tree Expand file tree Collapse file tree 1 file changed +11
-16
lines changed
Source/Orts.Simulation/Simulation Expand file tree Collapse file tree 1 file changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -1376,33 +1376,28 @@ private Train matchesConsist(List<string> wagonIdList)
1376
1376
return null ;
1377
1377
}
1378
1378
/// <summary>
1379
- /// Finds the train that contains exactly the wagons (and maybe loco) in the list. Exact order is not required.
1379
+ /// Finds the train that contains exactly the wagons in the list. Exact order is not required.
1380
1380
/// </summary>
1381
1381
/// <param name="wagonIdList"></param>
1382
1382
/// <returns>train or null</returns>
1383
1383
private Train matchesConsistNoOrder ( List < string > wagonIdList )
1384
1384
{
1385
1385
foreach ( var trainItem in Simulator . Trains )
1386
1386
{
1387
- int nCars = 0 ; //all cars other than WagonIdList.
1388
- int nWagonListCars = 0 ; //individual wagon drop.
1387
+ int nWagonListCars = 0 ;
1389
1388
foreach ( var item in trainItem . Cars )
1390
1389
{
1391
- if ( ! wagonIdList . Contains ( item . CarID ) ) nCars ++ ;
1392
- if ( wagonIdList . Contains ( item . CarID ) ) nWagonListCars ++ ;
1393
- }
1394
- // Compare two lists to make sure wagons are present.
1395
- bool listsMatch = true ;
1396
- //support individual wagonIdList drop
1397
- if ( trainItem . Cars . Count - nCars == ( wagonIdList . Count == nWagonListCars ? wagonIdList . Count : nWagonListCars ) )
1398
- {
1399
- if ( excludesWagons ( trainItem , wagonIdList ) ) listsMatch = false ; //all wagons dropped
1400
-
1401
- if ( listsMatch ) return trainItem ;
1402
-
1390
+ if ( wagonIdList . Contains ( item . CarID ) )
1391
+ {
1392
+ nWagonListCars ++ ;
1393
+ }
1394
+ if ( nWagonListCars == trainItem . Cars . Count )
1395
+ {
1396
+ return trainItem ;
1397
+ }
1403
1398
}
1404
-
1405
1399
}
1400
+
1406
1401
return null ;
1407
1402
}
1408
1403
/// <summary>
You can’t perform that action at this time.
0 commit comments