Skip to content

Commit

Permalink
Fix breaking changes for new openrct2.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
guysv committed Oct 20, 2024
1 parent 8ddad73 commit 3080f3f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/services/spacingEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function getDistanceFromProgress(car: Car, trackProgress: number): number
? new ForwardIterator(trackProgress, currentProgress)
: new BackwardIterator(abs(trackProgress), currentProgress);

let trackPosition = currentTrackLocation;
let trackPosition = currentTrackLocation as CoordsXYZD;
let trackDistances = getTrackDistances(iteratorSegment, subposition, trackPosition.direction);
subpositionIterator._setInitialDistanceFromCarRemainingDistance(car.remainingDistance);

Expand Down Expand Up @@ -371,4 +371,4 @@ class BackwardIterator extends SubpositionIterator
nextTile.z + nextTrack._endZ
);
}
}
}
2 changes: 1 addition & 1 deletion src/services/vehiclePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function toggleVehiclePicker(isPressed: boolean, onPick: (car: Car) => vo
/**
* Finds a car within a certain range of the selected tile element.
*/
function findCarNearbyTileElement(coords: CoordsXYZ, elementIdx: number): Car | undefined
function findCarNearbyTileElement(coords: CoordsXY, elementIdx: number): Car | undefined
{
const element = getTileElement(coords.x, coords.y, elementIdx);
const entitiesOnTile = map.getAllEntitiesOnTile("car", coords);
Expand Down
30 changes: 15 additions & 15 deletions tests/services/spacingEditor.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ const multiTurnTest = test.macro({
exec(t, startTrackPiece: number, startProgress: number, progress: number, expectedResult: number): void
{
const trackPieces = [ rightTurn1TrackPiece, rightTurn2TrackPiece, steepUpTrackPiece, steepTurnTrackPiece ];
const trackLocation: CoordsXYZD = { ...trackPieces[startTrackPiece].position, direction: 0 };
const trackLocation: CarTrackLocation = { ...trackPieces[startTrackPiece].position, direction: 0, trackType: 0 };
setupTrackIterator(trackPieces, startTrackPiece);
const car = Mock.car({ trackProgress: startProgress, trackLocation, remainingDistance: (progress >= 0) ? ForwardRemainingDistance : 0 });

Expand Down Expand Up @@ -405,8 +405,8 @@ test("Flat track: get spacing to preceding vehicle 1 step away", t =>
{
const mapMock = setupTrackIterator([ flatTrackPiece ]);
const train = createTrain(mapMock, [
{ trackProgress: 17, trackLocation: flatTrackPiece.position }, // front car
{ trackProgress: 16, trackLocation: flatTrackPiece.position }
{ trackProgress: 17, trackLocation: {...flatTrackPiece.position, trackType: flatTrackPiece.type} }, // front car
{ trackProgress: 16, trackLocation: {...flatTrackPiece.position, trackType: flatTrackPiece.type} }
]);

const spacing = getSpacingToPrecedingVehicle(train, train._at(1)._car(), 1);
Expand All @@ -419,8 +419,8 @@ test("Flat track: get spacing to preceding vehicle 10 step away", t =>
{
const mapMock = setupTrackIterator([ flatTrackPiece ]);
const train = createTrain(mapMock, [
{ trackProgress: 17, trackLocation: flatTrackPiece.position }, // front car
{ trackProgress: 7, trackLocation: flatTrackPiece.position }
{ trackProgress: 17, trackLocation: {...flatTrackPiece.position, trackType: flatTrackPiece.type} }, // front car
{ trackProgress: 7, trackLocation: {...flatTrackPiece.position, trackType: flatTrackPiece.type} }
]);

const spacing = getSpacingToPrecedingVehicle(train, train._at(1)._car(), 1);
Expand All @@ -433,8 +433,8 @@ test("Flat track: get spacing to preceding vehicle 31 step away", t =>
{
const mapMock = setupTrackIterator([ flatTrackPiece ]);
const train = createTrain(mapMock, [
{ trackProgress: 31, trackLocation: flatTrackPiece.position }, // front car
{ trackProgress: 0, trackLocation: flatTrackPiece.position } // back car
{ trackProgress: 31, trackLocation: {...flatTrackPiece.position, trackType: flatTrackPiece.type} }, // front car
{ trackProgress: 0, trackLocation: {...flatTrackPiece.position, trackType: flatTrackPiece.type} } // back car
]);

const spacing = getSpacingToPrecedingVehicle(train, train._at(1)._car(), 1);
Expand All @@ -447,8 +447,8 @@ test("Flat track: get spacing to preceding vehicle is too far away", t =>
{
const mapMock = setupTrackIterator([ flatTrackPiece ]);
const train = createTrain(mapMock, [
{ trackProgress: 15, trackLocation: { x: 10, y: 10, z: 10, direction: 0 } }, // front car
{ trackProgress: 10, trackLocation: flatTrackPiece.position }
{ trackProgress: 15, trackLocation: { x: 10, y: 10, z: 10, direction: 0, trackType: 0 } }, // front car
{ trackProgress: 10, trackLocation: {...flatTrackPiece.position, trackType: 0}, }
]);

const spacing = getSpacingToPrecedingVehicle(train, train._at(1)._car(), 1);
Expand All @@ -462,8 +462,8 @@ test("Two flat tracks: get spacing to next track piece by 1", t =>
const pieces = [ flatTrackPiece.copyTo(32, 64), flatTrackPiece.copyTo(32, 32) ];
const mapMock = setupTrackIterator(pieces);
const train = createTrain(mapMock, [
{ trackProgress: 0, trackLocation: pieces[1].position }, // front car
{ trackProgress: 31, trackLocation: pieces[0].position } // back car
{ trackProgress: 0, trackLocation: {...pieces[1].position, trackType: pieces[1].type} }, // front car
{ trackProgress: 31, trackLocation: {...pieces[0].position, trackType: pieces[0].type} } // back car
]);
const car = train._at(1)._car();

Expand All @@ -478,8 +478,8 @@ test("Two flat tracks: get spacing to next track piece by 10", t =>
const pieces = [ flatTrackPiece.copyTo(32, 64), flatTrackPiece.copyTo(32, 32) ];
const mapMock = setupTrackIterator(pieces);
const train = createTrain(mapMock, [
{ trackProgress: 3, trackLocation: pieces[1].position }, // front car
{ trackProgress: 25, trackLocation: pieces[0].position } // back car
{ trackProgress: 3, trackLocation: {...pieces[1].position, trackType: pieces[1].type} }, // front car
{ trackProgress: 25, trackLocation: {...pieces[0].position, trackType: pieces[0].type} } // back car
]);
const car = train._at(1)._car();

Expand All @@ -494,8 +494,8 @@ test("Three flat tracks: get spacing to next track piece by 50", t =>
const pieces = [ flatTrackPiece.copyTo(32, 96), flatTrackPiece.copyTo(32, 64), flatTrackPiece.copyTo(32, 32) ];
const mapMock = setupTrackIterator(pieces);
const train = createTrain(mapMock, [
{ trackProgress: 5, trackLocation: pieces[2].position }, // front car
{ trackProgress: 19, trackLocation: pieces[0].position } // back car
{ trackProgress: 5, trackLocation: {...pieces[2].position, trackType: pieces[2].type} }, // front car
{ trackProgress: 19, trackLocation: {...pieces[0].position, trackType: pieces[0].type} } // back car
]);
const car = train._at(1)._car();

Expand Down

0 comments on commit 3080f3f

Please sign in to comment.