1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 12:33:17 +01:00

Merge pull request #15414 from frutiemax/develop

#15367: Encode RideType in TrackElement
This commit is contained in:
Michael Steenbeek
2021-09-25 12:02:08 +02:00
committed by GitHub
11 changed files with 41 additions and 18 deletions

View File

@@ -2444,6 +2444,7 @@ static void sub_6CBCE2(
_tempTrackTileElement.SetBaseZ(baseZ);
_tempTrackTileElement.SetClearanceZ(clearanceZ);
_tempTrackTileElement.AsTrack()->SetTrackType(trackType);
_tempTrackTileElement.AsTrack()->SetRideType(ride->type);
_tempTrackTileElement.AsTrack()->SetSequenceIndex(trackBlock->index);
_tempTrackTileElement.AsTrack()->SetHasCableLift(false);
_tempTrackTileElement.AsTrack()->SetInverted((liftHillAndInvertedState & CONSTRUCTION_INVERTED_TRACK_SELECTED) != 0);

View File

@@ -1928,28 +1928,31 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
case TILE_ELEMENT_TYPE_TRACK:
{
// Details
// Ride
auto trackElement = tileElement->AsTrack();
ride_id_t rideId = trackElement->GetRideIndex();
auto ride = get_ride(rideId);
if (ride != nullptr)
{
auto ft = Formatter();
ft.Add<rct_string_id>(ride->GetRideTypeDescriptor().Naming.Name);
DrawTextBasic(dpi, screenCoords, STR_TILE_INSPECTOR_TRACK_RIDE_TYPE, ft, { COLOUR_WHITE });
}
// Ride ID
auto ft = Formatter();
ft.Add<int16_t>(trackElement->GetRideIndex());
DrawTextBasic(
dpi, screenCoords + ScreenCoordsXY{ 0, 11 }, STR_TILE_INSPECTOR_TRACK_RIDE_ID, ft, { COLOUR_WHITE });
ft.Add<int16_t>(rideId);
DrawTextBasic(dpi, screenCoords, STR_TILE_INSPECTOR_TRACK_RIDE_ID, ft, { COLOUR_WHITE });
// Ride name
if (ride != nullptr)
{
ft = Formatter();
ride->FormatNameTo(ft);
DrawTextBasic(
dpi, screenCoords + ScreenCoordsXY{ 0, 22 }, STR_TILE_INSPECTOR_TRACK_RIDE_NAME, ft, { COLOUR_WHITE });
dpi, screenCoords + ScreenCoordsXY{ 0, 11 }, STR_TILE_INSPECTOR_TRACK_RIDE_NAME, ft, { COLOUR_WHITE });
}
// Ride type. Individual pieces may be of a different ride type from the ride it belongs to.
const auto& rtd = GetRideTypeDescriptor(trackElement->GetRideType());
ft = Formatter();
ft.Add<rct_string_id>(rtd.Naming.Name);
DrawTextBasic(
dpi, screenCoords + ScreenCoordsXY{ 0, 22 }, STR_TILE_INSPECTOR_TRACK_RIDE_TYPE, ft, { COLOUR_WHITE });
// Track
ft = Formatter();
ft.Add<track_type_t>(trackElement->GetTrackType());

View File

@@ -168,6 +168,7 @@ GameActions::Result::Ptr MazePlaceTrackAction::Execute() const
trackElement->SetClearanceZ(clearanceHeight);
trackElement->SetTrackType(TrackElemType::Maze);
trackElement->SetRideType(ride->type);
trackElement->SetRideIndex(_rideIndex);
trackElement->SetMazeEntry(_mazeEntry);
trackElement->SetGhost(flags & GAME_COMMAND_FLAG_GHOST);

View File

@@ -183,6 +183,7 @@ GameActions::Result::Ptr MazeSetTrackAction::Execute() const
trackElement->SetClearanceZ(_loc.z + MAZE_CLEARANCE_HEIGHT);
trackElement->SetTrackType(TrackElemType::Maze);
trackElement->SetRideType(ride->type);
trackElement->SetRideIndex(_rideIndex);
trackElement->SetMazeEntry(0xFFFF);
trackElement->SetGhost(flags & GAME_COMMAND_FLAG_GHOST);

View File

@@ -561,6 +561,7 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const
trackElement->SetSequenceIndex(trackBlock->index);
trackElement->SetRideIndex(_rideIndex);
trackElement->SetTrackType(_trackType);
trackElement->SetRideType(ride->type);
trackElement->SetGhost(GetFlags() & GAME_COMMAND_FLAG_GHOST);
switch (_trackType)

View File

@@ -1631,6 +1631,7 @@ namespace RCT1
auto rideType = (ride != nullptr) ? ride->type : RIDE_TYPE_NULL;
dst2->SetTrackType(RCT1TrackTypeToOpenRCT2(src2->GetTrackType(), rideType));
dst2->SetRideType(rideType);
dst2->SetSequenceIndex(src2->GetSequenceIndex());
dst2->SetRideIndex(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
dst2->SetColourScheme(src2->GetColourScheme());

View File

@@ -1198,7 +1198,8 @@ public:
auto rideType = _s6.rides[src2->GetRideIndex()].type;
track_type_t trackType = static_cast<track_type_t>(src2->GetTrackType());
dst2->SetTrackType(RCT2TrackTypeToOpenRCT2(trackType, _s6.rides[src2->GetRideIndex()].type));
dst2->SetTrackType(RCT2TrackTypeToOpenRCT2(trackType, rideType));
dst2->SetRideType(rideType);
dst2->SetSequenceIndex(src2->GetSequenceIndex());
dst2->SetRideIndex(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
dst2->SetColourScheme(src2->GetColourScheme());

View File

@@ -20,6 +20,8 @@ struct Ride;
constexpr const ride_id_t RIDE_ID_NULL = static_cast<ride_id_t>(std::numeric_limits<std::underlying_type_t<ride_id_t>>::max());
using ride_type_t = uint16_t;
/**
* Couples a ride type and subtype together.
*/

View File

@@ -730,6 +730,16 @@ void TrackElement::SetTrackType(uint16_t newType)
TrackType = newType;
}
ride_type_t TrackElement::GetRideType() const
{
return RideType;
}
void TrackElement::SetRideType(const ride_type_t rideType)
{
RideType = rideType;
}
uint8_t TrackElement::GetSequenceIndex() const
{
return Sequence;

View File

@@ -2277,7 +2277,9 @@ void PaintTrack(paint_session* session, Direction direction, int32_t height, con
{
return;
}
TRACK_PAINT_FUNCTION_GETTER paintFunctionGetter = ride->GetRideTypeDescriptor().TrackPaintFunction;
const auto& rtd = GetRideTypeDescriptor(trackElement.GetRideType());
TRACK_PAINT_FUNCTION_GETTER paintFunctionGetter = rtd.TrackPaintFunction;
if (paintFunctionGetter != nullptr)
{
TRACK_PAINT_FUNCTION paintFunction = paintFunctionGetter(trackType);

View File

@@ -378,15 +378,15 @@ private:
};
uint8_t Flags2;
ride_id_t RideIndex;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
uint8_t pad[2];
#pragma clang diagnostic pop
ride_type_t RideType;
public:
track_type_t GetTrackType() const;
void SetTrackType(track_type_t newEntryIndex);
ride_type_t GetRideType() const;
void SetRideType(const ride_type_t rideType);
uint8_t GetSequenceIndex() const;
void SetSequenceIndex(uint8_t newSequenceIndex);