Perform the refactor described in #27199, move ObjectAsset to its own cpp file. I also added a brief docstring for the class based on my understanding of its function.
Every image source of the form `$RCT2:OBJDATA/NAME.DAT` was resolved by
probing that exact name, then the `.POB` name, and on failure by scanning
the object directory recursively. Scanning it stats every entry, so on an
RCT Classic installation -- a single flat `Assets` folder of 2708 lower
case files, which never match the upper case names the shipped JSON
objects ask for -- both probes missed and each object cost a scan of the
whole folder. A park needs hundreds of those, and the cache holding the
results is thread_local on threads that are destroyed together with the
job pool, so the work was repeated on every park load and title sequence
transition.
Stat and open are ~45x more expensive on the FUSE file system Flatpak's
document portal provides than on local disk, which is why this became
unbearable there in particular.
The RCT1/RCT2 data directories are now listed once into a case
insensitive name index that IPlatformEnvironment::FindFile answers from,
so resolving a name costs no file system operations at all. Reading a
listing only needs the names, not the metadata, and the index is dropped
when a base path changes.
Loading test/tests/testdata/parks/bpb.sv6 with RCT Classic game data,
measured with `openrct2-cli screenshot` (byte identical output before and
after):
before after
document portal 54.5 s 0.45 s
local disk 2.58 s 0.34 s
Used an LLM to find the problem and generate the patch, and verified the
speedup on my own.
Assisted-by: LLM
Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com>
FileScannerUnix stats every entry it lists in order to read its size and
modified time, but files whose name does not match the search pattern are
never returned by next(). Skipping them before that call cuts the
repository freshness scans at startup from 10832 stat calls to 345 for a
RollerCoaster Tycoon Classic installation, and lets the load/save window
list a directory's sub directories without querying every file in it.
This matters on file systems where metadata operations are expensive: a
stat costs ~60us on the FUSE file system Flatpak's document portal
provides, against ~1.4us on local disk.
Entries whose type readdir did not report are still queried, as they may
be a directory that has to be recursed into.
Used an LLM to find the issue, and generate the patch. Performed my own
testing.
Assisted-by: LLM
Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com>
Advance adoption of the 'Direction' type for cardinal directions:
* Split `Direction` and its helpers out to their own header (`Direction.h`)
* Replace loops that iterate all four directions with range-based loops
* Replace some math with calls to helper functions. I also introduced a new `DirectionRotate()` function, a generalisation of `DirectionNext()`/`DirectionPrev()`.
* Replace `uint8_t`/`int32_t` with `Direction` in some function signatures and field types, if the thing being passed/stored is supposed to be a cardinal direction
In the process I also fixed two defects in the code:
* The bitmask used to select the direction from a TD6EntranceElement was too wide - it was grabbing the low 4 bits, but only needs the low 2.
* `CoordsXYZD.toTileCentre()` was taking the tile corner and adding a `CoordsXYZD` value to it, to add half-tile offsets to X and Y. So, it's more correct to add a `CoordsXY` value instead, and skip the unnecessary Z and D dimensions.
Git refuses to read the repo inside the container jobs because the
workspace is owned by a different user, so CMake silently gets no
branch or commit hash. Mark the workspace as a safe directory, as
check-code-formatting already does.
- Feature: [#16014] Land surfaces and edges can now be recoloured.
- Feature: [#26894] Added 18 additional colours, including 5 from the base version of RCT1 (which were removed in later versions).
- Feature: [#27153] [Plugin] Add `guestsEntertained` to `Entertainer` interface.
- Feature: [#27184] [Plugin] Double limit of miscellaneous entities (e.g. crash particles, steam plumes and balloons) to 6400.
- Feature: [#27254] New title sequence (see https://github.com/OpenRCT2/title-sequences/releases/tag/v0.5.6 for credits).
- Feature: [objects#447] Track designer grid can now be used outside the Track Designer.
- Improved: [#21400] The selector for setting staff patrol areas is now drawn on the water as well as on the surface under water.
- Improved: [#22933] You can now toggle between long and short base flat-to-steep pieces if the ride has both available.
- Improved: [#26947] Rain is now drawn next to the bottom info panels (in RCT2 style).
- Improved: [#27097] On Linux, Flatpak Steam RCTC/RCT2 paths are now auto-detected.
- Improved: [#27110] The option to automatically open shops after construction now also closes them before construction.
- Change: [#27071] The gamepad deadzone has been raised from 11% to 25% by default to compensate for stick drift.
- Change: [#27100] Negative G-forces no longer turn red in the stats window and graph when below -2.50.
- Fix: [#1514] Wrong capitalisation for strings in the Guest List window.
- Fix: [#12516] Sprites past 65,536 pixels are drawn in the wrong place by the software renderer, most visibly in long scenario lists.
- Fix: [#15423] Crash when a guest or handyman uses a bin whose path addition object is not loaded.
- Fix: [#17409] When reading system settings, non-US dollar currencies are not recognised correctly.
- Fix: [#18151] Park value and company value are out of date after loading a save.
- Fix: [#19754, #27109] Some rides in RCT1 saves have a wrong number of cars per train.
- Fix: [#19755, #21320] RCT1 allows more cars per train on some rides than OpenRCT2.
- Fix: [#20882] When setting rides with preservation status in the Scenario Editor, some rides are not shown.
- Fix: [#21576] RCT1 Wooden wild mouse track designs with 2-car trains are not imported correctly.
- Fix: [#22298] [Plugin] Crash when changing a large scenery element whose object is not loaded.
- Fix: [#24457] Yellow is always rendered as third remap in Ride window.
- Fix: [#25400] The Inverted Flying RollerCoaster draws upright Twister track pieces for pieces it doesn’t have.
- Fix: [#26222] ‘Follow this on Main View’ follows the invisible first car on ride types that have one, making the view turn too early.
- Fix: [#26754] Switching window tabs by touch could crash the game on some Linux builds.
- Fix: [#26998] Crash when generating a `Simplex Height Map` with a higher width than height.
- Fix: [#27052] Unnamed rides in RCT2 base and Wacky Worlds scenarios have hardcoded English names.
- Fix: [#27056] [Plugin] Loading water palettes from plugin does not update the palette correctly.
- Fix: [#27070] The game keeps responding to input while the window is not focused (primarily gamepads).
- Fix: [#27084] [Plugin] `PermissionType` for `drag_path_area` is missing.
- Fix: [#27087] The ‘Update available’ widget is offset incorrectly.
- Fix: [#27093] Pause and fast forward buttons are shown in multiplayer.
- Fix: [#27113] Chat button is shown in editor mode.
- Fix: [#27133] [Plugin] Dropdown and spinner are not fully hidden with isVisible on creation.
- Fix: [#27134] Viewing track designs may cause network desyncs.
- Fix: [#27136] Guests keep waiting at a level crossing after the train has passed, due to faulty iteration over the track the train has vacated.
- Fix: [#27212] Chain lifts are blue in screenshots taken from the command line.
- Fix: [#27218] Tile inspector coordinate spinners are too short for coordinate 1000.
- Fix: [#27233] `openrct2 parkinfo objects` crashes when called with a scenario instead of save.
- Fix: [#27234] [Plugin] Setting `TrackElement.seatRotation` fails on every ride except mazes, where it does not apply.
The maze check in ScTileElement::seatRotation_set was inverted, so the
setter refused every track element except maze ones, the only ride type
seat rotation does not apply to. Use the same check as the getter.