1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 13:33:02 +01:00

Remove focus union and replace with typed focus (#15426)

* Remove focus union and replace with typed focus

This if for the NSF to allow for CoordsXYZ

* Remove legacy structures

* Rework viewport_create to deduplicate logic

* Simplify yet further

* Apply review comments

* Remove intermediate
This commit is contained in:
Duncan
2021-09-18 20:34:38 +01:00
committed by GitHub
parent c05068e8d1
commit fa57b6aea0
19 changed files with 140 additions and 270 deletions

View File

@@ -12,28 +12,10 @@ void rct_window::SetLocation(const CoordsXYZ& coords)
void rct_window::ScrollToViewport()
{
// In original checked to make sure x and y were not -1 as well.
if (viewport == nullptr || viewport_focus_coordinates.y == -1)
if (viewport == nullptr || !focus2.has_value())
return;
CoordsXYZ newCoords = {};
if (viewport_focus_sprite.type & VIEWPORT_FOCUS_TYPE_SPRITE)
{
auto* sprite = GetEntity(viewport_focus_sprite.sprite_id);
if (sprite == nullptr)
{
return;
}
newCoords.x = sprite->x;
newCoords.y = sprite->y;
newCoords.z = sprite->z;
}
else
{
newCoords.x = viewport_focus_coordinates.x;
newCoords.y = viewport_focus_coordinates.y & VIEWPORT_FOCUS_Y_MASK;
newCoords.z = viewport_focus_coordinates.z;
}
CoordsXYZ newCoords = focus2.value().GetPos();
auto mainWindow = window_get_main();
if (mainWindow != nullptr)