1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Merge pull request #24446 from Basssiiie/fix-plugin-track-segment-origin

[Plugin] Fix regression from #24142 breaking `ScTrackIterator` on specific track pieces
This commit is contained in:
Matt
2025-05-26 02:38:41 +03:00
committed by GitHub
3 changed files with 13 additions and 7 deletions

View File

@@ -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.

View File

@@ -774,7 +774,7 @@ std::optional<CoordsXYZD> 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);
}

View File

@@ -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();