Skip to content

Commit

Permalink
Automatic merge of X1.3.1-196-g253eec25a and 8 pull requests
Browse files Browse the repository at this point in the history
- Pull request #79 at 7d9f14b: Update version calculation for new unstable versions
- Pull request #226 at 26983e9: EmbedIO web server graphical track monitor
- Pull request #227 at 6ec1539: EmbedIO web server graphical train driving monitor
- Pull request #228 at 72c0146: adds links to OR on Elvas Tower
- Pull request #232 at e5c2207: JSON consist format: https://blueprints.launchpad.net/or/+spec/consist-editor
- Pull request #234 at 3ac34fe: Rehabilitate unit testing suite, migrate to xUnit 2
- Pull request #237 at abd68c3: Fixed 3D cab loading with undefined cabview control in CVF file https://bugs.launchpad.net/or/+bug/1888945
- Pull request #238 at 13fcbd7: Allow the webserver to listen on all IP addresses: https://blueprints.launchpad.net/or/+spec/embedio-for-web-server
  • Loading branch information
openrails-bot committed Jul 25, 2020
10 parents 460aa57 + 253eec2 + 7d9f14b + 26983e9 + 6ec1539 + 72c0146 + e5c2207 + 3ac34fe + abd68c3 + 13fcbd7 commit c205cb2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Source/ORTS.Content/TrainFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static string ResolveTrainFile(string basePath, string filename)
/// <param name="filename">The filename, minus its extension, of the file to locate.</param>
/// <returns>The full path to the train file.</returns>
public static string ResolveOrtsTrainFile(string basePath, string filename) =>
Path.GetFullPath(Path.ChangeExtension(Path.Combine(basePath, "trains", "lists", filename), ".train-or"));
Path.GetFullPath(Path.ChangeExtension(Path.Combine(basePath, "trains", "consists", filename), ".train-or"));

/// <summary>
/// Locate a consist by filename.
Expand Down Expand Up @@ -235,7 +235,7 @@ ISet<string> BaseNames(string directory, string pattern)
StringComparer.InvariantCultureIgnoreCase);
}

ISet<string> ortsBaseNames = BaseNames(Path.Combine(basePath, "trains", "lists"), "*.train-or");
ISet<string> ortsBaseNames = BaseNames(Path.Combine(basePath, "trains", "consists"), "*.train-or");
ISet<string> mstsBaseNames = BaseNames(Path.Combine(basePath, "trains", "consists"), "*.con");

IEnumerable<string> CombinedIterator()
Expand All @@ -245,7 +245,7 @@ IEnumerable<string> CombinedIterator()
string path;
// Prioritize native .train-or files.
if (ortsBaseNames.Contains(baseName))
path = Path.ChangeExtension(Path.Combine(basePath, "trains", "lists", baseName), ".train-or");
path = Path.ChangeExtension(Path.Combine(basePath, "trains", "consists", baseName), ".train-or");
else
path = Path.ChangeExtension(Path.Combine(basePath, "trains", "consists", baseName), ".con");
yield return Path.GetFullPath(path);
Expand Down
36 changes: 18 additions & 18 deletions Source/Orts.Simulation/Simulation/Simulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,7 @@ public void SetExplore(string path, string consist, string start, string season,
ExploreConFile = consist;
PreferredLocomotive = preferredLocomotive;
patFileName = Path.ChangeExtension(path, "PAT");
switch (Path.GetDirectoryName(consist).ToLowerInvariant())
{
case "consists":
trainFileName = Path.ChangeExtension(consist, "CON");
break;
case "lists":
trainFileName = Path.ChangeExtension(consist, "TRAIN-OR");
break;
}
trainFileName = ResolveConsistFileExtension(consist);
var time = start.Split(':');
TimeSpan StartTime = new TimeSpan(int.Parse(time[0]), time.Length > 1 ? int.Parse(time[1]) : 0, time.Length > 2 ? int.Parse(time[2]) : 0);
ClockTime = StartTime.TotalSeconds;
Expand All @@ -414,15 +406,7 @@ public void SetExploreThroughActivity(string path, string consist, string start,
ExploreConFile = consist;
PreferredLocomotive = preferredLocomotive;
patFileName = Path.ChangeExtension(path, "PAT");
switch (Path.GetDirectoryName(consist).ToLowerInvariant())
{
case "consists":
trainFileName = Path.ChangeExtension(consist, "CON");
break;
case "lists":
trainFileName = Path.ChangeExtension(consist, "TRAIN-OR");
break;
}
trainFileName = ResolveConsistFileExtension(consist);
var time = start.Split(':');
TimeSpan StartTime = new TimeSpan(int.Parse(time[0]), time.Length > 1 ? int.Parse(time[1]) : 0, time.Length > 2 ? int.Parse(time[2]) : 0);
Activity.Tr_Activity.Tr_Activity_File.Player_Service_Definition.Player_Traffic_Definition.Time = StartTime.Hours + StartTime.Minutes * 60 +
Expand All @@ -434,6 +418,22 @@ public void SetExploreThroughActivity(string path, string consist, string start,
IsAutopilotMode = true;
}

private static string ResolveConsistFileExtension(string consistPath)
{
switch (Path.GetExtension(consistPath).ToLowerInvariant())
{
case ".train-or":
case ".con":
return consistPath;
default:
string ortsTrain = Path.ChangeExtension(consistPath, ".train-or");
if (File.Exists(ortsTrain))
return ortsTrain;
else
return Path.ChangeExtension(consistPath, ".con");
}
}

public void Start(CancellationToken cancellation)
{
Signals = new Signals(this, SIGCFG, cancellation);
Expand Down

0 comments on commit c205cb2

Please sign in to comment.