Skip to content

Commit a11e129

Browse files
committed
Merge branch 'master' into release
2 parents db8e3f4 + 81ead22 commit a11e129

File tree

18 files changed

+155
-31
lines changed

18 files changed

+155
-31
lines changed

assets/Languages/en-US.xlf

+9
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,15 @@
14661466
<trans-unit id="delimiter">
14671467
<source>\x20</source>
14681468
</trans-unit>
1469+
<trans-unit id="signal_access_invalid">
1470+
<source>The next section is not a permissive section.</source>
1471+
</trans-unit>
1472+
<trans-unit id="signal_access_denied">
1473+
<source>The next section is a permissive section, but access is not currently possible. Please wait and retry.</source>
1474+
</trans-unit>
1475+
<trans-unit id="signal_access_granted">
1476+
<source>Access to the next section has been granted.</source>
1477+
</trans-unit>
14691478
<trans-unit id="signal_proceed">
14701479
<source>You may proceed at [speed] [unit] with extreme caution.</source>
14711480
</trans-unit>

source/OpenBVE/Game/SwitchChange/SwitchChangeDialog.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ internal void Show()
8686
TextureManager.UnloadTexture(ref MapPicturebox.Texture);
8787
Program.CurrentHost.RegisterTexture(Illustrations.CreateRouteMap(Program.Renderer.Screen.Width, Program.Renderer.Screen.Height, true, out AvailableSwitches, trackFollower, drawRadius), new TextureParameters(null, null), out MapPicturebox.Texture);
8888
TitleLabel.Location = new Vector2(Program.Renderer.Screen.Width * 0.5 - TitleLabel.Size.X * 0.5, 5);
89-
89+
CloseButton.IsVisible = true;
90+
ZoomInButton.IsVisible = true;
91+
ZoomOutButton.IsVisible = true;
9092
}
9193

9294
internal void Draw()

source/OpenBVE/System/Input/ProcessControls.Digital.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,9 @@ private static void ProcessDigitalControl(double TimeElapsed, ref Control Contro
13801380
break;
13811381
}
13821382
break;
1383+
case Translations.Command.AccessPermissiveSection:
1384+
TrainManager.PlayerTrain.ContactSignaller();
1385+
break;
13831386
}
13841387
}
13851388
else if (Control.DigitalState == DigitalControlState.Released)

source/OpenBveApi/Interface/Input/Commands.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,10 @@ public enum Command
315315
/// <summary>Uncouples the rear coupling of a car</summary>
316316
UncoupleRear,
317317
/// <summary>Controls the DSD</summary>
318-
DriverSupervisionDevice
318+
DriverSupervisionDevice,
319+
// Added in 1.11.2.0
320+
/// <summary>Press to request permission from the signaller to access a permissive section</summary>
321+
AccessPermissiveSection
319322
}
320323

321324
/// <summary>Defines the possible command types</summary>

source/Plugins/Formats.OpenBve/Block.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ public virtual bool TryGetValue(T2 key, ref string value)
117117
return false;
118118
}
119119

