|
50 | 50 | // #define DEBUG_COUPLER_FORCES
|
51 | 51 |
|
52 | 52 | using Microsoft.Xna.Framework;
|
53 |
| -using Microsoft.Xna.Framework.Graphics; |
54 | 53 | using Orts.Formats.Msts;
|
55 | 54 | using Orts.MultiPlayer;
|
56 | 55 | using Orts.Simulation.AIs;
|
57 | 56 | using Orts.Simulation.RollingStocks;
|
58 |
| -using Orts.Simulation.RollingStocks.SubSystems; |
59 | 57 | using Orts.Simulation.RollingStocks.SubSystems.Brakes;
|
60 | 58 | using Orts.Simulation.RollingStocks.SubSystems.Brakes.MSTS;
|
61 |
| -using Orts.Parsers.Msts; |
| 59 | +using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies; |
62 | 60 | using Orts.Simulation.Signalling;
|
63 | 61 | using Orts.Simulation.Timetables;
|
64 | 62 | using ORTS.Common;
|
|
71 | 69 | using System.Linq;
|
72 | 70 | using System.Text;
|
73 | 71 | using Event = Orts.Common.Event;
|
74 |
| -using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies; |
75 | 72 |
|
76 | 73 | namespace Orts.Simulation.Physics
|
77 | 74 | {
|
@@ -664,11 +661,9 @@ public Train(Simulator simulator, Train orgTrain)
|
664 | 661 |
|
665 | 662 | }
|
666 | 663 |
|
667 |
| - //================================================================================================// |
668 | 664 | /// <summary>
|
669 | 665 | /// Restore
|
670 |
| - /// <\summary> |
671 |
| - |
| 666 | + /// </summary> |
672 | 667 | public Train(Simulator simulator, BinaryReader inf)
|
673 | 668 | {
|
674 | 669 | Init(simulator);
|
@@ -953,7 +948,11 @@ private void RestoreCars(Simulator simulator, BinaryReader inf)
|
953 | 948 | if (count > 0)
|
954 | 949 | {
|
955 | 950 | for (int i = 0; i < count; ++i)
|
956 |
| - Cars.Add(RollingStock.Restore(simulator, inf, this)); |
| 951 | + { |
| 952 | + TrainCar car = RollingStock.Load(simulator, this, inf.ReadString(), false); |
| 953 | + car.Restore(inf); |
| 954 | + car.Initialize(); |
| 955 | + } |
957 | 956 | }
|
958 | 957 | SetDPUnitIDs(true);
|
959 | 958 | }
|
@@ -1014,12 +1013,9 @@ private void RestoreDeadlockInfo(BinaryReader inf)
|
1014 | 1013 | }
|
1015 | 1014 | }
|
1016 | 1015 |
|
1017 |
| - |
1018 |
| - //================================================================================================// |
1019 | 1016 | /// <summary>
|
1020 | 1017 | /// save game state
|
1021 |
| - /// <\summary> |
1022 |
| - |
| 1018 | + /// </summary> |
1023 | 1019 | public virtual void Save(BinaryWriter outf)
|
1024 | 1020 | {
|
1025 | 1021 | SaveCars(outf);
|
@@ -1209,8 +1205,11 @@ public virtual void Save(BinaryWriter outf)
|
1209 | 1205 | private void SaveCars(BinaryWriter outf)
|
1210 | 1206 | {
|
1211 | 1207 | outf.Write(Cars.Count);
|
1212 |
| - foreach (TrainCar car in Cars) |
1213 |
| - RollingStock.Save(outf, car); |
| 1208 | + foreach (MSTSWagon wagon in Cars.OfType<MSTSWagon>()) |
| 1209 | + { |
| 1210 | + outf.Write(wagon.WagFilePath); |
| 1211 | + wagon.Save(outf); |
| 1212 | + } |
1214 | 1213 | }
|
1215 | 1214 |
|
1216 | 1215 | static void SaveTrafficSDefinition(BinaryWriter outf, Traffic_Service_Definition thisTSD)
|
@@ -4258,9 +4257,8 @@ public TrainCar FindLeadLocomotive()
|
4258 | 4257 |
|
4259 | 4258 | public void PropagateBrakePressure(float elapsedClockSeconds)
|
4260 | 4259 | {
|
4261 |
| - if (LeadLocomotiveIndex >= 0) |
| 4260 | + if (LeadLocomotive is MSTSLocomotive lead) |
4262 | 4261 | {
|
4263 |
| - MSTSLocomotive lead = (MSTSLocomotive)Cars[LeadLocomotiveIndex]; |
4264 | 4262 | if (lead.TrainBrakeController != null)
|
4265 | 4263 | lead.TrainBrakeController.UpdatePressure(ref EqualReservoirPressurePSIorInHg, elapsedClockSeconds, ref BrakeLine4);
|
4266 | 4264 | if (lead.EngineBrakeController != null)
|
|
0 commit comments