forked from rosebudai/OpenRCT2-Web
Refactor checks for station pieces (#11876)
This commit is contained in:
1 parent
d145b64ab8
commit
f21ddb0723
12 files changed
+49
-52
No files matched your search
@@ -284,7 +284,7 @@ int32_t viewport_interaction_get_item_right(const ScreenCoordsXY& screenCoords,
|
||||
}
|
||||
ft.Add<rct_string_id>(stringId);
|
||||
}
|
||||
else if (track_element_is_station(tileElement))
|
||||
else if (tileElement->AsTrack()->IsStation())
|
||||
{
|
||||
rct_string_id stringId;
|
||||
if (ride->num_stations > 1)
|
||||
|
||||
@@ -1922,7 +1922,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
int16_t sequenceNumber = trackElement->GetSequenceIndex();
|
||||
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_TRACK_PIECE_ID, &trackType, COLOUR_WHITE, x, y + 33);
|
||||
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_TRACK_SEQUENCE, &sequenceNumber, COLOUR_WHITE, x, y + 44);
|
||||
if (track_element_is_station(tileElement))
|
||||
if (trackElement->IsStation())
|
||||
{
|
||||
int16_t stationIndex = trackElement->GetStationIndex();
|
||||
auto ft = Formatter::Common();
|
||||
|
||||
@@ -2203,17 +2203,7 @@ bool Staff::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride* ride)
|
||||
}
|
||||
|
||||
uint8_t trackType = vehicle->track_type >> 2;
|
||||
if (trackType == TRACK_ELEM_END_STATION)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (trackType == TRACK_ELEM_BEGIN_STATION)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (trackType == TRACK_ELEM_MIDDLE_STATION)
|
||||
if (track_type_is_station(trackType))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -2453,7 +2443,7 @@ bool Staff::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride)
|
||||
track_begin_end trackBeginEnd;
|
||||
while (track_block_get_previous(input, &trackBeginEnd))
|
||||
{
|
||||
if (track_element_is_station(trackBeginEnd.begin_element))
|
||||
if (trackBeginEnd.begin_element->AsTrack()->IsStation())
|
||||
{
|
||||
input.x = trackBeginEnd.begin_x;
|
||||
input.y = trackBeginEnd.begin_y;
|
||||
|
||||
@@ -221,8 +221,7 @@ uint8_t RCT12TrackElement::GetColourScheme() const
|
||||
|
||||
uint8_t RCT12TrackElement::GetStationIndex() const
|
||||
{
|
||||
if (trackType == TRACK_ELEM_END_STATION || trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION
|
||||
|| trackType == TRACK_ELEM_TOWER_BASE)
|
||||
if (track_type_is_station(trackType) || trackType == TRACK_ELEM_TOWER_BASE)
|
||||
{
|
||||
return (sequence & RCT12_TRACK_ELEMENT_SEQUENCE_STATION_INDEX_MASK) >> 4;
|
||||
}
|
||||
@@ -255,7 +254,7 @@ uint8_t RCT12TrackElement::GetBrakeBoosterSpeed() const
|
||||
|
||||
bool RCT12TrackElement::HasGreenLight() const
|
||||
{
|
||||
if (trackType == TRACK_ELEM_END_STATION || trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION)
|
||||
if (track_type_is_station(trackType))
|
||||
{
|
||||
return (sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT) != 0;
|
||||
}
|
||||
@@ -753,8 +752,7 @@ void RCT12TrackElement::SetSequenceIndex(uint8_t newSequenceIndex)
|
||||
|
||||
void RCT12TrackElement::SetStationIndex(uint8_t newStationIndex)
|
||||
{
|
||||
if (trackType == TRACK_ELEM_END_STATION || trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION
|
||||
|| trackType == TRACK_ELEM_TOWER_BASE)
|
||||
if (track_type_is_station(trackType) || trackType == TRACK_ELEM_TOWER_BASE)
|
||||
{
|
||||
sequence &= ~RCT12_TRACK_ELEMENT_SEQUENCE_STATION_INDEX_MASK;
|
||||
sequence |= (newStationIndex << 4);
|
||||
@@ -819,7 +817,7 @@ void RCT12TrackElement::SetBlockBrakeClosed(bool isClosed)
|
||||
|
||||
void RCT12TrackElement::SetHasGreenLight(uint8_t greenLight)
|
||||
{
|
||||
if (trackType == TRACK_ELEM_END_STATION || trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION)
|
||||
if (track_type_is_station(trackType))
|
||||
{
|
||||
sequence &= ~MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
|
||||
if (greenLight)
|
||||
|
||||
@@ -3414,7 +3414,7 @@ void ride_set_map_tooltip(TileElement* tileElement)
|
||||
}
|
||||
else if (tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK)
|
||||
{
|
||||
if (track_element_is_station(tileElement))
|
||||
if (tileElement->AsTrack()->IsStation())
|
||||
{
|
||||
ride_station_set_map_tooltip(tileElement);
|
||||
}
|
||||
@@ -6222,12 +6222,9 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(const ScreenC
|
||||
if (tileElement->AsTrack()->GetStationIndex() != gRideEntranceExitPlaceStationIndex)
|
||||
continue;
|
||||
|
||||
switch (tileElement->AsTrack()->GetTrackType())
|
||||
if (tileElement->AsTrack()->IsStation())
|
||||
{
|
||||
case TRACK_ELEM_END_STATION:
|
||||
case TRACK_ELEM_BEGIN_STATION:
|
||||
case TRACK_ELEM_MIDDLE_STATION:
|
||||
goToNextTile = true;
|
||||
goToNextTile = true;
|
||||
}
|
||||
} while (!goToNextTile && !(tileElement++)->IsLastForTile());
|
||||
|
||||
@@ -7228,7 +7225,7 @@ TileElement* get_station_platform(int32_t x, int32_t y, int32_t z, int32_t z_tol
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
/* Check if tileElement is a station platform. */
|
||||
if (!track_element_is_station(tileElement))
|
||||
if (!tileElement->AsTrack()->IsStation())
|
||||
continue;
|
||||
|
||||
if (z - z_tolerance > tileElement->base_height || z + z_tolerance < tileElement->base_height)
|
||||
|
||||
@@ -684,10 +684,7 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
|
||||
}
|
||||
else
|
||||
{
|
||||
trackType = tileElement->AsTrack()->GetTrackType();
|
||||
bool isStation
|
||||
= (trackType == TRACK_ELEM_END_STATION || trackType == TRACK_ELEM_MIDDLE_STATION
|
||||
|| trackType == TRACK_ELEM_BEGIN_STATION);
|
||||
bool isStation = tileElement->AsTrack()->IsStation();
|
||||
if (tileElement->clearance_height == inputTileElement->base_height)
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_OWN_TRACK_TOUCH_ABOVE);
|
||||
|
||||
@@ -611,7 +611,7 @@ static TileElement* find_station_element(const CoordsXYZD& loc, ride_id_t rideIn
|
||||
continue;
|
||||
if (tileElement->AsTrack()->GetRideIndex() != rideIndex)
|
||||
continue;
|
||||
if (!track_element_is_station(tileElement))
|
||||
if (!tileElement->AsTrack()->IsStation())
|
||||
continue;
|
||||
|
||||
return tileElement;
|
||||
@@ -1163,9 +1163,14 @@ int32_t track_get_actual_bank_3(Vehicle* vehicle, TileElement* tileElement)
|
||||
return track_get_actual_bank_2(ride->type, isInverted, bankStart);
|
||||
}
|
||||
|
||||
bool track_element_is_station(TileElement* trackElement)
|
||||
bool TrackElement::IsStation() const
|
||||
{
|
||||
switch (trackElement->AsTrack()->GetTrackType())
|
||||
return track_type_is_station(GetTrackType());
|
||||
}
|
||||
|
||||
bool track_type_is_station(track_type_t trackType)
|
||||
{
|
||||
switch (trackType)
|
||||
{
|
||||
case TRACK_ELEM_END_STATION:
|
||||
case TRACK_ELEM_BEGIN_STATION:
|
||||
|
||||
@@ -554,7 +554,7 @@ void track_get_front(CoordsXYE* input, CoordsXYE* output);
|
||||
|
||||
bool track_element_is_block_start(TileElement* trackElement);
|
||||
bool track_element_is_covered(int32_t trackElementType);
|
||||
bool track_element_is_station(TileElement* trackElement);
|
||||
bool track_type_is_station(track_type_t trackType);
|
||||
|
||||
int32_t track_get_actual_bank(TileElement* tileElement, int32_t bank);
|
||||
int32_t track_get_actual_bank_2(int32_t rideType, bool isInverted, int32_t bank);
|
||||
|
||||
@@ -6988,16 +6988,10 @@ void Vehicle::UpdateSwingingCar()
|
||||
break;
|
||||
}
|
||||
|
||||
switch (trackType)
|
||||
if (track_type_is_station(trackType) || trackType == TRACK_ELEM_BRAKES || trackType == TRACK_ELEM_BLOCK_BRAKES)
|
||||
{
|
||||
case TRACK_ELEM_END_STATION:
|
||||
case TRACK_ELEM_BEGIN_STATION:
|
||||
case TRACK_ELEM_MIDDLE_STATION:
|
||||
case TRACK_ELEM_BRAKES:
|
||||
case TRACK_ELEM_BLOCK_BRAKES:
|
||||
dx = 0;
|
||||
cx = 0;
|
||||
break;
|
||||
dx = 0;
|
||||
cx = 0;
|
||||
}
|
||||
|
||||
if (UpdateFlag(VEHICLE_UPDATE_FLAG_ON_LIFT_HILL))
|
||||
@@ -8088,7 +8082,7 @@ loc_6DB41D:
|
||||
}
|
||||
else if (ride->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING)
|
||||
{
|
||||
if (track_element_is_station(tileElement))
|
||||
if (tileElement->AsTrack()->IsStation())
|
||||
{
|
||||
VehicleUpdateGoKartAttemptSwitchLanes(vehicle);
|
||||
}
|
||||
@@ -9941,9 +9935,7 @@ void Vehicle::UpdateCrossings() const
|
||||
xyElement.element = output.begin_element;
|
||||
}
|
||||
|
||||
if (xyElement.element->AsTrack()->GetTrackType() == TRACK_ELEM_BEGIN_STATION
|
||||
|| xyElement.element->AsTrack()->GetTrackType() == TRACK_ELEM_MIDDLE_STATION
|
||||
|| xyElement.element->AsTrack()->GetTrackType() == TRACK_ELEM_END_STATION)
|
||||
if (xyElement.element->AsTrack()->IsStation())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -370,6 +370,8 @@ public:
|
||||
uint8_t GetDoorBState() const;
|
||||
void SetDoorAState(uint8_t newState);
|
||||
void SetDoorBState(uint8_t newState);
|
||||
|
||||
bool IsStation() const;
|
||||
};
|
||||
assert_struct_size(TrackElement, 16);
|
||||
|
||||
|
||||
@@ -495,3 +495,21 @@ CoordsXYZ RideStation::GetStart() const
|
||||
TileCoordsXYZ stationTileCoords{ Start.x, Start.y, Height };
|
||||
return stationTileCoords.ToCoordsXYZ();
|
||||
}
|
||||
|
||||
bool TrackElement::IsStation() const
|
||||
{
|
||||
return track_type_is_station(GetTrackType());
|
||||
}
|
||||
|
||||
bool track_type_is_station(track_type_t trackType)
|
||||
{
|
||||
switch (trackType)
|
||||
{
|
||||
case TRACK_ELEM_END_STATION:
|
||||
case TRACK_ELEM_BEGIN_STATION:
|
||||
case TRACK_ELEM_MIDDLE_STATION:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -150,8 +150,7 @@ class EntranceStyleFilter : public ITestTrackFilter
|
||||
public:
|
||||
bool AppliesTo(uint8_t rideType, uint8_t trackType) override
|
||||
{
|
||||
if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION
|
||||
|| trackType == TRACK_ELEM_END_STATION)
|
||||
if (track_type_is_station(trackType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -222,8 +221,7 @@ uint8_t TestTrack::TestPaintTrackElement(uint8_t rideType, uint8_t trackType, st
|
||||
|
||||
if (rideType == RIDE_TYPE_CHAIRLIFT)
|
||||
{
|
||||
if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION
|
||||
|| trackType == TRACK_ELEM_END_STATION)
|
||||
if (track_type_is_station(trackType))
|
||||
{
|
||||
// These rides check neighbouring tiles for tracks
|
||||
return TEST_SKIPPED;
|
||||
|
||||
Reference in new issue
Block a user