Skip to content

Conversation

@mbm-OR
Copy link
Contributor

@mbm-OR mbm-OR commented Mar 17, 2025

Fix a crash reported here.

Bug #2102839

@mbm-OR mbm-OR self-assigned this Mar 17, 2025
@mbm-OR mbm-OR added the bug Something isn't working label Mar 17, 2025
@mbm-OR mbm-OR requested a review from Csantucci March 17, 2025 09:33
twpol pushed a commit that referenced this pull request Mar 17, 2025
- Pull request #900 at b54024b: DMI in 3D cab + two more dials
- Pull request #1030 at d3ae4a2: Refactor settings, in prep for settings exporter
- Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH
- Pull request #961 at ffccb2e: Improvements for Power Supplies
- Pull request #1015 at 1ade99e: Enhancements for EP brakes
- Pull request #1029 at 31fd7d2: Superelevation Follow Up Fixes
- Pull request #1031 at c097fd2: Multiplayer Server, forked from Open Rails Ultimate; blueprint https://blueprints.launchpad.net/or/+spec/multiplayer-server
- Pull request #1047 at eb8027b: Docs: adds translation docs
- Pull request #1058 at 626ebed: Refactor notification parameters
- Pull request #1059 at 313f795: Fix F9 powersupply crashes
- Pull request #1055 at 1a01818: Route Based TTrack Sounds
- Pull request #896 at f1681df: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains
twpol pushed a commit that referenced this pull request Mar 17, 2025
- Pull request #900 at b54024b: DMI in 3D cab + two more dials
- Pull request #1030 at d3ae4a2: Refactor settings, in prep for settings exporter
- Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH
- Pull request #961 at ffccb2e: Improvements for Power Supplies
- Pull request #1015 at 1ade99e: Enhancements for EP brakes
- Pull request #1029 at 31fd7d2: Superelevation Follow Up Fixes
- Pull request #1031 at c097fd2: Multiplayer Server, forked from Open Rails Ultimate; blueprint https://blueprints.launchpad.net/or/+spec/multiplayer-server
- Pull request #1047 at eb8027b: Docs: adds translation docs
- Pull request #1059 at 313f795: Fix F9 powersupply crashes
- Pull request #1061 at f75dc71: Fix F9 Web-page conflict.
- Pull request #1055 at 1a01818: Route Based TTrack Sounds
- Pull request #896 at f1681df: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains
Copy link
Contributor

@Csantucci Csantucci left a comment

Choose a reason for hiding this comment

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

Hi Mauricio,
may I understand why Cars[CarPosition -1] surely exists if Cars[CarPosition] does not exist?

twpol pushed a commit that referenced this pull request Mar 17, 2025
- Pull request #900 at b54024b: DMI in 3D cab + two more dials
- Pull request #1030 at d3ae4a2: Refactor settings, in prep for settings exporter
- Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH
- Pull request #961 at ffccb2e: Improvements for Power Supplies
- Pull request #1015 at 1ade99e: Enhancements for EP brakes
- Pull request #1029 at 31fd7d2: Superelevation Follow Up Fixes
- Pull request #1047 at eb8027b: Docs: adds translation docs
- Pull request #1059 at 313f795: Fix F9 powersupply crashes
- Pull request #1061 at f75dc71: Fix F9 Web-page conflict.
- Pull request #1055 at 1a01818: Route Based TTrack Sounds
- Pull request #896 at f1681df: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains
@mbm-OR
Copy link
Contributor Author

mbm-OR commented Mar 17, 2025

... may I understand why Cars[CarPosition -1] surely exists if Cars[CarPosition] does not exist?

Hi Carlo,
When we uncouple a car, the CarPosition index is outside of the currently attached cars index. It takes the same value as PlayerTrain.Cars.Count.

To avoid a crash type:
System.ArgumentOutOfRangeException : Index was outside the bounds of the array…
We set CarPosition - 1, a value in the range within the existing PlayerTrain.Cars.Count. This way we avoid the crash.

Copy link
Contributor

@rwf-rr rwf-rr left a comment

Choose a reason for hiding this comment

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

The change looks fine to me. I stumbled on this bug, made the same change, and it tested fine.

Copy link
Contributor

@Csantucci Csantucci left a comment

Choose a reason for hiding this comment

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

That's OK for me.

@mbm-OR mbm-OR merged commit 90cae11 into openrails:master Mar 21, 2025
1 check passed
Csantucci added a commit to Csantucci/openrails that referenced this pull request Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

3 participants