Skip to content

Commit 0a51ff5

Browse files
committed
Automatic merge of T1.5.1-1090-g9915d87ce6 and 20 pull requests
- Pull request #891 at 9a1d6b2: Auto save - Pull request #954 at 3efaf6d: Multiple Track Profiles & Superelevation Improvements - Pull request #959 at 2452cb0: Fix TrackViewer crash on big zoom value - Pull request #972 at e90a2aa: On Map window color changed switch or signal is not changed - Pull request #976 at 877cc94: Increased center of gravity range - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #882 at 8f695a4: Blueprint/train car operations UI window - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #922 at a3bc9e7: Autopilot for timetable mode - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #962 at 46d0472: Fix pantographs on unpowered cars - Pull request #970 at 6fa5eed: feat: Remove unnecessary Windows.Forms usage - Pull request #973 at c35be87: fix: Using singular target framework to allow for different platforms across different projects - Pull request #974 at 5faea6f: Bug fix for https://bugs.launchpad.net/or/+bug/2076034 Doors remain open in AI trains - Pull request #977 at 6c1eb75: adds cache for SD files - Pull request #900 at c27f32d: DMI updates - Pull request #903 at 4a4b032: Downloading route content (Github, zip) - Pull request #799 at dfc715e: Consolidated wind simulation - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #952 at 8347095: Investigation - Pulsing graphics
22 parents c90f6e3 + 9915d87 + 9a1d6b2 + 3efaf6d + 2452cb0 + e90a2aa + 877cc94 + d00beb9 + 8f695a4 + 1f5ba4c + a3bc9e7 + a519452 + 46d0472 + 6fa5eed + c35be87 + 5faea6f + 6c1eb75 + c27f32d + 4a4b032 + dfc715e + f92de76 + 8347095 commit 0a51ff5

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

Source/Orts.Formats.Msts/ShapeDescriptorFile.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
1717

1818
using System;
19+
using System.Collections.Generic;
20+
1921
using Orts.Parsers.Msts;
2022

2123
namespace Orts.Formats.Msts
@@ -29,16 +31,26 @@ public class ShapeDescriptorFile
2931
shape = new SDShape();
3032
}
3133

34+
public static Dictionary<string, SDShape> Cache = new Dictionary<string, SDShape>();
35+
3236
public ShapeDescriptorFile(string filename)
3337
{
34-
using (STFReader stf = new STFReader(filename, false))
38+
var shapeDescriptorPath = filename.ToLowerInvariant();
39+
if (Cache.ContainsKey(shapeDescriptorPath))
3540
{
36-
stf.ParseFile(new STFReader.TokenProcessor[] {
37-
new STFReader.TokenProcessor("shape", ()=>{ shape = new SDShape(stf); }),
38-
});
39-
//TODO This should be changed to STFException.TraceError() with defaults values created
40-
if (shape == null)
41-
throw new STFException(stf, "Missing shape statement");
41+
shape = Cache[shapeDescriptorPath];
42+
}
43+
else
44+
{
45+
using (STFReader stf = new STFReader(filename, false))
46+
{
47+
stf.ParseFile(new STFReader.TokenProcessor[] {
48+
new STFReader.TokenProcessor("shape", ()=>{ shape = new SDShape(stf); }),
49+
});
50+
//TODO This should be changed to STFException.TraceError() with defaults values created
51+
if (shape == null) throw new STFException(stf, "Missing shape statement");
52+
}
53+
Cache.Add(shapeDescriptorPath, shape);
4254
}
4355
}
4456

Source/RunActivity/Viewer3D/Scenery.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,12 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
349349
}
350350
}
351351

352-
if (shapeFilePath != null && File.Exists(shapeFilePath + "d"))
352+
var shapeDescriptorPath = shapeFilePath + "d";
353+
if (shapeFilePath != null)
354+
{
355+
var shape = new ShapeDescriptorFile(shapeDescriptorPath);
356+
if (shape != null)
353357
{
354-
var shape = new ShapeDescriptorFile(shapeFilePath + "d");
355358
if (shape.shape.ESD_Bounding_Box != null)
356359
{
357360
var min = shape.shape.ESD_Bounding_Box.Min;
@@ -364,6 +367,7 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
364367
BoundingBoxes.Add(new BoundingBox(transform, new Vector3((max.X - min.X) / 2, (max.Y - min.Y) / 2, (max.Z - min.Z) / 2), worldMatrix.XNAMatrix.Translation.Y));
365368
}
366369
}
370+
}
367371

368372
try
369373
{

0 commit comments

Comments
 (0)