Change track segment API to use null

This commit is contained in:
Ted John committed 2022-05-17 19:33:04 +01:00
1 parent 7af322f8eb
commit 31764f62c6
3 files changed
+9 -9

No files matched your search

+5 -5
View File
@@ -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.
@@ -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
{
@@ -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<ScTrackSegment>(_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<TileElement*>(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<TileElement*>(el));
CoordsXYE next;