Make change of odometer count direction apply immediately. #1040
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously the change in count direction (Shift-Ctrl-Z) would not apply until a reset (Ctrl-Z) is done.
Now, the odometer will change immediately when its count direction is changed.
For example, you pass a switch and reset (Ctrl-Z) the odometer. Then you notice it counts up. Now, when you hit toggle-direction (Shift-Ctrl-Z), the counter will jump to the length of the train minus the distance already traveled between when the reset was done and when the count-direction was changed. When the counter reaches zero, your train has passed the switch.
See https://www.elvastower.com/forums/index.php?/topic/38587-odometer-count-updown-not-taking-effect-until-reset/.
I ended up doing some refactoring, as I had a hard time understanding the logic. Part of the complexity is that the odometer behaves different from a typical odometer. When doing a reverse move, the odometer can be used to count the distance as if it were a normal move.
Hence, the reset logic depends on the position of the reverser at the time of the reset. The reverser position at reset is preserved in the OdometerDirectionForward flag.