From 7344b7fbfdb6ec477461ca3a22df05945f640996 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Thu, 1 Apr 2021 17:02:57 +0200 Subject: [PATCH] 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 --- CMakeLists.txt | 4 ++-- openrct2.proj | 4 ++-- .../interface/ViewportInteraction.cpp | 2 +- src/openrct2-ui/windows/NewRide.cpp | 22 +++++++++--------- src/openrct2-ui/windows/TrackDesignPlace.cpp | 2 +- src/openrct2/EditorObjectSelectionSession.cpp | 4 ++-- src/openrct2/actions/RideCreateAction.h | 4 ++-- src/openrct2/actions/RideDemolishAction.h | 2 +- .../actions/RideSetAppearanceAction.h | 2 +- src/openrct2/actions/RideSetNameAction.h | 2 +- src/openrct2/actions/RideSetPriceAction.h | 2 +- src/openrct2/actions/RideSetSettingAction.h | 2 +- src/openrct2/actions/RideSetStatusAction.h | 2 +- src/openrct2/actions/RideSetVehicleAction.h | 2 +- src/openrct2/actions/TrackPlaceAction.h | 2 +- src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/peep/Guest.cpp | 11 +++++---- src/openrct2/rct1/S4Importer.cpp | 23 ++++++++++--------- src/openrct2/rct2/S6Exporter.cpp | 12 +++++----- src/openrct2/rct2/S6Importer.cpp | 12 +++++----- src/openrct2/ride/CableLift.cpp | 2 +- src/openrct2/ride/Ride.cpp | 12 +++++----- src/openrct2/ride/Ride.h | 2 -- src/openrct2/ride/RideRatings.cpp | 2 +- src/openrct2/ride/RideTypes.h | 3 +-- src/openrct2/ride/TrackDesign.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 6 ++--- src/openrct2/ride/VehiclePaint.cpp | 2 +- src/openrct2/scenario/Scenario.cpp | 4 ++-- src/openrct2/world/Banner.cpp | 4 ++-- src/openrct2/world/Banner.h | 2 +- src/openrct2/world/Footpath.cpp | 2 +- 32 files changed, 80 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b78109770..7e5e6a387c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/openrct2.proj b/openrct2.proj index 00eddedcdb..365a794c31 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -48,8 +48,8 @@ 304d13a126c15bf2c86ff13b81a2f2cc1856ac8d https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip c38af45d51a6e440386180feacf76c64720b6ac5 - https://github.com/OpenRCT2/replays/releases/download/v0.0.36/replays.zip - F539E5BD4F5062C2972C6E0DA974318DB01A0308 + https://github.com/OpenRCT2/replays/releases/download/v0.0.37/replays.zip + C31C299539EB86DA013AEE47C9B2B2F4609F52C4 diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 60a35dca0a..3607cc8714 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -91,7 +91,7 @@ InteractionInfo ViewportInteractionGetItemLeft(const ScreenCoordsXY& screenCoord case EntityType::Vehicle: { auto vehicle = sprite->As(); - 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; diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index dc804fa722..e42330aed6 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -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::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; diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index f8655d1811..05fc98cfc6 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -96,7 +96,7 @@ static rct_window_event_list window_track_place_events([](auto& events) static std::vector _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; diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 38250eaa2d..cd13e2f396 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -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()) { 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); } diff --git a/src/openrct2/actions/RideCreateAction.h b/src/openrct2/actions/RideCreateAction.h index 83cf87a994..098a749bf4 100644 --- a/src/openrct2/actions/RideCreateAction.h +++ b/src/openrct2/actions/RideCreateAction.h @@ -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 }; diff --git a/src/openrct2/actions/RideDemolishAction.h b/src/openrct2/actions/RideDemolishAction.h index c468843971..69a4e99363 100644 --- a/src/openrct2/actions/RideDemolishAction.h +++ b/src/openrct2/actions/RideDemolishAction.h @@ -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: diff --git a/src/openrct2/actions/RideSetAppearanceAction.h b/src/openrct2/actions/RideSetAppearanceAction.h index fdc4e65992..ce9a93d0d6 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.h +++ b/src/openrct2/actions/RideSetAppearanceAction.h @@ -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{}; diff --git a/src/openrct2/actions/RideSetNameAction.h b/src/openrct2/actions/RideSetNameAction.h index de75055ecd..5da79e27a2 100644 --- a/src/openrct2/actions/RideSetNameAction.h +++ b/src/openrct2/actions/RideSetNameAction.h @@ -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: diff --git a/src/openrct2/actions/RideSetPriceAction.h b/src/openrct2/actions/RideSetPriceAction.h index 6aa63c643d..07bebe0a1c 100644 --- a/src/openrct2/actions/RideSetPriceAction.h +++ b/src/openrct2/actions/RideSetPriceAction.h @@ -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 }; diff --git a/src/openrct2/actions/RideSetSettingAction.h b/src/openrct2/actions/RideSetSettingAction.h index 08c868c21c..5eebc14bbe 100644 --- a/src/openrct2/actions/RideSetSettingAction.h +++ b/src/openrct2/actions/RideSetSettingAction.h @@ -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{}; diff --git a/src/openrct2/actions/RideSetStatusAction.h b/src/openrct2/actions/RideSetStatusAction.h index a8e4c188df..35e4f9d030 100644 --- a/src/openrct2/actions/RideSetStatusAction.h +++ b/src/openrct2/actions/RideSetStatusAction.h @@ -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: diff --git a/src/openrct2/actions/RideSetVehicleAction.h b/src/openrct2/actions/RideSetVehicleAction.h index a8dfe37fd3..7c7662a85e 100644 --- a/src/openrct2/actions/RideSetVehicleAction.h +++ b/src/openrct2/actions/RideSetVehicleAction.h @@ -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{}; diff --git a/src/openrct2/actions/TrackPlaceAction.h b/src/openrct2/actions/TrackPlaceAction.h index e85f11fa57..507bcc7558 100644 --- a/src/openrct2/actions/TrackPlaceAction.h +++ b/src/openrct2/actions/TrackPlaceAction.h @@ -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{}; diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index bea96f556c..faf925b339 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -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; diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 716d381e53..a04082ca8e 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -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() 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; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 34dc1a1d17..f8b60a8d72 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -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(); @@ -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); diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 15ab45fea7..6a1301a925 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -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(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()); diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 73856af713..2ac8390f39 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -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) { diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index 11d7b57fa6..5d9791d242 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -26,7 +26,7 @@ Vehicle* cable_lift_segment_create( { Vehicle* current = CreateEntity(); 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; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 9ad59a05f6..53b8987753 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -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 diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 7796e48d65..3029c1144b 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -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) diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index ba486eb147..faaebc9c2e 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -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) diff --git a/src/openrct2/ride/RideTypes.h b/src/openrct2/ride/RideTypes.h index 6fb92c57c2..2a1567ad4b 100644 --- a/src/openrct2/ride/RideTypes.h +++ b/src/openrct2/ride/RideTypes.h @@ -17,8 +17,7 @@ using ride_id_t = uint16_t; struct Ride; -constexpr const ride_id_t RIDE_ID_NULL = 0xFF; // std::numeric_limits::max(); -constexpr const ride_id_t RideIdNewNull = std::numeric_limits::max(); +constexpr const ride_id_t RIDE_ID_NULL = std::numeric_limits::max(); /** * Couples a ride type and subtype together. diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 8338af9e42..44292c0e0f 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -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; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index c5be97c9db..b6a13fbb56 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -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(); diff --git a/src/openrct2/ride/VehiclePaint.cpp b/src/openrct2/ride/VehiclePaint.cpp index d7a1d4b05c..9183704028 100644 --- a/src/openrct2/ride/VehiclePaint.cpp +++ b/src/openrct2/ride/VehiclePaint.cpp @@ -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; } diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 456fd0f929..4b4a1f953d 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -761,7 +761,7 @@ ObjectiveStatus Objective::Check10RollerCoasters() const std::bitset 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) diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index 0291fb83c2..ef75f7677b 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -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 NeighbourCheckOrder = { CoordsXY{ COORDS_XY_STEP, 0 }, CoordsXY{ -COORDS_XY_STEP, 0 }, diff --git a/src/openrct2/world/Banner.h b/src/openrct2/world/Banner.h index c7c739ffe6..e586b0a3d5 100644 --- a/src/openrct2/world/Banner.h +++ b/src/openrct2/world/Banner.h @@ -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); diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 9c420a0c66..9731d31a66 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -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; };