Skip to content

Commit ac4e072

Browse files
author
Chris Jakeman
committed
Merge remote-tracking branch 'upstream/master' into menu-options01
2 parents f81fe9f + 8b269d8 commit ac4e072

File tree

12 files changed

+179
-155
lines changed

12 files changed

+179
-155
lines changed

Source/Documentation/Manual/cabs.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,15 @@ if e.g. the wiper moves from left to right and back, only the frames related
527527
to the motion from left to right have to be included. For the reverse
528528
motion the same frames are used from last to first. SwitchVal can vary from 0 to 1.
529529

530+
Control Labels
531+
--------------
532+
533+
The string appearing on the screen when the mouse browses over a command control
534+
can be customized with following line, to be added within the control block in the
535+
.cvf file::
536+
537+
ORTSLabel ( "string" )
538+
530539
Multiple screen pages on displays
531540
---------------------------------
532541

Source/Documentation/Manual/physics.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,17 @@ however if the modeler desires greater accuracy the following parameters can be
160160
WAG/ENG file in the wagon section:
161161

162162
``ORTSLengthBogieCentre`` - length between bogie centres.
163-
``ORTSLengthCarBody`` - Length between car ends.
163+
164+
``ORTSLengthCarBody`` - Length between car ends (typically measured between the coupler pivot points).
165+
164166
``ORTSLengthCouplerFace`` - length between coupler faces.
165167

166-
``ORTSNumAxles`` - number of axles on the car.
167-
``ORTSNumBogies`` - number of bogies on the car.
168+
``ORTSNumberAxles`` - number of axles on the car.
169+
170+
``ORTSNumberDriveAxles`` - number of driven axles on the locomotive. NB: Total axles on locomotive will be
171+
``ORTSNumberAxles`` + ``ORTSNumberDriveAxles``.
172+
173+
``ORTSNumberBogies`` - number of bogies on the car.
168174

169175
.. _physics-adhesion:
170176

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ public class CabViewControl
406406

407407
public double OldValue;
408408
public string ACEFile = "";
409+
public string Label = "";
409410

410411
public int Display;
411412
public List<string> Screens;
@@ -607,6 +608,11 @@ public CVCDial(STFReader stf, string basepath)
607608
ToDegree = stf.ReadFloat(STFReader.UNITS.None, null);
608609
stf.SkipRestOfBlock();
609610
}),
611+
new STFReader.TokenProcessor("ortslabel", ()=>{
612+
stf.MustMatch("(");
613+
Label = stf.ReadString();
614+
stf.SkipRestOfBlock();
615+
}),
610616
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
611617
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
612618
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
@@ -696,6 +702,11 @@ public CVCGauge(STFReader stf, string basepath)
696702
}
697703
}),
698704
new STFReader.TokenProcessor("ortsangle", () =>{ Rotation = ParseRotation(stf); }),
705+
new STFReader.TokenProcessor("ortslabel", ()=>{
706+
stf.MustMatch("(");
707+
Label = stf.ReadString();
708+
stf.SkipRestOfBlock();
709+
}),
699710
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
700711
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
701712
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
@@ -822,6 +833,11 @@ public CVCDigital(STFReader stf, string basepath)
822833
}),
823834
new STFReader.TokenProcessor("ortsfont", ()=>{ParseFont(stf); }),
824835
new STFReader.TokenProcessor("ortsangle", () => {Rotation = ParseRotation(stf); }),
836+
new STFReader.TokenProcessor("ortslabel", ()=>{
837+
stf.MustMatch("(");
838+
Label = stf.ReadString();
839+
stf.SkipRestOfBlock();
840+
}),
825841
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
826842
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
827843
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
@@ -1066,6 +1082,11 @@ public CVCDiscrete(STFReader stf, string basepath, DiscreteStates discreteState)
10661082
_ValuesRead++;
10671083
}
10681084
}),
1085+
new STFReader.TokenProcessor("ortslabel", ()=>{
1086+
stf.MustMatch("(");
1087+
Label = stf.ReadString();
1088+
stf.SkipRestOfBlock();
1089+
}),
10691090
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
10701091
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
10711092
new STFReader.TokenProcessor("ortsnewscreenpage", () => {ParseNewScreen(stf); }),

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5208,7 +5208,7 @@ public virtual float GetDataOf(CabViewControl cvc)
52085208
break;
52095209