120-
/// <summary>Unconditionally reads the specified Vector2 from the block</summary>
120+
/// <summary>Reads the specified bool from the block, preserving the prior value if not present</summary>
121+
public virtual bool TryGetValue(T2 key, ref bool boolValue)
122+
{
123+
return false;
124+
}
125+
126+
/// <summary>Unconditionally reads the specified Vector2 from the block</summary>
121127
public virtual bool GetVector2(T2 key, char separator, out Vector2 value)
122128
{
123129
value = Vector2.Null;

source/Plugins/Formats.OpenBve/CFG/ConfigFile.cs

+18-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public ConfigFile(string[] lines, HostInterface currentHost, string expectedHead
120120

121121
if (blockLines.Count > 0)
122122
{
123-
subBlocks.Add(new ConfigSection<T1, T2>(previousIdx, startingLine, previousSection, blockLines.ToArray(), currentHost));
123+
subBlocks.Add(new ConfigSection<T1, T2>(previousIdx, startingLine + 1, previousSection, blockLines.ToArray(), currentHost));
124124
blockLines.Clear();
125125
}
126126
previousSection = currentSection;
@@ -137,7 +137,7 @@ public ConfigFile(string[] lines, HostInterface currentHost, string expectedHead
137137
// final block
138138
if (blockLines.Count > 0)
139139
{
140-
subBlocks.Add(new ConfigSection<T1, T2>(idx, startingLine, previousSection, blockLines.ToArray(), currentHost));
140+
subBlocks.Add(new ConfigSection<T1, T2>(idx, startingLine + 1, previousSection, blockLines.ToArray(), currentHost));
141141
}
142142
}
143143

@@ -568,6 +568,20 @@ public override bool TryGetValue(T2 key, ref string stringValue)
568568
return false;
569569
}
570570

571+
public override bool TryGetValue(T2 key, ref bool boolValue)
572+
{
573+
if (keyValuePairs.TryRemove(key, out var s))
574+
{
575+
var ss = s.Value.ToLowerInvariant().Trim();
576+
if (ss == "1" || ss == "true")
577+
{
578+
boolValue = true;
579+
return true;
580+
}
581+
}
582+
return false;
583+
}
584+
571585
public override bool GetValue(T2 key, out string stringValue)
572586
{
573587
if (keyValuePairs.TryRemove(key, out var value))
@@ -756,12 +770,12 @@ public override bool GetEnumValue<T3>(T2 key, out T3 enumValue, out int index, o
756770
num = s.Substring(3);
757771
s = s.Substring(0, 3);
758772
}
759-
else if (s.StartsWith("doorsl"))
773+
else if (s.StartsWith("doorl"))
760774
{
761775
num = s.Substring(5);
762776
s = s.Substring(0, 5);
763777
}
764-
else if (s.StartsWith("doorsr"))
778+
else if (s.StartsWith("doorr"))
765779
{
766780
num = s.Substring(5);
767781
s = s.Substring(0, 5);

source/Plugins/Object.Animated/Plugin.Parser.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,9 @@ private static AnimatedObjectCollection ReadObject(string FileName, System.Text.
317317
Block.TryGetValue(AnimatedKey.Pitch, ref pitch);
318318
Block.TryGetValue(AnimatedKey.Volume, ref volume);
319319
Block.TryGetValue(AnimatedKey.Radius, ref radius);
320-
Block.GetValue(AnimatedKey.PlayOnShow, out bool playOnShow);
321-
Block.GetValue(AnimatedKey.PlayOnHide, out bool playOnHide);
320+
bool playOnShow = true, playOnHide = true;
321+
Block.TryGetValue(AnimatedKey.PlayOnShow, ref playOnShow);
322+
Block.TryGetValue(AnimatedKey.PlayOnHide, ref playOnHide);
322323

323324
if (ObjectCount > 0)
324325
{

source/Plugins/Route.CsvRw/Namespaces/Track/Track.Commands.cs

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ internal enum TrackCommand
2929
Section,
3030
/// <summary>Adds a signalling section</summary>
3131
SectionS,
32+
/// <summary>Adds a permissive signalling section</summary>
33+
/// <remarks>Must be value based</remarks>
34+
SectionP,
3235
/// <summary>Adds a signal object</summary>
3336
SigF,
3437
/// <summary>Adds a signal object</summary>

source/Plugins/Route.CsvRw/Namespaces/Track/Track.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ private void ParseTrackCommand(TrackCommand Command, string[] Arguments, string
461461
break;
462462
case TrackCommand.Section:
463463
case TrackCommand.SectionS:
464+
case TrackCommand.SectionP:
464465
{
465466
if (!PreviewOnly)
466467
{
@@ -531,7 +532,16 @@ private void ParseTrackCommand(TrackCommand Command, string[] Arguments, string
531532
}
532533
}
533534

534-
Data.Blocks[BlockIndex].Sections[n] = new Section(Data.TrackPosition, aspects, departureStationIndex, valueBased ? SectionType.ValueBased : SectionType.IndexBased);
535+
SectionType type;
536+
if (valueBased)
537+
{
538+
type = Command == TrackCommand.SectionP ? SectionType.PermissiveValueBased : SectionType.ValueBased;
539+
}
540+
else
541+
{
542+
type = Command == TrackCommand.SectionP ? SectionType.PermissiveIndexBased : SectionType.IndexBased;
543+
}
544+
Data.Blocks[BlockIndex].Sections[n] = new Section(Data.TrackPosition, aspects, departureStationIndex, type);
535545

536546

537547
CurrentSection++;

source/Plugins/Train.OpenBve/Panel/Enums/Panel2Subject.cs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ internal enum Panel2Subject
2020
BP,
2121
ER,
2222
Door,
23+
DoorL,
24+
DoorR,
2325
CsC,
2426
Power,
2527
Brake,

source/Plugins/Train.OpenBve/Panel/Panel2CfgParser.cs

+15-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ internal void ParsePanel2Config(string PanelFile, string TrainPath, CarBase Car)
189189
Block.TryGetValue(Panel2Key.Minimum, ref Minimum);
190190
Block.TryGetValue(Panel2Key.Maximum, ref Maximum);
191191
Block.TryGetValue(Panel2Key.NaturalFreq, ref NaturalFrequency);
192-
Block.TryGetValue(Panel2Key.DampingRatio, ref DampingRatio);
193-
if (DampingRatio < 0)
192+
if(Block.TryGetValue(Panel2Key.DampingRatio, ref DampingRatio) && DampingRatio < 0)
194193
{
195194
DampingRatio = -DampingRatio;
196195
Plugin.CurrentHost.AddMessage(MessageType.Error, false, "DampingRatio is expected to be non-negative in [Needle] in " + PanelFile);
@@ -251,6 +250,7 @@ internal void ParsePanel2Config(string PanelFile, string TrainPath, CarBase Car)
251250
catch
252251
{
253252
Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Invalid animated function provided in " + Block.Key + " in " + FileName);
253+
break;
254254
}
255255
if (Backstop)
256256
{
@@ -820,6 +820,18 @@ internal string GetStackLanguageFromSubject(AbstractTrain Train, Panel2Subject S
820820
case Panel2Subject.Door:
821821
Code = "1 doors -";
822822
break;
823+
case Panel2Subject.DoorL:
824+
case Panel2Subject.DoorR:
825+
if (SubjectIndex < Train.NumberOfCars)
826+
{
827+
Code = SubjectIndex + (Subject == Panel2Subject.DoorL ? " leftdoorsindex ceiling" : " rightdoorsindex ceiling");
828+
}
829+
else
830+
{
831+
Plugin.CurrentHost.AddMessage("CarIndex was invalid for " + Subject);
832+
return "2";
833+
}
834+
break;
823835
case Panel2Subject.CsC:
824836
Code = "constSpeed";
825837
break;
@@ -859,6 +871,7 @@ internal string GetStackLanguageFromSubject(AbstractTrain Train, Panel2Subject S
859871
case Panel2Subject.Wheelslip:
860872
case Panel2Subject.Sanders:
861873
case Panel2Subject.SandLevel:
874+
case Panel2Subject.RouteLimit:
862875
Code = Subject.ToString().ToLowerInvariant();
863876
break;
864877
default:

source/Plugins/Train.OpenBve/Panel/PanelXmlParser.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Drawing;
44
using System.IO;
@@ -258,7 +258,7 @@ private void ParsePanelNode(XElement Element, string FileName, TrainBase Train,
258258
}
259259
else
260260
{
261-
Plugin.CurrentHost.RegisterTexture(PanelDaytimeImage, new TextureParameters(null, new Color24(PanelTransparentColor.R, PanelTransparentColor.G, PanelTransparentColor.B)), out var tday, true);
261+
Plugin.CurrentHost.RegisterTexture(PanelDaytimeImage, new TextureParameters(null, new Color24(PanelTransparentColor.R, PanelTransparentColor.G, PanelTransparentColor.B)), out var tday, true, 20000);
262262
Texture tnight = null;
263263
if (PanelNighttimeImage != null)
264264
{
@@ -268,7 +268,7 @@ private void ParsePanelNode(XElement Element, string FileName, TrainBase Train,
268268
}
269269
else
270270
{
271-
Plugin.CurrentHost.RegisterTexture(PanelNighttimeImage, new TextureParameters(null, new Color24(PanelTransparentColor.R, PanelTransparentColor.G, PanelTransparentColor.B)), out tnight);
271+
Plugin.CurrentHost.RegisterTexture(PanelNighttimeImage, new TextureParameters(null, new Color24(PanelTransparentColor.R, PanelTransparentColor.G, PanelTransparentColor.B)), out tnight, true, 20000);
272272
}
273273
}
274274
Plugin.Panel2CfgParser.CreateElement(ref CarSection.Groups[GroupIndex], 0.0, 0.0, new Vector2(0.5, 0.5), OffsetLayer * StackDistance, PanelResolution, PanelBottom, PanelCenter, Train.Cars[Car].Driver, tday, tnight);

source/Plugins/Train.OpenBve/Sound/SoundCfg.Bve4.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ internal void Parse(string FileName, string trainFolder, TrainBase train)
200200
train.Cars[train.DriverCar].Horns[0].StartSound = startSound as SoundBuffer;
201201
train.Cars[train.DriverCar].Horns[0].StartEndSounds = true;
202202
}
203-
if (block.GetPath(SoundCfgKey.PrimaryStart, trainFolder, out string primaryEnd))
203+
if (block.GetPath(SoundCfgKey.PrimaryEnd, trainFolder, out string primaryEnd))
204204
{
205205
Plugin.CurrentHost.RegisterSound(primaryEnd, SoundCfgParser.largeRadius, out var endSound);
206206
train.Cars[train.DriverCar].Horns[0].StartSound = endSound as SoundBuffer;

source/Plugins/Train.OpenBve/Train/BVE/ExtensionsCfgParser.cs

+19-10
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ internal void ParseExtensionsConfig(string TrainPath, Encoding Encoding, ref Uni
8989
Plugin.CurrentHost.LoadObject(carObject, Encoding, out CarObjects[block.Index]);
9090
}
9191

92+
bool definedLength = false;
9293
if (block.GetValue(ExtensionCfgKey.Length, out double carLength))
9394
{
9495
Train.Cars[block.Index].Length = carLength;
96+
Train.Cars[block.Index].BeaconReceiverPosition = 0.5 * carLength;
97+
definedLength = true;
9598
}
9699
block.GetValue(ExtensionCfgKey.Reversed, out CarObjectsReversed[block.Index]);
97100
block.GetValue(ExtensionCfgKey.VisibleFromInterior, out VisibleFromInterior[block.Index]);
@@ -107,7 +110,15 @@ internal void ParseExtensionsConfig(string TrainPath, Encoding Encoding, ref Uni
107110
Train.Cars[block.Index].RearAxle.Position = carAxles.X;
108111
Train.Cars[block.Index].FrontAxle.Position = carAxles.Y;
109112
}
110-
113+
}
114+
else
115+
{
116+
if (definedLength == false)
117+
{
118+
double axleDistance = 0.4 * Train.Cars[block.Index].Length;
119+
Train.Cars[block.Index].RearAxle.Position = -axleDistance;
120+
Train.Cars[block.Index].FrontAxle.Position = axleDistance;
121+
}
111122
}
112123
break;
113124
case ExtensionCfgSection.Coupler:
@@ -150,7 +161,6 @@ internal void ParseExtensionsConfig(string TrainPath, Encoding Encoding, ref Uni
150161
//Assuming that there are two bogies per car
151162
bool IsOdd = (block.Index % 2 != 0);
152163
int CarIndex = block.Index / 2;
153-
bool DefinedAxles = false;
154164

155165
if (block.GetPath(ExtensionCfgKey.Object, TrainPath, out string bogieObject))
156166
{
@@ -175,22 +185,21 @@ internal void ParseExtensionsConfig(string TrainPath, Encoding Encoding, ref Uni
175185
Train.Cars[CarIndex].RearBogie.RearAxle.Position = bogieAxles.X;
176186
Train.Cars[CarIndex].RearBogie.FrontAxle.Position = bogieAxles.Y;
177187
}
178-
DefinedAxles = true;
179188
}
180189
}
181-
if (!DefinedAxles)
190+
else
182191
{
183192
if (IsOdd)
184193
{
185-
double AxleDistance = 0.4 * Train.Cars[CarIndex].FrontBogie.Length;
186-
Train.Cars[CarIndex].FrontBogie.RearAxle.Position = -AxleDistance;
187-
Train.Cars[CarIndex].FrontBogie.FrontAxle.Position = AxleDistance;
194+
double axleDistance = 0.4 * Train.Cars[CarIndex].FrontBogie.Length;
195+
Train.Cars[CarIndex].FrontBogie.RearAxle.Position = -axleDistance;
196+
Train.Cars[CarIndex].FrontBogie.FrontAxle.Position = axleDistance;
188197
}
189198
else
190199
{
191-
double AxleDistance = 0.4 * Train.Cars[CarIndex].RearBogie.Length;
192-
Train.Cars[CarIndex].RearBogie.RearAxle.Position = -AxleDistance;
193-
Train.Cars[CarIndex].RearBogie.FrontAxle.Position = AxleDistance;
200+
double axleDistance = 0.4 * Train.Cars[CarIndex].RearBogie.Length;
201+
Train.Cars[CarIndex].RearBogie.RearAxle.Position = -axleDistance;
202+
Train.Cars[CarIndex].RearBogie.FrontAxle.Position = axleDistance;
194203
}
195204
}
196205
break;

source/RouteManager2/CurrentRoute.cs

+15-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void UpdateSection(Section Section, out Section PreviousSection)
170170
int zeroAspect = 0;
171171
bool setToRed = false;
172172

173-
if (Section.Type == SectionType.ValueBased)
173+
if (Section.Type == SectionType.ValueBased || Section.Type == SectionType.PermissiveValueBased)
174174
{
175175
// value-based
176176
zeroAspect = 0;
@@ -312,6 +312,19 @@ public void UpdateSection(Section Section, out Section PreviousSection)
312312
setToRed = true;
313313
}
314314

315+
if ((Section.Type == SectionType.PermissiveValueBased || Section.Type == SectionType.PermissiveIndexBased) && Section.SignallerPermission == false)
316+
{
317+
// with a permissive section, check to see if the *previous* section holds the player train
318+
// ignore for AI trains (we'll assume they can contact the signaller silently)
319+
for (int i = 0; i < Section.PreviousSection.Trains.Length; i++)
320+
{
321+
if (Section.PreviousSection.Trains[i].Type == TrainType.LocalPlayerTrain || Section.PreviousSection.Trains[i].Type == TrainType.RemotePlayerTrain)
322+
{
323+
setToRed = true;
324+
}
325+
}
326+
}
327+
315328
// free sections
316329
int newAspect = -1;
317330

@@ -344,7 +357,7 @@ public void UpdateSection(Section Section, out Section PreviousSection)
344357
// change aspect
345358
if (newAspect == -1)
346359
{
347-
if (Section.Type == SectionType.ValueBased)
360+
if (Section.Type == SectionType.ValueBased || Section.Type == SectionType.PermissiveValueBased)
348361
{
349362
// value-based
350363
Section n = Section.NextSection;

source/RouteManager2/SignalManager/Section.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Linq;
3+
using System.Runtime.CompilerServices;
34
using OpenBveApi.Runtime;
45
using OpenBveApi.Trains;
56

@@ -46,6 +47,8 @@ public class Section
4647

4748
internal double RedTimer;
4849

50+
public bool SignallerPermission;
51+
4952
/// <summary>Whether this section has been announced with accessibility in use</summary>
5053
public bool AccessibilityAnnounced;
5154

source/RouteManager2/SignalManager/SectionTypes.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
public enum SectionType
55
{
66
/// <summary>A section aspect may have any value</summary>
7-
ValueBased,
8-
7+
ValueBased,
8+
/// <summary>A section aspect may have any value</summary>
9+
/// <remarks>The section is held at red until the permissive key is pressed</remarks>
10+
PermissiveValueBased,
11+
/// <summary>Section aspect count upwards from zero (0,1,2,3....)</summary>
12+
IndexBased,
913
/// <summary>Section aspect count upwards from zero (0,1,2,3....)</summary>
10-
IndexBased
14+
/// <remarks>The section is held at red until the permissive key is pressed</remarks>
15+
PermissiveIndexBased
16+
1117
}
1218
}

0 commit comments

Comments
 (0)