diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index c88a3b40e4..9781f1ba32 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -1505,7 +1505,7 @@ private: for (; ObjectEntryGetChunk(ObjectType::Ride, entry_index) == nullptr; entry_index++) ; - RideObjectEntry* ride_entry = GetRideEntryByIndex(entry_index); + const auto* ride_entry = GetRideEntryByIndex(entry_index); auto rideType = ride_entry->GetFirstNonNullRideType(); auto intent = Intent(WindowClass::TrackDesignList); @@ -1586,7 +1586,7 @@ void EditorLoadSelectedObjects() auto entryIndex = ObjectManagerGetLoadedObjectEntryIndex(loadedObject); if (objectType == ObjectType::Ride) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(entryIndex); + const auto* rideEntry = GetRideEntryByIndex(entryIndex); auto rideType = rideEntry->GetFirstNonNullRideType(); ResearchCategory category = static_cast(GetRideTypeDescriptor(rideType).Category); ResearchInsertRideEntry(rideType, entryIndex, category, true); diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index 551ecbe0eb..5bf54f3f96 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -680,7 +680,7 @@ private: continue; // Ride entries - RideObjectEntry* rideEntry = GetRideEntryByIndex(rideEntryIndex); + const auto* rideEntry = GetRideEntryByIndex(rideEntryIndex); // Skip if the vehicle isn't the preferred vehicle for this generic track type if (!gConfigInterface.ListRideVehiclesSeparately @@ -919,7 +919,7 @@ private: void DrawRideInformation(DrawPixelInfo& dpi, RideSelection item, const ScreenCoordsXY& screenPos, int32_t textWidth) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(item.EntryIndex); + const auto* rideEntry = GetRideEntryByIndex(item.EntryIndex); RideNaming rideNaming = GetRideNaming(item.Type, *rideEntry); auto ft = Formatter(); @@ -1077,7 +1077,7 @@ void WindowNewRideFocus(RideSelection rideItem) return; } - RideObjectEntry* rideEntry = GetRideEntryByIndex(rideItem.EntryIndex); + const auto* rideEntry = GetRideEntryByIndex(rideItem.EntryIndex); if (rideEntry == nullptr) return; diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index be5ec1fb3b..e2d28030d1 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -858,7 +858,7 @@ struct VehicleTypeLabel }; static int32_t VehicleDropdownDataLanguage = LANGUAGE_UNDEFINED; -static RideObjectEntry* VehicleDropdownRideType = nullptr; +static const RideObjectEntry* VehicleDropdownRideType = nullptr; static bool VehicleDropdownExpanded = false; static std::vector VehicleDropdownData; @@ -970,7 +970,7 @@ static void WindowRideDrawTabVehicle(DrawPixelInfo* dpi, WindowBase* w) } const auto vehicle = RideEntryGetVehicleAtPosition(ride->subtype, ride->num_cars_per_train, rideEntry->TabCar); - CarEntry* carEntry = &rideEntry->Cars[vehicle]; + const auto& carEntry = rideEntry->Cars[vehicle]; auto vehicleId = ((ride->colour_scheme_type & 3) == VEHICLE_COLOUR_SCHEME_PER_VEHICLE) ? rideEntry->TabCar : 0; VehicleColour vehicleColour = RideGetVehicleColour(*ride, vehicleId); @@ -979,10 +979,10 @@ static void WindowRideDrawTabVehicle(DrawPixelInfo* dpi, WindowBase* w) auto imageIndex = OpenRCT2::Entity::Yaw::YawFrom4(2) * 2; if (w->page == WINDOW_RIDE_PAGE_VEHICLE) imageIndex += w->frame_no; - imageIndex = carEntry->SpriteByYaw(imageIndex / 2, SpriteGroupType::SlopeFlat); - imageIndex &= carEntry->TabRotationMask; - imageIndex *= carEntry->base_num_frames; - imageIndex += carEntry->base_image_id; + imageIndex = carEntry.SpriteByYaw(imageIndex / 2, SpriteGroupType::SlopeFlat); + imageIndex &= carEntry.TabRotationMask; + imageIndex *= carEntry.base_num_frames; + imageIndex += carEntry.base_image_id; auto imageId = ImageId(imageIndex, vehicleColour.Body, vehicleColour.Trim, vehicleColour.Tertiary); GfxDrawSprite(&clipDPI, imageId, screenCoords); } @@ -1073,7 +1073,7 @@ static void WindowRideDisableTabs(WindowBase* w) if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER) != 0) disabled_tabs |= (1uLL << WIDX_TAB_4 | 1uLL << WIDX_TAB_6 | 1uLL << WIDX_TAB_9 | 1uLL << WIDX_TAB_10); // 0x3280 - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride->subtype); + const auto* rideEntry = GetRideEntryByIndex(ride->subtype); if (rideEntry == nullptr) { @@ -1516,7 +1516,7 @@ static void WindowRideInitViewport(WindowBase* w) if (viewSelectionIndex >= 0 && viewSelectionIndex < ride->NumTrains && ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) { auto vehId = ride->vehicles[viewSelectionIndex]; - RideObjectEntry* ride_entry = ride->GetRideEntry(); + const auto* ride_entry = ride->GetRideEntry(); if (ride_entry != nullptr && ride_entry->TabCar != 0) { Vehicle* vehicle = GetEntity(vehId); @@ -2010,7 +2010,7 @@ static void WindowRideMainFollowRide(WindowBase* w) static void PopulateVehicleTypeDropdown(const Ride& ride, bool forceRefresh) { auto& objManager = GetContext()->GetObjectManager(); - RideObjectEntry* rideEntry = ride.GetRideEntry(); + const auto* rideEntry = ride.GetRideEntry(); bool selectionShouldBeExpanded; int32_t rideTypeIterator, rideTypeIteratorMax; @@ -2798,7 +2798,6 @@ static OpenRCT2String WindowRideVehicleTooltip(WindowBase* const w, const Widget static void WindowRideVehicleInvalidate(WindowBase* w) { Widget* widgets; - RideObjectEntry* rideEntry; StringId stringId; int32_t carsPerTrain; @@ -2815,7 +2814,7 @@ static void WindowRideVehicleInvalidate(WindowBase* w) if (ride == nullptr) return; - rideEntry = ride->GetRideEntry(); + const auto* rideEntry = ride->GetRideEntry(); w->widgets[WIDX_TITLE].text = STR_ARG_20_STRINGID; @@ -2970,7 +2969,7 @@ static void WindowRideVehicleScrollpaint(WindowBase* w, DrawPixelInfo* dpi, int3 if (ride == nullptr) return; - RideObjectEntry* rideEntry = ride->GetRideEntry(); + const auto* rideEntry = ride->GetRideEntry(); // Background GfxFillRect(dpi, { { dpi->x, dpi->y }, { dpi->x + dpi->width, dpi->y + dpi->height } }, PALETTE_INDEX_12); @@ -2979,8 +2978,8 @@ static void WindowRideVehicleScrollpaint(WindowBase* w, DrawPixelInfo* dpi, int3 int32_t startX = std::max(2, (widget->width() - ((ride->NumTrains - 1) * 36)) / 2 - 25); int32_t startY = widget->height() - 4; - CarEntry* carEntry = &rideEntry->Cars[RideEntryGetVehicleAtPosition(ride->subtype, ride->num_cars_per_train, 0)]; - startY += carEntry->tab_height; + const auto& firstCarEntry = rideEntry->Cars[RideEntryGetVehicleAtPosition(ride->subtype, ride->num_cars_per_train, 0)]; + startY += firstCarEntry.tab_height; // For each train for (int32_t i = 0; i < ride->NumTrains; i++) @@ -2994,9 +2993,9 @@ static void WindowRideVehicleScrollpaint(WindowBase* w, DrawPixelInfo* dpi, int3 static_assert(std::numeric_limitsnum_cars_per_train)>::max() <= std::size(trainCarImages)); for (int32_t j = 0; j < ride->num_cars_per_train; j++) { - carEntry = &rideEntry->Cars[RideEntryGetVehicleAtPosition(ride->subtype, ride->num_cars_per_train, j)]; - x += carEntry->spacing / 17432; - y -= (carEntry->spacing / 2) / 17432; + const auto& carEntry = rideEntry->Cars[RideEntryGetVehicleAtPosition(ride->subtype, ride->num_cars_per_train, j)]; + x += carEntry.spacing / 17432; + y -= (carEntry.spacing / 2) / 17432; // Get colour of vehicle int32_t vehicleColourIndex = 0; @@ -3014,10 +3013,10 @@ static void WindowRideVehicleScrollpaint(WindowBase* w, DrawPixelInfo* dpi, int3 } VehicleColour vehicleColour = RideGetVehicleColour(*ride, vehicleColourIndex); - ImageIndex imageIndex = carEntry->SpriteByYaw(OpenRCT2::Entity::Yaw::BaseRotation / 2, SpriteGroupType::SlopeFlat); - imageIndex &= carEntry->TabRotationMask; - imageIndex *= carEntry->base_num_frames; - imageIndex += carEntry->base_image_id; + ImageIndex imageIndex = carEntry.SpriteByYaw(OpenRCT2::Entity::Yaw::BaseRotation / 2, SpriteGroupType::SlopeFlat); + imageIndex &= carEntry.TabRotationMask; + imageIndex *= carEntry.base_num_frames; + imageIndex += carEntry.base_image_id; auto imageId = ImageId(imageIndex, vehicleColour.Body, vehicleColour.Trim, vehicleColour.Tertiary); @@ -3026,8 +3025,8 @@ static void WindowRideVehicleScrollpaint(WindowBase* w, DrawPixelInfo* dpi, int3 nextSpriteToDraw->imageId = imageId; nextSpriteToDraw++; - x += carEntry->spacing / 17432; - y -= (carEntry->spacing / 2) / 17432; + x += carEntry.spacing / 17432; + y -= (carEntry.spacing / 2) / 17432; } if (ride->type == RIDE_TYPE_REVERSER_ROLLER_COASTER) @@ -5021,17 +5020,17 @@ static void WindowRideColourScrollpaint(WindowBase* w, DrawPixelInfo* dpi, int32 auto trainCarIndex = (ride->colour_scheme_type & 3) == RIDE_COLOUR_SCHEME_MODE_DIFFERENT_PER_CAR ? w->vehicleIndex : rideEntry->TabCar; - CarEntry* carEntry = &rideEntry - ->Cars[RideEntryGetVehicleAtPosition(ride->subtype, ride->num_cars_per_train, trainCarIndex)]; + const auto& carEntry = rideEntry + ->Cars[RideEntryGetVehicleAtPosition(ride->subtype, ride->num_cars_per_train, trainCarIndex)]; - screenCoords.y += carEntry->tab_height; + screenCoords.y += carEntry.tab_height; // Draw the coloured spinning vehicle // w->frame_no represents a SpritePrecision of 64 - ImageIndex imageIndex = carEntry->SpriteByYaw(w->frame_no / 2, SpriteGroupType::SlopeFlat); - imageIndex &= carEntry->TabRotationMask; - imageIndex *= carEntry->base_num_frames; - imageIndex += carEntry->base_image_id; + ImageIndex imageIndex = carEntry.SpriteByYaw(w->frame_no / 2, SpriteGroupType::SlopeFlat); + imageIndex &= carEntry.TabRotationMask; + imageIndex *= carEntry.base_num_frames; + imageIndex += carEntry.base_image_id; auto imageId = ImageId(imageIndex, vehicleColour.Body, vehicleColour.Trim, vehicleColour.Tertiary); GfxDrawSprite(dpi, imageId, screenCoords); } diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 09e9c06810..6384aaf7a3 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -362,7 +362,7 @@ public: void OnPrepareDraw() override { StringId stringId = STR_NONE; - RideObjectEntry* entry = GetRideEntryByIndex(_window_track_list_item.EntryIndex); + const auto* entry = GetRideEntryByIndex(_window_track_list_item.EntryIndex); if (entry != nullptr) { diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index 2188ff35f5..136850663a 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -279,7 +279,7 @@ StringId LandSetHeightAction::CheckRideSupports() const if (ride == nullptr) continue; - RideObjectEntry* rideEntry = ride->GetRideEntry(); + const auto* rideEntry = ride->GetRideEntry(); if (rideEntry == nullptr) continue; diff --git a/src/openrct2/actions/RideCreateAction.cpp b/src/openrct2/actions/RideCreateAction.cpp index 9f5c2776ef..53752387a9 100644 --- a/src/openrct2/actions/RideCreateAction.cpp +++ b/src/openrct2/actions/RideCreateAction.cpp @@ -97,13 +97,13 @@ GameActions::Result RideCreateAction::Query() const return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); } - RideObjectEntry* rideEntry = GetRideEntryByIndex(rideEntryIndex); + const auto* rideEntry = GetRideEntryByIndex(rideEntryIndex); if (rideEntry == nullptr) { return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); } - VehicleColourPresetList* presetList = rideEntry->vehicle_preset_list; + const auto* presetList = rideEntry->vehicle_preset_list; if ((presetList->count > 0 && presetList->count != 255) && _colour2 >= presetList->count) { return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); @@ -117,14 +117,13 @@ GameActions::Result RideCreateAction::Query() const GameActions::Result RideCreateAction::Execute() const { - RideObjectEntry* rideEntry; auto res = GameActions::Result(); int32_t rideEntryIndex = RideGetEntryIndex(_rideType, _subType); auto rideIndex = GetNextFreeRideId(); auto ride = GetOrAllocateRide(rideIndex); - rideEntry = GetRideEntryByIndex(rideEntryIndex); + const auto* rideEntry = GetRideEntryByIndex(rideEntryIndex); if (rideEntry == nullptr) { LOG_WARNING("Invalid request for ride %u", rideIndex); diff --git a/src/openrct2/actions/RideSetPriceAction.cpp b/src/openrct2/actions/RideSetPriceAction.cpp index 562632c939..261056a67d 100644 --- a/src/openrct2/actions/RideSetPriceAction.cpp +++ b/src/openrct2/actions/RideSetPriceAction.cpp @@ -58,7 +58,7 @@ GameActions::Result RideSetPriceAction::Query() const return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride->subtype); + const auto* rideEntry = GetRideEntryByIndex(ride->subtype); if (rideEntry == nullptr) { LOG_WARNING("Invalid game command for ride %u", _rideIndex.ToUnderlying()); @@ -80,7 +80,7 @@ GameActions::Result RideSetPriceAction::Execute() const return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride->subtype); + const auto* rideEntry = GetRideEntryByIndex(ride->subtype); if (rideEntry == nullptr) { LOG_WARNING("Invalid game command for ride %u", _rideIndex.ToUnderlying()); diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 6d5c197185..53ae41ffb5 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -74,7 +74,7 @@ GameActions::Result TrackPlaceAction::Query() const return GameActions::Result( GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE); } - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride->subtype); + const auto* rideEntry = GetRideEntryByIndex(ride->subtype); if (rideEntry == nullptr) { LOG_WARNING("Invalid ride subtype for track placement, rideIndex = %d", _rideIndex.ToUnderlying()); @@ -417,7 +417,7 @@ GameActions::Result TrackPlaceAction::Execute() const GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE); } - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride->subtype); + const auto* rideEntry = GetRideEntryByIndex(ride->subtype); if (rideEntry == nullptr) { LOG_WARNING("Invalid ride subtype for track placement, rideIndex = %d", _rideIndex.ToUnderlying()); diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index d73fce029c..d7b8d77ede 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -2503,7 +2503,7 @@ void Guest::GoToRideEntrance(const Ride& ride) int16_t y_shift = DirectionOffsets[location.direction].y; uint8_t shift_multiplier = 21; - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride.subtype); + const auto* rideEntry = GetRideEntryByIndex(ride.subtype); if (rideEntry != nullptr) { if (rideEntry->Cars[rideEntry->DefaultCar].flags & CAR_ENTRY_FLAG_MINI_GOLF @@ -3386,7 +3386,7 @@ void Guest::UpdateBuying() } else { - RideObjectEntry* ride_type = GetRideEntryByIndex(ride->subtype); + const auto* ride_type = GetRideEntryByIndex(ride->subtype); if (ride_type == nullptr) { return; @@ -3578,7 +3578,7 @@ void PeepUpdateRideLeaveEntranceDefault(Guest* peep, Ride& ride, CoordsXYZD& ent } } -uint8_t Guest::GetWaypointedSeatLocation(const Ride& ride, CarEntry* vehicle_type, uint8_t track_direction) const +uint8_t Guest::GetWaypointedSeatLocation(const Ride& ride, const CarEntry* vehicle_type, uint8_t track_direction) const { // The seatlocation can be split into segments around the ride base // to decide the segment first split off the segmentable seat location @@ -3619,8 +3619,8 @@ void Guest::UpdateRideLeaveEntranceWaypoints(const Ride& ride) // TODO: Goto ride exit on failure. return; } - auto ride_entry = vehicle->GetRideEntry(); - auto vehicle_type = &ride_entry->Cars[vehicle->vehicle_type]; + const auto* ride_entry = vehicle->GetRideEntry(); + const auto* vehicle_type = &ride_entry->Cars[vehicle->vehicle_type]; Var37 = (direction_entrance | GetWaypointedSeatLocation(ride, vehicle_type, direction_track) * 4) * 4; @@ -3648,7 +3648,7 @@ void Guest::UpdateRideAdvanceThroughEntrance() int16_t actionZ, xy_distance; - auto ride_entry = ride->GetRideEntry(); + const auto* ride_entry = ride->GetRideEntry(); if (auto loc = UpdateAction(xy_distance); loc.has_value()) { @@ -3715,7 +3715,7 @@ void Guest::UpdateRideAdvanceThroughEntrance() return; } - CarEntry* vehicle_type = &ride_entry->Cars[vehicle->vehicle_type]; + const auto* vehicle_type = &ride_entry->Cars[vehicle->vehicle_type]; if (vehicle_type->flags & CAR_ENTRY_FLAG_LOADING_WAYPOINTS) { @@ -3789,11 +3789,11 @@ static void PeepGoToRideExit(Peep* peep, const Ride& ride, int16_t x, int16_t y, int16_t shift_multiplier = 20; - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride.subtype); + const auto* rideEntry = GetRideEntryByIndex(ride.subtype); if (rideEntry != nullptr) { - CarEntry* carEntry = &rideEntry->Cars[rideEntry->DefaultCar]; - if (carEntry->flags & CAR_ENTRY_FLAG_MINI_GOLF || carEntry->flags & (CAR_ENTRY_FLAG_CHAIRLIFT | CAR_ENTRY_FLAG_GO_KART)) + const CarEntry& carEntry = rideEntry->Cars[rideEntry->DefaultCar]; + if (carEntry.flags & CAR_ENTRY_FLAG_MINI_GOLF || carEntry.flags & (CAR_ENTRY_FLAG_CHAIRLIFT | CAR_ENTRY_FLAG_GO_KART)) { shift_multiplier = 32; } @@ -3930,7 +3930,7 @@ void Guest::UpdateRideFreeVehicleCheck() if (vehicle == nullptr) return; - RideObjectEntry* ride_entry = vehicle->GetRideEntry(); + const auto* ride_entry = vehicle->GetRideEntry(); if (ride_entry == nullptr) { return; @@ -4123,13 +4123,13 @@ void Guest::UpdateRideLeaveVehicle() ride_station = bestStationIndex; } CurrentRideStation = ride_station; - RideObjectEntry* rideEntry = vehicle->GetRideEntry(); + const auto* rideEntry = vehicle->GetRideEntry(); if (rideEntry == nullptr) { return; } - CarEntry* carEntry = &rideEntry->Cars[vehicle->vehicle_type]; + const auto* carEntry = &rideEntry->Cars[vehicle->vehicle_type]; assert(CurrentRideStation.ToUnderlying() < OpenRCT2::Limits::MaxStationsPerRide); auto& station = ride->GetStation(CurrentRideStation); @@ -4291,7 +4291,7 @@ void Guest::UpdateRideLeaveVehicle() */ void Guest::UpdateRidePrepareForExit() { - auto ride = GetRide(CurrentRide); + const auto* ride = GetRide(CurrentRide); if (ride == nullptr || CurrentRideStation.ToUnderlying() >= std::size(ride->GetStations())) return; @@ -4302,11 +4302,11 @@ void Guest::UpdateRidePrepareForExit() int16_t shiftMultiplier = 20; - RideObjectEntry* rideEntry = ride->GetRideEntry(); + const auto* rideEntry = ride->GetRideEntry(); if (rideEntry != nullptr) { - CarEntry* carEntry = &rideEntry->Cars[rideEntry->DefaultCar]; - if (carEntry->flags & (CAR_ENTRY_FLAG_CHAIRLIFT | CAR_ENTRY_FLAG_GO_KART)) + const auto& carEntry = rideEntry->Cars[rideEntry->DefaultCar]; + if (carEntry.flags & (CAR_ENTRY_FLAG_CHAIRLIFT | CAR_ENTRY_FLAG_GO_KART)) { shiftMultiplier = 32; } @@ -4424,16 +4424,16 @@ void Guest::UpdateRideApproachVehicleWaypoints() CoordsXY targetLoc = rtd.GetGuestWaypointLocation(*vehicle, *ride, CurrentRideStation); - RideObjectEntry* ride_entry = vehicle->GetRideEntry(); + const auto* ride_entry = vehicle->GetRideEntry(); if (ride_entry == nullptr) { return; } - CarEntry* vehicle_type = &ride_entry->Cars[vehicle->vehicle_type]; + const auto& vehicle_type = ride_entry->Cars[vehicle->vehicle_type]; Guard::Assert(waypoint < 3); - targetLoc.x += vehicle_type->peep_loading_waypoints[Var37 / 4][waypoint].x; - targetLoc.y += vehicle_type->peep_loading_waypoints[Var37 / 4][waypoint].y; + targetLoc.x += vehicle_type.peep_loading_waypoints[Var37 / 4][waypoint].x; + targetLoc.y += vehicle_type.peep_loading_waypoints[Var37 / 4][waypoint].y; SetDestination(targetLoc); } @@ -4516,7 +4516,7 @@ void Guest::UpdateRideApproachExitWaypoints() return; } - RideObjectEntry* rideEntry = vehicle->GetRideEntry(); + const auto* rideEntry = vehicle->GetRideEntry(); if (rideEntry == nullptr) return; diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index 36ef34d179..3c7fd5708b 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -393,7 +393,7 @@ private: void UpdateRideAtEntrance(); void UpdateRideAdvanceThroughEntrance(); void UpdateRideLeaveEntranceWaypoints(const Ride& ride); - uint8_t GetWaypointedSeatLocation(const Ride& ride, CarEntry* vehicle_type, uint8_t track_direction) const; + uint8_t GetWaypointedSeatLocation(const Ride& ride, const CarEntry* vehicle_type, uint8_t track_direction) const; void UpdateRideFreeVehicleCheck(); void UpdateRideFreeVehicleEnterRide(Ride& ride); void UpdateRideApproachVehicle(); diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index d71ce8ffa5..78518dc2a5 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1233,9 +1233,7 @@ static int32_t ConsoleCommandLoadObject(InteractiveConsole& console, const argum if (objectType == ObjectType::Ride) { // Automatically research the ride so it's supported by the game. - RideObjectEntry* rideEntry; - - rideEntry = GetRideEntryByIndex(groupIndex); + const auto* rideEntry = GetRideEntryByIndex(groupIndex); for (int32_t j = 0; j < RCT2::ObjectLimits::MaxRideTypesPerRideEntry; j++) { diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 24e8c9a9d0..7b26628a5b 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -202,7 +202,7 @@ void ResearchFinishItem(ResearchItem* researchItem) // Ride auto base_ride_type = researchItem->baseRideType; ObjectEntryIndex rideEntryIndex = researchItem->entryIndex; - RideObjectEntry* rideEntry = GetRideEntryByIndex(rideEntryIndex); + const auto* rideEntry = GetRideEntryByIndex(rideEntryIndex); if (rideEntry != nullptr && base_ride_type != RIDE_TYPE_NULL) { @@ -234,7 +234,7 @@ void ResearchFinishItem(ResearchItem* researchItem) { if (!seenRideEntry[i]) { - RideObjectEntry* rideEntry2 = GetRideEntryByIndex(i); + const auto* rideEntry2 = GetRideEntryByIndex(i); if (rideEntry2 != nullptr) { for (uint8_t j = 0; j < RCT2::ObjectLimits::MaxRideTypesPerRideEntry; j++) @@ -475,7 +475,7 @@ void ResearchPopulateListRandom() // Rides for (int32_t i = 0; i < MAX_RIDE_OBJECTS; i++) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(i); + const auto* rideEntry = GetRideEntryByIndex(i); if (rideEntry == nullptr) { continue; @@ -520,7 +520,7 @@ bool ResearchInsertRideEntry(ride_type_t rideType, ObjectEntryIndex entryIndex, void ResearchInsertRideEntry(ObjectEntryIndex entryIndex, bool researched) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(entryIndex); + const auto* rideEntry = GetRideEntryByIndex(entryIndex); if (rideEntry == nullptr) return; @@ -707,7 +707,7 @@ StringId ResearchItem::GetName() const { if (type == Research::EntryType::Ride) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(entryIndex); + const auto* rideEntry = GetRideEntryByIndex(entryIndex); if (rideEntry == nullptr) { return STR_EMPTY; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index f11869250e..a67ae0e6ff 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -806,7 +806,7 @@ namespace RCT1 dst->subtype = _rideTypeToRideEntryMap[EnumValue(src->Type)]; } - RideObjectEntry* rideEntry = GetRideEntryByIndex(dst->subtype); + const auto* rideEntry = GetRideEntryByIndex(dst->subtype); // This can happen with hacked parks if (rideEntry == nullptr) { @@ -2229,7 +2229,7 @@ namespace RCT1 if (entryIndex != OBJECT_ENTRY_INDEX_NULL) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(entryIndex); + const auto* rideEntry = GetRideEntryByIndex(entryIndex); if (rideEntry != nullptr) { @@ -2248,7 +2248,7 @@ namespace RCT1 if (entryIndex != OBJECT_ENTRY_INDEX_NULL) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(entryIndex); + const auto* rideEntry = GetRideEntryByIndex(entryIndex); if (rideEntry != nullptr) { diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 84a0c4418a..e540153216 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -197,18 +197,17 @@ Ride* GetRide(RideId index) return nullptr; } -RideObjectEntry* GetRideEntryByIndex(ObjectEntryIndex index) +const RideObjectEntry* GetRideEntryByIndex(ObjectEntryIndex index) { - RideObjectEntry* result = nullptr; auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); auto obj = objMgr.GetLoadedObject(ObjectType::Ride, index); - if (obj != nullptr) + if (obj == nullptr) { - result = static_cast(obj->GetLegacyData()); + return nullptr; } - return result; + return static_cast(obj->GetLegacyData()); } std::string_view GetRideEntryName(ObjectEntryIndex index) @@ -227,7 +226,7 @@ std::string_view GetRideEntryName(ObjectEntryIndex index) return {}; } -RideObjectEntry* Ride::GetRideEntry() const +const RideObjectEntry* Ride::GetRideEntry() const { return GetRideEntryByIndex(subtype); } @@ -369,7 +368,7 @@ void RideUpdateFavouritedStat() money64 Ride::CalculateIncomePerHour() const { // Get entry by ride to provide better reporting - RideObjectEntry* entry = GetRideEntry(); + const auto* entry = GetRideEntry(); if (entry == nullptr) { return 0; @@ -1456,7 +1455,7 @@ bool Ride::CanBreakDown() const return false; } - RideObjectEntry* entry = GetRideEntry(); + const auto* entry = GetRideEntry(); return entry != nullptr && !(entry->flags & RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN); } @@ -2186,26 +2185,23 @@ int32_t RideGetUnusedPresetVehicleColour(ObjectEntryIndex subType) */ void RideSetVehicleColoursToRandomPreset(Ride& ride, uint8_t preset_index) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride.subtype); - VehicleColourPresetList* presetList = rideEntry->vehicle_preset_list; + const auto* rideEntry = GetRideEntryByIndex(ride.subtype); + const auto* presetList = rideEntry->vehicle_preset_list; if (presetList->count != 0 && presetList->count != 255) { assert(preset_index < presetList->count); ride.colour_scheme_type = RIDE_COLOUR_SCHEME_MODE_ALL_SAME; - VehicleColour* preset = &presetList->list[preset_index]; - ride.vehicle_colours[0] = *preset; + ride.vehicle_colours[0] = presetList->list[preset_index]; } else { ride.colour_scheme_type = RIDE_COLOUR_SCHEME_MODE_DIFFERENT_PER_TRAIN; - uint32_t count = presetList->count; - for (uint32_t i = 0; i < count; i++) + for (uint32_t i = 0; i < presetList->count; i++) { - auto index = i % static_cast(32); - VehicleColour* preset = &presetList->list[index]; - ride.vehicle_colours[i] = *preset; + const auto index = i % 32U; + ride.vehicle_colours[i] = presetList->list[index]; } } } @@ -4156,7 +4152,7 @@ void Ride::SetColourPreset(uint8_t index) // Stalls save their default colour in the vehicle settings (since they share a common ride type) if (!IsRide()) { - auto rideEntry = GetRideEntryByIndex(subtype); + const auto* rideEntry = GetRideEntryByIndex(subtype); if (rideEntry != nullptr && rideEntry->vehicle_preset_list->count > 0) { auto list = rideEntry->vehicle_preset_list->list[0]; @@ -4577,7 +4573,7 @@ void RideUpdateVehicleColours(const Ride& ride) uint8_t RideEntryGetVehicleAtPosition(int32_t rideEntryIndex, int32_t numCarsPerTrain, int32_t position) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(rideEntryIndex); + const auto* rideEntry = GetRideEntryByIndex(rideEntryIndex); if (position == 0 && rideEntry->FrontCar != 255) { return rideEntry->FrontCar; @@ -4872,7 +4868,7 @@ void Ride::UpdateMaxVehicles() if (subtype == OBJECT_ENTRY_INDEX_NULL) return; - const RideObjectEntry* rideEntry = GetRideEntryByIndex(subtype); + const auto* rideEntry = GetRideEntryByIndex(subtype); if (rideEntry == nullptr) { return; @@ -5339,7 +5335,7 @@ int32_t RideGetEntryIndex(int32_t rideType, int32_t rideSubType) subType = rideEntries[0]; for (auto rideEntryIndex : rideEntries) { - auto rideEntry = GetRideEntryByIndex(rideEntryIndex); + const auto* rideEntry = GetRideEntryByIndex(rideEntryIndex); if (rideEntry == nullptr) { return OBJECT_ENTRY_INDEX_NULL; @@ -5756,7 +5752,7 @@ ResultWithMessage Ride::ChangeStatusCheckTrackValidity(const CoordsXYE& trackEle if (subtype != OBJECT_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(subtype); + const auto* rideEntry = GetRideEntryByIndex(subtype); if (rideEntry->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS) { if (RideCheckTrackContainsInversions(trackElement, &problematicTrackElement)) diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 3e4b02b62b..cb5b15148a 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -353,7 +353,7 @@ public: void SetColourPreset(uint8_t index); - RideObjectEntry* GetRideEntry() const; + const RideObjectEntry* GetRideEntry() const; size_t GetNumPrices() const; int32_t GetAge() const; @@ -996,7 +996,7 @@ struct RideManager RideManager GetRideManager(); RideId GetNextFreeRideId(); Ride* GetOrAllocateRide(RideId index); -RideObjectEntry* GetRideEntryByIndex(ObjectEntryIndex index); +const RideObjectEntry* GetRideEntryByIndex(ObjectEntryIndex index); std::string_view GetRideEntryName(ObjectEntryIndex index); extern money16 gTotalRideValueForMoney; diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 3266d32e1f..cdffb5d8c2 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -94,7 +94,7 @@ using namespace OpenRCT2::TrackMetaData; static int32_t ride_check_if_construction_allowed(Ride& ride) { Formatter ft; - RideObjectEntry* rideEntry = ride.GetRideEntry(); + const auto* rideEntry = ride.GetRideEntry(); if (rideEntry == nullptr) { ContextShowError(STR_INVALID_RIDE_TYPE, STR_CANT_EDIT_INVALID_RIDE_TYPE, ft); diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index a4d45d249e..63c39053be 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -976,7 +976,7 @@ static uint16_t ride_compute_upkeep(RideRatingUpdateState& state, const Ride& ri */ static void ride_ratings_apply_adjustments(const Ride& ride, RatingTuple* ratings) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride.subtype); + const auto* rideEntry = GetRideEntryByIndex(ride.subtype); if (rideEntry == nullptr) { @@ -1135,7 +1135,7 @@ static ShelteredEights get_num_of_sheltered_eighths(const Ride& ride) } uint8_t trackShelteredEighths = numShelteredEighths; - RideObjectEntry* rideType = GetRideEntryByIndex(ride.subtype); + const auto* rideType = GetRideEntryByIndex(ride.subtype); if (rideType == nullptr) { return { 0, 0 }; diff --git a/src/openrct2/ride/Station.cpp b/src/openrct2/ride/Station.cpp index a26fed7855..6e1ca6d744 100644 --- a/src/openrct2/ride/Station.cpp +++ b/src/openrct2/ride/Station.cpp @@ -280,7 +280,7 @@ static void ride_race_init_vehicle_speeds(const Ride& ride) vehicle->ClearUpdateFlag(VEHICLE_UPDATE_FLAG_6); - RideObjectEntry* rideEntry = vehicle->GetRideEntry(); + const auto* rideEntry = vehicle->GetRideEntry(); vehicle->speed = (ScenarioRand() & 15) - 8 + rideEntry->Cars[vehicle->vehicle_type].powered_max_speed; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index c6eda6af35..ac8cbab257 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -811,7 +811,7 @@ OpenRCT2::Audio::VehicleSoundParams Vehicle::CreateSoundParam(uint16_t priority) int32_t frequency = std::abs(velocity); - RideObjectEntry* rideType = GetRideEntry(); + const auto* rideType = GetRideEntry(); if (rideType != nullptr) { if (rideType->Cars[vehicle_type].double_sound_frequency & 1) @@ -1322,15 +1322,15 @@ bool Vehicle::OpenRestraints() continue; } - CarEntry* carEntry = &rideEntry->Cars[vehicle->vehicle_type]; + const auto& carEntry = rideEntry->Cars[vehicle->vehicle_type]; - if (carEntry->flags & CAR_ENTRY_FLAG_SPINNING) + if (carEntry.flags & CAR_ENTRY_FLAG_SPINNING) { // If the vehicle is a spinner it must be spinning slow // For vehicles without additional frames there are 4 rotations it can unload from // For vehicles with additional frames it must be facing forward if (abs(vehicle->spin_speed) <= VEHICLE_MAX_SPIN_SPEED_FOR_STOPPING && !(vehicle->spin_sprite & 0x30) - && (!(carEntry->flags & CAR_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES) || !(vehicle->spin_sprite & 0xF8))) + && (!(carEntry.flags & CAR_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES) || !(vehicle->spin_sprite & 0xF8))) { vehicle->spin_speed = 0; } @@ -1351,7 +1351,7 @@ bool Vehicle::OpenRestraints() continue; } } - if (carEntry->animation == CAR_ENTRY_ANIMATION_OBSERVATION_TOWER && vehicle->animation_frame != 0) + if (carEntry.animation == CAR_ENTRY_ANIMATION_OBSERVATION_TOWER && vehicle->animation_frame != 0) { if (vehicle->animationState <= 0xCCCC) { @@ -1367,7 +1367,7 @@ bool Vehicle::OpenRestraints() restraintsOpen = false; continue; } - if (carEntry->animation == CAR_ENTRY_ANIMATION_ANIMAL_FLYING + if (carEntry.animation == CAR_ENTRY_ANIMATION_ANIMAL_FLYING && (vehicle->animation_frame != 0 || vehicle->animationState > 0)) { vehicle->UpdateAnimationAnimalFlying(); @@ -2019,15 +2019,15 @@ void Vehicle::UpdateMovingToEndOfStation() break; default: { - RideObjectEntry* rideEntry = GetRideEntry(); + const auto* rideEntry = GetRideEntry(); if (rideEntry == nullptr) { return; } - CarEntry* carEntry = &rideEntry->Cars[vehicle_type]; + const auto& carEntry = rideEntry->Cars[vehicle_type]; - if (!(carEntry->flags & CAR_ENTRY_FLAG_POWERED)) + if (!(carEntry.flags & CAR_ENTRY_FLAG_POWERED)) { if (velocity <= 131940) { @@ -2331,15 +2331,15 @@ void Vehicle::UpdateDodgemsMode() if (curRide == nullptr) return; - RideObjectEntry* rideEntry = GetRideEntry(); + const auto* rideEntry = GetRideEntry(); if (rideEntry == nullptr) { return; } - CarEntry* carEntry = &rideEntry->Cars[vehicle_type]; + const auto& carEntry = rideEntry->Cars[vehicle_type]; // Mark the dodgem as in use. - if (carEntry->flags & CAR_ENTRY_FLAG_DODGEM_INUSE_LIGHTS && animation_frame != 1) + if (carEntry.flags & CAR_ENTRY_FLAG_DODGEM_INUSE_LIGHTS && animation_frame != 1) { animation_frame = 1; Invalidate(); @@ -3100,7 +3100,7 @@ void Vehicle::UpdateDeparting() if (curRide == nullptr) return; - auto rideEntry = GetRideEntry(); + const auto* rideEntry = GetRideEntry(); if (rideEntry == nullptr) return; @@ -3160,7 +3160,7 @@ void Vehicle::UpdateDeparting() } } - CarEntry* carEntry = &rideEntry->Cars[vehicle_type]; + const auto& carEntry = rideEntry->Cars[vehicle_type]; const auto& rtd = curRide->GetRideTypeDescriptor(); switch (curRide->mode) { @@ -3191,7 +3191,7 @@ void Vehicle::UpdateDeparting() case RideMode::RotatingLift: case RideMode::FreefallDrop: case RideMode::BoatHire: - if (carEntry->flags & CAR_ENTRY_FLAG_POWERED) + if (carEntry.flags & CAR_ENTRY_FLAG_POWERED) break; if (velocity <= 131940) @@ -3915,10 +3915,10 @@ void Vehicle::UpdateArriving() stationBrakesWork = false; } - RideObjectEntry* rideEntry = GetRideEntry(); - CarEntry* carEntry = &rideEntry->Cars[vehicle_type]; + const auto* rideEntry = GetRideEntry(); + const auto& carEntry = rideEntry->Cars[vehicle_type]; - UpdateArrivingPassThroughStation(*curRide, *carEntry, stationBrakesWork); + UpdateArrivingPassThroughStation(*curRide, carEntry, stationBrakesWork); curFlags = UpdateTrackMotion(nullptr); if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION && !stationBrakesWork) @@ -3943,7 +3943,7 @@ void Vehicle::UpdateArriving() } var_C0++; - if ((curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1) && (carEntry->flags & CAR_ENTRY_FLAG_GO_KART) && (var_C0 < 40)) + if ((curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1) && (carEntry.flags & CAR_ENTRY_FLAG_GO_KART) && (var_C0 < 40)) { return; } @@ -5466,17 +5466,17 @@ void Vehicle::UpdateSound() if (rideEntry == nullptr) return; - CarEntry* carEntry = &rideEntry->Cars[vehicle_type]; + const auto& carEntry = rideEntry->Cars[vehicle_type]; int32_t ecx = abs(velocity) - 0x10000; if (ecx >= 0) { - frictionSound.id = carEntry->friction_sound_id; + frictionSound.id = carEntry.friction_sound_id; ecx >>= 15; frictionSound.volume = std::min(208 + (ecx & 0xFF), 255); } - switch (carEntry->sound_range) + switch (carEntry.sound_range) { case SOUND_RANGE_WHISTLE: screamSound.id = scream_sound_id; @@ -5523,7 +5523,7 @@ void Vehicle::UpdateSound() break; default: - if ((carEntry->flags & CAR_ENTRY_FLAG_RIDERS_SCREAM)) + if ((carEntry.flags & CAR_ENTRY_FLAG_RIDERS_SCREAM)) { screamSound.id = UpdateScreamSound(); if (screamSound.id == OpenRCT2::Audio::SoundId::NoScream) @@ -5607,16 +5607,16 @@ OpenRCT2::Audio::SoundId Vehicle::UpdateScreamSound() OpenRCT2::Audio::SoundId Vehicle::ProduceScreamSound(const int32_t totalNumPeeps) { - RideObjectEntry* rideEntry = GetRideEntry(); + const auto* rideEntry = GetRideEntry(); - CarEntry* carEntry = &rideEntry->Cars[vehicle_type]; + const auto& carEntry = rideEntry->Cars[vehicle_type]; if (scream_sound_id == OpenRCT2::Audio::SoundId::Null) { auto r = ScenarioRand(); if (totalNumPeeps >= static_cast(r % 16)) { - switch (carEntry->sound_range) + switch (carEntry.sound_range) { case SOUND_RANGE_SCREAMS_0: scream_sound_id = _screamSet0[r % std::size(_screamSet0)]; @@ -5892,10 +5892,10 @@ int32_t Vehicle::UpdateMotionDodgems() { eax /= mass; } - RideObjectEntry* rideEntry = GetRideEntry(); - CarEntry* carEntry = &rideEntry->Cars[vehicle_type]; + const auto* rideEntry = GetRideEntry(); + const auto& carEntry = rideEntry->Cars[vehicle_type]; - if (!(carEntry->flags & CAR_ENTRY_FLAG_POWERED)) + if (!(carEntry.flags & CAR_ENTRY_FLAG_POWERED)) { acceleration = -eax; return _vehicleMotionTrackFlags; @@ -7006,7 +7006,7 @@ static void vehicle_update_play_water_splash_sound() */ void Vehicle::UpdateHandleWaterSplash() const { - RideObjectEntry* rideEntry = GetRideEntry(); + const auto* rideEntry = GetRideEntry(); auto trackType = GetTrackType(); if (!(rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND)) @@ -7299,7 +7299,7 @@ void Vehicle::ReverseReverserCar() */ void Vehicle::Sub6DBF3E() { - CarEntry* carEntry = Entry(); + const auto* carEntry = Entry(); acceleration /= _vehicleUnkF64E10; if (TrackSubposition == VehicleTrackSubposition::ChairliftGoingBack) @@ -7507,7 +7507,7 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, const Rid TrackLocation = location; // TODO check if getting the vehicle entry again is necessary - CarEntry* carEntry = Entry(); + const auto* carEntry = Entry(); if (carEntry == nullptr) { return false; @@ -7572,7 +7572,7 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, const Rid * * rct2: 0x006DAEB9 */ -bool Vehicle::UpdateTrackMotionForwards(CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) +bool Vehicle::UpdateTrackMotionForwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) { EntityId otherVehicleIndex = EntityId::GetNull(); Loc6DAEB9: @@ -7970,7 +7970,7 @@ bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, const Ri * * rct2: 0x006DBA33 */ -bool Vehicle::UpdateTrackMotionBackwards(CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) +bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) { EntityId otherVehicleIndex = EntityId::GetNull(); @@ -8118,7 +8118,7 @@ bool Vehicle::UpdateTrackMotionBackwards(CarEntry* carEntry, const Ride& curRide * */ -void Vehicle::UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, CarEntry* carEntry) +void Vehicle::UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry) { EntityId otherVehicleIndex = EntityId::GetNull(); TileElement* tileElement = nullptr; @@ -8740,11 +8740,11 @@ int32_t Vehicle::UpdateTrackMotionMiniGolf(int32_t* outStation) if (curRide == nullptr) return 0; - RideObjectEntry* rideEntry = GetRideEntry(); + const auto* rideEntry = GetRideEntry(); if (rideEntry == nullptr) return 0; - CarEntry* carEntry = Entry(); + const auto* carEntry = Entry(); gCurrentVehicle = this; _vehicleMotionTrackFlags = 0; @@ -8821,7 +8821,7 @@ static uint8_t modified_speed(uint16_t trackType, VehicleTrackSubposition trackS return speed; } -int32_t Vehicle::UpdateTrackMotionPoweredRideAcceleration(CarEntry* carEntry, uint32_t totalMass, const int32_t curAcceleration) +int32_t Vehicle::UpdateTrackMotionPoweredRideAcceleration(const CarEntry* carEntry, uint32_t totalMass, const int32_t curAcceleration) { if (carEntry->flags & CAR_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY) { @@ -8903,8 +8903,8 @@ int32_t Vehicle::UpdateTrackMotion(int32_t* outStation) if (curRide == nullptr) return 0; - RideObjectEntry* rideEntry = GetRideEntry(); - auto carEntry = Entry(); + const auto* rideEntry = GetRideEntry(); + const auto* carEntry = Entry(); if (carEntry == nullptr) { @@ -9118,14 +9118,14 @@ int32_t Vehicle::UpdateTrackMotion(int32_t* outStation) return _vehicleMotionTrackFlags; } -RideObjectEntry* Vehicle::GetRideEntry() const +const RideObjectEntry* Vehicle::GetRideEntry() const { return GetRideEntryByIndex(ride_subtype); } -CarEntry* Vehicle::Entry() const +const CarEntry* Vehicle::Entry() const { - RideObjectEntry* rideEntry = GetRideEntry(); + const auto* rideEntry = GetRideEntry(); if (rideEntry == nullptr) { return nullptr; @@ -9285,7 +9285,7 @@ void Vehicle::UpdateCrossings() const void Vehicle::Claxon() const { - RideObjectEntry* rideEntry = GetRideEntry(); + const auto* rideEntry = GetRideEntry(); switch (rideEntry->Cars[vehicle_type].sound_range) { case SOUND_RANGE_WHISTLE: diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index 38b3bd891e..fd11aae9b2 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -226,8 +226,8 @@ struct Vehicle : EntityBase GForces GetGForces() const; void SetMapToolbar() const; int32_t IsUsedInPairs() const; - RideObjectEntry* GetRideEntry() const; - CarEntry* Entry() const; + const RideObjectEntry* GetRideEntry() const; + const CarEntry* Entry() const; Ride* GetRide() const; Vehicle* TrainHead() const; Vehicle* TrainTail() const; @@ -333,9 +333,9 @@ private: void UpdateAdditionalAnimation(); void CheckIfMissing(); bool CurrentTowerElementIsTop(); - bool UpdateTrackMotionForwards(CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry); - bool UpdateTrackMotionBackwards(CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry); - int32_t UpdateTrackMotionPoweredRideAcceleration(CarEntry* carEntry, uint32_t totalMass, const int32_t curAcceleration); + bool UpdateTrackMotionForwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry); + bool UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry); + int32_t UpdateTrackMotionPoweredRideAcceleration(const CarEntry* carEntry, uint32_t totalMass, const int32_t curAcceleration); int32_t NumPeepsUntilTrainTail() const; void InvalidateWindow(); void TestReset(); @@ -364,7 +364,7 @@ private: void TrainReadyToDepart(uint8_t num_peeps_on_train, uint8_t num_used_seats); int32_t UpdateTrackMotionMiniGolfCalculateAcceleration(const CarEntry& carEntry); int32_t UpdateTrackMotionMiniGolf(int32_t* outStation); - void UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, CarEntry* carEntry); + void UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry); bool UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, const Ride& curRide, const RideObjectEntry& rideEntry); bool UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, const Ride& curRide, uint16_t* progress); bool UpdateMotionCollisionDetection(const CoordsXYZ& loc, EntityId* otherVehicleIndex); diff --git a/src/openrct2/ride/gentle/SpaceRings.cpp b/src/openrct2/ride/gentle/SpaceRings.cpp index e7812e3c87..532e7cb36d 100644 --- a/src/openrct2/ride/gentle/SpaceRings.cpp +++ b/src/openrct2/ride/gentle/SpaceRings.cpp @@ -40,7 +40,7 @@ static void PaintSpaceRingsStructure( if (ride.num_stations == 0 || vehicleIndex < ride.NumTrains) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride.subtype); + const auto* rideEntry = GetRideEntryByIndex(ride.subtype); int32_t frameNum = direction; diff --git a/src/openrct2/ride/thrill/SwingingInverterShip.cpp b/src/openrct2/ride/thrill/SwingingInverterShip.cpp index 0a12a37260..0fdf280f5a 100644 --- a/src/openrct2/ride/thrill/SwingingInverterShip.cpp +++ b/src/openrct2/ride/thrill/SwingingInverterShip.cpp @@ -61,7 +61,7 @@ static constexpr const uint32_t SwingingInverterShipFrameSprites[] = { static void PaintSwingingInverterShipStructure( PaintSession& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride.subtype); + const auto* rideEntry = GetRideEntryByIndex(ride.subtype); if (rideEntry == nullptr) return; diff --git a/src/openrct2/ride/thrill/SwingingShip.cpp b/src/openrct2/ride/thrill/SwingingShip.cpp index d96d240ba8..50e3fb4eeb 100644 --- a/src/openrct2/ride/thrill/SwingingShip.cpp +++ b/src/openrct2/ride/thrill/SwingingShip.cpp @@ -86,7 +86,7 @@ static void PaintSwingingShipRiders( static void PaintSwingingShipStructure( PaintSession& session, const Ride& ride, uint8_t direction, int8_t axisOffset, uint16_t height) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride.subtype); + const auto* rideEntry = GetRideEntryByIndex(ride.subtype); if (rideEntry == nullptr) return; diff --git a/src/openrct2/ride/thrill/Twist.cpp b/src/openrct2/ride/thrill/Twist.cpp index 75323d4fc0..32afc8ca1d 100644 --- a/src/openrct2/ride/thrill/Twist.cpp +++ b/src/openrct2/ride/thrill/Twist.cpp @@ -23,7 +23,7 @@ static void PaintTwistStructure( PaintSession& session, const Ride& ride, uint8_t direction, int8_t xOffset, int8_t yOffset, uint16_t height) { - RideObjectEntry* rideEntry = GetRideEntryByIndex(ride.subtype); + const auto* rideEntry = GetRideEntryByIndex(ride.subtype); Vehicle* vehicle = nullptr; if (rideEntry == nullptr)