52105210
case CABViewControlTypes.ORTS_BATTERY_SWITCH_COMMAND_BUTTON_OPEN:
5211-
data = LocomotivePowerSupply.BatterySwitch.CommandButtonOn ? 1 : 0;
5211+
data = LocomotivePowerSupply.BatterySwitch.CommandButtonOff ? 1 : 0;
52125212
break;
52135213

52145214
case CABViewControlTypes.ORTS_BATTERY_SWITCH_ON:

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ public float TenderCoalMassKG // Decreased by firing and increased
571571
float DisplayCriticalSpeedTractiveEffortLbf; // Display power value @ speed of piston
572572
float absStartTractiveEffortN = 0.0f; // Record starting tractive effort
573573
float TractiveEffortLbsF; // Current sim calculated tractive effort
574-
const float TractiveEffortFactor = 0.85f; // factor for calculating Theoretical Tractive Effort for non-geared locomotives
574+
float TractiveEffortFactor = 0.85f; // factor for calculating Theoretical Tractive Effort for non-geared locomotives
575575
float GearedTractiveEffortFactor = 0.7f; // factor for calculating Theoretical Tractive Effort for geared locomotives
576576
float NeutralGearedDavisAN; // Davis A value adjusted for neutral gearing
577577
const float DavisMechanicalResistanceFactor = 20.0f;
@@ -1254,6 +1254,13 @@ public override void Initialize()
12541254

12551255
// ****************** Test Locomotive and Gearing type ***********************
12561256

1257+
// if the maximum cutoff for the locomotive is less then the default value, then decrease it so that tractive effort is not excessive.
1258+
// At some future stage it may be worthwhile to add an extra parameter to the ENG file to allow user setting.
1259+
if (CutoffController.MaximumValue < TractiveEffortFactor)
1260+
{
1261+
TractiveEffortFactor = CutoffController.MaximumValue;
1262+
}
1263+
12571264
if (SteamEngineType == SteamEngineTypes.Compound)
12581265
{
12591266
// Initialise Compound locomotive

Source/RunActivity/Viewer3D/MSTSSky.cs

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,8 @@ public class MSTSSkyDrawer
6868

6969
public Orts.Viewer3D.SkyViewer.Date date;
7070

71-
// Size of the sun- and moon-position lookup table arrays.
72-
// Must be an integral divisor of 1440 (which is the number of minutes in a day).
73-
private int maxSteps = 72;
74-
private double mstsskyoldClockTime;
75-
private int step1, step2;
71+
private SkySteps skySteps = new SkySteps();
72+
7673
// Phase of the moon
7774
public int mstsskymoonPhase;
7875
// Wind speed and direction
@@ -128,11 +125,11 @@ public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
128125
{
129126
// First time around, initialize the following items:
130127
mstsskyworldLoc = new WorldLatLon();
131-
mstsskyoldClockTime = MSTSSkyViewer.Simulator.ClockTime % 86400;
132-
while (mstsskyoldClockTime < 0) mstsskyoldClockTime += 86400;
133-
step1 = step2 = (int)(mstsskyoldClockTime / 1200);
134-
step2 = step2 < maxSteps - 1 ? step2 + 1 : 0; // limit to max. steps in case activity starts near midnight
135-
// Get the current latitude and longitude coordinates
128+
skySteps.OldClockTime = MSTSSkyViewer.Simulator.ClockTime % 86400;
129+
while (skySteps.OldClockTime < 0) skySteps.OldClockTime += 86400;
130+
skySteps.Step1 = skySteps.Step2 = (int)(skySteps.OldClockTime / 1200);
131+
skySteps.Step2 = skySteps.Step2 < skySteps.MaxSteps - 1 ? skySteps.Step2 + 1 : 0; // limit to max. steps in case activity starts near midnight
132+
// Get the current latitude and longitude coordinates
136133
mstsskyworldLoc.ConvertWTC(MSTSSkyViewer.Camera.TileX, MSTSSkyViewer.Camera.TileZ, MSTSSkyViewer.Camera.Location, ref mstsskylatitude, ref mstsskylongitude);
137134
if (mstsskyseasonType != (int)MSTSSkyViewer.Simulator.Season)
138135
{
@@ -144,10 +141,10 @@ public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
144141
date.year = 2017;
145142
}
146143
// Fill in the sun- and moon-position lookup tables
147-
for (int i = 0; i < maxSteps; i++)
144+
for (int i = 0; i < skySteps.MaxSteps; i++)
148145
{
149-
mstsskysolarPosArray[i] = SunMoonPos.SolarAngle(mstsskylatitude, mstsskylongitude, ((float)i / maxSteps), date);
150-
mstsskylunarPosArray[i] = SunMoonPos.LunarAngle(mstsskylatitude, mstsskylongitude, ((float)i / maxSteps), date);
146+
mstsskysolarPosArray[i] = SunMoonPos.SolarAngle(mstsskylatitude, mstsskylongitude, ((float)i / skySteps.MaxSteps), date);
147+
mstsskylunarPosArray[i] = SunMoonPos.LunarAngle(mstsskylatitude, mstsskylongitude, ((float)i / skySteps.MaxSteps), date);
151148
}
152149
// Phase of the moon is generated at random
153150
mstsskymoonPhase = Viewer.Random.Next(8);
@@ -209,58 +206,14 @@ public void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
209206
}
210207
}
211208

212-
////////////////////////////////////////////////////////////////////
213-
214-
// Current solar and lunar position are calculated by interpolation in the lookup arrays.
215-
// Using the Lerp() function, so need to calculate the in-between differential
216-
float diff = (float)(MSTSSkyViewer.Simulator.ClockTime - mstsskyoldClockTime) / 1200;
217-
// The rest of this increments/decrements the array indices and checks for overshoot/undershoot.
218-
if (MSTSSkyViewer.Simulator.ClockTime >= (mstsskyoldClockTime + 1200)) // Plus key, or normal forward in time
219-
{
220-
step1++;
221-
step2++;
222-
mstsskyoldClockTime = MSTSSkyViewer.Simulator.ClockTime;
223-
diff = 0;
224-
if (step2 >= maxSteps) // Midnight.
225-
{
226-
step2 = 0;
227-
}
228-
if (step1 >= maxSteps) // Midnight.
229-
{
230-
step1 = 0;
231-
}
232-
}
233-
if (MSTSSkyViewer.Simulator.ClockTime <= (mstsskyoldClockTime - 1200)) // Minus key
234-
{
235-
step1--;
236-
step2--;
237-
mstsskyoldClockTime = MSTSSkyViewer.Simulator.ClockTime;
238-
diff = 0;
239-
if (step1 < 0) // Midnight.
240-
{
241-
step1 = maxSteps - 1;
242-
}
243-
if (step2 < 0) // Midnight.
244-
{
245-
step2 = maxSteps - 1;
246-
}
247-
}
248-
249-
250-
mstsskysolarDirection.X = MathHelper.Lerp(mstsskysolarPosArray[step1].X, mstsskysolarPosArray[step2].X, diff);
251-
mstsskysolarDirection.Y = MathHelper.Lerp(mstsskysolarPosArray[step1].Y, mstsskysolarPosArray[step2].Y, diff);
252-
mstsskysolarDirection.Z = MathHelper.Lerp(mstsskysolarPosArray[step1].Z, mstsskysolarPosArray[step2].Z, diff);
253-
mstsskylunarDirection.X = MathHelper.Lerp(mstsskylunarPosArray[step1].X, mstsskylunarPosArray[step2].X, diff);
254-
mstsskylunarDirection.Y = MathHelper.Lerp(mstsskylunarPosArray[step1].Y, mstsskylunarPosArray[step2].Y, diff);
255-
mstsskylunarDirection.Z = MathHelper.Lerp(mstsskylunarPosArray[step1].Z, mstsskylunarPosArray[step2].Z, diff);
209+
skySteps.SetSunAndMoonDirection(ref mstsskysolarDirection, ref mstsskylunarDirection, ref mstsskysolarPosArray, ref mstsskylunarPosArray,
210+
MSTSSkyViewer.Simulator.ClockTime);
256211

257212
frame.AddPrimitive(MSTSSkyMaterial, MSTSSkyMesh, RenderPrimitiveGroup.Sky, ref XNASkyWorldLocation);
258213
}
259214

