File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Source/Orts.Simulation/Simulation/RollingStocks Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 5050using System . Collections . Generic ;
5151using System . Diagnostics ;
5252using System . IO ;
53+ using System . Linq ;
5354using Event = Orts . Common . Event ;
5455
5556namespace Orts . Simulation . RollingStocks
@@ -1504,12 +1505,7 @@ public override void Restore(BinaryReader inf)
15041505 MassKG = inf . ReadSingle ( ) ;
15051506 MaxBrakeForceN = inf . ReadSingle ( ) ;
15061507 MaxHandbrakeForceN = inf . ReadSingle ( ) ;
1507- int n = inf . ReadInt32 ( ) ;
1508- for ( int i = 0 ; i < n ; i ++ )
1509- {
1510- Couplers . Add ( new MSTSCoupling ( ) ) ;
1511- Couplers [ i ] . Restore ( inf ) ;
1512- }
1508+ Couplers = ReadCouplersFromSave ( inf ) . ToList ( ) ;
15131509 Pantographs . Restore ( inf ) ;
15141510 if ( FreightAnimations != null )
15151511 {
@@ -1531,6 +1527,17 @@ public override void Restore(BinaryReader inf)
15311527 AuxPowerOn = true ;
15321528 }
15331529
1530+ private static IEnumerable < MSTSCoupling > ReadCouplersFromSave ( BinaryReader inf )
1531+ {
1532+ var n = inf . ReadInt32 ( ) ;
1533+ foreach ( int _ in Enumerable . Range ( 0 , n ) )
1534+ {
1535+ var coupler = new MSTSCoupling ( ) ;
1536+ coupler . Restore ( inf ) ;
1537+ yield return coupler ;
1538+ }
1539+ }
1540+
15341541 public override void Update ( float elapsedClockSeconds )
15351542 {
15361543 base . Update ( elapsedClockSeconds ) ;
You can’t perform that action at this time.
0 commit comments