Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initail build of duplex steam #877

Merged
merged 5 commits into from Sep 26, 2023

Conversation

peternewell
Copy link
Contributor

Initial build of duplex steam - addition of control commands only

https://blueprints.launchpad.net/or/+spec/duplex-steam-locomotives

It is desired to merge this so that control keys are "reserved".

Additional functionality supporting this will be added later under a separate PR

@peternewell peternewell added the enhancement New feature or request label Sep 25, 2023
@peternewell peternewell self-assigned this Sep 25, 2023
twpol pushed a commit that referenced this pull request Sep 25, 2023
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
- Pull request #857 at 9afc8c3: Adding Air Flow Meters
- Pull request #865 at 776d6df: Dispatcher window improvements
- Pull request #874 at 86d58ff: Dynamic brake controller refactoring
- Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs
- Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
- Pull request #877 at c567eba: Initail build of duplex steam
twpol pushed a commit that referenced this pull request Sep 25, 2023
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
- Pull request #857 at 9afc8c3: Adding Air Flow Meters
- Pull request #865 at 776d6df: Dispatcher window improvements
- Pull request #874 at 86d58ff: Dynamic brake controller refactoring
- Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs
- Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
- Pull request #877 at ce3490b: Initail build of duplex steam
Copy link
Contributor

@cesarBLG cesarBLG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two style fixes, sorry for not having spotted them before

Comment on lines 1591 to 1594
if (Receiver == null) return;
{
Receiver.SteamBoosterChangeTo(ToState, Target);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (Receiver == null) return;
{
Receiver.SteamBoosterChangeTo(ToState, Target);
}
Receiver?.SteamBoosterChangeTo(ToState, Target);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not as comfortable with this change.

Firstly I think that long hand code is sometimes more "readable" then short hand code.

Secondly there are a number of other similar entries in the other controllers. Hence for consistency these should be changed as well.

So I would prefer to leave this as it is, and somebody else can refactor all the code to be similar at a later date.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but I won't approve it as is. It looks confusing to me. In particular, at first glance your code seems to do

if (Receiver == null)
{
    Receiver.SteamBoosterChangeTo(ToState, Target);
}

until you notice the "return" statement. The curly braces are completely misleading.

The ?. operator is my preferred choice in this case, and is also recommended by ORMT (see http://www.elvastower.com/forums/index.php?/topic/35509-cs-null-conditional-operator/). It is also used elsewhere in Commands.cs, so your argument about consistency is not really valid. In my opinion, new code should use it whenever possible.

However, my intention is not to force you to use that syntax. It was just my suggestion. I have no problem if you prefer to use "standard" syntax, as long as the misleading braces are removed. Other acceptable solutions for me are:

if (Receiver == null) return;
Receiver.SteamBoosterChangeTo(ToState, Target);

or

if (Receiver != null)
{
    Receiver.SteamBoosterChangeTo(ToState, Target);
}

or

if (Receiver != null) Receiver.SteamBoosterChangeTo(ToState, Target);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I have adopted one of your suggested solutions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry for being so nitpicking, but the indentation of Receiver.SteamBoosterChangeTo(ToState, Target); is still incorrect. I think it is important that we follow the coding guidelines to make code more readable for others. I could have corrected it myself, but you disabled "allow edits from maintainers".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved it across now. Thanks for checking.

twpol pushed a commit that referenced this pull request Sep 25, 2023
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
- Pull request #857 at 9afc8c3: Adding Air Flow Meters
- Pull request #865 at 776d6df: Dispatcher window improvements
- Pull request #874 at 86d58ff: Dynamic brake controller refactoring
- Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs
- Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
- Pull request #877 at a0bd9ec: Initail build of duplex steam
twpol pushed a commit that referenced this pull request Sep 25, 2023
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
- Pull request #865 at 776d6df: Dispatcher window improvements
- Pull request #874 at 86d58ff: Dynamic brake controller refactoring
- Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs
- Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
- Pull request #877 at a0bd9ec: Initail build of duplex steam
twpol pushed a commit that referenced this pull request Sep 26, 2023
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
- Pull request #865 at 776d6df: Dispatcher window improvements
- Pull request #874 at 86d58ff: Dynamic brake controller refactoring
- Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs
- Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
- Pull request #877 at a76c45b: Initail build of duplex steam
twpol pushed a commit that referenced this pull request Sep 26, 2023
- Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters
- Pull request #865 at 776d6df: Dispatcher window improvements
- Pull request #874 at 86d58ff: Dynamic brake controller refactoring
- Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs
- Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
- Pull request #877 at 55f9ddd: Initail build of duplex steam
Copy link
Contributor

@cesarBLG cesarBLG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and sorry for the inconvenience of the multiple style suggestions.

@peternewell peternewell merged commit d394472 into openrails:master Sep 26, 2023
3 checks passed
@peternewell peternewell deleted the duplex_engines_initial branch September 26, 2023 08:27
@peternewell
Copy link
Contributor Author

Thanks Cesar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants