Skip to content

Fix #24426: More efficiently search viewports. #24474

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

Merged

Conversation

Harry-Hopkinson
Copy link
Contributor

Fix for #24426 by creating a new function that only searches windows that are currently active. This means WindowGetPreviousViewport is currently unused so can be removed.

@Harry-Hopkinson Harry-Hopkinson force-pushed the more-efficiently-search-viewports branch 2 times, most recently from e464426 to 8b563e4 Compare May 22, 2025 20:15
@Gymnasiast Gymnasiast requested a review from ZehMatt May 22, 2025 20:55
@ZehMatt
Copy link
Member

ZehMatt commented May 23, 2025

I should have made it more clear in the issue I created, the idea is to not use windows to obtain the viewports, there is a list of viewports so we don't have to jump over each window to get them.

@Harry-Hopkinson Harry-Hopkinson force-pushed the more-efficiently-search-viewports branch from 4836242 to 49ee07e Compare May 25, 2025 10:37
@Harry-Hopkinson Harry-Hopkinson force-pushed the more-efficiently-search-viewports branch from 0ec7b16 to 9f3a7b5 Compare May 26, 2025 07:36
@Harry-Hopkinson Harry-Hopkinson force-pushed the more-efficiently-search-viewports branch from 9f3a7b5 to 994cc85 Compare May 26, 2025 07:37
@Harry-Hopkinson Harry-Hopkinson requested a review from ZehMatt May 27, 2025 15:51
@Harry-Hopkinson
Copy link
Contributor Author

Note that this makes WindowGetPreviousViewport unused. Should this function be removed in this PR?

@ZehMatt
Copy link
Member

ZehMatt commented May 27, 2025

Note that this makes WindowGetPreviousViewport unused. Should this function be removed in this PR?

Yeah, ditch it, no point in keeping dead stuff around.

Copy link
Member

@ZehMatt ZehMatt left a comment

Choose a reason for hiding this comment

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

LGTM.

@ZehMatt ZehMatt added this to the v0.4.23 milestone May 27, 2025
@ZehMatt ZehMatt linked an issue May 27, 2025 that may be closed by this pull request
@Gymnasiast Gymnasiast added the testing required PR needs to be tested before it is merged. label May 28, 2025
@Gymnasiast
Copy link
Member

@ZeeMaji Could you test if this works correctly? Including focusing sound on a specific viewport?

@Gymnasiast Gymnasiast requested a review from ZeeMaji May 28, 2025 21:40
@ZeeMaji
Copy link
Contributor

ZeeMaji commented May 28, 2025

Sure.

Copy link
Contributor

@ZeeMaji ZeeMaji left a comment

Choose a reason for hiding this comment

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

Seems to work as expected, for the audio i checked both regular ride window viewports and extra viewports and audio played as expected from both.

Scratch that, the second i looked back at the game after approving i just found an issue with guest viewports. It doesn't seem to properly update when picking up guests and just goes blank when rotating the view.
ksnip_20250529-033548 webp
ksnip_20250529-033553 webp
ksnip_20250529-033600 webp
ksnip_20250529-033602 webp

@ZeeMaji ZeeMaji self-requested a review May 29, 2025 07:34
@ZeeMaji
Copy link
Contributor

ZeeMaji commented May 29, 2025

The scrolling thought text that appears when a guest has a new thought also glitches.
ksnip_20250529-034047 webp

@Harry-Hopkinson
Copy link
Contributor Author

That's strange, I cannot seem to reproduce it. Will have a look.

@ZeeMaji
Copy link
Contributor

ZeeMaji commented May 29, 2025

This was on the software renderer for what it's worth, just incase it's renderer specific.

@ZehMatt
Copy link
Member

ZehMatt commented May 29, 2025

Seems to work as expected, for the audio i checked both regular ride window viewports and extra viewports and audio played as expected from both.

Scratch that, the second i looked back at the game after approving i just found an issue with guest viewports. It doesn't seem to properly update when picking up guests and just goes blank when rotating the view. ksnip_20250529-033548 webp ksnip_20250529-033553 webp ksnip_20250529-033600 webp ksnip_20250529-033602 webp

I don't see how the changes would affect those things, can you confirm that this is not happening on the develop branch?

@mixiate
Copy link
Contributor

mixiate commented May 29, 2025

That's very likely to be a regression from #24433. There were similar issues with other windows and thought i'd caught them all.

@ZeeMaji
Copy link
Contributor

ZeeMaji commented May 29, 2025

I don't see how the changes would affect those things, can you confirm that this is not happening on the develop branch?

Ahh good catch. It's happening on develop but not release, so this was introduced since the last release.

