@@ -131,6 +131,9 @@ public struct ListLabel
131131 }
132132 public List < ListLabel > Labels = new List < ListLabel > ( ) ;
133133
134+ public List < bool > RearBrakes = new List < bool > ( ) ;
135+ public bool RefreshRestoredData = false ;
136+
134137 Train PlayerTrain ;
135138 int LastPlayerTrainCars ;
136139 bool LastPlayerLocomotiveFlippedState ;
@@ -151,6 +154,14 @@ protected internal override void Save(BinaryWriter outf)
151154 outf . Write ( Location . Y ) ;
152155 outf . Write ( Location . Width ) ;
153156 outf . Write ( Location . Height ) ;
157+
158+ // Saves brake hose state
159+ var carsCount = PlayerTrain . Cars . Count ( ) ;
160+ outf . Write ( carsCount ) ;
161+ foreach ( var data in RearBrakes )
162+ {
163+ outf . Write ( data ) ;
164+ }
154165 }
155166 protected internal override void Restore ( BinaryReader inf )
156167 {
@@ -161,6 +172,14 @@ protected internal override void Restore(BinaryReader inf)
161172 LocationRestore . Width = inf . ReadInt32 ( ) ;
162173 LocationRestore . Height = inf . ReadInt32 ( ) ;
163174
175+ // Restores brake hose state
176+ var carsCount = inf . ReadInt32 ( ) ;
177+ for ( int i = 0 ; i < carsCount ; i ++ )
178+ {
179+ RearBrakes . Add ( inf . ReadBoolean ( ) ) ;
180+ }
181+ RefreshRestoredData = true ;
182+
164183 // Display window
165184 SizeTo ( LocationRestore . Width , LocationRestore . Height ) ;
166185 MoveTo ( LocationRestore . X , LocationRestore . Y ) ;
@@ -313,6 +332,19 @@ void AddSpace()
313332 line . AddSpace ( textHeight / 2 , line . RemainingHeight ) ;
314333 }
315334
335+ if ( RefreshRestoredData )
336+ { // Restores brake hose
337+ RefreshRestoredData = false ;
338+ for ( int i = 0 ; i < PlayerTrain . Cars . Count ; i ++ )
339+ {
340+ ( PlayerTrain . Cars [ i ] as MSTSWagon ) . BrakeSystem . RearBrakeHoseConnected = RearBrakes [ i ] ;
341+ }
342+ }
343+ if ( RearBrakes . Count == 0 )
344+ { // Init brake hose
345+ RearBrakes = Enumerable . Repeat ( true , PlayerTrain . Cars . Count ) . ToList ( ) ;
346+ }
347+
316348 // reset WarningCarPosition
317349 WarningCarPosition = Enumerable . Repeat ( false , PlayerTrain . Cars . Count ) . ToList ( ) ;
318350
@@ -821,6 +853,7 @@ public buttonRearBrakeHose(int x, int y, int size, Viewer viewer, TrainCar car,
821853 {
822854 trainCarOperations . updateWarningCarPosition ( carPosition , Texture , BrakeHoseDis ) ;
823855 }
856+ Viewer . TrainCarOperationsWindow . RearBrakes [ carPosition ] = ( viewer . PlayerTrain . Cars [ carPosition ] as MSTSWagon ) . BrakeSystem . RearBrakeHoseConnected ;
824857 }
825858 }
826859 class buttonFrontAngleCock : Image
0 commit comments