mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Fix #24661: convert console command always crashes with a segmentation fault
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
- Fix: [#24615] Blank strings in Windows installer.
|
||||
- Fix: [#24617] ‘Divide by zero’ error when updating boat hire acceleration.
|
||||
- Fix: [#24626] Viewports that only follow sprites (e.g. in the Ride and Guest windows) can be made to unfollow them.
|
||||
- Fix: [#24661] `convert` console command always crashes with a segmentation fault.
|
||||
|
||||
0.4.23 (2025-06-07)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
@@ -183,21 +183,23 @@ namespace OpenRCT2
|
||||
const auto mainWindow = WindowGetMain();
|
||||
const auto mainViewport = WindowGetViewport(mainWindow);
|
||||
|
||||
CoordsXYZ mapPosXYZ{};
|
||||
CoordsXYZD mapPosXYZD{};
|
||||
if (mainViewport != nullptr)
|
||||
{
|
||||
const auto centre = mainViewport->viewPos
|
||||
+ ScreenCoordsXY{ mainViewport->ViewWidth() / 2, mainViewport->ViewHeight() / 2 };
|
||||
const auto mapPos = ViewportPosToMapPos(centre, 24, mainViewport->rotation);
|
||||
mapPosXYZ = CoordsXYZ(mapPos.x, mapPos.y, int32_t{ TileElementHeight(mapPos) });
|
||||
mapPosXYZD = CoordsXYZD(mapPos.x, mapPos.y, int32_t{ TileElementHeight(mapPos) }, mainViewport->rotation);
|
||||
}
|
||||
else if (!gameState.park.Entrances.empty())
|
||||
{
|
||||
const auto& entrance = gameState.park.Entrances[0];
|
||||
mapPosXYZ = CoordsXYZ{ entrance.x + 16, entrance.y + 16, entrance.z + 32 };
|
||||
mapPosXYZD = CoordsXYZD(entrance.x + 16, entrance.y + 16, entrance.z + 32, DirectionReverse(entrance.direction));
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
PreviewImage image{
|
||||
.type = PreviewImageType::screenshot,
|
||||
@@ -210,10 +212,10 @@ namespace OpenRCT2
|
||||
.height = image.height,
|
||||
.flags = 0,
|
||||
.zoom = ZoomLevel{ 1 },
|
||||
.rotation = mainViewport->rotation,
|
||||
.rotation = mapPosXYZD.direction,
|
||||
};
|
||||
|
||||
auto viewPos = centre_2d_coordinates(mapPosXYZ, &saveVp);
|
||||
auto viewPos = centre_2d_coordinates(mapPosXYZD, &saveVp);
|
||||
if (viewPos == std::nullopt)
|
||||
return std::nullopt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user