From 31764f62c6c6dff4ea2ea7d37cc8447974e9259b Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 17 May 2022 19:33:04 +0100 Subject: [PATCH] Change track segment API to use null --- distribution/openrct2.d.ts | 10 +++++----- src/openrct2/scripting/bindings/game/ScContext.hpp | 2 +- .../scripting/bindings/ride/ScTrackIterator.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 65ffb72aaf..98c0a1d734 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -228,7 +228,7 @@ declare global { * Gets the {@link TrackSegment} for the given type. * @param type The track segment type. */ - getTrackSegment(type: number): TrackSegment | undefined; + getTrackSegment(type: number): TrackSegment | null; /** * Gets a random integer within the specified range using the game's pseudo- @@ -642,7 +642,7 @@ declare global { * @param location The tile coordinates. * @param elementIndex The index of the track element on the tile. */ - getTrackIterator(location: CoordsXY, elementIndex: number): TrackIterator | undefined; + getTrackIterator(location: CoordsXY, elementIndex: number): TrackIterator | null; } type TileElementType = @@ -1251,17 +1251,17 @@ declare global { /** * The current track segment. */ - readonly segment: TrackSegment | undefined; + readonly segment: TrackSegment | null; /** * Gets the position of where the previous track element should start. */ - readonly previousPosition: CoordsXYZD | undefined; + readonly previousPosition: CoordsXYZD | null; /** * Gets the position of where the next track element should start. */ - readonly nextPosition: CoordsXYZD | undefined; + readonly nextPosition: CoordsXYZD | null; /** * Moves the iterator to the previous track segment. diff --git a/src/openrct2/scripting/bindings/game/ScContext.hpp b/src/openrct2/scripting/bindings/game/ScContext.hpp index 7abaa2f135..d4599101e5 100644 --- a/src/openrct2/scripting/bindings/game/ScContext.hpp +++ b/src/openrct2/scripting/bindings/game/ScContext.hpp @@ -224,7 +224,7 @@ namespace OpenRCT2::Scripting auto ctx = GetContext()->GetScriptEngine().GetContext(); if (type >= TrackElemType::Count) { - return ToDuk(ctx, undefined); + return ToDuk(ctx, nullptr); } else { diff --git a/src/openrct2/scripting/bindings/ride/ScTrackIterator.cpp b/src/openrct2/scripting/bindings/ride/ScTrackIterator.cpp index 3209600e80..e1953fe07d 100644 --- a/src/openrct2/scripting/bindings/ride/ScTrackIterator.cpp +++ b/src/openrct2/scripting/bindings/ride/ScTrackIterator.cpp @@ -61,7 +61,7 @@ DukValue ScTrackIterator::segment_get() const auto ctx = scriptEngine.GetContext(); if (_type >= TrackElemType::Count) - return ToDuk(ctx, undefined); + return ToDuk(ctx, nullptr); return GetObjectAsDukValue(ctx, std::make_shared(_type)); } @@ -77,7 +77,7 @@ DukValue ScTrackIterator::previousPosition_get() const auto el = map_get_track_element_at_of_type_seq(pos, _type, 0); if (el == nullptr) - return ToDuk(ctx, undefined); + return ToDuk(ctx, nullptr); auto posEl = CoordsXYE(pos.x, pos.y, reinterpret_cast(el)); track_begin_end tbe{}; @@ -97,7 +97,7 @@ DukValue ScTrackIterator::nextPosition_get() const auto el = map_get_track_element_at_of_type_seq(pos, _type, 0); if (el == nullptr) - return ToDuk(ctx, undefined); + return ToDuk(ctx, nullptr); auto posEl = CoordsXYE(_position.x, _position.y, reinterpret_cast(el)); CoordsXYE next;