Skip to content

Improve ride rating calculation#19683

Merged
ZehMatt merged 8 commits into
OpenRCT2:developfrom
ZehMatt:parallel-ride-ratings
Mar 22, 2023
Merged

Improve ride rating calculation#19683
ZehMatt merged 8 commits into
OpenRCT2:developfrom
ZehMatt:parallel-ride-ratings

Conversation

@ZehMatt

@ZehMatt ZehMatt commented Mar 20, 2023

Copy link
Copy Markdown
Contributor

A couple of things this PR does:

  • Has now 4 states that can be updated rather than a single ride only.
  • The previous implementation did not skip shops/facilities and instead spent an entire tick to reset the state machine, now it filters rides beforehand so it wont potentially do one tick nothing but initialize data and discard it the next tick. it also considers some other ride states.
  • Updating the ride state now has sub-stepping updates to process more data without rewriting the entire state machine, because there is still a problem with hacked rides we can't allow processing it all at once currently, there seems to be no real performance impact doing it like this, I did a bit of testing and 20 sub steps seem to hardly impact the overall framerate, could probably raise this even further but it now updates all rides in a couple of seconds which seemed good enough to me.

My testing shows that iterating and updating all rides takes only a couple seconds now. This will probably break bpb replay as the calculation goes a lot faster now.

@ZehMatt ZehMatt requested a review from duncanspumpkin March 20, 2023 15:43
@ocalhoun6

ocalhoun6 commented Mar 20, 2023

Copy link
Copy Markdown
Contributor

I'm concerned that this part might be a problem:

// Skip rides that are closed.

    if (ride.status == RideStatus::Closed)

    {

        return true;

    }

Often, when I'm first testing a new coaster, I'll put it in test mode just long enough for the first train to depart, and then put it back into closed mode for the duration of the test. (This makes it simpler to watch, avoiding crowding the track with trains, and it can help avoid crashes if a train valleys out.)

Currently, this works fine and still generates ride ratings once the train completes the circuit. But if the ride rating calculator doesn't look at closed rides, maybe this would no longer work, and now the ride won't be able to get ratings until it completes a full circuit while in open or testing mode?

@ZehMatt

ZehMatt commented Mar 20, 2023

Copy link
Copy Markdown
Contributor Author

I'm concerned that this part might be a problem:

// Skip rides that are closed.

    if (ride.status == RideStatus::Closed)

    {

        return true;

    }

Often, when I'm first testing a new coaster, I'll put it in test mode just long enough for the first train to depart, and then put it back into closed mode for the duration of the test. (This makes it simpler to watch, avoiding crowding the track with trains, and it can help avoid crashes if a train valleys out.)

Currently, this works fine and still generates ride ratings once the train completes the circuit. But if the ride rating calculator doesn't look at closed rides, maybe this would no longer work, and now the ride won't be able to get ratings until it completes a full circuit while in open or testing mode?

This hasn't changed and you need to be lucky to open/close the right at the time it picked up the ride calculation also, that condition already existed.

@Broxzier Broxzier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code changes LGTM. A few minor points. When testing the build, I noticed that the Excitement/Intensity/Nausea rating appeared instantly. Is this intended?

Comment thread src/openrct2/ride/RideRatings.cpp
Comment thread src/openrct2/park/ParkFile.cpp
Comment thread src/openrct2/ride/RideRatings.cpp Outdated
@Broxzier Broxzier added the changelog This issue/PR deserves a changelog entry. label Mar 20, 2023
@ZehMatt

ZehMatt commented Mar 20, 2023

Copy link
Copy Markdown
Contributor Author

Code changes LGTM. A few minor points. When testing the build, I noticed that the Excitement/Intensity/Nausea rating appeared instantly. Is this intended?

If its correct then yes, its supposed to be a lot quicker

@Broxzier

Copy link
Copy Markdown
Member

Normally when a vehicle finishes a lap, the statistics appear, but the ratings appeared much later. I thought this was intentional, desired behaviour. That the ratings appear much sooner now seems like a good change to me, I was just wondering if this was an intended change.

@ZehMatt

ZehMatt commented Mar 21, 2023

Copy link
Copy Markdown
Contributor Author

Normally when a vehicle finishes a lap, the statistics appear, but the ratings appeared much later. I thought this was intentional, desired behaviour. That the ratings appear much sooner now seems like a good change to me, I was just wondering if this was an intended change.

Yeah they were massively delayed because of a lot of factors, each tick would only do a few calculations for a single ride, it also spent ticks doing nothing if the ride id it encountered has been a shop, it would basically enter the next state in the state machine and on the next tick determines it has no stations and resets the state back to "find next ride", I skip all rides now where the required condition fails to process it. Its still not exactly instant but it should only take a couple seconds now if you are unlucky and the current tick processed the last ride where it then starts over with the first ride.

