@@ -96,6 +96,7 @@ public TrainCar LastCar
96
96
}
97
97
public Traveller RearTDBTraveller; // positioned at the back of the last car in the train
98
98
public Traveller FrontTDBTraveller; // positioned at the front of the train by CalculatePositionOfCars
99
+ Traveller CalculatorTraveller; // CalculatePositionOfCars uses it for the calculations
99
100
public float Length; // length of train from FrontTDBTraveller to RearTDBTraveller
100
101
public float MassKg; // weight of the train
101
102
public float SpeedMpS; // meters per second +ve forward, -ve when backing
@@ -420,6 +421,8 @@ public enum END_AUTHORITY
420
421
421
422
public bool nextRouteReady = false; // indication to activity.cs that a reversal has taken place
422
423
424
+ readonly List<int[]> sectionList = new List<int[]>(); // internally used in UpdateSectionState()
425
+
423
426
// Deadlock Info :
424
427
// list of sections where deadlock begins
425
428
// per section : list with trainno and end section
@@ -4378,7 +4381,9 @@ public void CalculatePositionOfCars(float elapsedTime, float distance)
4378
4381
4379
4382
// TODO : check if train moved back into previous section
4380
4383
4381
- var traveller = new Traveller(RearTDBTraveller);
4384
+ CalculatorTraveller = CalculatorTraveller ?? new Traveller(RearTDBTraveller);
4385
+ var traveller = CalculatorTraveller;
4386
+ traveller.Copy(RearTDBTraveller);
4382
4387
// The traveller location represents the back of the train.
4383
4388
var length = 0f;
4384
4389
@@ -4453,7 +4458,7 @@ public void CalculatePositionOfCars(float elapsedTime, float distance)
4453
4458
car.UpdateFreightAnimationDiscretePositions();
4454
4459
}
4455
4460
4456
- FrontTDBTraveller = traveller ;
4461
+ ( FrontTDBTraveller, CalculatorTraveller) = (CalculatorTraveller, FrontTDBTraveller) ;
4457
4462
Length = length;
4458
4463
travelled += distance;
4459
4464
} // CalculatePositionOfCars
@@ -6521,7 +6526,7 @@ public void ObtainRequiredActions(int backward)
6521
6526
public void UpdateSectionState(int backward)
6522
6527
{
6523
6528
6524
- List<int[]> sectionList = new List<int[]> ();
6529
+ sectionList.Clear ();
6525
6530
6526
6531
int lastIndex = PreviousPosition[0].RouteListIndex;
6527
6532
int presentIndex = PresentPosition[0].RouteListIndex;
@@ -20025,6 +20030,7 @@ public RoughReversalInfo(int subPathIndex, float reverseReversalOffset, int reve
20025
20030
20026
20031
public class DistanceTravelledActions : LinkedList<DistanceTravelledItem>
20027
20032
{
20033
+ readonly List<DistanceTravelledItem> itemList = new List<DistanceTravelledItem>();
20028
20034
20029
20035
//================================================================================================//
20030
20036
//
@@ -20111,7 +20117,7 @@ public void InsertClearSection(float distance, int sectionIndex)
20111
20117
20112
20118
public List<DistanceTravelledItem> GetActions(float distance)
20113
20119
{
20114
- List<DistanceTravelledItem> itemList = new List<DistanceTravelledItem> ();
20120
+ itemList.Clear ();
20115
20121
20116
20122
bool itemsCollected = false;
20117
20123
LinkedListNode<DistanceTravelledItem> nextNode = this.First;
@@ -20136,7 +20142,7 @@ public List<DistanceTravelledItem> GetActions(float distance)
20136
20142
20137
20143
public List<DistanceTravelledItem> GetAuxActions(Train thisTrain, float distance)
20138
20144
{
20139
- List<DistanceTravelledItem> itemList = new List<DistanceTravelledItem> ();
20145
+ itemList.Clear ();
20140
20146
LinkedListNode<DistanceTravelledItem> nextNode = this.First;
20141
20147
20142
20148
while (nextNode != null)
@@ -20159,7 +20165,7 @@ public List<DistanceTravelledItem> GetAuxActions(Train thisTrain, float distance
20159
20165
20160
20166
public List<DistanceTravelledItem> GetActions(float distance, Type reqType)
20161
20167
{
20162
- List<DistanceTravelledItem> itemList = new List<DistanceTravelledItem> ();
20168
+ itemList.Clear ();
20163
20169
20164
20170
bool itemsCollected = false;
20165
20171
LinkedListNode<DistanceTravelledItem> nextNode = this.First;
0 commit comments