Skip to content

Commit 8eea009

Browse files
committed
Cleanup code
1 parent fd34961 commit 8eea009

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

Source/Orts.Simulation/MultiPlayer/Message.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,7 @@ public override void HandleMsg()
23472347
}
23482348

23492349
}
2350-
#endregion MSGGetTrain
2350+
#endregion MSGGetTrain
23512351

23522352
#region MSGUncouple
23532353

@@ -2781,7 +2781,7 @@ public override void HandleMsg()
27812781
}
27822782
}
27832783
}
2784-
#endregion MSGUncouple
2784+
#endregion MSGUncouple
27852785

27862786

27872787
#region MSGCouple
@@ -3900,25 +3900,25 @@ public override string ToString()
39003900

39013901
public class MSGMovingTbl : Message
39023902
{
3903-
public string user, newTrainName, carID, firstCarIDOld, firstCarIDNew;
3904-
public MovingTable.submessagecode subMessageCode;
3905-
public int movingTableIndex;
3906-
public bool clockwise;
3907-
public float yangle;
3903+
private string user;
3904+
private MovingTable.subMessageCode subMessageCode;
3905+
private int movingTableIndex;
3906+
private bool clockwise;
3907+
private float yangle;
39083908

39093909
public MSGMovingTbl(string m)
39103910
{
39113911
string[] areas = m.Split('\t');
39123912

39133913
movingTableIndex = int.Parse(areas[0].Trim());
39143914
user = areas[1].Trim();
3915-
subMessageCode = (MovingTable.submessagecode) int.Parse(areas[2].Trim());
3915+
subMessageCode = (MovingTable.subMessageCode)int.Parse(areas[2].Trim());
39163916
clockwise = int.Parse(areas[3].Trim()) == 0 ? false : true;
39173917
yangle = float.Parse(areas[4].Trim());
39183918

39193919
}
39203920

3921-
public MSGMovingTbl(int mti, string u, MovingTable.submessagecode smc, bool cw, float y)
3921+
public MSGMovingTbl(int mti, string u, MovingTable.subMessageCode smc, bool cw, float y)
39223922
{
39233923
movingTableIndex = mti;
39243924
user = u;
@@ -3943,7 +3943,7 @@ public override void HandleMsg()
39433943
{
39443944
switch (subMessageCode)
39453945
{
3946-
case MovingTable.submessagecode.GoToTarget:
3946+
case MovingTable.subMessageCode.GoToTarget:
39473947
turntable.RemotelyControlled = true;
39483948
if (Math.Abs(MathHelper.WrapAngle(turntable.YAngle - yangle)) > 0.2f)
39493949
{
@@ -3953,7 +3953,7 @@ public override void HandleMsg()
39533953
}
39543954
turntable.GeneralComputeTarget(clockwise);
39553955
break;
3956-
case MovingTable.submessagecode.StartingContinuous:
3956+
case MovingTable.subMessageCode.StartingContinuous:
39573957
turntable.YAngle = yangle;
39583958
turntable.TargetY = yangle;
39593959
turntable.AlignToRemote = true;
@@ -3967,7 +3967,7 @@ public override void HandleMsg()
39673967
{
39683968
switch (subMessageCode)
39693969
{
3970-
case MovingTable.submessagecode.GoToTarget:
3970+
case MovingTable.subMessageCode.GoToTarget:
39713971
transfertable.RemotelyControlled = true;
39723972
if (Math.Abs(transfertable.OffsetPos - yangle) > 2.8f)
39733973
{
@@ -3977,7 +3977,7 @@ public override void HandleMsg()
39773977
}
39783978
transfertable.GeneralComputeTarget(clockwise);
39793979
break;
3980-
case MovingTable.submessagecode.StartingContinuous:
3980+
case MovingTable.subMessageCode.StartingContinuous:
39813981
transfertable.OffsetPos = yangle;
39823982
transfertable.TargetOffset = yangle;
39833983
transfertable.AlignToRemote = true;

Source/Orts.Simulation/Simulation/Transfertables.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public float CenterOffsetComponent
4747
{
4848
get => VerticalTransfer ? CenterOffset.Y : CenterOffset.X;
4949
}
50-
public float OffsetDiff = 1.4f;
50+
public float OffsetDiff
51+
{
52+
get => RemotelyControlled ? 2.8f : 1.4f;
53+
}
5154
// Dynamic data
5255
public bool Forward; // forward motion on
5356
public bool Reverse; // reverse motion on
@@ -177,7 +180,7 @@ public override void ComputeTarget(bool isForward)
177180
if (!Continuous) return;
178181
if (MultiPlayer.MPManager.IsMultiPlayer())
179182
{
180-
SubMessageCode = submessagecode.GoToTarget;
183+
SubMessageCode = subMessageCode.GoToTarget;
181184
MultiPlayer.MPManager.Notify(new MultiPlayer.MSGMovingTbl(Simulator.ActiveMovingTableIndex, Orts.MultiPlayer.MPManager.GetUserName(), SubMessageCode, isForward, OffsetPos).ToString());
182185
}
183186
RemotelyControlled = false;
@@ -191,7 +194,6 @@ public void GeneralComputeTarget(bool isForward)
191194
GoToTarget = false;
192195
Forward = isForward;
193196
Reverse = !isForward;
194-
OffsetDiff = RemotelyControlled ? 2.8f : 1.4f;
195197
if (Forward)
196198
{
197199
Connected = false;
@@ -278,7 +280,7 @@ public override void StartContinuous(bool isForward)
278280
}
279281
if (MultiPlayer.MPManager.IsMultiPlayer())
280282
{
281-
SubMessageCode = submessagecode.StartingContinuous;
283+
SubMessageCode = subMessageCode.StartingContinuous;
282284
MultiPlayer.MPManager.Notify(new MultiPlayer.MSGMovingTbl(Simulator.ActiveMovingTableIndex, Orts.MultiPlayer.MPManager.GetUserName(), SubMessageCode, isForward, OffsetPos).ToString());
283285
}
284286
GeneralStartContinuous(isForward);

Source/Orts.Simulation/Simulation/Turntables.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class MovingTable
8181
protected int[] MyTrVectorSectionsIndex;
8282
public bool[] MyTrackNodesOrientation { get; protected set; } // true if forward, false if backward
8383
public int TrackShapeIndex;
84-
public enum submessagecode
84+
public enum subMessageCode
8585
{
8686
GoToTarget,
8787
StartingContinuous,
@@ -108,7 +108,7 @@ public enum submessagecode
108108
public Vector3 FinalFrontTravellerXNALocation;
109109
public Vector3 FinalRearTravellerXNALocation;
110110
public Simulator Simulator;
111-
public submessagecode SubMessageCode;
111+
public subMessageCode SubMessageCode;
112112
public bool AlignToRemote;
113113
public bool RemotelyControlled;
114114

@@ -485,7 +485,7 @@ public override void ComputeTarget(bool isClockwise)
485485
if (!Continuous) return;
486486
if (MultiPlayer.MPManager.IsMultiPlayer())
487487
{
488-
SubMessageCode = submessagecode.GoToTarget;
488+
SubMessageCode = subMessageCode.GoToTarget;
489489
MultiPlayer.MPManager.Notify(new MultiPlayer.MSGMovingTbl(Simulator.ActiveMovingTableIndex, Orts.MultiPlayer.MPManager.GetUserName(), SubMessageCode, isClockwise, YAngle).ToString());
490490
}
491491
RemotelyControlled = false;
@@ -628,7 +628,7 @@ public override void StartContinuous(bool isClockwise)
628628
}
629629
if (MultiPlayer.MPManager.IsMultiPlayer())
630630
{
631-
SubMessageCode = submessagecode.StartingContinuous;
631+
SubMessageCode = subMessageCode.StartingContinuous;
632632
MultiPlayer.MPManager.Notify(new MultiPlayer.MSGMovingTbl(Simulator.ActiveMovingTableIndex, Orts.MultiPlayer.MPManager.GetUserName(), SubMessageCode, isClockwise, YAngle).ToString());
633633
}
634634
GeneralStartContinuous(isClockwise);

0 commit comments

Comments
 (0)