diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 2cad08f413..13e45e81ab 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -28,6 +28,7 @@ - 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. diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 2cfafb4ea3..25c9056a9b 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -774,7 +774,7 @@ std::optional GetTrackSegmentOrigin(const CoordsXYE& posEl) const auto& trackBlock = ted.sequences[sequenceIndex].clearance; CoordsXY trackBlockOffset = { trackBlock.x, trackBlock.y }; coords += trackBlockOffset.Rotate(DirectionReverse(direction)); - coords.z += ted.sequences[0].clearance.z - trackBlock.z; + coords.z -= trackBlock.z; return CoordsXYZD(coords, direction); } diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp index e8b016c71e..b0ef6eb28c 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp @@ -9,12 +9,14 @@ #include "ScVehicle.hpp" +#include "../../../ride/TrackData.h" #include "../../../world/tile_element/TrackElement.h" #include "../ride/ScRide.hpp" #ifdef ENABLE_SCRIPTING using namespace OpenRCT2::Drawing; +using namespace OpenRCT2::TrackMetaData; namespace OpenRCT2::Scripting { @@ -548,11 +550,11 @@ namespace OpenRCT2::Scripting void ScVehicle::moveToTrack(int32_t x, int32_t y, int32_t elementIndex) { - CoordsXY coords = TileCoordsXY(x, y).ToCoordsXY(); auto vehicle = GetVehicle(); if (vehicle == nullptr) return; + CoordsXY coords = TileCoordsXY(x, y).ToCoordsXY(); auto el = MapGetNthElementAt(coords, elementIndex); if (el == nullptr) return; @@ -561,13 +563,16 @@ namespace OpenRCT2::Scripting if (!origin) return; - auto trackEl = el->AsTrack(); + const auto& trackType = el->AsTrack()->GetTrackType(); + const auto& ted = GetTrackElementDescriptor(trackType); + const auto& seq0 = ted.sequences[0].clearance; + const auto trackLoc = CoordsXYZ(origin->x + seq0.x, origin->y + seq0.y, origin->z + seq0.z); - vehicle->TrackLocation.x = origin->x; - vehicle->TrackLocation.y = origin->y; - vehicle->TrackLocation.z = origin->z; + vehicle->TrackLocation.x = trackLoc.x; + vehicle->TrackLocation.y = trackLoc.y; + vehicle->TrackLocation.z = trackLoc.z; vehicle->SetTrackDirection(origin->direction); - vehicle->SetTrackType(trackEl->GetTrackType()); + vehicle->SetTrackType(trackType); // Clip track progress to avoid being out of bounds of current piece uint16_t trackTotalProgress = vehicle->GetTrackProgress();