Skip to content

Commit 8196a3f

Browse files
authored
Merge pull request #743 from Csantucci/default-include-filename
Default filename for include statements
2 parents 3756630 + c1801f4 commit 8196a3f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4211,6 +4211,22 @@ OpenRails subfolder that uses the second possibility is as follows::
42114211

42124212
Take into account that the first line must be blank (before the include line).
42134213

4214+
In case of more trainsets residing in the same folder and requiring the same
4215+
additional .wag or .eng files with exactly the same contents, it is useful to
4216+
use the conventional filename ``[[SameName]]``.
4217+
OR will replace that filename with the filename of the file containing the Include
4218+
statement. So, in the case of the example above, instead of::
4219+
4220+
include ( ../bc13ge70tonner.eng )
4221+
4222+
the following can be written::
4223+
4224+
include ( ../[[SameName]] )
4225+
4226+
This way all additional .wag or .eng files referring to similar trainsets would
4227+
have exactly the same contents, drastically reducing editing time.
4228+
4229+
42144230
.. index::
42154231
single: ORTSMaxTractiveForceCurves
42164232

Source/Orts.Parsers.Msts/STFReader.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,9 @@ private string ReadItem(bool skip_mode, bool string_mode)
18271827
filename = ReadItem(skip_mode, string_mode);
18281828
SkipRestOfBlock();
18291829
}
1830+
var purefilename = Path.GetFileName(filename).ToLower();
1831+
if (purefilename == "[[samename]]")
1832+
filename = Path.GetDirectoryName(filename) + @"\" + Path.GetFileName(FileName);
18301833
var includeFileName = Path.GetDirectoryName(FileName) + @"\" + filename;
18311834
if (!File.Exists(includeFileName))
18321835
STFException.TraceWarning(this, string.Format("'{0}' not found", includeFileName));

0 commit comments

Comments
 (0)