Comment thread src/openrct2/park/ParkFile.h Outdated

@duncanspumpkin duncanspumpkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems sensible

@ZehMatt ZehMatt merged commit e8ec7b6 into OpenRCT2:develop Mar 22, 2023
@ZehMatt ZehMatt deleted the parallel-ride-ratings branch March 22, 2023 20:25
janisozaur added a commit that referenced this pull request Mar 28, 2023
- Feature: [#11269] Add properties for speed and length of vehicle animations.
- Feature: [#15849] Objectives can now be set for up to 50000 guests.
- Feature: [#18537] Add shift/control modifiers to window close buttons, closing all but the given window or all windows of the same type, respectively.
- Feature: [#18732] [Plugin] API to get the guests thoughts.
- Feature: [#18744] Cheat to allow using a regular path as a queue path.
- Feature: [#19023] Add Canadian French translation.
- Feature: [#19341] Add “All Scenery” tab to scenery window.
- Feature: [#19378] Add command to combine CSG1i.DAT and CSG1.DAT.
- Feature: [objects#226] Port RCT1 Corkscrew Coaster train.
- Feature: [objects#229] Port RCT1 go karts with helmets.
- Feature: [OpenMusic#20, OpenMusic#21] Added Blizzard and Extraterresterial ride music styles.
- Improved: [#11473] Hot reload for plug-ins now works on macOS.
- Improved: [#12466] RCT1 parks now use RCT1’s interest calculation algorithm.
- Improved: [#14635] Scenery window now shows up to 255 scenery groups.
- Improved: [#17288] Reorganise the order of shortcut keys in the Shortcut Keys window.
- Improved: [#18706] Ability to view the list of contributors in-game.
- Improved: [#18749] Ability to have 4 active awards for more than one month in a row.
- Improved: [#18826] [Plugin] Added all actions and their documentation to plugin API.
- Improved: [#18945] Languages can now fall back to other languages than English.
- Improved: [#18970] Trying to load a non-park save will now display a context error.
- Improved: [#18975] Add lift sprites for steep hills on the wooden roller coaster.
- Improved: [#19044] Added special thanks to RMC and Wiegand to the About page.
- Improved: [#19131] Track missing objects when selecting scenery groups in console.
- Improved: [#19253] Queue junctions drawn properly when using regular paths as queue. Note: Requires using tile inspector to indicate railings can be used at T or X junctions.
- Improved: [#19067] New Ride window now allows filtering similarly to Object Selection.
- Improved: [#19272] Scenery window now allows filtering similarly to Object Selection.
- Improved: [#19447] The control key now enables word jumping in text input fields.
- Improved: [#19463] Added ‘W’ and ‘Y’ with circumflex to sprite font (for Welsh).
- Improved: [#19549] Enable large address awareness for 32 bit Windows builds allowing to use 4 GiB of virtual memory.
- Improved: [#19668] Decreased the minimum map size from 13 to 3.
- Improved: [#19683] The delays for ride ratings to appear has been reduced drastically.
- Improved: [#19697] “Show guest purchases” will now work in multiplayer.
- Change: [#19018] Renamed actions to fit the naming scheme.
- Change: [#19091] [Plugin] Add game action information to callback arguments of custom actions.
- Change: [#19233] Reduce lift speed minimum and maximum values for “Classic Wooden Coaster”.
- Removed: [#19520] Support for Windows Vista systems.
- Fix: [#474] Mini golf window shows more players than there actually are (original bug).
- Fix: [#592] Window scrollbar not able to navigate to the end of large lists.
- Fix: [#7210] Land tile smoothing occurs with edge tiles (original bug).
- Fix: [#17996] Finances window not cleared when starting some .park scenarios.
- Fix: [#18260] Crash opening parks that have multiple tiles referencing the same banner entry.
- Fix: [#18467] “Selected only” Object Selection filter is active in Track Designs Manager, and cannot be toggled.
- Fix: [#18904] OpenRCT2 audio object accidentally exported in saves.
- Fix: [#18905] Ride Construction window theme is not applied correctly.
- Fix: [#18911] Mini Golf station does not draw correctly from all angles.
- Fix: [#18971] New Game does not prompt for save before quitting.
- Fix: [#18986] [Plugin] Sending remote scripts larger than 63KiB crashing all clients.
- Fix: [#18994] Title music doesn’t start after enabling master volume.
- Fix: [#19025] Park loan behaves inconsistently with non-round and out-of-bounds values.
- Fix: [#19026] Park loan is clamped to a 32-bit integer.
- Fix: [#19068] Guests may not join queues correctly.
- Fix: [#19091] [Plugin] Remote plugins in multiplayer servers do not unload properly.
- Fix: [#19112] Clearing the last character in the Object Selection filter does not properly reset it.
- Fix: [#19112] Text boxes not updated with empty strings in Track List, Server List, and Start Server windows.
- Fix: [#19114] [Plugin] ‘GameActionResult’ does not comply to API specification.
- Fix: [#19136] SV6 saves with experimental RCT1 paths not imported correctly.
- Fix: [#19243] .park scenarios don’t complete properly.
- Fix: [#19250] MusicObjects do not free their preview images.
- Fix: [#19292] Overflow in ‘totalRideValue’.
- Fix: [#19339] Incorrect import of crashed particles from SV4.
- Fix: [#19379] “No platforms” station style shows platforms on the Junior Roller Coaster.
- Fix: [#19380] Startup crash when no sequences are installed and random sequences are enabled.
- Fix: [#19391] String corruption caused by an improper buffer handling in ‘GfxWrapString’.
- Fix: [#19434, #19509] Object types added by OpenRCT2 do not get removed when executing ‘remove_unused_objects’.
- Fix: [#19475] Cannot increase loan when more than £1000 in debt.
- Fix: [#19493] SV4 saves not importing the correct vehicle colours.
- Fix: [#19517] Crash when peeps try to exit or enter hacked rides that have no waypoints specified.
- Fix: [#19524] Staff counter shows incorrect values if there are more than 32767 staff members.
- Fix: [#19574] Handle exits in null locations.
- Fix: [#19641, #19643] Missing water tile in Infernal Views’ and Six Flags Holland’s river.
@cheweytoo

Copy link
Copy Markdown
Contributor

Just for the record: This. Is. Amazing! I consider this to be one of the greatest QoL improvements in OpenRCT2 ever.

Thank you!

qwzhaox pushed a commit to qwzhaox/OpenRCT2 that referenced this pull request Apr 10, 2023
- Feature: [OpenRCT2#11269] Add properties for speed and length of vehicle animations.
- Feature: [OpenRCT2#15849] Objectives can now be set for up to 50000 guests.
- Feature: [OpenRCT2#18537] Add shift/control modifiers to window close buttons, closing all but the given window or all windows of the same type, respectively.
- Feature: [OpenRCT2#18732] [Plugin] API to get the guests thoughts.
- Feature: [OpenRCT2#18744] Cheat to allow using a regular path as a queue path.
- Feature: [OpenRCT2#19023] Add Canadian French translation.
- Feature: [OpenRCT2#19341] Add “All Scenery” tab to scenery window.
- Feature: [OpenRCT2#19378] Add command to combine CSG1i.DAT and CSG1.DAT.
- Feature: [objects#226] Port RCT1 Corkscrew Coaster train.
- Feature: [objects#229] Port RCT1 go karts with helmets.
- Feature: [OpenMusic#20, OpenMusic#21] Added Blizzard and Extraterresterial ride music styles.
- Improved: [OpenRCT2#11473] Hot reload for plug-ins now works on macOS.
- Improved: [OpenRCT2#12466] RCT1 parks now use RCT1’s interest calculation algorithm.
- Improved: [OpenRCT2#14635] Scenery window now shows up to 255 scenery groups.
- Improved: [OpenRCT2#17288] Reorganise the order of shortcut keys in the Shortcut Keys window.
- Improved: [OpenRCT2#18706] Ability to view the list of contributors in-game.
- Improved: [OpenRCT2#18749] Ability to have 4 active awards for more than one month in a row.
- Improved: [OpenRCT2#18826] [Plugin] Added all actions and their documentation to plugin API.
- Improved: [OpenRCT2#18945] Languages can now fall back to other languages than English.
- Improved: [OpenRCT2#18970] Trying to load a non-park save will now display a context error.
- Improved: [OpenRCT2#18975] Add lift sprites for steep hills on the wooden roller coaster.
- Improved: [OpenRCT2#19044] Added special thanks to RMC and Wiegand to the About page.
- Improved: [OpenRCT2#19131] Track missing objects when selecting scenery groups in console.
- Improved: [OpenRCT2#19253] Queue junctions drawn properly when using regular paths as queue. Note: Requires using tile inspector to indicate railings can be used at T or X junctions.
- Improved: [OpenRCT2#19067] New Ride window now allows filtering similarly to Object Selection.
- Improved: [OpenRCT2#19272] Scenery window now allows filtering similarly to Object Selection.
- Improved: [OpenRCT2#19447] The control key now enables word jumping in text input fields.
- Improved: [OpenRCT2#19463] Added ‘W’ and ‘Y’ with circumflex to sprite font (for Welsh).
- Improved: [OpenRCT2#19549] Enable large address awareness for 32 bit Windows builds allowing to use 4 GiB of virtual memory.
- Improved: [OpenRCT2#19668] Decreased the minimum map size from 13 to 3.
- Improved: [OpenRCT2#19683] The delays for ride ratings to appear has been reduced drastically.
- Improved: [OpenRCT2#19697] “Show guest purchases” will now work in multiplayer.
- Change: [OpenRCT2#19018] Renamed actions to fit the naming scheme.
- Change: [OpenRCT2#19091] [Plugin] Add game action information to callback arguments of custom actions.
- Change: [OpenRCT2#19233] Reduce lift speed minimum and maximum values for “Classic Wooden Coaster”.
- Removed: [OpenRCT2#19520] Support for Windows Vista systems.
- Fix: [OpenRCT2#474] Mini golf window shows more players than there actually are (original bug).
- Fix: [OpenRCT2#592] Window scrollbar not able to navigate to the end of large lists.
- Fix: [OpenRCT2#7210] Land tile smoothing occurs with edge tiles (original bug).
- Fix: [OpenRCT2#17996] Finances window not cleared when starting some .park scenarios.
- Fix: [OpenRCT2#18260] Crash opening parks that have multiple tiles referencing the same banner entry.
- Fix: [OpenRCT2#18467] “Selected only” Object Selection filter is active in Track Designs Manager, and cannot be toggled.
- Fix: [OpenRCT2#18904] OpenRCT2 audio object accidentally exported in saves.
- Fix: [OpenRCT2#18905] Ride Construction window theme is not applied correctly.
- Fix: [OpenRCT2#18911] Mini Golf station does not draw correctly from all angles.
- Fix: [OpenRCT2#18971] New Game does not prompt for save before quitting.
- Fix: [OpenRCT2#18986] [Plugin] Sending remote scripts larger than 63KiB crashing all clients.
- Fix: [OpenRCT2#18994] Title music doesn’t start after enabling master volume.
- Fix: [OpenRCT2#19025] Park loan behaves inconsistently with non-round and out-of-bounds values.
- Fix: [OpenRCT2#19026] Park loan is clamped to a 32-bit integer.
- Fix: [OpenRCT2#19068] Guests may not join queues correctly.
- Fix: [OpenRCT2#19091] [Plugin] Remote plugins in multiplayer servers do not unload properly.
- Fix: [OpenRCT2#19112] Clearing the last character in the Object Selection filter does not properly reset it.
- Fix: [OpenRCT2#19112] Text boxes not updated with empty strings in Track List, Server List, and Start Server windows.
- Fix: [OpenRCT2#19114] [Plugin] ‘GameActionResult’ does not comply to API specification.
- Fix: [OpenRCT2#19136] SV6 saves with experimental RCT1 paths not imported correctly.
- Fix: [OpenRCT2#19243] .park scenarios don’t complete properly.
- Fix: [OpenRCT2#19250] MusicObjects do not free their preview images.
- Fix: [OpenRCT2#19292] Overflow in ‘totalRideValue’.
- Fix: [OpenRCT2#19339] Incorrect import of crashed particles from SV4.
- Fix: [OpenRCT2#19379] “No platforms” station style shows platforms on the Junior Roller Coaster.
- Fix: [OpenRCT2#19380] Startup crash when no sequences are installed and random sequences are enabled.
- Fix: [OpenRCT2#19391] String corruption caused by an improper buffer handling in ‘GfxWrapString’.
- Fix: [OpenRCT2#19434, OpenRCT2#19509] Object types added by OpenRCT2 do not get removed when executing ‘remove_unused_objects’.
- Fix: [OpenRCT2#19475] Cannot increase loan when more than £1000 in debt.
- Fix: [OpenRCT2#19493] SV4 saves not importing the correct vehicle colours.
- Fix: [OpenRCT2#19517] Crash when peeps try to exit or enter hacked rides that have no waypoints specified.
- Fix: [OpenRCT2#19524] Staff counter shows incorrect values if there are more than 32767 staff members.
- Fix: [OpenRCT2#19574] Handle exits in null locations.
- Fix: [OpenRCT2#19641, OpenRCT2#19643] Missing water tile in Infernal Views’ and Six Flags Holland’s river.
@ZehMatt ZehMatt mentioned this pull request Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog This issue/PR deserves a changelog entry.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants