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)
13761376 return null ;
13771377 }
13781378 /// <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.
13801380 /// </summary>
13811381 /// <param name="wagonIdList"></param>
13821382 /// <returns>train or null</returns>
13831383 private Train matchesConsistNoOrder ( List < string > wagonIdList )
13841384 {
13851385 foreach ( var trainItem in Simulator . Trains )
13861386 {
1387- int nCars = 0 ; //all cars other than WagonIdList.
1388- int nWagonListCars = 0 ; //individual wagon drop.
1387+ int nWagonListCars = 0 ;
13891388 foreach ( var item in trainItem . Cars )
13901389 {
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+ }
14031398 }
1404-
14051399 }
1400+
14061401 return null ;
14071402 }
14081403 /// <summary>
You can’t perform that action at this time.
0 commit comments