In that case, this PR is probably good then.

@ZehMatt ZehMatt merged commit fb834e6 into OpenRCT2:develop May 29, 2025
23 checks passed
@Harry-Hopkinson Harry-Hopkinson deleted the more-efficiently-search-viewports branch May 29, 2025 18:31
tupaschoal added a commit that referenced this pull request Jun 7, 2025
- Feature: [#22476] “Time since last inspection” statistic is available in the rides window.
- Feature: [#24313] [Plugin] Add API for setting a ride vehicle’s sprite to a smoke plume.
- Improved: [#24345] Vehicle fallback sprites are less likely to glitch with the track.
- Improved: [#24362, #24491] The Windows installer is now translated as well.
- Improved: [#24364] Improve the fallback vehicle sprites for Zero G Rolls, and allow small ones to be built without cheats if the fallbacks are available.
- Improved: [#24368] Clicking the in-game update notication now leads to a more user-friendly download page.
- Improved: [#24400] Ride list in preservation window is now sorted alphabetically.
- Improved: [#24409] Steam installs of RCT Classic are now detected automatically.
- Improved: [#24413] Better performance when moving the viewport on Windows and Linux platforms.
- Improved: [#24417] Improve the fallback vehicle sprites for Dive Loops.
- Improved: [#24433] The ride, new ride, scenery, path, viewport, park and tool windows no longer redraw every frame if they have not changed.
- Improved: [#24467] Apply tweening only to on-screen entities when not zoomed out for better performance with uncapped FPS.
- Improved: [#24474] More efficiently search viewports when playing Audio.
- Improved: [#24479] More descriptive error messages for `set` commands in the in-game console.
- Improved: [#24563] The Linux .desktop file will now request the more powerful dedicated GPU on hybrid graphics systems.
- Change: [#24342, #24484] g2.dat is now split into g2.dat, fonts.dat and tracks.dat.
- Change: [#24362] The Windows installer now prevents installing to the same folder as RollerCoaster Tycoon 2 or Classic.
- Change: [#24418] Small & Large Zero G Rolls can now be built on the LIM Launched RC without cheats if vehicle sprites are available.
- Fix: [#5269] Font bugs when using the Russian release of RCT2 as the base game.
- Fix: [#11071, #22958] The virtual floor does not always draw correctly.
- Fix: [#18220] Some custom RCT1 scenarios are detected as competition DLC scenarios.
- Fix: [#20095] UCES Halloween - Cemetery Ridge scenario has mismatched entrance/exit on haunted house.
- Fix: [#20158] Custom animated scenery .DATs with frame offsets draw a random sprite at the end of their animation.
- Fix: [#22628] Potential crash while rebuilding the scenario index.
- Fix: [#23289] Dodgems and Flying Saucer cars can spawn on top of each other when the ride is opened.
- Fix: [#24332] Banner font renders differently when using RCT Classic as the base game.
- Fix: [#24343] Large gently sloped turns are buildable without cheats when the vehicles do not have sprites for them.
- Fix: [#24346] Possible crash during line drawing in OpenGL mode.
- Fix: [#24353] ‘Show dirty visuals’ is off by one pixel and does not work correctly with higher framerates.
- Fix: [#24362] When upgrading from an older version on Windows, old versions of official objects are not always removed.
- Fix: [#24366] Zero G Rolls have some incorrect vehicle yaw rotations.
- Fix: [#24371] Fix divide by zero in the scenery window when there is no scenery.
- Fix: [#24378] Prevent ride and stall statistics from overflowing.
- Fix: [#24388] Shortcut keys are not localised based on the user’s language settings.
- Fix: [#24403] Park fences draw underneath and through opaque water.
- Fix: [#24406] The network status window uses an undefined string for its title.
- Fix: [#24444] In the object load error window, the guide text overlaps when the title bar is enlarged.
- Fix: [#24446] [Plugin] Fix regression breaking the track iterator on specific track pieces.
- Fix: [#24447] Shortcut list is not refreshed when changing language.
- Fix: [#24448] Shortcuts involving the Caps Lock key are wrongly localised to NumPad Dot.
- Fix: [#24464] Window and viewport visibility is not calculated correctly causing minor performance issues.
- Fix: [#24488] Objects are not always redrawn immediately when they are reloaded from the Object Selection window.
- Fix: [#24544] RCT1 Maze designs with wooden walls are not imported correctly.
- Fix: [#24567] Long flat-to-steep wooden mine support sprites don't connect to flat supports exactly.
tupaschoal added a commit that referenced this pull request Jun 7, 2025
- Feature: [#22476] “Time since last inspection” statistic is available in the rides window.
- Feature: [#24313] [Plugin] Add API for setting a ride vehicle’s sprite to a smoke plume.
- Improved: [#24345] Vehicle fallback sprites are less likely to glitch with the track.
- Improved: [#24362, #24491] The Windows installer is now translated as well.
- Improved: [#24364] Improve the fallback vehicle sprites for Zero G Rolls, and allow small ones to be built without cheats if the fallbacks are available.
- Improved: [#24368] Clicking the in-game update notication now leads to a more user-friendly download page.
- Improved: [#24400] Ride list in preservation window is now sorted alphabetically.
- Improved: [#24409] Steam installs of RCT Classic are now detected automatically.
- Improved: [#24413] Better performance when moving the viewport on Windows and Linux platforms.
- Improved: [#24417] Improve the fallback vehicle sprites for Dive Loops.
- Improved: [#24433] The ride, new ride, scenery, path, viewport, park and tool windows no longer redraw every frame if they have not changed.
- Improved: [#24467] Apply tweening only to on-screen entities when not zoomed out for better performance with uncapped FPS.
- Improved: [#24474] More efficiently search viewports when playing Audio.
- Improved: [#24479] More descriptive error messages for `set` commands in the in-game console.
- Improved: [#24563] The Linux .desktop file will now request the more powerful dedicated GPU on hybrid graphics systems.
- Change: [#24342, #24484] g2.dat is now split into g2.dat, fonts.dat and tracks.dat.
- Change: [#24362] The Windows installer now prevents installing to the same folder as RollerCoaster Tycoon 2 or Classic.
- Change: [#24418] Small & Large Zero G Rolls can now be built on the LIM Launched RC without cheats if vehicle sprites are available.
- Fix: [#5269] Font bugs when using the Russian release of RCT2 as the base game.
- Fix: [#11071, #22958] The virtual floor does not always draw correctly.
- Fix: [#18220] Some custom RCT1 scenarios are detected as competition DLC scenarios.
- Fix: [#20095] UCES Halloween - Cemetery Ridge scenario has mismatched entrance/exit on haunted house.
- Fix: [#20158] Custom animated scenery .DATs with frame offsets draw a random sprite at the end of their animation.
- Fix: [#22628] Potential crash while rebuilding the scenario index.
- Fix: [#23289] Dodgems and Flying Saucer cars can spawn on top of each other when the ride is opened.
- Fix: [#24332] Banner font renders differently when using RCT Classic as the base game.
- Fix: [#24343] Large gently sloped turns are buildable without cheats when the vehicles do not have sprites for them.
- Fix: [#24346] Possible crash during line drawing in OpenGL mode.
- Fix: [#24353] ‘Show dirty visuals’ is off by one pixel and does not work correctly with higher framerates.
- Fix: [#24362] When upgrading from an older version on Windows, old versions of official objects are not always removed.
- Fix: [#24366] Zero G Rolls have some incorrect vehicle yaw rotations.
- Fix: [#24371] Fix divide by zero in the scenery window when there is no scenery.
- Fix: [#24378] Prevent ride and stall statistics from overflowing.
- Fix: [#24388] Shortcut keys are not localised based on the user’s language settings.
- Fix: [#24403] Park fences draw underneath and through opaque water.
- Fix: [#24406] The network status window uses an undefined string for its title.
- Fix: [#24444] In the object load error window, the guide text overlaps when the title bar is enlarged.
- Fix: [#24446] [Plugin] Fix regression breaking the track iterator on specific track pieces.
- Fix: [#24447] Shortcut list is not refreshed when changing language.
- Fix: [#24448] Shortcuts involving the Caps Lock key are wrongly localised to NumPad Dot.
- Fix: [#24464] Window and viewport visibility is not calculated correctly causing minor performance issues.
- Fix: [#24488] Objects are not always redrawn immediately when they are reloaded from the Object Selection window.
- Fix: [#24544] RCT1 Maze designs with wooden walls are not imported correctly.
- Fix: [#24567] Long flat-to-steep wooden mine support sprites don't connect to flat supports exactly.
CorySanin added a commit to CorySanin/OpenRCT2 that referenced this pull request Jun 22, 2025
v0.4.23

Release v0.4.23

- Feature: [OpenRCT2#22476] “Time since last inspection” statistic is available in the rides window.
- Feature: [OpenRCT2#24313] [Plugin] Add API for setting a ride vehicle’s sprite to a smoke plume.
- Improved: [OpenRCT2#24345] Vehicle fallback sprites are less likely to glitch with the track.
- Improved: [OpenRCT2#24362, OpenRCT2#24491] The Windows installer is now translated as well.
- Improved: [OpenRCT2#24364] Improve the fallback vehicle sprites for Zero G Rolls, and allow small ones to be built without cheats if the fallbacks are available.
- Improved: [OpenRCT2#24368] Clicking the in-game update notication now leads to a more user-friendly download page.
- Improved: [OpenRCT2#24400] Ride list in preservation window is now sorted alphabetically.
- Improved: [OpenRCT2#24409] Steam installs of RCT Classic are now detected automatically.
- Improved: [OpenRCT2#24413] Better performance when moving the viewport on Windows and Linux platforms.
- Improved: [OpenRCT2#24417] Improve the fallback vehicle sprites for Dive Loops.
- Improved: [OpenRCT2#24433] The ride, new ride, scenery, path, viewport, park and tool windows no longer redraw every frame if they have not changed.
- Improved: [OpenRCT2#24467] Apply tweening only to on-screen entities when not zoomed out for better performance with uncapped FPS.
- Improved: [OpenRCT2#24474] More efficiently search viewports when playing Audio.
- Improved: [OpenRCT2#24479] More descriptive error messages for `set` commands in the in-game console.
- Improved: [OpenRCT2#24563] The Linux .desktop file will now request the more powerful dedicated GPU on hybrid graphics systems.
- Change: [OpenRCT2#24342, OpenRCT2#24484] g2.dat is now split into g2.dat, fonts.dat and tracks.dat.
- Change: [OpenRCT2#24362] The Windows installer now prevents installing to the same folder as RollerCoaster Tycoon 2 or Classic.
- Change: [OpenRCT2#24418] Small & Large Zero G Rolls can now be built on the LIM Launched RC without cheats if vehicle sprites are available.
- Fix: [OpenRCT2#5269] Font bugs when using the Russian release of RCT2 as the base game.
- Fix: [OpenRCT2#11071, OpenRCT2#22958] The virtual floor does not always draw correctly.
- Fix: [OpenRCT2#18220] Some custom RCT1 scenarios are detected as competition DLC scenarios.
- Fix: [OpenRCT2#20095] UCES Halloween - Cemetery Ridge scenario has mismatched entrance/exit on haunted house.
- Fix: [OpenRCT2#20158] Custom animated scenery .DATs with frame offsets draw a random sprite at the end of their animation.
- Fix: [OpenRCT2#22628] Potential crash while rebuilding the scenario index.
- Fix: [OpenRCT2#23289] Dodgems and Flying Saucer cars can spawn on top of each other when the ride is opened.
- Fix: [OpenRCT2#24332] Banner font renders differently when using RCT Classic as the base game.
- Fix: [OpenRCT2#24343] Large gently sloped turns are buildable without cheats when the vehicles do not have sprites for them.
- Fix: [OpenRCT2#24346] Possible crash during line drawing in OpenGL mode.
- Fix: [OpenRCT2#24353] ‘Show dirty visuals’ is off by one pixel and does not work correctly with higher framerates.
- Fix: [OpenRCT2#24362] When upgrading from an older version on Windows, old versions of official objects are not always removed.
- Fix: [OpenRCT2#24366] Zero G Rolls have some incorrect vehicle yaw rotations.
- Fix: [OpenRCT2#24371] Fix divide by zero in the scenery window when there is no scenery.
- Fix: [OpenRCT2#24378] Prevent ride and stall statistics from overflowing.
- Fix: [OpenRCT2#24388] Shortcut keys are not localised based on the user’s language settings.
- Fix: [OpenRCT2#24403] Park fences draw underneath and through opaque water.
- Fix: [OpenRCT2#24406] The network status window uses an undefined string for its title.
- Fix: [OpenRCT2#24444] In the object load error window, the guide text overlaps when the title bar is enlarged.
- Fix: [OpenRCT2#24446] [Plugin] Fix regression breaking the track iterator on specific track pieces.
- Fix: [OpenRCT2#24447] Shortcut list is not refreshed when changing language.
- Fix: [OpenRCT2#24448] Shortcuts involving the Caps Lock key are wrongly localised to NumPad Dot.
- Fix: [OpenRCT2#24464] Window and viewport visibility is not calculated correctly causing minor performance issues.
- Fix: [OpenRCT2#24488] Objects are not always redrawn immediately when they are reloaded from the Object Selection window.
- Fix: [OpenRCT2#24544] RCT1 Maze designs with wooden walls are not imported correctly.
- Fix: [OpenRCT2#24567] Long flat-to-steep wooden mine support sprites don't connect to flat supports exactly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing required PR needs to be tested before it is merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inefficient lookup of viewports to play audio
6 participants