Skip to content

Commit ce66076

Browse files
authored
Merge branch 'openrails:master' into alternate-tokens
2 parents 34e0569 + 2f57132 commit ce66076

File tree

17 files changed

+109
-134
lines changed

17 files changed

+109
-134
lines changed

Source/Documentation/Manual/appendices.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ The following folders are also written to by Open Rails.
123123
Save images AppData\\Roaming\\Open Rails\\shunt_1 2021-07-18 19.46.35.png
124124
Replays AppData\\Roaming\\Open Rails\\shunt_1 2021-07-18 19.46.35.replay
125125
Evaluations AppData\\Roaming\\Open Rails\\shunt_1 2021-07-18 19.46.35.dbfeval
126-
Loading progress bar AppData\\Roaming\\Open Rails\\Load Cache\\3cd9... ...0ce2.dat
126+
Loading progress bar AppData\\Roaming\\Open Rails\\Cache\\Load\\3cd9... ...0ce2.cache-or
127+
Timetable path files AppData\\Roaming\\Open Rails\\Cache\\Path\\4ae2... ...4132.cache-or
127128
==================== ========================================================================================
128129

129130

Source/Documentation/Manual/timetable.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,15 @@ Special Rows
296296

297297
Large timetables can require many paths, and loading those paths can take
298298
considerable time (several minutes). To reduce this loading time, the paths
299-
can be stored in a processed, binary format. This format is the same as used
300-
in the 'save' command. Note that the binary path information cannot be
301-
directly accessed by the user, either for reading or for writing. When
302-
``/binary`` is set, the program will check if a binary path exists. If so, it
303-
will read that path. If not, it will read the 'normal' path, and will then
304-
store this as binary for future use. Binary paths are stored in a subdirectory
305-
named ``OpenRails`` which must be created in the Paths directory of the route.
299+
can be stored in files in a processed, binary format. When
300+
``/binary`` is set, the program will check if a binary path file exists.
301+
If so, it will read that path. If not, it will read the 'normal' path, and will then
302+
store this as a binary path file for future use.
306303

307304
Note: If a path or the route is edited, then the binary data will be out of date.
308305
If so, it is deleted and re-created automatically when the user starts the route.
306+
These files are stored in the same
307+
folder as Saves - see :ref:`Folders used by Open Rails <appendices-folders_used>`.
309308

310309
- ``#consist`` row
311310

Source/Orts.Simulation/Simulation/Physics/Train.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,8 @@ private void RestoreCars(Simulator simulator, BinaryReader inf)
952952
{
953953
for (int i = 0; i < count; ++i)
954954
{
955-
TrainCar car = RollingStock.Load(simulator, this, inf.ReadString(), false);
955+
TrainCar car = RollingStock.Load(simulator, this, inf.ReadString());
956956
car.Restore(inf);
957-
car.Initialize();
958957
}
959958
}
960959
SetDPUnitIDs(true);

Source/Orts.Simulation/Simulation/RollingStocks/MSTSControlTrailerCar.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public override void Copy(MSTSWagon copy)
128128
/// </summary>
129129
public override void Save(BinaryWriter outf)
130130
{
131+
base.Save(outf);
131132
ControllerFactory.Save(GearBoxController, outf);
132133
outf.Write(ControlGearIndication);
133134
outf.Write(ControlGearIndex);

Source/Orts.Simulation/Simulation/RollingStocks/MSTSDieselLocomotive.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ public float DieselLevelL
9191

9292
public float LocomotiveMaxRailOutputPowerW;
9393

94-
public int currentGearIndexRestore = -1;
95-
public int currentnextGearRestore = -1;
96-
public bool gearSaved;
97-
public int dieselEngineRestoreState;
98-
9994
public float EngineRPM;
10095
public SmoothedData ExhaustParticles = new SmoothedData(1);
10196
public SmoothedData ExhaustMagnitude = new SmoothedData(1);
@@ -476,17 +471,6 @@ public override void Initialize()
476471
}
477472
}
478473

479-
// TO BE LOOKED AT - fix restoration process for gearbox and gear controller
480-
// It appears that the gearbox is initialised in two different places to cater for Basic and Advanced ENG file configurations(?).
481-
// Hence the restore values recovered in gearbox class are being overwritten , and resume was not working correctly
482-
// Hence restore gear position values are read as part of the diesel and restored at this point.
483-
if (gearSaved)
484-
{
485-
DieselEngines[0].GearBox.nextGearIndex = currentnextGearRestore;
486-
DieselEngines[0].GearBox.currentGearIndex = currentGearIndexRestore;
487-
GearBoxController.SetValue((float)DieselEngines[0].GearBox.currentGearIndex);
488-
}
489-
490474
if (Simulator.Settings.VerboseConfigurationMessages)
491475
{
492476
if (DieselEngines.HasGearBox)

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ public override void Save(BinaryWriter outf)
322322
outf.Write(ReleaseRatePSIpS);
323323
outf.Write(RetainerPressureThresholdPSI);
324324
outf.Write(AutoCylPressurePSI);
325+
outf.Write(CylPressurePSI);
325326
outf.Write(AuxResPressurePSI);
326327
outf.Write(EmergResPressurePSI);
327328
outf.Write(ControlResPressurePSI);
@@ -345,6 +346,7 @@ public override void Restore(BinaryReader inf)
345346
ReleaseRatePSIpS = inf.ReadSingle();
346347
RetainerPressureThresholdPSI = inf.ReadSingle();
347348
AutoCylPressurePSI = inf.ReadSingle();
349+
CylPressurePSI = inf.ReadSingle();
348350
AuxResPressurePSI = inf.ReadSingle();
349351
EmergResPressurePSI = inf.ReadSingle();
350352
ControlResPressurePSI = inf.ReadSingle();

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/CircuitBreaker.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ public void HandleEvent(PowerSupplyEvent evt)
188188

189189
public void Save(BinaryWriter outf)
190190
{
191-
outf.Write(ScriptName);
192191
outf.Write(DelayS);
193192
outf.Write(State.ToString());
194193
outf.Write(DriverClosingOrder);
@@ -199,7 +198,6 @@ public void Save(BinaryWriter outf)
199198

200199
public void Restore(BinaryReader inf)
201200
{
202-
ScriptName = inf.ReadString();
203201
DelayS = inf.ReadSingle();
204202
State = (CircuitBreakerState)Enum.Parse(typeof(CircuitBreakerState), inf.ReadString());
205203
DriverClosingOrder = inf.ReadBoolean();

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DieselEngine.cs

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public void Parse(string lowercasetoken, STFReader stf)
109109
DEList.Add(new DieselEngine(Locomotive));
110110

111111
DEList[i].Parse(stf);
112-
DEList[i].Initialize();
113112

114113
// sets flag to indicate that a diesel eng prime mover code block has been defined by user, otherwise OR will define one through the next code section using "MSTS" values
115114
DEList[i].DieselEngineConfigured = true;
@@ -119,7 +118,6 @@ public void Parse(string lowercasetoken, STFReader stf)
119118
{
120119
STFException.TraceWarning(stf, "Diesel engine model has some errors - loading MSTS format");
121120
DEList[i].InitFromMSTS();
122-
DEList[i].Initialize();
123121
}
124122
}
125123
break;
@@ -993,15 +991,11 @@ public void Copy(DieselEngine other)
993991

994992
public void Initialize()
995993
{
996-
if (!Simulator.Settings.NoDieselEngineStart && !Locomotive.gearSaved)
994+
if (!Simulator.Settings.NoDieselEngineStart)
997995
{
998996
RealRPM = IdleRPM;
999997
State = DieselEngineState.Running;
1000998
}
1001-
else if (Locomotive.gearSaved)
1002-
{
1003-
State = (DieselEngineState)Locomotive.dieselEngineRestoreState;
1004-
}
1005999

10061000
RPMRange = MaxRPM - IdleRPM;
10071001
MagnitudeRange = MaxMagnitude - InitialMagnitude;
@@ -1018,16 +1012,14 @@ public void Initialize()
10181012

10191013
public void InitializeMoving()
10201014
{
1021-
if (!Simulator.Settings.NoDieselEngineStart && !Locomotive.gearSaved)
1022-
{
1023-
RealRPM = IdleRPM;
1024-
State = DieselEngineState.Running;
1025-
}
1026-
else if (Locomotive.gearSaved)
1015+
RealRPM = IdleRPM;
1016+
State = DieselEngineState.Running;
1017+
if (ThrottleRPMTab != null)
10271018
{
1028-
State = (DieselEngineState)Locomotive.dieselEngineRestoreState;
1019+
DemandedRPM = ThrottleRPMTab[Locomotive.ThrottlePercent];
1020+
DemandedRPM = MathHelper.Clamp(DemandedRPM, IdleRPM, MaxRPM); // Clamp throttle setting within bounds
1021+
RealRPM = DemandedRPM;
10291022
}
1030-
10311023
GearBox?.InitializeMoving();
10321024
}
10331025

@@ -1594,20 +1586,12 @@ public void HandleEvent(PowerSupplyEvent evt)
15941586

15951587
public void Restore(BinaryReader inf)
15961588
{
1597-
Locomotive.dieselEngineRestoreState = inf.ReadInt32();
1598-
State = (DieselEngineState)Locomotive.dieselEngineRestoreState;
1589+
State = (DieselEngineState)inf.ReadInt32();
15991590
RealRPM = inf.ReadSingle();
16001591
OutputPowerW = inf.ReadSingle();
16011592
DieselTemperatureDeg = inf.ReadSingle();
16021593
GovernorEnabled = inf.ReadBoolean();
1603-
1604-
Locomotive.gearSaved = inf.ReadBoolean(); // read boolean which indicates gear data was saved
1605-
1606-
if (Locomotive.gearSaved)
1607-
{
1608-
GearBox = new GearBox(this);
1609-
GearBox.Restore(inf);
1610-
}
1594+
GearBox?.Restore(inf);
16111595
}
16121596

16131597
public void Save(BinaryWriter outf)
@@ -1617,16 +1601,7 @@ public void Save(BinaryWriter outf)
16171601
outf.Write(OutputPowerW);
16181602
outf.Write(DieselTemperatureDeg);
16191603
outf.Write(GovernorEnabled);
1620-
1621-
if (GearBox != null)
1622-
{
1623-
outf.Write(true);
1624-
GearBox.Save(outf);
1625-
}
1626-
else
1627-
{
1628-
outf.Write(false);
1629-
}
1604+
GearBox?.Save(outf);
16301605
}
16311606

16321607
/// <summary>

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DieselPowerSupply.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,12 @@ public override void InitializeMoving()
110110

111111
public override void Save(BinaryWriter outf)
112112
{
113-
outf.Write(ScriptName);
114-
115113
base.Save(outf);
116114
TractionCutOffRelay.Save(outf);
117115
}
118116

119117
public override void Restore(BinaryReader inf)
120118
{
121-
ScriptName = inf.ReadString();
122-
123119
base.Restore(inf);
124120
TractionCutOffRelay.Restore(inf);
125121
}

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DualModePowerSupply.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,13 @@ public override void InitializeMoving()
112112

113113
public override void Save(BinaryWriter outf)
114114
{
115-
outf.Write(ScriptName);
116-
117115
base.Save(outf);
118116
CircuitBreaker.Save(outf);
119117
TractionCutOffRelay.Save(outf);
120118
}
121119

122120
public override void Restore(BinaryReader inf)
123121
{
124-
ScriptName = inf.ReadString();
125-
126122
base.Restore(inf);
127123
CircuitBreaker.Restore(inf);
128124
TractionCutOffRelay.Restore(inf);

0 commit comments

Comments
 (0)