Use 16-bit ride_id_t thoughout and raise RIDE_ID_NULL (#14411)

* Replace RIDE_ENTRY_INDEX_NULL with OBJECT_ENTRY_INDEX_NULL

Ride entries are objects like any other, so there is little point having separate constants.

* Use ride_id_t in many more places

* Change RIDE_ID_NULL to 0xFFFF

* Increment network version

* Update replays

Co-authored-by: duncanspumpkin <duncans_pumpkin@hotmail.co.uk>
This commit is contained in:
Michael Steenbeek 2021-04-01 17:02:57 +02:00 committed by GitHub
parent cbefc4fe38
commit 7344b7fbfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 80 additions and 81 deletions

View File

@ -48,8 +48,8 @@ set(TITLE_SEQUENCE_SHA1 "304d13a126c15bf2c86ff13b81a2f2cc1856ac8d")
set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip")
set(OBJECTS_SHA1 "c38af45d51a6e440386180feacf76c64720b6ac5")
set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.36/replays.zip")
set(REPLAYS_SHA1 "F539E5BD4F5062C2972C6E0DA974318DB01A0308")
set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.37/replays.zip")
set(REPLAYS_SHA1 "C31C299539EB86DA013AEE47C9B2B2F4609F52C4")
option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.")
option(WITH_TESTS "Build tests")

View File

@ -48,8 +48,8 @@
<TitleSequencesSha1>304d13a126c15bf2c86ff13b81a2f2cc1856ac8d</TitleSequencesSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip</ObjectsUrl>
<ObjectsSha1>c38af45d51a6e440386180feacf76c64720b6ac5</ObjectsSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.36/replays.zip</ReplaysUrl>
<ReplaysSha1>F539E5BD4F5062C2972C6E0DA974318DB01A0308</ReplaysSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.37/replays.zip</ReplaysUrl>
<ReplaysSha1>C31C299539EB86DA013AEE47C9B2B2F4609F52C4</ReplaysSha1>
</PropertyGroup>
<ItemGroup>

View File

@ -91,7 +91,7 @@ InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& screenCoord
case EntityType::Vehicle:
{
auto vehicle = sprite->As<Vehicle>();
if (vehicle != nullptr && vehicle->ride_subtype != RIDE_ENTRY_INDEX_NULL)
if (vehicle != nullptr && vehicle->ride_subtype != OBJECT_ENTRY_INDEX_NULL)
vehicle->SetMapToolbar();
else
info.SpriteType = ViewportInteractionItem::None;

View File

@ -312,7 +312,7 @@ static void window_new_ride_populate_list()
}
nextListItem->Type = RIDE_TYPE_NULL;
nextListItem->EntryIndex = RIDE_ENTRY_INDEX_NULL;
nextListItem->EntryIndex = OBJECT_ENTRY_INDEX_NULL;
}
static RideSelection* window_new_ride_iterate_over_ride_type(uint8_t rideType, RideSelection* nextListItem)
@ -392,7 +392,7 @@ static void window_new_ride_scroll_to_focused_ride(rct_window* w)
auto focusRideType = _windowNewRideHighlightedItem[_windowNewRideCurrentTab];
int32_t count = 0, row = 0;
RideSelection* listItem = _windowNewRideListItems;
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != OBJECT_ENTRY_INDEX_NULL)
{
if (listItem->Type == focusRideType.Type)
{
@ -436,9 +436,9 @@ rct_window* window_new_ride_open()
WindowInitScrollWidgets(w);
w->frame_no = 0;
w->new_ride.SelectedRide = { RIDE_TYPE_NULL, RIDE_ENTRY_INDEX_NULL };
w->new_ride.SelectedRide = { RIDE_TYPE_NULL, OBJECT_ENTRY_INDEX_NULL };
_lastTrackDesignCountRideType.Type = RIDE_TYPE_NULL;
_lastTrackDesignCountRideType.EntryIndex = RIDE_ENTRY_INDEX_NULL;
_lastTrackDesignCountRideType.EntryIndex = OBJECT_ENTRY_INDEX_NULL;
w->new_ride.HighlightedRide = _windowNewRideHighlightedItem[_windowNewRideCurrentTab];
if (w->new_ride.HighlightedRide.Type == RIDE_TYPE_NULL)
w->new_ride.HighlightedRide = _windowNewRideListItems[0];
@ -516,7 +516,7 @@ static void window_new_ride_set_page(rct_window* w, int32_t page)
{
_windowNewRideCurrentTab = page;
w->frame_no = 0;
w->new_ride.HighlightedRide = { RIDE_TYPE_NULL, RIDE_ENTRY_INDEX_NULL };
w->new_ride.HighlightedRide = { RIDE_TYPE_NULL, OBJECT_ENTRY_INDEX_NULL };
w->new_ride.selected_ride_countdown = std::numeric_limits<uint16_t>::max();
window_new_ride_populate_list();
if (page < WINDOW_NEW_RIDE_PAGE_RESEARCH)
@ -689,7 +689,7 @@ static void window_new_ride_scrollgetsize(rct_window* w, int32_t scrollIndex, in
RideSelection* listItem = _windowNewRideListItems;
int32_t count = 0;
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != OBJECT_ENTRY_INDEX_NULL)
{
count++;
listItem++;
@ -706,7 +706,7 @@ static void window_new_ride_scrollmousedown(rct_window* w, int32_t scrollIndex,
RideSelection item;
item = window_new_ride_scroll_get_ride_list_item_at(w, screenCoords);
if (item.Type == RIDE_TYPE_NULL && item.EntryIndex == RIDE_ENTRY_INDEX_NULL)
if (item.Type == RIDE_TYPE_NULL && item.EntryIndex == OBJECT_ENTRY_INDEX_NULL)
return;
_windowNewRideHighlightedItem[_windowNewRideCurrentTab] = item;
@ -777,7 +777,7 @@ static void window_new_ride_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
RideSelection item;
item = w->new_ride.HighlightedRide;
if (item.Type != RIDE_TYPE_NULL || item.EntryIndex != RIDE_ENTRY_INDEX_NULL)
if (item.Type != RIDE_TYPE_NULL || item.EntryIndex != OBJECT_ENTRY_INDEX_NULL)
window_new_ride_paint_ride_information(
w, dpi, item, w->windowPos + ScreenCoordsXY{ 3, w->height - 64 }, w->width - 6);
}
@ -800,7 +800,7 @@ static void window_new_ride_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i
ScreenCoordsXY coords{ 1, 1 };
RideSelection* listItem = _windowNewRideListItems;
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != OBJECT_ENTRY_INDEX_NULL)
{
rct_ride_entry* rideEntry;
// Draw flat button rectangle
@ -846,7 +846,7 @@ static RideSelection window_new_ride_scroll_get_ride_list_item_at(rct_window* w,
{
RideSelection result;
result.Type = RIDE_TYPE_NULL;
result.EntryIndex = RIDE_ENTRY_INDEX_NULL;
result.EntryIndex = OBJECT_ENTRY_INDEX_NULL;
if (screenCoords.x <= 0 || screenCoords.y <= 0)
return result;
@ -859,7 +859,7 @@ static RideSelection window_new_ride_scroll_get_ride_list_item_at(rct_window* w,
int32_t index = column + (row * 5);
RideSelection* listItem = _windowNewRideListItems;
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != RIDE_ENTRY_INDEX_NULL)
while (listItem->Type != RIDE_TYPE_NULL || listItem->EntryIndex != OBJECT_ENTRY_INDEX_NULL)
{
if (index-- == 0)
return *listItem;

View File

@ -96,7 +96,7 @@ static rct_window_event_list window_track_place_events([](auto& events)
static std::vector<uint8_t> _window_track_place_mini_preview;
static CoordsXY _windowTrackPlaceLast;
static uint8_t _window_track_place_ride_index;
static ride_id_t _window_track_place_ride_index;
static bool _window_track_place_last_was_valid;
static CoordsXYZ _windowTrackPlaceLastValid;
static money32 _window_track_place_last_cost;

View File

@ -206,7 +206,7 @@ void setup_in_use_selection_flags()
for (auto* vehicle : TrainManager::View())
{
ObjectEntryIndex type = vehicle->ride_subtype;
if (type != RIDE_ENTRY_INDEX_NULL) // cable lifts use index null. Ignore them
if (type != OBJECT_ENTRY_INDEX_NULL) // cable lifts use index null. Ignore them
{
Editor::SetSelectedObject(ObjectType::Ride, type, OBJECT_SELECTION_FLAG_SELECTED);
}
@ -214,7 +214,7 @@ void setup_in_use_selection_flags()
for (auto vehicle : EntityList<Vehicle>())
{
ObjectEntryIndex type = vehicle->ride_subtype;
if (type != RIDE_ENTRY_INDEX_NULL) // cable lifts use index null. Ignore them
if (type != OBJECT_ENTRY_INDEX_NULL) // cable lifts use index null. Ignore them
{
Editor::SetSelectedObject(ObjectType::Ride, type, OBJECT_SELECTION_FLAG_SELECTED);
}

View File

@ -23,8 +23,8 @@ public:
DEFINE_GAME_ACTION(RideCreateAction, GameCommand::CreateRide, RideCreateGameActionResult)
{
private:
int32_t _rideType{ RIDE_ID_NULL };
ObjectEntryIndex _subType{ RIDE_ENTRY_INDEX_NULL };
ObjectEntryIndex _rideType{ OBJECT_ENTRY_INDEX_NULL };
ObjectEntryIndex _subType{ OBJECT_ENTRY_INDEX_NULL };
uint8_t _colour1{ 0xFF };
uint8_t _colour2{ 0xFF };

View File

@ -14,7 +14,7 @@
DEFINE_GAME_ACTION(RideDemolishAction, GameCommand::DemolishRide, GameActions::Result)
{
private:
NetworkRideId_t _rideIndex{ RideIdNewNull };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
uint8_t _modifyType{ RIDE_MODIFY_DEMOLISH };
public:

View File

@ -27,7 +27,7 @@ enum class RideSetAppearanceType : uint8_t
DEFINE_GAME_ACTION(RideSetAppearanceAction, GameCommand::SetRideAppearance, GameActions::Result)
{
private:
NetworkRideId_t _rideIndex{ RideIdNewNull };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
RideSetAppearanceType _type{};
uint8_t _value{};
uint32_t _index{};

View File

@ -14,7 +14,7 @@
DEFINE_GAME_ACTION(RideSetNameAction, GameCommand::SetRideName, GameActions::Result)
{
private:
NetworkRideId_t _rideIndex{ RideIdNewNull };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
std::string _name;
public:

View File

@ -14,7 +14,7 @@
DEFINE_GAME_ACTION(RideSetPriceAction, GameCommand::SetRidePrice, GameActions::Result)
{
private:
NetworkRideId_t _rideIndex{ RideIdNewNull };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
money16 _price{ MONEY16_UNDEFINED };
bool _primaryPrice{ true };

View File

@ -29,7 +29,7 @@ enum class RideSetSetting : uint8_t
DEFINE_GAME_ACTION(RideSetSettingAction, GameCommand::SetRideSetting, GameActions::Result)
{
private:
NetworkRideId_t _rideIndex{ RideIdNewNull };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
RideSetSetting _setting{};
uint8_t _value{};

View File

@ -14,7 +14,7 @@
DEFINE_GAME_ACTION(RideSetStatusAction, GameCommand::SetRideStatus, GameActions::Result)
{
private:
NetworkRideId_t _rideIndex{ RideIdNewNull };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
uint8_t _status{ RIDE_STATUS_CLOSED };
public:

View File

@ -22,7 +22,7 @@ enum class RideSetVehicleType : uint8_t
DEFINE_GAME_ACTION(RideSetVehicleAction, GameCommand::SetRideVehicles, GameActions::Result)
{
private:
NetworkRideId_t _rideIndex{ RideIdNewNull };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
RideSetVehicleType _type{};
uint8_t _value{};
uint8_t _colour{};

View File

@ -25,7 +25,7 @@ public:
DEFINE_GAME_ACTION(TrackPlaceAction, GameCommand::PlaceTrack, TrackPlaceActionResult)
{
private:
NetworkRideId_t _rideIndex{ RideIdNewNull };
NetworkRideId_t _rideIndex{ RIDE_ID_NULL };
int32_t _trackType{};
CoordsXYZD _origin;
int32_t _brakeSpeed{};

View File

@ -36,7 +36,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "7"
#define NETWORK_STREAM_VERSION "8"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;

View File

@ -228,7 +228,7 @@ static void peep_decide_whether_to_leave_park(Peep* peep);
static void peep_leave_park(Peep* peep);
static void peep_head_for_nearest_ride_type(Guest* peep, int32_t rideType);
static void peep_head_for_nearest_ride_with_flags(Guest* peep, int32_t rideTypeFlags);
bool loc_690FD0(Peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement);
bool loc_690FD0(Peep* peep, ride_id_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement);
template<> bool SpriteBase::Is<Guest>() const
{
@ -4960,7 +4960,7 @@ void Guest::UpdateRide()
}
static void peep_update_walking_break_scenery(Peep* peep);
static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToView, uint8_t* rideSeatToView);
static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, ride_id_t* rideToView, uint8_t* rideSeatToView);
/**
*
@ -5174,7 +5174,8 @@ void Guest::UpdateWalking()
for (; !(edges & (1 << chosen_edge));)
chosen_edge = (chosen_edge + 1) & 3;
uint8_t ride_to_view, ride_seat_to_view;
ride_id_t ride_to_view;
uint8_t ride_seat_to_view;
if (!peep_find_ride_to_look_at(this, chosen_edge, &ride_to_view, &ride_seat_to_view))
return;
@ -5976,7 +5977,7 @@ static bool peep_should_watch_ride(TileElement* tileElement)
return true;
}
bool loc_690FD0(Peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement)
bool loc_690FD0(Peep* peep, ride_id_t* rideToView, uint8_t* rideSeatToView, TileElement* tileElement)
{
auto ride = get_ride(tileElement->AsTrack()->GetRideIndex());
if (ride == nullptr)
@ -6023,7 +6024,7 @@ bool loc_690FD0(Peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileEl
* @param[out] rideSeatToView (ch)
* @return !CF
*/
static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToView, uint8_t* rideSeatToView)
static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, ride_id_t* rideToView, uint8_t* rideSeatToView)
{
TileElement* tileElement;

View File

@ -575,7 +575,7 @@ private:
void AddEntryForRideType(uint8_t rideType)
{
assert(rideType < std::size(_rideTypeToRideEntryMap));
if (_rideTypeToRideEntryMap[rideType] == RIDE_ENTRY_INDEX_NULL)
if (_rideTypeToRideEntryMap[rideType] == OBJECT_ENTRY_INDEX_NULL)
{
const char* entryName = RCT1::GetRideTypeObject(rideType);
if (!String::Equals(entryName, " "))
@ -589,7 +589,7 @@ private:
void AddEntryForVehicleType(uint8_t rideType, uint8_t vehicleType)
{
assert(vehicleType < std::size(_vehicleTypeToRideEntryMap));
if (_vehicleTypeToRideEntryMap[vehicleType] == RIDE_ENTRY_INDEX_NULL)
if (_vehicleTypeToRideEntryMap[vehicleType] == OBJECT_ENTRY_INDEX_NULL)
{
const char* entryName = RCT1::GetVehicleObject(vehicleType);
if (!String::Equals(entryName, " "))
@ -1075,7 +1075,7 @@ private:
{
if (src.ride_index != RCT12_RIDE_ID_NULL)
{
auto ride = get_ride(src.ride_index);
auto ride = get_ride(RCT12RideIdToOpenRCT2RideId(src.ride_index));
if (ride != nullptr)
{
ride->measurement = std::make_unique<RideMeasurement>();
@ -1475,7 +1475,7 @@ private:
campaign.WeeksLeft = _s4.marketing_status[i] & ~CAMPAIGN_ACTIVE_FLAG;
if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE)
{
campaign.RideId = _s4.marketing_assoc[i];
campaign.RideId = RCT12RideIdToOpenRCT2RideId(_s4.marketing_assoc[i]);
}
else if (campaign.Type == ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE)
{
@ -1672,7 +1672,7 @@ private:
dst2->SetQueueBannerDirection(src2->GetQueueBannerDirection());
dst2->SetSloped(src2->IsSloped());
dst2->SetSlopeDirection(src2->GetSlopeDirection());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
dst2->SetStationIndex(src2->GetStationIndex());
dst2->SetWide(src2->IsWide());
dst2->SetHasQueueBanner(src2->HasQueueBanner());
@ -1739,12 +1739,12 @@ private:
{
auto dst2 = dst->AsTrack();
auto src2 = src->AsTrack();
const auto* ride = get_ride(src2->GetRideIndex());
const auto* ride = get_ride(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
auto rideType = (ride != nullptr) ? ride->type : RIDE_TYPE_NULL;
dst2->SetTrackType(RCT1TrackTypeToOpenRCT2(src2->GetTrackType(), rideType));
dst2->SetSequenceIndex(src2->GetSequenceIndex());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
dst2->SetColourScheme(src2->GetColourScheme());
dst2->SetHasChain(src2->HasChain());
dst2->SetHasCableLift(false);
@ -1822,7 +1822,7 @@ private:
auto src2 = src->AsEntrance();
dst2->SetEntranceType(src2->GetEntranceType());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
dst2->SetStationIndex(src2->GetStationIndex());
dst2->SetSequenceIndex(src2->GetSequenceIndex());
@ -1995,7 +1995,8 @@ private:
_researchRideTypeUsed[rct1RideType] = true;
auto ownRideEntryIndex = _rideTypeToRideEntryMap[rct1RideType];
Guard::Assert(ownRideEntryIndex != RIDE_ENTRY_INDEX_NULL, "ownRideEntryIndex was RIDE_ENTRY_INDEX_NULL");
Guard::Assert(
ownRideEntryIndex != OBJECT_ENTRY_INDEX_NULL, "ownRideEntryIndex was OBJECT_ENTRY_INDEX_NULL");
bool foundOwnType = false;
// If the ride type does not use vehicles, no point looking for them in the research list.
@ -2291,7 +2292,7 @@ private:
{
auto entryIndex = _rideTypeToRideEntryMap[srcItem];
if (entryIndex != RIDE_ENTRY_INDEX_NULL)
if (entryIndex != OBJECT_ENTRY_INDEX_NULL)
{
rct_ride_entry* rideEntry = get_ride_entry(entryIndex);
@ -2310,7 +2311,7 @@ private:
{
auto entryIndex = _vehicleTypeToRideEntryMap[srcItem];
if (entryIndex != RIDE_ENTRY_INDEX_NULL)
if (entryIndex != OBJECT_ENTRY_INDEX_NULL)
{
rct_ride_entry* rideEntry = get_ride_entry(entryIndex);

View File

@ -778,7 +778,7 @@ void S6Exporter::ExportRideRatingsCalcData()
dst.proximity_start_x = src.ProximityStart.x;
dst.proximity_start_y = src.ProximityStart.y;
dst.proximity_start_z = src.ProximityStart.z;
dst.current_ride = src.CurrentRide;
dst.current_ride = OpenRCT2RideIdToRCT12RideId(src.CurrentRide);
dst.state = src.State;
if (src.ProximityTrackType == TrackElemType::None)
dst.proximity_track_type = 0xFF;
@ -928,7 +928,7 @@ void S6Exporter::ExportMarketingCampaigns()
_s6.campaign_weeks_left[campaign.Type] |= CAMPAIGN_FIRST_WEEK_FLAG;
if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE)
{
_s6.campaign_ride_index[campaign.Type] = campaign.RideId;
_s6.campaign_ride_index[campaign.Type] = OpenRCT2RideIdToRCT12RideId(campaign.RideId);
}
else if (campaign.Type == ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE)
{
@ -1528,7 +1528,7 @@ void S6Exporter::ExportBanner(RCT12Banner& dst, const Banner& src)
if (src.flags & BANNER_FLAG_LINKED_TO_RIDE)
{
dst.ride_index = src.ride_index;
dst.ride_index = OpenRCT2RideIdToRCT12RideId(src.ride_index);
}
else
{
@ -1621,7 +1621,7 @@ void S6Exporter::ExportTileElement(RCT12TileElement* dst, TileElement* src)
dst2->SetQueueBannerDirection(src2->GetQueueBannerDirection());
dst2->SetSloped(src2->IsSloped());
dst2->SetSlopeDirection(src2->GetSlopeDirection());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(OpenRCT2RideIdToRCT12RideId(src2->GetRideIndex()));
dst2->SetStationIndex(src2->GetStationIndex());
dst2->SetWide(src2->IsWide());
dst2->SetIsQueue(src2->IsQueue());
@ -1644,7 +1644,7 @@ void S6Exporter::ExportTileElement(RCT12TileElement* dst, TileElement* src)
auto trackType = OpenRCT2TrackTypeToRCT2(src2->GetTrackType());
dst2->SetTrackType(static_cast<uint8_t>(trackType));
dst2->SetSequenceIndex(src2->GetSequenceIndex());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(OpenRCT2RideIdToRCT12RideId(src2->GetRideIndex()));
dst2->SetColourScheme(src2->GetColourScheme());
dst2->SetStationIndex(src2->GetStationIndex());
dst2->SetHasGreenLight(src2->HasGreenLight());
@ -1705,7 +1705,7 @@ void S6Exporter::ExportTileElement(RCT12TileElement* dst, TileElement* src)
auto src2 = src->AsEntrance();
dst2->SetEntranceType(src2->GetEntranceType());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(OpenRCT2RideIdToRCT12RideId(src2->GetRideIndex()));
dst2->SetStationIndex(src2->GetStationIndex());
dst2->SetSequenceIndex(src2->GetSequenceIndex());
dst2->SetPathType(src2->GetPathType());

View File

@ -802,7 +802,7 @@ public:
dst = {};
dst.Proximity = { src.proximity_x, src.proximity_y, src.proximity_z };
dst.ProximityStart = { src.proximity_start_x, src.proximity_start_y, src.proximity_start_z };
dst.CurrentRide = src.current_ride;
dst.CurrentRide = RCT12RideIdToOpenRCT2RideId(src.current_ride);
dst.State = src.state;
if (src.current_ride < RCT12_MAX_RIDES_IN_PARK && _s6.rides[src.current_ride].type < std::size(RideTypeDescriptors))
dst.ProximityTrackType = RCT2TrackTypeToOpenRCT2(src.proximity_track_type, _s6.rides[src.current_ride].type);
@ -942,7 +942,7 @@ public:
if (src->flags & BANNER_FLAG_LINKED_TO_RIDE)
{
dst->ride_index = src->ride_index;
dst->ride_index = RCT12RideIdToOpenRCT2RideId(src->ride_index);
}
else
{
@ -1122,7 +1122,7 @@ public:
dst2->SetQueueBannerDirection(src2->GetQueueBannerDirection());
dst2->SetSloped(src2->IsSloped());
dst2->SetSlopeDirection(src2->GetSlopeDirection());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
dst2->SetStationIndex(src2->GetStationIndex());
dst2->SetWide(src2->IsWide());
dst2->SetIsQueue(src2->IsQueue());
@ -1147,7 +1147,7 @@ public:
dst2->SetTrackType(RCT2TrackTypeToOpenRCT2(trackType, _s6.rides[src2->GetRideIndex()].type));
dst2->SetSequenceIndex(src2->GetSequenceIndex());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
dst2->SetColourScheme(src2->GetColourScheme());
dst2->SetHasChain(src2->HasChain());
dst2->SetHasCableLift(src2->HasCableLift());
@ -1205,7 +1205,7 @@ public:
auto src2 = src->AsEntrance();
dst2->SetEntranceType(src2->GetEntranceType());
dst2->SetRideIndex(src2->GetRideIndex());
dst2->SetRideIndex(RCT12RideIdToOpenRCT2RideId(src2->GetRideIndex()));
dst2->SetStationIndex(src2->GetStationIndex());
dst2->SetSequenceIndex(src2->GetSequenceIndex());
dst2->SetPathType(src2->GetPathType());
@ -1310,7 +1310,7 @@ public:
}
if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE)
{
campaign.RideId = _s6.campaign_ride_index[i];
campaign.RideId = RCT12RideIdToOpenRCT2RideId(_s6.campaign_ride_index[i]);
}
else if (campaign.Type == ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE)
{

View File

@ -26,7 +26,7 @@ Vehicle* cable_lift_segment_create(
{
Vehicle* current = CreateEntity<Vehicle>();
current->ride = ride.id;
current->ride_subtype = RIDE_ENTRY_INDEX_NULL;
current->ride_subtype = OBJECT_ENTRY_INDEX_NULL;
if (head)
{
ride.cable_lift = current->sprite_index;

View File

@ -4430,7 +4430,7 @@ static void ride_create_vehicles_find_first_block(Ride* ride, CoordsXYE* outXYEl
bool Ride::CreateVehicles(const CoordsXYE& element, bool isApplying)
{
UpdateMaxVehicles();
if (subtype == RIDE_ENTRY_INDEX_NULL)
if (subtype == OBJECT_ENTRY_INDEX_NULL)
{
return true;
}
@ -4889,7 +4889,7 @@ bool Ride::Test(int32_t newStatus, bool isApplying)
}
}
if (subtype != RIDE_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces)
if (subtype != OBJECT_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces)
{
rct_ride_entry* rideType = get_ride_entry(subtype);
if (rideType->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS)
@ -5022,7 +5022,7 @@ bool Ride::Open(bool isApplying)
}
}
if (subtype != RIDE_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces)
if (subtype != OBJECT_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces)
{
rct_ride_entry* rideEntry = get_ride_entry(subtype);
if (rideEntry->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS)
@ -6344,7 +6344,7 @@ static int32_t ride_get_track_length(Ride* ride)
*/
void Ride::UpdateMaxVehicles()
{
if (subtype == RIDE_ENTRY_INDEX_NULL)
if (subtype == OBJECT_ENTRY_INDEX_NULL)
return;
rct_ride_entry* rideEntry = get_ride_entry(subtype);
@ -7077,7 +7077,7 @@ int32_t ride_get_entry_index(int32_t rideType, int32_t rideSubType)
{
int32_t subType = rideSubType;
if (subType == RIDE_ENTRY_INDEX_NULL)
if (subType == OBJECT_ENTRY_INDEX_NULL)
{
auto& objManager = GetContext()->GetObjectManager();
auto& rideEntries = objManager.GetAllRideEntries(rideType);
@ -7089,7 +7089,7 @@ int32_t ride_get_entry_index(int32_t rideType, int32_t rideSubType)
auto rideEntry = get_ride_entry(rideEntryIndex);
if (rideEntry == nullptr)
{
return RIDE_ENTRY_INDEX_NULL;
return OBJECT_ENTRY_INDEX_NULL;
}
// Can happen in select-by-track-type mode

View File

@ -54,8 +54,6 @@ constexpr uint16_t const MAX_HELICES = RCT12_MAX_HELICES;
constexpr uint16_t const MAZE_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP;
constexpr const ObjectEntryIndex RIDE_ENTRY_INDEX_NULL = OBJECT_ENTRY_INDEX_NULL;
constexpr const uint8_t NUM_SHOP_ITEMS_PER_RIDE = 2;
#pragma pack(push, 1)

View File

@ -154,7 +154,7 @@ static void ride_ratings_update_state()
*/
static void ride_ratings_update_state_0()
{
int32_t currentRide = gRideRatingsCalcData.CurrentRide;
ride_id_t currentRide = gRideRatingsCalcData.CurrentRide;
currentRide++;
if (currentRide == RIDE_ID_NULL)

View File

@ -17,8 +17,7 @@
using ride_id_t = uint16_t;
struct Ride;
constexpr const ride_id_t RIDE_ID_NULL = 0xFF; // std::numeric_limits<ride_id_t>::max();
constexpr const ride_id_t RideIdNewNull = std::numeric_limits<ride_id_t>::max();
constexpr const ride_id_t RIDE_ID_NULL = std::numeric_limits<ride_id_t>::max();
/**
* Couples a ride type and subtype together.

View File

@ -1887,7 +1887,7 @@ static bool track_design_place_preview(TrackDesign* td6, money32* cost, Ride** o
ObjectEntryIndex entry_index;
if (!find_object_in_entry_group(&td6->vehicle_object, &entry_type, &entry_index))
{
entry_index = RIDE_ENTRY_INDEX_NULL;
entry_index = OBJECT_ENTRY_INDEX_NULL;
}
ride_id_t rideIndex;

View File

@ -1985,7 +1985,7 @@ void Vehicle::GetLiftHillSound(Ride* curRide, SoundIdVolume& curSound)
void Vehicle::Update()
{
// The cable lift uses a ride entry index of NULL
if (ride_subtype == RIDE_ENTRY_INDEX_NULL)
if (ride_subtype == OBJECT_ENTRY_INDEX_NULL)
{
CableLiftUpdate();
return;
@ -2907,7 +2907,7 @@ static bool ride_station_can_depart_synchronised(const Ride& ride, StationIndex
if (!(sv_ride->stations[sv->stationIndex].Depart & STATION_DEPART_FLAG))
{
sv = _synchronisedVehicles;
uint8_t rideId = RIDE_ID_NULL;
ride_id_t rideId = RIDE_ID_NULL;
for (; sv < _lastSynchronisedVehicle; sv++)
{
if (rideId == RIDE_ID_NULL)
@ -7749,7 +7749,7 @@ bool Vehicle::UpdateMotionCollisionDetection(const CoordsXYZ& loc, uint16_t* oth
if (z_diff > 16)
continue;
if (vehicle2->ride_subtype == RIDE_ENTRY_INDEX_NULL)
if (vehicle2->ride_subtype == OBJECT_ENTRY_INDEX_NULL)
continue;
auto collideVehicleEntry = vehicle2->Entry();

View File

@ -3147,7 +3147,7 @@ template<> void PaintEntity(paint_session* session, const Vehicle* vehicle, int3
return;
}
if (vehicle->ride_subtype == RIDE_ENTRY_INDEX_NULL)
if (vehicle->ride_subtype == OBJECT_ENTRY_INDEX_NULL)
{
vehicleEntry = &CableLiftVehicle;
}

View File

@ -761,7 +761,7 @@ ObjectiveStatus Objective::Check10RollerCoasters() const
std::bitset<MAX_RIDE_OBJECTS> type_already_counted;
for (const auto& ride : GetRideManager())
{
if (ride.status == RIDE_STATUS_OPEN && ride.excitement >= RIDE_RATING(6, 00) && ride.subtype != RIDE_ENTRY_INDEX_NULL)
if (ride.status == RIDE_STATUS_OPEN && ride.excitement >= RIDE_RATING(6, 00) && ride.subtype != OBJECT_ENTRY_INDEX_NULL)
{
auto rideEntry = ride.GetRideEntry();
if (rideEntry != nullptr)
@ -861,7 +861,7 @@ ObjectiveStatus Objective::Check10RollerCoastersLength() const
auto rcs = 0;
for (const auto& ride : GetRideManager())
{
if (ride.status == RIDE_STATUS_OPEN && ride.excitement >= RIDE_RATING(7, 00) && ride.subtype != RIDE_ENTRY_INDEX_NULL)
if (ride.status == RIDE_STATUS_OPEN && ride.excitement >= RIDE_RATING(7, 00) && ride.subtype != OBJECT_ENTRY_INDEX_NULL)
{
auto rideEntry = ride.GetRideEntry();
if (rideEntry != nullptr)

View File

@ -85,7 +85,7 @@ void Banner::FormatTextTo(Formatter& ft) const
*
* rct2: 0x006B7EAB
*/
static uint8_t banner_get_ride_index_at(const CoordsXYZ& bannerCoords)
static ride_id_t banner_get_ride_index_at(const CoordsXYZ& bannerCoords)
{
TileElement* tileElement = map_get_first_element_at(bannerCoords);
ride_id_t resultRideIndex = RIDE_ID_NULL;
@ -217,7 +217,7 @@ WallElement* banner_get_scrolling_wall_tile_element(BannerIndex bannerIndex)
*
* rct2: 0x006B7D86
*/
uint8_t banner_get_closest_ride_index(const CoordsXYZ& mapPos)
ride_id_t banner_get_closest_ride_index(const CoordsXYZ& mapPos)
{
static constexpr const std::array<CoordsXY, 9> NeighbourCheckOrder = { CoordsXY{ COORDS_XY_STEP, 0 },
CoordsXY{ -COORDS_XY_STEP, 0 },

View File

@ -59,7 +59,7 @@ void banner_init();
BannerIndex create_new_banner(uint8_t flags);
TileElement* banner_get_tile_element(BannerIndex bannerIndex);
WallElement* banner_get_scrolling_wall_tile_element(BannerIndex bannerIndex);
uint8_t banner_get_closest_ride_index(const CoordsXYZ& mapPos);
ride_id_t banner_get_closest_ride_index(const CoordsXYZ& mapPos);
void banner_reset_broken_index();
void fix_duplicated_banners();
Banner* GetBanner(BannerIndex id);

View File

@ -572,7 +572,7 @@ struct rct_neighbour
{
uint8_t order;
uint8_t direction;
uint8_t ride_index;
ride_id_t ride_index;
uint8_t entrance_index;
};