From d58a8d1184078d102fa5bd0b4b1888de5eeb613f Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 27 Oct 2020 21:59:55 +0100 Subject: [PATCH 1/7] Change tile_element_get_ride_index() to method --- src/openrct2-ui/interface/ViewportInteraction.cpp | 2 +- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2/actions/RideEntranceExitRemoveAction.hpp | 4 ++-- src/openrct2/ride/Ride.cpp | 2 +- src/openrct2/world/TileElement.cpp | 10 +++++----- src/openrct2/world/TileElement.h | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 3040975094..58a22d3850 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -296,7 +296,7 @@ InteractionInfo ViewportInteractionGetItemRight(const ScreenCoordsXY& screenCoor return info; } - ride = get_ride(tile_element_get_ride_index(tileElement)); + ride = get_ride(tileElement->GetRideIndex()); if (ride == nullptr) { info.SpriteType = VIEWPORT_INTERACTION_ITEM_NONE; diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 128e81832c..ef3ebc0fe4 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1376,7 +1376,7 @@ static rct_window* window_ride_open_station(Ride* ride, StationIndex stationInde rct_window* window_ride_open_track(TileElement* tileElement) { assert(tileElement != nullptr); - auto rideIndex = tile_element_get_ride_index(tileElement); + auto rideIndex = tileElement->GetRideIndex(); if (rideIndex != RIDE_ID_NULL) { auto ride = get_ride(rideIndex); diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.hpp b/src/openrct2/actions/RideEntranceExitRemoveAction.hpp index a25aae91c8..c46cab164c 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.hpp +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.hpp @@ -88,7 +88,7 @@ public: if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE) continue; - if (tile_element_get_ride_index(tileElement) != _rideIndex) + if (tileElement->GetRideIndex() != _rideIndex) continue; if (tileElement->AsEntrance()->GetStationIndex() != _stationNum) @@ -148,7 +148,7 @@ public: if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE) continue; - if (tile_element_get_ride_index(tileElement) != _rideIndex) + if (tileElement->GetRideIndex() != _rideIndex) continue; if (tileElement->AsEntrance()->GetStationIndex() != _stationNum) diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 979dcf80da..4d1d8bbbec 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1821,7 +1821,7 @@ bool ride_modify(CoordsXYE* input) if (tileElement.element == nullptr) return false; - auto rideIndex = tile_element_get_ride_index(tileElement.element); + auto rideIndex = tileElement.element->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride == nullptr) { diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index 2ca7c680d2..03e5374092 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -141,16 +141,16 @@ void tile_element_remove_banner_entry(TileElement* tileElement) } } -uint8_t tile_element_get_ride_index(const TileElement* tileElement) +ride_id_t TileElement::GetRideIndex() const { - switch (tileElement->GetType()) + switch (GetType()) { case TILE_ELEMENT_TYPE_TRACK: - return tileElement->AsTrack()->GetRideIndex(); + return AsTrack()->GetRideIndex(); case TILE_ELEMENT_TYPE_ENTRANCE: - return tileElement->AsEntrance()->GetRideIndex(); + return AsEntrance()->GetRideIndex(); case TILE_ELEMENT_TYPE_PATH: - return tileElement->AsPath()->GetRideIndex(); + return AsPath()->GetRideIndex(); default: return RIDE_ID_NULL; } diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index f25410d3d9..7cc9037652 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -181,6 +181,8 @@ public: } void ClearAs(uint8_t newType); + + ride_id_t GetRideIndex() const; }; assert_struct_size(TileElement, 16); @@ -683,5 +685,3 @@ bool tile_element_is_underground(TileElement* tileElement); // ~Oli414: The banner functions should probably be part of banner. void tile_element_set_banner_index(TileElement* tileElement, BannerIndex bannerIndex); void tile_element_remove_banner_entry(TileElement* tileElement); - -uint8_t tile_element_get_ride_index(const TileElement* tileElement); From 9e17081ee8e42bcf2c19fcfb30150da733011967 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 27 Oct 2020 22:02:39 +0100 Subject: [PATCH 2/7] Use 16 bits for gTrackDesignSaveRideIndex throughout --- src/openrct2-ui/windows/Ride.cpp | 2 +- test/testpaint/Compat.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index ef3ebc0fe4..f05950e96f 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -5175,7 +5175,7 @@ static void setup_scenery_selection(rct_window* w) while (tool_set(w, WIDX_BACKGROUND, TOOL_CROSSHAIR)) ; - gTrackDesignSaveRideIndex = static_cast(w->number); + gTrackDesignSaveRideIndex = w->number; track_design_save_init(); gGamePaused |= GAME_PAUSED_SAVING_TRACK; diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index f214499691..e4c6d4b56f 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -35,7 +35,7 @@ Ride gRideList[MAX_RIDES]; int16_t gMapSizeUnits; int16_t gMapBaseZ; bool gTrackDesignSaveMode = false; -uint8_t gTrackDesignSaveRideIndex = RIDE_ID_NULL; +ride_id_t gTrackDesignSaveRideIndex = RIDE_ID_NULL; uint8_t gClipHeight = 255; CoordsXY gClipSelectionA = { 0, 0 }; CoordsXY gClipSelectionB = { MAXIMUM_TILE_START_XY, MAXIMUM_TILE_START_XY }; From a3aef90637731ec2310a33e5154443afd7942e24 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 27 Oct 2020 22:24:39 +0100 Subject: [PATCH 3/7] Replace loose usages of 0xFF --- src/openrct2-ui/windows/GuestList.cpp | 6 +++--- src/openrct2-ui/windows/Ride.cpp | 4 ++-- src/openrct2/EditorObjectSelectionSession.cpp | 4 ++-- src/openrct2/actions/TrackDesignAction.cpp | 2 +- src/openrct2/peep/GuestPathfinding.cpp | 2 +- src/openrct2/peep/Peep.cpp | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index 90289b3d58..3148915626 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -273,7 +273,7 @@ rct_window* window_guest_list_open_with_filter(GuestListFilterType type, int32_t { case GuestListFilterType::GuestsOnRide: { - auto ride = get_ride(index & 0xFF); + auto ride = get_ride(index); if (ride != nullptr) { ft.Add(ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IN_RIDE) ? STR_IN_RIDE : STR_ON_RIDE); @@ -288,7 +288,7 @@ rct_window* window_guest_list_open_with_filter(GuestListFilterType type, int32_t } case GuestListFilterType::GuestsInQueue: { - auto ride = get_ride(index & 0xFF); + auto ride = get_ride(index); if (ride != nullptr) { ft.Add(STR_QUEUING_FOR); @@ -303,7 +303,7 @@ rct_window* window_guest_list_open_with_filter(GuestListFilterType type, int32_t } case GuestListFilterType::GuestsThinkingAboutRide: { - auto ride = get_ride(index & 0xFF); + auto ride = get_ride(index); if (ride != nullptr) { ft.Add(STR_NONE); diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index f05950e96f..3cea839356 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1133,7 +1133,7 @@ static void window_ride_draw_tab_images(rct_drawpixelinfo* dpi, rct_window* w) static void window_ride_disable_tabs(rct_window* w) { uint32_t disabled_tabs = 0; - auto ride = get_ride(w->number & 0xFF); + auto ride = get_ride(w->number); if (ride == nullptr) return; @@ -3816,7 +3816,7 @@ static void window_ride_maintenance_mousedown(rct_window* w, rct_widgetindex wid num_items = 1; for (j = 0; j < MAX_RIDE_TYPES_PER_RIDE_ENTRY; j++) { - if (rideEntry->ride_type[j] != 0xFF) + if (rideEntry->ride_type[j] != RIDE_TYPE_NULL) break; } gDropdownItemsFormat[0] = STR_DROPDOWN_MENU_LABEL; diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index a452593156..2295f985f7 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -186,12 +186,12 @@ void setup_in_use_selection_flags() } } while (tile_element_iterator_next(&iter)); - for (uint8_t ride_index = 0; ride_index < 0xFF; ride_index++) + for (ride_id_t ride_index = 0; ride_index < MAX_RIDES; ride_index++) { auto ride = get_ride(ride_index); if (ride != nullptr) { - uint8_t type = ride->subtype; + ObjectEntryIndex type = ride->subtype; Editor::SetSelectedObject(OBJECT_TYPE_RIDE, type, OBJECT_SELECTION_FLAG_SELECTED); } } diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/TrackDesignAction.cpp index a55cf8681b..d3ca63d2bb 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/TrackDesignAction.cpp @@ -174,7 +174,7 @@ GameActions::Result::Ptr TrackDesignAction::Execute() const return MakeResult(GameActions::Status::Disallowed, error_reason); } - if (entryIndex != 0xFF) + if (entryIndex != OBJECT_ENTRY_INDEX_NULL) { auto colour = ride_get_unused_preset_vehicle_colour(entryIndex); auto rideSetVehicleAction = RideSetVehicleAction(ride->id, RideSetVehicleType::RideEntry, entryIndex, colour); diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 2a55d8d9ac..dc1ba42c82 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -284,7 +284,7 @@ static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, PathElement if (nextTileElement->AsPath()->IsWide()) return PATH_SEARCH_WIDE; // Only queue tiles that are connected to a ride are returned as ride queues. - if (nextTileElement->AsPath()->IsQueue() && nextTileElement->AsPath()->GetRideIndex() != 0xFF) + if (nextTileElement->AsPath()->IsQueue() && nextTileElement->AsPath()->GetRideIndex() != RIDE_ID_NULL) return PATH_SEARCH_RIDE_QUEUE; return PATH_SEARCH_OTHER; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 1751e714bb..f55d97bd59 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2316,7 +2316,7 @@ static void peep_interact_with_entrance(Peep* peep, const CoordsXYE& coords, uin { // Default guest/staff behaviour attempting to enter a // ride exit is to turn around. - peep->InteractionRideIndex = 0xFF; + peep->InteractionRideIndex = RIDE_ID_NULL; peep_return_to_centre_of_tile(peep); return; } @@ -2333,7 +2333,7 @@ static void peep_interact_with_entrance(Peep* peep, const CoordsXYE& coords, uin { // Default staff behaviour attempting to enter a // ride entrance is to turn around. - peep->InteractionRideIndex = 0xFF; + peep->InteractionRideIndex = RIDE_ID_NULL; peep_return_to_centre_of_tile(peep); return; } @@ -2774,7 +2774,7 @@ static void peep_interact_with_path(Peep* peep, const CoordsXYE& coords) else { // Queue got disconnected from the original ride. - peep->InteractionRideIndex = 0xFF; + peep->InteractionRideIndex = RIDE_ID_NULL; guest->RemoveFromQueue(); peep->SetState(PeepState::One); peep_footpath_move_forward(peep, { coords, tile_element }, vandalism_present); @@ -2845,7 +2845,7 @@ static void peep_interact_with_path(Peep* peep, const CoordsXYE& coords) } else { - peep->InteractionRideIndex = 0xFF; + peep->InteractionRideIndex = RIDE_ID_NULL; if (peep->State == PeepState::Queuing) { peep->RemoveFromQueue(); @@ -3059,7 +3059,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result) int16_t height = abs(tile_element_height(newLoc) - z); if (height <= 3 || (AssignedPeepType == PeepType::Staff && height <= 32)) { - InteractionRideIndex = 0xFF; + InteractionRideIndex = RIDE_ID_NULL; if (State == PeepState::Queuing) { RemoveFromQueue(); From 28466635330be1d6fc1768edf315c0f0dff649de Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Tue, 27 Oct 2020 22:31:28 +0100 Subject: [PATCH 4/7] Use ride_id_t for remaining peep ride fields --- src/openrct2/peep/Peep.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 5426bbdc65..8db7170eb5 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -699,7 +699,7 @@ struct Peep : SpriteBase uint8_t MazeLastEdge; Direction PeepDirection; // Direction ? }; - uint8_t InteractionRideIndex; + ride_id_t InteractionRideIndex; uint16_t TimeInQueue; uint8_t RidesBeenOn[32]; // 255 bit bitmap of every ride the peep has been on see @@ -713,7 +713,7 @@ struct Peep : SpriteBase int32_t HireDate; }; int8_t RejoinQueueTimeout; // whilst waiting for a free vehicle (or pair) in the entrance - uint8_t PreviousRide; + ride_id_t PreviousRide; uint16_t PreviousRideTimeOut; rct_peep_thought Thoughts[PEEP_MAX_THOUGHTS]; uint8_t PathCheckOptimisation; // see peep.checkForPath From 802285fd928d13d40a9c82f62712671fedf8ab21 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 7 Nov 2020 13:21:31 +0100 Subject: [PATCH 5/7] Autoconvert ride id between RCT2 and OpenRCT2 --- src/openrct2/rct1/RCT1.h | 16 ++++++++-------- src/openrct2/rct1/S4Importer.cpp | 14 +++++++------- src/openrct2/rct12/RCT12.cpp | 16 ++++++++++++++++ src/openrct2/rct12/RCT12.h | 6 +++++- src/openrct2/rct2/RCT2.h | 22 +++++++++++----------- src/openrct2/rct2/S6Exporter.cpp | 20 ++++++++++---------- src/openrct2/rct2/S6Importer.cpp | 20 ++++++++++---------- 7 files changed, 67 insertions(+), 47 deletions(-) diff --git a/src/openrct2/rct1/RCT1.h b/src/openrct2/rct1/RCT1.h index 4b39987ecd..222c27bcfc 100644 --- a/src/openrct2/rct1/RCT1.h +++ b/src/openrct2/rct1/RCT1.h @@ -367,7 +367,7 @@ struct rct1_peep : RCT12SpriteBase uint8_t photo3_ride_ref; // 0x5D uint8_t photo4_ride_ref; // 0x5E uint8_t pad_5F[0x09]; // 0x5F - uint8_t current_ride; // 0x68 + RCT12RideId current_ride; // 0x68 uint8_t current_ride_station; // 0x69 uint8_t current_train; // 0x6A union @@ -406,7 +406,7 @@ struct rct1_peep : RCT12SpriteBase uint8_t maze_last_edge; // 0x78 uint8_t direction; // Direction ? }; - uint8_t interaction_ride_index; + RCT12RideId interaction_ride_index; uint16_t time_in_queue; // 0x7A uint8_t rides_been_on[32]; // 0x7C // 255 bit bitmap of every ride the peep has been on see @@ -416,21 +416,21 @@ struct rct1_peep : RCT12SpriteBase money32 cash_spent; // 0xA4 int32_t park_entry_time; // 0xA8 int8_t rejoin_queue_timeout; // 0xAC - uint8_t previous_ride; // 0xAD + RCT12RideId previous_ride; // 0xAD uint16_t previous_ride_time_out; // 0xAE RCT12PeepThought thoughts[RCT12_PEEP_MAX_THOUGHTS]; // 0xB0 uint8_t pad_C4; union { - uint8_t staff_id; // 0xC5 - uint8_t guest_heading_to_ride_id; // 0xC5 + uint8_t staff_id; // 0xC5 + RCT12RideId guest_heading_to_ride_id; // 0xC5 }; union { uint8_t staff_orders; // 0xC6 uint8_t peep_is_lost_countdown; // 0xC6 }; - uint8_t photo1_ride_ref; // 0xC7 + RCT12RideId photo1_ride_ref; // 0xC7 uint32_t peep_flags; // 0xC8 rct12_xyzd8 pathfind_goal; // 0xCC rct12_xyzd8 pathfind_history[4]; // 0xD0 @@ -453,7 +453,7 @@ struct rct1_peep : RCT12SpriteBase uint8_t no_of_souvenirs; // 0xEE uint8_t vandalism_seen; // 0xEF uint8_t voucher_type; // 0xF0 - uint8_t voucher_arguments; // 0xF1 ride_id or string_offset_id + RCT12RideId voucher_arguments; // 0xF1 ride_id or string_offset_id uint8_t surroundings_thought_timeout; // 0xF2 uint8_t angriness; // 0xF3 uint8_t time_lost; @@ -461,7 +461,7 @@ struct rct1_peep : RCT12SpriteBase uint8_t balloon_colour; // 0xF6 uint8_t umbrella_colour; // 0xF7 uint8_t hat_colour; // 0xF8 - uint8_t favourite_ride; // 0xF9 + RCT12RideId favourite_ride; // 0xF9 uint8_t favourite_ride_rating; // 0xFA uint8_t pad_FB; uint32_t item_standard_flags; // 0xFC diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 661ed6db77..634b9efd44 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1477,7 +1477,7 @@ private: dst->NauseaTolerance = static_cast(src->nausea_tolerance); dst->WindowInvalidateFlags = 0; - dst->CurrentRide = src->current_ride; + dst->CurrentRide = RCT12RideIdToOpenRCT2RideId(src->current_ride); dst->CurrentRideStation = src->current_ride_station; dst->CurrentTrain = src->current_train; dst->CurrentCar = src->current_car; @@ -1485,7 +1485,7 @@ private: dst->GuestTimeOnRide = src->time_on_ride; dst->DaysInQueue = src->days_in_queue; - dst->InteractionRideIndex = src->interaction_ride_index; + dst->InteractionRideIndex = RCT12RideIdToOpenRCT2RideId(src->interaction_ride_index); dst->Id = src->id; dst->CashInPocket = src->cash_in_pocket; @@ -1506,7 +1506,7 @@ private: dst->PaidOnFood = src->paid_on_food; dst->PaidOnSouvenirs = src->paid_on_souvenirs; - dst->VoucherRideId = src->voucher_arguments; + dst->VoucherRideId = RCT12RideIdToOpenRCT2RideId(src->voucher_arguments); dst->VoucherType = src->voucher_type; dst->SurroundingsThoughtTimeout = src->surroundings_thought_timeout; @@ -1522,7 +1522,7 @@ private: dst->RideTypesBeenOn[i] = src->ride_types_been_on[i]; } - dst->Photo1RideRef = src->photo1_ride_ref; + dst->Photo1RideRef = RCT12RideIdToOpenRCT2RideId(src->photo1_ride_ref); for (size_t i = 0; i < std::size(src->thoughts); i++) { @@ -1534,11 +1534,11 @@ private: dstThought->fresh_timeout = srcThought->fresh_timeout; } - dst->PreviousRide = src->previous_ride; + dst->PreviousRide = RCT12RideIdToOpenRCT2RideId(src->previous_ride); dst->PreviousRideTimeOut = src->previous_ride_time_out; dst->PathCheckOptimisation = 0; - dst->GuestHeadingToRideId = src->guest_heading_to_ride_id; + dst->GuestHeadingToRideId = RCT12RideIdToOpenRCT2RideId(src->guest_heading_to_ride_id); // Doubles as staff orders dst->GuestIsLostCountdown = src->peep_is_lost_countdown; // The ID is fixed later @@ -1554,7 +1554,7 @@ private: // Set it to N/A if the save comes from the original or AA. if (_gameVersion == FILE_VERSION_RCT1_LL) { - dst->FavouriteRide = src->favourite_ride; + dst->FavouriteRide = RCT12RideIdToOpenRCT2RideId(src->favourite_ride); dst->FavouriteRideRating = src->favourite_ride_rating; } else diff --git a/src/openrct2/rct12/RCT12.cpp b/src/openrct2/rct12/RCT12.cpp index 5032753e08..60e177aa64 100644 --- a/src/openrct2/rct12/RCT12.cpp +++ b/src/openrct2/rct12/RCT12.cpp @@ -1024,3 +1024,19 @@ RCT12ObjectEntryIndex OpenRCT2EntryIndexToRCTEntryIndex(const ObjectEntryIndex i return index; } + +ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId) +{ + if (rideId == RCT12_RIDE_ID_NULL) + return RIDE_ID_NULL; + + return rideId; +} + +RCT12RideId OpenRCT2RideIdToRCT12RideId(const ride_id_t rideId) +{ + if (rideId == RIDE_ID_NULL) + return RCT12_RIDE_ID_NULL; + + return rideId; +} diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index 9decf10df7..bb85218866 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -13,6 +13,7 @@ #include "../common.h" #include "../object/Object.h" +#include "../ride/RideTypes.h" #include #include @@ -41,7 +42,8 @@ constexpr const uint8_t RCT12_USER_STRING_MAX_LENGTH = 32; constexpr const uint8_t RCT12_PEEP_MAX_THOUGHTS = 5; -constexpr const uint8_t RCT12_RIDE_ID_NULL = 255; +using RCT12RideId = uint8_t; +constexpr const RCT12RideId RCT12_RIDE_ID_NULL = 255; constexpr const uint16_t RCT12_RIDE_MEASUREMENT_MAX_ITEMS = 4800; constexpr uint16_t const RCT12_MAX_INVERSIONS = 31; @@ -858,3 +860,5 @@ assert_struct_size(RCT12ResearchItem, 5); ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(const RCT12ObjectEntryIndex index); RCT12ObjectEntryIndex OpenRCT2EntryIndexToRCTEntryIndex(const ObjectEntryIndex index); +ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId); +RCT12RideId OpenRCT2RideIdToRCT12RideId(const ride_id_t rideId); diff --git a/src/openrct2/rct2/RCT2.h b/src/openrct2/rct2/RCT2.h index 71bd916166..31030edf0e 100644 --- a/src/openrct2/rct2/RCT2.h +++ b/src/openrct2/rct2/RCT2.h @@ -613,11 +613,11 @@ struct RCT2SpritePeep : RCT12SpriteBase money16 paid_on_drink; // 0x46 uint8_t ride_types_been_on[16]; // 0x48 uint32_t item_extra_flags; // 0x58 - uint8_t photo2_ride_ref; // 0x5C - uint8_t photo3_ride_ref; // 0x5D - uint8_t photo4_ride_ref; // 0x5E + RCT12RideId photo2_ride_ref; // 0x5C + RCT12RideId photo3_ride_ref; // 0x5D + RCT12RideId photo4_ride_ref; // 0x5E uint8_t pad_5F[0x09]; // 0x5F - uint8_t current_ride; // 0x68 + RCT12RideId current_ride; // 0x68 uint8_t current_ride_station; // 0x69 uint8_t current_train; // 0x6A union @@ -653,7 +653,7 @@ struct RCT2SpritePeep : RCT12SpriteBase uint8_t maze_last_edge; // 0x78 uint8_t direction; }; - uint8_t interaction_ride_index; + RCT12RideId interaction_ride_index; uint16_t time_in_queue; // 0x7A uint8_t rides_been_on[32]; // 0x7C uint32_t id; // 0x9C @@ -661,21 +661,21 @@ struct RCT2SpritePeep : RCT12SpriteBase money32 cash_spent; // 0xA4 int32_t park_entry_time; // 0xA8 int8_t rejoin_queue_timeout; // 0xAC - uint8_t previous_ride; // 0xAD + RCT12RideId previous_ride; // 0xAD uint16_t previous_ride_time_out; // 0xAE RCT12PeepThought thoughts[RCT12_PEEP_MAX_THOUGHTS]; // 0xB0 uint8_t path_check_optimisation; // 0xC4 union { - uint8_t staff_id; // 0xC5 - uint8_t guest_heading_to_ride_id; // 0xC5 + uint8_t staff_id; // 0xC5 + RCT12RideId guest_heading_to_ride_id; // 0xC5 }; union { uint8_t staff_orders; // 0xC6 uint8_t peep_is_lost_countdown; // 0xC6 }; - uint8_t photo1_ride_ref; // 0xC7 + RCT12RideId photo1_ride_ref; // 0xC7 uint32_t peep_flags; // 0xC8 rct12_xyzd8 pathfind_goal; // 0xCC rct12_xyzd8 pathfind_history[4]; // 0xD0 @@ -714,7 +714,7 @@ struct RCT2SpritePeep : RCT12SpriteBase uint8_t no_of_souvenirs; // 0xEE uint8_t vandalism_seen; // 0xEF 0xC0 vandalism thought timeout, 0x3F vandalism tiles seen uint8_t voucher_type; // 0xF0 - uint8_t voucher_arguments; // 0xF1 ride_id or string_offset_id + RCT12RideId voucher_arguments; // 0xF1 ride_id or string_offset_id uint8_t surroundings_thought_timeout; // 0xF2 uint8_t angriness; // 0xF3 uint8_t time_lost; // 0xF4 the time the peep has been lost when it reaches 254 generates the lost thought @@ -722,7 +722,7 @@ struct RCT2SpritePeep : RCT12SpriteBase uint8_t balloon_colour; // 0xF6 uint8_t umbrella_colour; // 0xF7 uint8_t hat_colour; // 0xF8 - uint8_t favourite_ride; // 0xF9 + RCT12RideId favourite_ride; // 0xF9 uint8_t favourite_ride_rating; // 0xFA uint8_t pad_FB; uint32_t item_standard_flags; // 0xFC diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 776da9df3e..824a40092f 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1174,10 +1174,10 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) dst->ride_types_been_on[i] = src->RideTypesBeenOn[i]; } dst->item_extra_flags = src->ItemExtraFlags; - dst->photo2_ride_ref = src->Photo2RideRef; - dst->photo3_ride_ref = src->Photo3RideRef; - dst->photo4_ride_ref = src->Photo4RideRef; - dst->current_ride = src->CurrentRide; + dst->photo2_ride_ref = OpenRCT2RideIdToRCT12RideId(src->Photo2RideRef); + dst->photo3_ride_ref = OpenRCT2RideIdToRCT12RideId(src->Photo3RideRef); + dst->photo4_ride_ref = OpenRCT2RideIdToRCT12RideId(src->Photo4RideRef); + dst->current_ride = OpenRCT2RideIdToRCT12RideId(src->CurrentRide); dst->current_ride_station = src->CurrentRideStation; dst->current_train = src->CurrentTrain; dst->time_to_sitdown = src->TimeToSitdown; @@ -1190,7 +1190,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) dst->step_progress = src->StepProgress; dst->next_in_queue = src->GuestNextInQueue; dst->direction = src->PeepDirection; - dst->interaction_ride_index = src->InteractionRideIndex; + dst->interaction_ride_index = OpenRCT2RideIdToRCT12RideId(src->InteractionRideIndex); dst->time_in_queue = src->TimeInQueue; for (size_t i = 0; i < std::size(src->RidesBeenOn); i++) { @@ -1201,7 +1201,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) dst->cash_spent = src->CashSpent; dst->park_entry_time = src->ParkEntryTime; dst->rejoin_queue_timeout = src->RejoinQueueTimeout; - dst->previous_ride = src->PreviousRide; + dst->previous_ride = OpenRCT2RideIdToRCT12RideId(src->PreviousRide); dst->previous_ride_time_out = src->PreviousRideTimeOut; for (size_t i = 0; i < std::size(src->Thoughts); i++) { @@ -1213,9 +1213,9 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) dstThought->fresh_timeout = srcThought->fresh_timeout; } dst->path_check_optimisation = src->PathCheckOptimisation; - dst->guest_heading_to_ride_id = src->GuestHeadingToRideId; + dst->guest_heading_to_ride_id = OpenRCT2RideIdToRCT12RideId(src->GuestHeadingToRideId); dst->peep_is_lost_countdown = src->GuestIsLostCountdown; - dst->photo1_ride_ref = src->Photo1RideRef; + dst->photo1_ride_ref = OpenRCT2RideIdToRCT12RideId(src->Photo1RideRef); dst->peep_flags = src->PeepFlags; dst->pathfind_goal = src->PathfindGoal; for (size_t i = 0; i < std::size(src->PathfindHistory); i++) @@ -1235,7 +1235,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) dst->no_of_souvenirs = src->AmountOfSouvenirs; dst->vandalism_seen = src->VandalismSeen; dst->voucher_type = src->VoucherType; - dst->voucher_arguments = src->VoucherRideId; + dst->voucher_arguments = OpenRCT2RideIdToRCT12RideId(src->VoucherRideId); dst->surroundings_thought_timeout = src->SurroundingsThoughtTimeout; dst->angriness = src->Angriness; dst->time_lost = src->TimeLost; @@ -1243,7 +1243,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) dst->balloon_colour = src->BalloonColour; dst->umbrella_colour = src->UmbrellaColour; dst->hat_colour = src->HatColour; - dst->favourite_ride = src->FavouriteRide; + dst->favourite_ride = OpenRCT2RideIdToRCT12RideId(src->FavouriteRide); dst->favourite_ride_rating = src->FavouriteRideRating; dst->item_standard_flags = src->ItemStandardFlags; } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index cb19d73f80..220b8a5b97 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1469,10 +1469,10 @@ public: dst->RideTypesBeenOn[i] = src->ride_types_been_on[i]; } dst->ItemExtraFlags = src->item_extra_flags; - dst->Photo2RideRef = src->photo2_ride_ref; - dst->Photo3RideRef = src->photo3_ride_ref; - dst->Photo4RideRef = src->photo4_ride_ref; - dst->CurrentRide = src->current_ride; + dst->Photo2RideRef = RCT12RideIdToOpenRCT2RideId(src->photo2_ride_ref); + dst->Photo3RideRef = RCT12RideIdToOpenRCT2RideId(src->photo3_ride_ref); + dst->Photo4RideRef = RCT12RideIdToOpenRCT2RideId(src->photo4_ride_ref); + dst->CurrentRide = RCT12RideIdToOpenRCT2RideId(src->current_ride); dst->CurrentRideStation = src->current_ride_station; dst->CurrentTrain = src->current_train; dst->TimeToSitdown = src->time_to_sitdown; @@ -1485,7 +1485,7 @@ public: dst->StepProgress = src->step_progress; dst->GuestNextInQueue = src->next_in_queue; dst->PeepDirection = src->direction; - dst->InteractionRideIndex = src->interaction_ride_index; + dst->InteractionRideIndex = RCT12RideIdToOpenRCT2RideId(src->interaction_ride_index); dst->TimeInQueue = src->time_in_queue; for (size_t i = 0; i < std::size(src->rides_been_on); i++) { @@ -1496,7 +1496,7 @@ public: dst->CashSpent = src->cash_spent; dst->ParkEntryTime = src->park_entry_time; dst->RejoinQueueTimeout = src->rejoin_queue_timeout; - dst->PreviousRide = src->previous_ride; + dst->PreviousRide = RCT12RideIdToOpenRCT2RideId(src->previous_ride); dst->PreviousRideTimeOut = src->previous_ride_time_out; for (size_t i = 0; i < std::size(src->thoughts); i++) { @@ -1508,9 +1508,9 @@ public: dstThought->fresh_timeout = srcThought->fresh_timeout; } dst->PathCheckOptimisation = src->path_check_optimisation; - dst->GuestHeadingToRideId = src->guest_heading_to_ride_id; + dst->GuestHeadingToRideId = RCT12RideIdToOpenRCT2RideId(src->guest_heading_to_ride_id); dst->GuestIsLostCountdown = src->peep_is_lost_countdown; - dst->Photo1RideRef = src->photo1_ride_ref; + dst->Photo1RideRef = RCT12RideIdToOpenRCT2RideId(src->photo1_ride_ref); dst->PeepFlags = src->peep_flags; dst->PathfindGoal = src->pathfind_goal; for (size_t i = 0; i < std::size(src->pathfind_history); i++) @@ -1530,7 +1530,7 @@ public: dst->AmountOfSouvenirs = src->no_of_souvenirs; dst->VandalismSeen = src->vandalism_seen; dst->VoucherType = src->voucher_type; - dst->VoucherRideId = src->voucher_arguments; + dst->VoucherRideId = RCT12RideIdToOpenRCT2RideId(src->voucher_arguments); dst->SurroundingsThoughtTimeout = src->surroundings_thought_timeout; dst->Angriness = src->angriness; dst->TimeLost = src->time_lost; @@ -1538,7 +1538,7 @@ public: dst->BalloonColour = src->balloon_colour; dst->UmbrellaColour = src->umbrella_colour; dst->HatColour = src->hat_colour; - dst->FavouriteRide = src->favourite_ride; + dst->FavouriteRide = RCT12RideIdToOpenRCT2RideId(src->favourite_ride); dst->FavouriteRideRating = src->favourite_ride_rating; dst->ItemStandardFlags = src->item_standard_flags; } From 7ef8082185dc882396526570e905d3f06d2cd8b4 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 7 Nov 2020 13:23:43 +0100 Subject: [PATCH 6/7] Bump network version --- src/openrct2/network/NetworkBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index ba2b229c39..843d4aeee2 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -34,7 +34,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 "1" +#define NETWORK_STREAM_VERSION "2" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; From 3729ebb542589e51aa8bd13881323015f3a45481 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 7 Nov 2020 14:14:16 +0000 Subject: [PATCH 7/7] Update replays for change --- CMakeLists.txt | 4 ++-- openrct2.proj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff81ed4369..fc8e92e457 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,8 +44,8 @@ set(TITLE_SEQUENCE_SHA1 "304d13a126c15bf2c86ff13b81a2f2cc1856ac8d") set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v1.0.18/objects.zip") set(OBJECTS_SHA1 "4a3c32a0251c3babe014844f2c683fc32138b3f2") -set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.20/replays.zip") -set(REPLAYS_SHA1 "65532bcb21c39236cfc1b7301d30297506383b65") +set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.21/replays.zip") +set(REPLAYS_SHA1 "23BF9B52D2D0BDBAF7E2DE4F35ED53F6A416539D") 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 bc535a7743..2b4478a78e 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -48,8 +48,8 @@ 304d13a126c15bf2c86ff13b81a2f2cc1856ac8d https://github.com/OpenRCT2/objects/releases/download/v1.0.18/objects.zip 4a3c32a0251c3babe014844f2c683fc32138b3f2 - https://github.com/OpenRCT2/replays/releases/download/v0.0.20/replays.zip - 65532bcb21c39236cfc1b7301d30297506383b65 + https://github.com/OpenRCT2/replays/releases/download/v0.0.21/replays.zip + 23BF9B52D2D0BDBAF7E2DE4F35ED53F6A416539D