Commit 04e55e06 authored by Paul Sladen's avatar Paul Sladen

New upstream stable release (1.4.1.0)

parents 24262385 00147282
This diff is collapsed.
......@@ -9,10 +9,10 @@ namespace OpenBve {
/// <summary>Represents different sound distance attenuation models.</summary>
internal enum SoundModels {
/// <summary>Represents the default Linear Distance Clamped Model.</summary>
Default = 0,
/// <summary>Represents the experimental Inverse Distance Clamped Model.</summary>
Experimental = 1
/// <summary>Represents the new Inverse Distance Clamped Model.</summary>
Inverse = 0,
/// <summary>Represents the old Linear Distance Clamped Model.</summary>
Linear = -1
}
......@@ -55,10 +55,9 @@ namespace OpenBve {
// --- inverse distance clamp model ---
internal static double ClampFactorLogarithm = -18.4206807439524;
internal static double ClampFactorLogarithmSpeed = 0.0;
internal const double ClampFactorLogarithmMinimum = -27.6310211159285;
internal const double ClampFactorLogarithmMaximum = -4.60517018598809;
internal static double LogClampFactor = -15.0;
internal const double MinLogClampFactor = -30.0;
internal const double MaxLogClampFactor = -1.0;
// --- initialization and deinitialization ---
......
......@@ -127,6 +127,11 @@ namespace OpenBve {
handle.Height = texture.Height;
handle.Transparency = texture.GetTransparencyType();
texture = UpsizeToPowerOfTwo(texture);
// int newWidth = Math.Min(texture.Width, 256);
// int newHeight = Math.Min(texture.Height, 256);
// texture = Resize(texture, newWidth, newHeight);
switch (Interface.CurrentOptions.Interpolation) {
case Interface.InterpolationMode.NearestNeighbor:
Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST);
......
......@@ -140,7 +140,7 @@ namespace OpenBve {
this.JoystickAxisThreshold = 0.0;
this.KeyRepeatDelay = 0.5;
this.KeyRepeatInterval = 0.1;
this.SoundModel = Sounds.SoundModels.Default;
this.SoundModel = Sounds.SoundModels.Inverse;
this.SoundRange = SoundRange.Low;
this.SoundNumber = 16;
this.ShowWarningMessages = true;
......@@ -387,8 +387,8 @@ namespace OpenBve {
switch (Key) {
case "model":
switch (Value.ToLowerInvariant()) {
case "experimental": Interface.CurrentOptions.SoundModel = Sounds.SoundModels.Experimental; break;
default: Interface.CurrentOptions.SoundModel = Sounds.SoundModels.Default; break;
case "linear": Interface.CurrentOptions.SoundModel = Sounds.SoundModels.Linear; break;
default: Interface.CurrentOptions.SoundModel = Sounds.SoundModels.Inverse; break;
}
break;
case "range":
......@@ -565,8 +565,8 @@ namespace OpenBve {
Builder.AppendLine("[sound]");
Builder.Append("model = ");
switch (CurrentOptions.SoundModel) {
case Sounds.SoundModels.Experimental: Builder.AppendLine("experimental"); break;
default: Builder.AppendLine("default"); break;
case Sounds.SoundModels.Linear: Builder.AppendLine("linear"); break;
default: Builder.AppendLine("inverse"); break;
}
Builder.Append("range = ");
switch (CurrentOptions.SoundRange) {
......
......@@ -339,7 +339,7 @@ namespace OpenBve {
Game.UpdateScore(TimeElapsed);
Game.UpdateMessages();
Game.UpdateScoreMessages(TimeElapsed);
Sounds.Update(TimeElapsed);
Sounds.Update(TimeElapsed, Interface.CurrentOptions.SoundModel);
Renderer.RenderScene(TimeElapsed);
Sdl.SDL_GL_SwapBuffers();
Game.UpdateBlackBox();
......@@ -621,7 +621,7 @@ namespace OpenBve {
break;
case Interface.Command.MiscMute:
Sounds.GlobalMute = !Sounds.GlobalMute;
Sounds.Update(TimeElapsed);
Sounds.Update(TimeElapsed, Interface.CurrentOptions.SoundModel);
break;
}
}
......@@ -753,7 +753,7 @@ namespace OpenBve {
case Interface.Command.MiscMute:
// mute
Sounds.GlobalMute = !Sounds.GlobalMute;
Sounds.Update(TimeElapsed);
Sounds.Update(TimeElapsed, Interface.CurrentOptions.SoundModel);
break;
}
......@@ -1641,7 +1641,7 @@ namespace OpenBve {
case Interface.Command.MiscMute:
// mute
Sounds.GlobalMute = !Sounds.GlobalMute;
Sounds.Update(TimeElapsed);
Sounds.Update(TimeElapsed, Interface.CurrentOptions.SoundModel);
break;
}
} else if (Interface.CurrentControls[i].DigitalState == Interface.DigitalControlState.Released) {
......
......@@ -530,17 +530,14 @@ namespace OpenBve {
return false;
}
foreach (Type type in types) {
if (type.IsPublic && (type.Attributes & TypeAttributes.Abstract) == 0) {
object instance = assembly.CreateInstance(type.FullName);
IRuntime api = instance as IRuntime;
if (api != null) {
train.Plugin = new NetPlugin(pluginFile, trainFolder, api, train);
if (train.Plugin.Load(specs, mode)) {
return true;
} else {
train.Plugin = null;
return false;
}
if (typeof(IRuntime).IsAssignableFrom(type)) {
IRuntime api = assembly.CreateInstance(type.FullName) as IRuntime;
train.Plugin = new NetPlugin(pluginFile, trainFolder, api, train);
if (train.Plugin.Load(specs, mode)) {
return true;
} else {
train.Plugin = null;
return false;
}
}
}
......
......@@ -2357,7 +2357,7 @@ namespace OpenBve {
"=sound",
"sound buffers: " + soundBuffersLoaded.ToString(Culture) + " / " + soundBuffersRegistered.ToString(Culture),
"sound sources: " + soundSourcesPlaying.ToString(Culture) + " / " + soundSourcesRegistered.ToString(Culture),
(Interface.CurrentOptions.SoundModel == Sounds.SoundModels.Experimental ? "log clamp factor: " + Sounds.ClampFactorLogarithm.ToString("0.00") : "outer radius factor: " + Sounds.OuterRadiusFactor.ToString("0.00", Culture)),
(Interface.CurrentOptions.SoundModel == Sounds.SoundModels.Inverse ? "log clamp factor: " + Sounds.LogClampFactor.ToString("0.00") : "outer radius factor: " + Sounds.OuterRadiusFactor.ToString("0.00", Culture)),
"",
"=debug",
"train plugin status: " + (TrainManager.PlayerTrain.Plugin != null ? (TrainManager.PlayerTrain.Plugin.PluginValid ? "ok" : "error") : "n/a"),
......
......@@ -852,7 +852,7 @@ namespace OpenBve {
* there will be additional flange noise.
* */
double cdti = Math.Abs(Train.Cars[CarIndex].FrontAxle.Follower.CantDueToInaccuracy) + Math.Abs(Train.Cars[CarIndex].RearAxle.Follower.CantDueToInaccuracy);
basegain += 15.0 * spd * cdti * cdti;
basegain += 0.5 * spd * spd * cdti * cdti;
/*
* This applies the settings.
* */
......
......@@ -1251,7 +1251,7 @@
this.panelOptionsRight.Controls.Add(this.groupboxSound);
this.panelOptionsRight.Location = new System.Drawing.Point(332, 72);
this.panelOptionsRight.Name = "panelOptionsRight";
this.panelOptionsRight.Size = new System.Drawing.Size(316, 416);
this.panelOptionsRight.Size = new System.Drawing.Size(316, 384);
this.panelOptionsRight.TabIndex = 17;
//
// groupboxDistance
......@@ -1346,7 +1346,7 @@
this.groupboxControls.Controls.Add(this.checkboxJoysticksUsed);
this.groupboxControls.Controls.Add(this.labelJoystickAxisThreshold);
this.groupboxControls.ForeColor = System.Drawing.Color.Black;
this.groupboxControls.Location = new System.Drawing.Point(0, 176);
this.groupboxControls.Location = new System.Drawing.Point(0, 144);
this.groupboxControls.Name = "groupboxControls";
this.groupboxControls.Size = new System.Drawing.Size(316, 80);
this.groupboxControls.TabIndex = 10;
......@@ -1394,7 +1394,7 @@
this.groupboxVerbosity.Controls.Add(this.checkboxErrorMessages);
this.groupboxVerbosity.Controls.Add(this.checkboxWarningMessages);
this.groupboxVerbosity.ForeColor = System.Drawing.Color.Black;
this.groupboxVerbosity.Location = new System.Drawing.Point(0, 352);
this.groupboxVerbosity.Location = new System.Drawing.Point(0, 320);
this.groupboxVerbosity.Name = "groupboxVerbosity";
this.groupboxVerbosity.Size = new System.Drawing.Size(316, 64);
this.groupboxVerbosity.TabIndex = 12;
......@@ -1430,7 +1430,7 @@
this.groupboxSimulation.Controls.Add(this.checkboxCollisions);
this.groupboxSimulation.Controls.Add(this.checkboxToppling);
this.groupboxSimulation.ForeColor = System.Drawing.Color.Black;
this.groupboxSimulation.Location = new System.Drawing.Point(0, 264);
this.groupboxSimulation.Location = new System.Drawing.Point(0, 232);
this.groupboxSimulation.Name = "groupboxSimulation";
this.groupboxSimulation.Size = new System.Drawing.Size(316, 80);
this.groupboxSimulation.TabIndex = 11;
......@@ -1493,7 +1493,7 @@
this.groupboxSound.ForeColor = System.Drawing.Color.Black;
this.groupboxSound.Location = new System.Drawing.Point(0, 88);
this.groupboxSound.Name = "groupboxSound";
this.groupboxSound.Size = new System.Drawing.Size(316, 80);
this.groupboxSound.Size = new System.Drawing.Size(316, 48);
this.groupboxSound.TabIndex = 9;
this.groupboxSound.TabStop = false;
this.groupboxSound.Text = "Sound";
......@@ -1501,7 +1501,7 @@
// updownSoundNumber
//
this.updownSoundNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.updownSoundNumber.Location = new System.Drawing.Point(156, 48);
this.updownSoundNumber.Location = new System.Drawing.Point(152, 16);
this.updownSoundNumber.Minimum = new decimal(new int[] {
8,
0,
......@@ -1521,28 +1521,30 @@
this.comboboxSoundRange.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.comboboxSoundRange.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboboxSoundRange.FormattingEnabled = true;
this.comboboxSoundRange.Location = new System.Drawing.Point(156, 24);
this.comboboxSoundRange.Location = new System.Drawing.Point(152, 40);
this.comboboxSoundRange.Name = "comboboxSoundRange";
this.comboboxSoundRange.Size = new System.Drawing.Size(152, 21);
this.comboboxSoundRange.TabIndex = 1;
this.comboboxSoundRange.Visible = false;
//
// labelSoundRange
//
this.labelSoundRange.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.labelSoundRange.AutoEllipsis = true;
this.labelSoundRange.Location = new System.Drawing.Point(8, 24);
this.labelSoundRange.Location = new System.Drawing.Point(4, 40);
this.labelSoundRange.Name = "labelSoundRange";
this.labelSoundRange.Size = new System.Drawing.Size(148, 16);
this.labelSoundRange.TabIndex = 0;
this.labelSoundRange.Text = "Effective range:";
this.labelSoundRange.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.labelSoundRange.Visible = false;
//
// labelSoundNumber
//
this.labelSoundNumber.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.labelSoundNumber.Location = new System.Drawing.Point(8, 50);
this.labelSoundNumber.Location = new System.Drawing.Point(4, 18);
this.labelSoundNumber.Name = "labelSoundNumber";
this.labelSoundNumber.Size = new System.Drawing.Size(148, 14);
this.labelSoundNumber.TabIndex = 2;
......@@ -3379,11 +3381,11 @@
this.Controls.Add(this.labelFillerOne);
this.Controls.Add(this.labelFillerTwo);
this.Controls.Add(this.labelFillerThree);
this.Controls.Add(this.panelStart);
this.Controls.Add(this.panelGetAddOns);
this.Controls.Add(this.panelOptions);
this.Controls.Add(this.panelControls);
this.Controls.Add(this.panelReview);
this.Controls.Add(this.panelStart);
this.Controls.Add(this.panelGetAddOns);
this.KeyPreview = true;
this.Name = "formMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
......
......@@ -168,7 +168,9 @@ namespace OpenBve {
// --- show database ---
private class RemoveIfPossibleAttribute { }
/// <summary>Shows the list of available packages.</summary>
private void ShowDatabase(bool expand) {
if (CurrentDatabase != null & !IsBusy()) {
......@@ -241,6 +243,26 @@ namespace OpenBve {
node = node.Nodes.Add(operatorx);
node.ImageKey = "folder";
node.SelectedImageKey = "folder";
switch (type.ToLowerInvariant()) {
case "route":
node = node.Nodes.Add(checkboxFilterRoutes.Text);
break;
case "train":
node = node.Nodes.Add(checkboxFilterTrains.Text);
break;
case "library":
node = node.Nodes.Add(checkboxFilterLibraries.Text);
break;
case "shared library":
node = node.Nodes.Add(checkboxFilterSharedLibraries.Text);
break;
default:
node = node.Nodes.Add(type);
break;
}
node.ImageKey = "folder";
node.SelectedImageKey = "folder";
node.Tag = new RemoveIfPossibleAttribute();
node = node.Nodes.Add(caption);
string imageKey;
if (ManagedContent.IsInstalledPackageProtected(package.Name)) {
......@@ -259,14 +281,16 @@ namespace OpenBve {
Group(treeviewPackages.Nodes);
if (keywords.Length == 0) {
foreach (TreeNode node in treeviewPackages.Nodes) {
Flatten(node.Nodes);
Flatten(node.Nodes, false);
}
} else {
Flatten(treeviewPackages.Nodes);
Flatten(treeviewPackages.Nodes, false);
}
treeviewPackages.Sort();
if (expand) {
treeviewPackages.ExpandAll();
} else {
Expand(treeviewPackages.Nodes, treeviewPackages.Height / treeviewPackages.ItemHeight - 1);
}
treeviewPackages.EndUpdate();
buttonPackageInstall.Enabled = false;
......@@ -314,9 +338,9 @@ namespace OpenBve {
private void Group(TreeNodeCollection collection) {
/* Group folders that have same text */
for (int i = 1; i < collection.Count; i++) {
if (collection[i].Tag == null) {
if (collection[i].Tag == null | collection[i].Tag is RemoveIfPossibleAttribute) {
for (int j = 0; j < i; j++) {
if (collection[j].Tag == null) {
if (collection[j].Tag == null | collection[j].Tag is RemoveIfPossibleAttribute) {
if (collection[i].Text == collection[j].Text) {
TreeNodeCollection elements = collection[i].Nodes;
collection.RemoveAt(i);
......@@ -336,19 +360,10 @@ namespace OpenBve {
}
}
private void Flatten(TreeNodeCollection collection) {
private void Flatten(TreeNodeCollection collection, bool shortify) {
/* Recursion */
foreach (TreeNode node in collection) {
Flatten(node.Nodes);
}
/* Flatten out folders that contain only one element */
for (int i = 0; i < collection.Count; i++) {
if (collection[i].Nodes.Count == 1) {
TreeNode element = collection[i].Nodes[0];
collection.RemoveAt(i);
collection.Add(element);
i--;
}
Flatten(node.Nodes, shortify);
}
/* Remove empty folders from the collection */
for (int i = 0; i < collection.Count; i++) {
......@@ -357,16 +372,50 @@ namespace OpenBve {
i--;
}
}
/* Flatten out the only element if it is a folder */
if (collection.Count == 1 && collection[0].Tag == null) {
TreeNodeCollection elements = collection[0].Nodes;
collection.RemoveAt(0);
foreach (TreeNode node in elements) {
collection.Add(node);
if (!shortify) {
/* If only element is Route/Train/Library/SharedLibrary, then remove it */
if (collection.Count == 1 && collection[0].Tag is RemoveIfPossibleAttribute) {
TreeNodeCollection elements = collection[0].Nodes;
collection.RemoveAt(0);
foreach (TreeNode element in elements) {
collection.Add(element);
}
}
/* Expand folders that only contain one element */
if (collection.Count == 1) {
if (collection[0].Nodes.Count != 0) {
collection[0].Expand();
}
}
} else {
/* Flatten out folders that contain only one element */
if (collection.Count == 1 && collection[0].Tag == null) {
TreeNodeCollection elements = collection[0].Nodes;
collection.RemoveAt(0);
foreach (TreeNode element in elements) {
collection.Add(element);
}
}
}
}
private int Count(TreeNodeCollection collection) {
int count = collection.Count;
foreach (TreeNode node in collection) {
count += Count(node.Nodes);
}
return count;
}
private void Expand(TreeNodeCollection collection, int total) {
int count = Count(collection);
if (count <= total) {
foreach (TreeNode node in collection) {
node.ExpandAll();
}
}
}
// --- functions ---
......@@ -458,7 +507,7 @@ namespace OpenBve {
private void TreeviewPackagesAfterSelect(object sender, TreeViewEventArgs e) {
if (treeviewPackages.SelectedNode == null || treeviewPackages.SelectedNode.Tag == null) {
ClearPackageDetails();
} else {
} else if (treeviewPackages.SelectedNode.Tag is ManagedContent.Version) {
ManagedContent.Version version = (ManagedContent.Version)treeviewPackages.SelectedNode.Tag;
string currentVersion = ManagedContent.GetInstalledPackageVersion(version.Name);
string caption = version.GetMetadata("caption", CurrentLanguageCode, null);
......
......@@ -61,11 +61,12 @@ namespace OpenBve {
Group(treeviewRouteAddOns.Nodes);
if (keywords.Length == 0) {
foreach (TreeNode node in treeviewRouteAddOns.Nodes) {
Flatten(node.Nodes);
Flatten(node.Nodes, true);
}
} else {
Flatten(treeviewRouteAddOns.Nodes);
Flatten(treeviewRouteAddOns.Nodes, true);
}
Expand(treeviewRouteAddOns.Nodes, treeviewRouteAddOns.Height / treeviewRouteAddOns.ItemHeight - 1);
treeviewRouteAddOns.Sort();
treeviewRouteAddOns.EndUpdate();
}
......@@ -179,11 +180,12 @@ namespace OpenBve {
Group(treeviewTrainAddOns.Nodes);
if (keywords.Length == 0) {
foreach (TreeNode node in treeviewTrainAddOns.Nodes) {
Flatten(node.Nodes);
Flatten(node.Nodes, true);
}
} else {
Flatten(treeviewTrainAddOns.Nodes);
Flatten(treeviewTrainAddOns.Nodes, true);
}
Expand(treeviewTrainAddOns.Nodes, treeviewTrainAddOns.Height / treeviewTrainAddOns.ItemHeight - 1);
treeviewTrainAddOns.Sort();
treeviewTrainAddOns.EndUpdate();
}
......
......@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyProduct("openBVE")]
[assembly: AssemblyCopyright("(Public Domain) http://trainsimframework.org/")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.4.0.10")]
[assembly: AssemblyFileVersion("1.4.0.10")]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: CLSCompliant(true)]
namespace OpenBve {
......
......@@ -11,7 +11,7 @@ namespace OpenBve {
/// <param name="client">The web client.</param>
/// <param name="url">The URL to be accessed.</param>
private static void AddWebClientHeaders(WebClient client, string url) {
const string agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20100101 Firefox/9.0";
const string agent = "Mozilla/5.0 (Windows NT 6.2; rv:9.0.1) Gecko/20100101 Firefox/9.0.1";
try {
client.Headers.Add(HttpRequestHeader.UserAgent, agent);
} catch { }
......
......@@ -54,7 +54,15 @@ namespace OpenBve {
characters[2 * j + 0] = (char)(value & 0xFF);
characters[2 * j + 1] = (char)(value >> 8);
}
AttachedJoysticks[i].Name = new string(characters);
AttachedJoysticks[i].Name = null;
for (int j = 0; j < characters.Length; j++) {
if (characters[j] == '\0') {
AttachedJoysticks[i].Name = new string(characters, 0, j);
}
}
if (AttachedJoysticks[i].Name == null) {
AttachedJoysticks[i].Name = new string(characters);
}
AttachedJoysticks[i].SdlHandle = Sdl.SDL_JoystickOpen(i);
}
Initialized = true;
......
......@@ -180,7 +180,10 @@ namespace OpenBve {
}
builder.AppendLine();
foreach (KeyValuePair pair in version.Metadata) {
if (!string.Equals(pair.Key, "protected", StringComparison.OrdinalIgnoreCase)) {
if (
!string.Equals(pair.Key, "protected", StringComparison.OrdinalIgnoreCase) &&
!string.Equals(pair.Key, "wip", StringComparison.OrdinalIgnoreCase)
) {
builder.AppendLine(pair.ToString());
}
}
......
......@@ -93,6 +93,7 @@ namespace OpenBve {
Plugin plugin = new Plugin(file);
Assembly assembly = Assembly.LoadFile(file);
Type[] types = assembly.GetTypes();
bool iruntime = false;
foreach (Type type in types) {
if (type.IsSubclassOf(typeof(OpenBveApi.Textures.TextureInterface))) {
plugin.Texture = (OpenBveApi.Textures.TextureInterface)assembly.CreateInstance(type.FullName);
......@@ -103,10 +104,16 @@ namespace OpenBve {
if (type.IsSubclassOf(typeof(OpenBveApi.Objects.ObjectInterface))) {
plugin.Object = (OpenBveApi.Objects.ObjectInterface)assembly.CreateInstance(type.FullName);
}
if (typeof(OpenBveApi.Runtime.IRuntime).IsAssignableFrom(type)) {
iruntime = true;
}
}
if (plugin.Texture != null | plugin.Sound != null | plugin.Object != null) {
plugin.Load();
list.Add(plugin);
} else if (!iruntime) {
builder.Append("Plugin ").Append(Path.GetFileName(file)).AppendLine(" does not implement compatible interfaces.");
builder.AppendLine();
}
#if !DEBUG
} catch (Exception ex) {
......
......@@ -3,7 +3,6 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Tao.Sdl;
namespace OpenBve {
......
......@@ -7,7 +7,7 @@
<OutputType>Library</OutputType>
<RootNamespace>OpenBveApi</RootNamespace>
<AssemblyName>OpenBveApi</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Documents and Settings\Administrator\Application Data\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
......@@ -15,7 +15,8 @@
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DocumentationFile>bin\Release\OpenBveApi.xml</DocumentationFile>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......
......@@ -9,6 +9,8 @@ namespace Plugin {
/// <summary>The underlying train.</summary>
private Train Train;
private bool AtcProbing;
// --- constructors ---
......@@ -80,7 +82,7 @@ namespace Plugin {
// --- ats-p ---
if (this.Train.AtsP != null) {
if (this.Train.AtsP.State == AtsP.States.Disabled) {
this.Train.KeyDown(VirtualKeys.E);
this.Train.KeyDown(VirtualKeys.D);
data.Response = AIResponse.Long;
return;
} else if (this.Train.AtsP.State == AtsP.States.Pattern) {
......@@ -140,18 +142,36 @@ namespace Plugin {
}
// --- atc ---
if (this.Train.Atc != null) {
if (this.Train.Atc.State == Atc.States.Disabled) {
this.Train.KeyDown(VirtualKeys.G);
data.Response = AIResponse.Long;
return;
} else if (this.Train.Atc.ShouldSwitchToAts()) {
this.Train.KeyDown(VirtualKeys.C1);
data.Response = AIResponse.Long;
return;
if (this.Train.Atc.ShouldSwitchToAts()) {
if (this.Train.AtsSx != null | this.Train.AtsP != null) {
if (this.Train.Atc.State == Atc.States.Normal | this.Train.Atc.State == Atc.States.Service | this.Train.Atc.State == Atc.States.Emergency) {
this.Train.KeyDown(VirtualKeys.C1);
data.Response = AIResponse.Long;
return;
}
} else if (this.Train.Atc.State != Atc.States.Disabled) {
this.Train.KeyDown(VirtualKeys.E);
data.Response = AIResponse.Long;
return;
}
} else if (this.Train.Atc.ShouldSwitchToAtc()) {
this.Train.KeyDown(VirtualKeys.C2);
if (this.Train.Atc.State == Atc.States.Disabled) {
this.Train.KeyDown(VirtualKeys.D);
this.AtcProbing = this.Train.State.Speed.MetersPerSecond < 0.1 / 3.6;
data.Response = AIResponse.Long;
return;
} else {
this.Train.KeyDown(VirtualKeys.C2);
data.Response = AIResponse.Long;
return;
}
} else if (this.Train.Atc.State == Atc.States.Disabled & this.Train.State.Speed.MetersPerSecond < 0.1 / 3.6 & !this.AtcProbing) {
this.Train.KeyDown(VirtualKeys.D);
this.AtcProbing = true;
data.Response = AIResponse.Long;
return;
} else if (this.AtcProbing & this.Train.State.Speed.MetersPerSecond > 10.0 / 3.6) {
this.AtcProbing = false;
} else if (this.Train.Atc.State == Atc.States.Normal | this.Train.Atc.State == Atc.States.Service) {
if (this.Train.State.Speed.KilometersPerHour > 15.0) {
if (this.Train.State.Speed.MetersPerSecond > this.Train.Atc.CurrentAtcSpeed - 5.0 / 3.6) {
......
......@@ -269,7 +269,11 @@ namespace Plugin {
}
if (this.State == States.Suppressed) {
if (data.Handles.BrakeNotch <= this.Train.Specs.BrakeNotches) {
this.State = States.Ats;
if (this.Train.AtsSx != null | this.Train.AtsP != null) {
this.State = States.Ats;
} else {
this.State = States.Normal;
}
}
}
if (blocking) {
......@@ -373,8 +377,10 @@ namespace Plugin {
case VirtualKeys.C1:
// --- switch to ats ---
if (this.State == States.Normal | this.State == States.Service | this.State == States.Emergency) {
this.State = States.Ats;
this.Train.Sounds.ToAts.Play();
if (this.Train.AtsSx != null | this.Train.AtsP != null) {
this.State = States.Ats;
this.Train.Sounds.ToAts.Play();
}
}
break;
case VirtualKeys.C2:
......
......@@ -7,14 +7,15 @@
<OutputType>Library</OutputType>
<RootNamespace>OpenBveAts</RootNamespace>
<AssemblyName>OpenBveAts</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Documents and Settings\Administrator\Application Data\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
......
......@@ -7,14 +7,15 @@
<OutputType>Library</OutputType>
<RootNamespace>Sound.Flac</RootNamespace>
<AssemblyName>Sound.Flac</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Documents and Settings\Administrator\Application Data\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......
......@@ -7,14 +7,15 @@
<OutputType>Library</OutputType>
<RootNamespace>Plugin</RootNamespace>
<AssemblyName>Sound.RiffWave</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Documents and Settings\Administrator\Application Data\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>