Skip to content

Commit

Permalink
Restore the state of the locomotive axle upon resume. Fixes https://b…
Browse files Browse the repository at this point in the history
  • Loading branch information
YoRyan committed Jul 4, 2020
1 parent e4e7123 commit 0817e32
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ public override void Save(BinaryWriter outf)
base.Save(outf);

TrainControlSystem.Save(outf);
LocomotiveAxle.Save(outf);
}

/// <summary>
Expand Down Expand Up @@ -1068,6 +1069,7 @@ public override void Restore(BinaryReader inf)
base.Restore(inf);

TrainControlSystem.Restore(inf);
LocomotiveAxle = new Axle(inf);
}

public bool IsLeadLocomotive()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using ORTS.Common;
using System;
using System.IO;

namespace Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions
{
Expand Down Expand Up @@ -582,6 +583,26 @@ public Axle(ElectricMotor electricMotor)
}
}

/// <summary>
/// A constructor that restores the game state.
/// </summary>
/// <param name="inf">The save stream to read from.</param>
public Axle(BinaryReader inf) : this()
{
previousSlipPercent = inf.ReadSingle();
previousSlipSpeedMpS = inf.ReadSingle();
}

/// <summary>
/// Save the game state.
/// </summary>
/// <param name="outf">The save stream to write to.</param>
public void Save(BinaryWriter outf)
{
outf.Write(previousSlipPercent);
outf.Write(previousSlipSpeedMpS);
}

/// <summary>
/// Main Update method
/// - computes slip characteristics to get new axle force
Expand Down

0 comments on commit 0817e32

Please sign in to comment.