260215
public void LoadPrep()
261216
{
262-
263-
264217
mstsskyworldLoc = new WorldLatLon();
265218
// Get the current latitude and longitude coordinates
266219
mstsskyworldLoc.ConvertWTC(MSTSSkyViewer.Camera.TileX, MSTSSkyViewer.Camera.TileZ, MSTSSkyViewer.Camera.Location, ref mstsskylatitude, ref mstsskylongitude);
@@ -274,7 +227,6 @@ public void LoadPrep()
274227
mstsskyworldLoc = null;
275228
mstsskylatitude = 0;
276229
mstsskylongitude = 0;
277-
278230
}
279231

280232
[CallOnThread("Loader")]

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@ public interface ICabViewMouseControlRenderer
15791579
bool IsMouseWithin();
15801580
void HandleUserInput();
15811581
string GetControlName();
1582-
1582+
string ControlLabel { get; }
15831583
}
15841584

15851585
/// <summary>
@@ -2215,6 +2215,8 @@ public string GetControlName()
22152215
return (Locomotive as MSTSLocomotive).TrainControlSystem.GetDisplayString(GetControlType().ToString());
22162216
}
22172217

2218+
public string ControlLabel => Control.Label;
2219+
22182220
/// <summary>
22192221
/// Handles cabview mouse events, and changes the corresponding locomotive control values.
22202222
/// </summary>

Source/RunActivity/Viewer3D/RollingStock/SubSystems/ETCS/DriverMachineInterface.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ public string GetControlName()
856856
}
857857
return "";
858858
}
859-
859+
public string ControlLabel => GetControlName();
860860
public override void Draw(GraphicsDevice graphicsDevice)
861861
{
862862
DMI.Draw(ControlView.SpriteBatch, new Point(DrawPosition.X, DrawPosition.Y));

Source/RunActivity/Viewer3D/Scenery.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,10 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
463463
if (Program.Simulator.CarSpawnerLists != null && ((CarSpawnerObj)worldObject).ListName != null)
464464
{
465465
((CarSpawnerObj)worldObject).CarSpawnerListIdx = Program.Simulator.CarSpawnerLists.FindIndex(x => x.ListName == ((CarSpawnerObj)worldObject).ListName);
466-
if (((CarSpawnerObj)worldObject).CarSpawnerListIdx < 0 || ((CarSpawnerObj)worldObject).CarSpawnerListIdx > Program.Simulator.CarSpawnerLists.Count-1)
466+
if (((CarSpawnerObj)worldObject).CarSpawnerListIdx < 0 || ((CarSpawnerObj)worldObject).CarSpawnerListIdx > Program.Simulator.CarSpawnerLists.Count - 1)
467467
((CarSpawnerObj)worldObject).CarSpawnerListIdx = 0;
468468
}
469-
else
469+
else
470470
((CarSpawnerObj)worldObject).CarSpawnerListIdx = 0;
471471
carSpawners.Add(new RoadCarSpawner(viewer, worldMatrix, (CarSpawnerObj)worldObject));
472472
}
@@ -480,9 +480,13 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
480480
}
481481
else if (worldObject.GetType() == typeof(StaticObj))
482482
{
483-
// preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
483+
// preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
484484
StaticShape preTestShape = (new StaticShape(viewer, shapeFilePath, worldMatrix, shadowCaster ? ShapeFlags.ShadowCaster : ShapeFlags.None));
485-
var animNodes = preTestShape.SharedShape.Animations?[0]?.anim_nodes ?? new List<anim_node>();
485+
486+
// FirstOrDefault() checks for "animations( 0 )" as this is a valid entry in *.s files
487+
// and is included by MSTSexporter for Blender 2.8+ Release V4.0 or older
488+
var animNodes = preTestShape.SharedShape.Animations?.FirstOrDefault()?.anim_nodes ?? new List<anim_node>();
489+
486490
var isAnimatedClock = animNodes.Exists(node => Regex.IsMatch(node.Name, @"^orts_[hmsc]hand_clock", RegexOptions.IgnoreCase));
487491
if (isAnimatedClock)
488492
{

0 commit comments

Comments
 (0)