Route extending Open Rails files
#91
Posted 27 April 2021 - 06:33 PM
I am trying to program an editor for the clocks files. I have to read the JSON animated.clocks-or and the STF clocks.dat. So I just realize what a considerable effort is required for this.
Best regards
Jonas
#92
Posted 27 April 2021 - 06:38 PM
#93
Posted 27 April 2021 - 06:55 PM
YoRyan, on 27 April 2021 - 06:38 PM, said:
#94
Posted 27 April 2021 - 07:08 PM
#96
Posted 27 April 2021 - 11:10 PM
By the way, do you mean SD40 or SD40-2? The latter loads here.
#97
Posted 27 April 2021 - 11:47 PM
https://msts.steam4m...ls/gantlet.html
https://msts.steam4m..._dbl_slips.html
OR does not handle this to date. TSRE is already yes but not complete. This is when manual editing comes in.
There will always be something in the situation that the app creator does not think about.
Mindig kíváncsian figyelem az újdonságokat, mert ezek viszik előbbre az Open Railst.
#98
Posted 28 April 2021 - 08:11 AM
Genma Saotome, on 27 April 2021 - 05:12 PM, said:
. . .
I'm checking out.
Dave, I think the message has become muddled. We are not taking away the parsing of STF for existing types of file. JSON is only for new types of file.
Our policy is that "Open Rails will continue to maintain compatibility with content from previous official versions of Open Rails."
I will be publishing this and other policies on the Open Rails website shortly.
#99
Posted 28 April 2021 - 08:52 AM
YoRyan, on 27 April 2021 - 06:13 PM, said:
If you decide to use custom fast libs for JSON loading, then different libs can treat this kind of bugs differently too.
I don't think that pointing to bugs in some STF files is any reasonable argument against STF file format.
#100
Posted 28 April 2021 - 08:57 AM
Csantucci, on 27 April 2021 - 11:10 PM, said:
By the way, do you mean SD40 or SD40-2? The latter loads here.
The SD40-2. Here's the file that doesn't load; it's straight from the MSTS 1.2 update. I have just tested it on master and on NewYear and it doesn't work on either. It's possible you've already repaired your own copy.

Number of downloads: 340
It's the syntax that's badly defined about STF, not the names of the properties. In the case of the SD40-2, there's a backslash at the end of one of the lines. What is that supposed to mean to the parser? Kuju apparently just ignores it, but Open Rails doesn't. Should we change the behavior to match MSTS's? If we do, does this break any existing OR files that assume our current behavior?
You don't have these kinds of problems with JSON. If your data doesn't load correctly in your web browser, then it's not valid JSON.
Goku, on 28 April 2021 - 08:52 AM, said:
Actually, they don't. There's one and only one way to parse JSON. This information does not exist for STF.
Goku, on 28 April 2021 - 08:52 AM, said:
But it's a file produced by Kuju themselves. It's not a bug - it was intentional. The bug is in Open Rails itself, a consequence of the extreme difficulty of writing a consistent STF parser.
#101
Posted 28 April 2021 - 11:29 AM
[ { "Name": "Foo.s", "Type": "tree" } ]
And this would be the same json file with a typo:
[ { "Name": "Foo.s", "Type": "tree"\ } ]
Would the json parsers in general be robust enough to read the latter file flawless?
#102
Posted 28 April 2021 - 11:42 AM
#103
Posted 28 April 2021 - 11:56 AM
Error: Parse error on line 3: ....s", "Type": "tree"\}] ----------------------^ Expecting 'EOF', '}', ':', ',', ']', got 'undefined'
The point is not so much that the parser is "robust" - it's that you can expect every JSON reader ever written to follow the exact same logic. If it doesn't pass this validator, it's not JSON. Period.
Is the SD40-2 shape valid STF? Kuju thinks so. MSTS thinks so. Open Rails does not. But Open Rails has become the de-facto STF reader.
#104
Posted 28 April 2021 - 12:01 PM
YoRyan, on 28 April 2021 - 08:57 AM, said:

It's the syntax that's badly defined about STF, not the names of the properties. In the case of the SD40-2, there's a backslash at the end of one of the lines. What is that supposed to mean to the parser? Kuju apparently just ignores it, but Open Rails doesn't. Should we change the behavior to match MSTS's? If we do, does this break any existing OR files that assume our current behavior?
But the case with this file may be just an user made bug.
YoRyan, on 28 April 2021 - 08:57 AM, said:
So, maybe the SD40-2 file is not a valid file and MSTS parser just ignores this bug?
YoRyan, on 28 April 2021 - 08:57 AM, said:
No programmer is perfect and many of these fast libs don't have to follow the specs 100% correctly. Try opening advanced ODF file id different apps and the result may be completely different. It's common.
YoRyan, on 28 April 2021 - 08:57 AM, said:
How do you know that it was intentional? It doesn't mean anything.
I think that you are looking for problems where there are none. If you don't know what to do with "\" character in STF file when parsing it, just don't allow using it in OR files.
#105
Posted 28 April 2021 - 12:06 PM
https://i.imgur.com/WcSYOhq.png
I'm just a noob programmer and TSRE doesn't care about looking for errors. In the time of MSTS development it was common, handling errors makes things slower.