Genma Saotome, on 10 December 2014 - 10:45 AM, said:
...one of which is Weather(). Values 0-3 are allowed and they are, effectively, more conditions -- why KUJU didn't put them in conditions escapes me -- with values of 0 = all weather, 1 = rain, 2 = snow, and 3 = dry.
We do support this, though they don't seem to match the numbers you list... we have 0=all weather, 1=clear/dry, 2=rain, 3=snow. If we've got it wrong in Open Rails let's fix it - it's the order of the items in the LightWeatherCondition enum in MSTS.Formats\Lights.cs (around line 139).
Genma Saotome, on 10 December 2014 - 10:45 AM, said:
Another part of the Lights() block that is suspect has to do with Unit() and Coupler(). I have my doubts that all possible combinations of flipped/not flipped, direction of movement, and coupler in use are present -- both in the range of acceptable data and code to make it all work. I think Unit() is poorly defined: you should never couple two completely different data into one value and yet that's exactly what Unit() does by combining position and direction of travel. And IIRC Coupler() might be missing a data value for Both in use. For a switcher with headlights on both ends you want the light to be dimmed when it is shining into a car end 1.5m away (w/o regard to which end of the locomotive is in question) while the opposite end may or may not be bright, depending on the direction of travel. I'm not sure OR can handle that.
We support the MSTSBin extended values for "Unit":
- 1 - Middle (not first or last)
- 2 - First (first and not reversed)
- 3 - Last (last and not reversed)
- 4 - Last Reversed (last and reversed)
- 5 - First Reversed (first and reversed)
The "first" and "last" flags are based on the train as seen from the driving cab, so whether the driving locomotive is flipped and whether the driving locomotive cab is rear-facing.
The "reversed" flag is based on the following conditions:
- Car is flipped
- Driving locomotive is flipped
- Driving locomotive cab is a rear-facing cab
To be clear: the "reversed" flag is set if there is
an odd number of the above conditions present.
And we support the following for "Coupler":
- 1 - Front only
- 2 - Rear only
- 3 - Both
The "front"/"rear" are based on the direction of this individual wagon, so just whether it is flipped.
Note that this doesn't let you say "front is coupled but I don't care whether the rear is coupled or not".
This is
definitely a complex system to reason about and I certainly couldn't make any promises about its correctness. In fact, I can pretty much guarantee it is wrong - I just don't know where yet. We could definitely do with some tests on this code. In the mean time, feel free to make up some examples (e.g. list of wagons, which are flipped, where the driving cab is, etc.) and we can work out which values apply to which wagons by hand (or through running examples - this code does have debug logging available).
All comparisons for the light conditions must be made with MSTSBin, not original MSTS, as I don't think the two are compatible in general - the code is meant to be following MSTSBin's behaviour.
Genma Saotome, on 10 December 2014 - 03:19 PM, said:
Do you know what KUJU was doing in their code? James did not and so the choice was no headlights or doing something different that would work.
Heh, I think it is based on what MSTS does - or what the docs say - but as we all know, that's not the most reliable source. I'm quite happy for improvements to be made to how it matches MSTS if there relatively simple changes, but I don't think we want to make any major changes here.