Skip to content

Commit

Permalink
Add RtdSpecialType to replace checks for maze and other naughty types
Browse files Browse the repository at this point in the history
  • Loading branch information
Gymnasiast committed Nov 24, 2024
1 parent 6de1ac1 commit d9d5df5
Show file tree
Hide file tree
Showing 30 changed files with 187 additions and 155 deletions.
4 changes: 2 additions & 2 deletions src/openrct2-ui/windows/InstallTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ namespace OpenRCT2::Ui::Windows
}

const auto& rtd = GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex);
if (!rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType != RtdSpecialType::maze)
{
if (td.trackAndVehicle.rtdIndex == RIDE_TYPE_MINI_GOLF)
if (rtd.specialType == RtdSpecialType::miniGolf)
{
// Holes
auto ft = Formatter();
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2-ui/windows/NewCampaign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace OpenRCT2::Ui::Windows
continue;
if (rtd.HasFlag(RtdFlag::sellsDrinks))
continue;
if (rtd.HasFlag(RtdFlag::isToilet))
if (rtd.specialType == RtdSpecialType::toilet)
continue;

RideList.push_back(curRide.id);
Expand Down
34 changes: 19 additions & 15 deletions src/openrct2-ui/windows/Ride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ namespace OpenRCT2::Ui::Windows
if (!rtd.HasFlag(RtdFlag::hasDataLogging))
disabledTabs |= (1uLL << WIDX_TAB_8); // 0x800

if (ride->type == RIDE_TYPE_MINI_GOLF)
if (rtd.specialType == RtdSpecialType::miniGolf)
disabledTabs |= (1uLL << WIDX_TAB_2 | 1uLL << WIDX_TAB_3 | 1uLL << WIDX_TAB_4); // 0xE0

if (rtd.HasFlag(RtdFlag::noVehicles))
Expand All @@ -1383,7 +1383,7 @@ namespace OpenRCT2::Ui::Windows
disabledTabs |= (1uLL << WIDX_TAB_6); // 0x200
}

if (rtd.HasFlag(RtdFlag::isCashMachine) || rtd.HasFlag(RtdFlag::isFirstAid)
if (rtd.specialType == RtdSpecialType::cashMachine || rtd.specialType == RtdSpecialType::firstAid
|| (GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY) != 0)
disabledTabs |= (1uLL << WIDX_TAB_9); // 0x1000

Expand Down Expand Up @@ -2010,7 +2010,9 @@ namespace OpenRCT2::Ui::Windows
const auto& gameState = GetGameState();
const auto& rtd = ride.GetRideTypeDescriptor();
if (gameState.Cheats.ShowVehiclesFromOtherTrackTypes
&& !(rtd.HasFlag(RtdFlag::isFlatRide) || rtd.HasFlag(RtdFlag::isMaze) || ride.type == RIDE_TYPE_MINI_GOLF))
&& !(
rtd.HasFlag(RtdFlag::isFlatRide) || rtd.specialType == RtdSpecialType::maze
|| rtd.specialType == RtdSpecialType::miniGolf))
{
selectionShouldBeExpanded = true;
rideTypeIterator = 0;
Expand All @@ -2037,7 +2039,7 @@ namespace OpenRCT2::Ui::Windows
if (selectionShouldBeExpanded && rtdIterator.HasFlag(RtdFlag::isFlatRide))
continue;
if (selectionShouldBeExpanded
&& (rtdIterator.HasFlag(RtdFlag::isMaze) || rideTypeIterator == RIDE_TYPE_MINI_GOLF))
&& (rtdIterator.specialType == RtdSpecialType::maze || rtd.specialType == RtdSpecialType::miniGolf))
continue;

auto& rideEntries = objManager.GetAllRideEntries(rideTypeIterator);
Expand Down Expand Up @@ -2486,6 +2488,7 @@ namespace OpenRCT2::Ui::Windows
if (vehicle == nullptr)
return STR_EMPTY;

auto& rtd = ride->GetRideTypeDescriptor();
if (vehicle->status != Vehicle::Status::Crashing && vehicle->status != Vehicle::Status::Crashed)
{
auto trackType = vehicle->GetTrackType();
Expand All @@ -2494,15 +2497,15 @@ namespace OpenRCT2::Ui::Windows
|| trackType == TrackElemType::DiagUp25ToFlat || trackType == TrackElemType::DiagUp60ToFlat
|| trackType == TrackElemType::DiagBlockBrakes)
{
if (ride->GetRideTypeDescriptor().SupportsTrackGroup(TrackGroup::blockBrakes) && vehicle->velocity == 0)
if (rtd.SupportsTrackGroup(TrackGroup::blockBrakes) && vehicle->velocity == 0)
{
ft.Add<StringId>(STR_STOPPED_BY_BLOCK_BRAKES);
return STR_BLACK_STRING;
}
}
}

if (ride->type == RIDE_TYPE_MINI_GOLF)
if (rtd.specialType == RtdSpecialType::miniGolf)
return STR_EMPTY;

auto stringId = VehicleStatusNames[EnumValue(vehicle->status)];
Expand Down Expand Up @@ -4622,7 +4625,7 @@ namespace OpenRCT2::Ui::Windows

// Maze style
const auto& rtd = ride->GetRideTypeDescriptor();
if (rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType == RtdSpecialType::maze)
{
widgets[WIDX_MAZE_STYLE].type = WindowWidgetType::DropdownMenu;
widgets[WIDX_MAZE_STYLE_DROPDOWN].type = WindowWidgetType::Button;
Expand Down Expand Up @@ -4689,7 +4692,7 @@ namespace OpenRCT2::Ui::Windows
}

// Track supports colour
if (HasTrackColour(*ride, 2) && !rtd.HasFlag(RtdFlag::isMaze))
if (HasTrackColour(*ride, 2) && rtd.specialType != RtdSpecialType::maze)
{
widgets[WIDX_TRACK_SUPPORT_COLOUR].type = WindowWidgetType::ColourBtn;
widgets[WIDX_TRACK_SUPPORT_COLOUR].image = GetColourButtonImage(trackColour.supports);
Expand Down Expand Up @@ -4872,7 +4875,7 @@ namespace OpenRCT2::Ui::Windows

// Track
const auto& rtd = ride->GetRideTypeDescriptor();
if (rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType == RtdSpecialType::maze)
{
GfxDrawSprite(dpi, ImageId(MazeOptions[trackColour.supports].sprite), screenCoords);
}
Expand Down Expand Up @@ -5721,7 +5724,7 @@ namespace OpenRCT2::Ui::Windows

if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_NO_RAW_STATS))
{
if (ride->type == RIDE_TYPE_MINI_GOLF)
if (ride->GetRideTypeDescriptor().specialType == RtdSpecialType::miniGolf)
{
// Holes
ft = Formatter();
Expand Down Expand Up @@ -5873,7 +5876,7 @@ namespace OpenRCT2::Ui::Windows
screenCoords.y += kListRowHeight;
}

if (ride->type != RIDE_TYPE_MINI_GOLF)
if (ride->GetRideTypeDescriptor().specialType != RtdSpecialType::miniGolf)
{
// Inversions
if (ride->inversions != 0)
Expand Down Expand Up @@ -6314,7 +6317,7 @@ namespace OpenRCT2::Ui::Windows

ShopItem shopItem;
const auto& rtd = ride->GetRideTypeDescriptor();
if (rtd.HasFlag(RtdFlag::isToilet))
if (rtd.specialType == RtdSpecialType::toilet)
{
shopItem = ShopItem::Admission;
}
Expand Down Expand Up @@ -6420,7 +6423,7 @@ namespace OpenRCT2::Ui::Windows

auto rideEntry = ride->GetRideEntry();
const auto& rtd = ride->GetRideTypeDescriptor();
return Park::RidePricesUnlocked() || rtd.HasFlag(RtdFlag::isToilet)
return Park::RidePricesUnlocked() || rtd.specialType == RtdSpecialType::toilet
|| (rideEntry != nullptr && rideEntry->shop_item[0] != ShopItem::None);
}

Expand Down Expand Up @@ -6595,7 +6598,8 @@ namespace OpenRCT2::Ui::Windows

// If ride prices are locked, do not allow setting the price, unless we're dealing with a shop or toilet.
const auto& rtd = ride->GetRideTypeDescriptor();
if (!Park::RidePricesUnlocked() && rideEntry->shop_item[0] == ShopItem::None && !rtd.HasFlag(RtdFlag::isToilet))
if (!Park::RidePricesUnlocked() && rideEntry->shop_item[0] == ShopItem::None
&& rtd.specialType != RtdSpecialType::toilet)
{
disabled_widgets |= (1uLL << WIDX_PRIMARY_PRICE);
widgets[WIDX_PRIMARY_PRICE_LABEL].tooltip = STR_RIDE_INCOME_ADMISSION_PAY_FOR_ENTRY_TIP;
Expand All @@ -6614,7 +6618,7 @@ namespace OpenRCT2::Ui::Windows
widgets[WIDX_PRIMARY_PRICE].text = STR_FREE;

ShopItem primaryItem = ShopItem::Admission;
if (rtd.HasFlag(RtdFlag::isToilet) || ((primaryItem = rideEntry->shop_item[0]) != ShopItem::None))
if (rtd.specialType == RtdSpecialType::toilet || ((primaryItem = rideEntry->shop_item[0]) != ShopItem::None))
{
widgets[WIDX_PRIMARY_PRICE_SAME_THROUGHOUT_PARK].type = WindowWidgetType::Checkbox;

Expand Down
12 changes: 6 additions & 6 deletions src/openrct2-ui/windows/RideConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3059,7 +3059,7 @@ namespace OpenRCT2::Ui::Windows
{
WindowRideConstructionUpdateEnabledTrackPieces();
if (auto currentRide = GetRide(_currentRideIndex);
!currentRide || currentRide->GetRideTypeDescriptor().HasFlag(RtdFlag::isMaze))
!currentRide || currentRide->GetRideTypeDescriptor().specialType == RtdSpecialType::maze)
{
return;
}
Expand Down Expand Up @@ -3293,7 +3293,7 @@ namespace OpenRCT2::Ui::Windows
}

const auto& rtd = ride->GetRideTypeDescriptor();
if (!rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType != RtdSpecialType::maze)
{
auto window = static_cast<RideConstructionWindow*>(WindowFindByClass(WindowClass::RideConstruction));
if (!window)
Expand Down Expand Up @@ -3349,7 +3349,7 @@ namespace OpenRCT2::Ui::Windows
// search for appropriate z value for ghost, up to max ride height
int numAttempts = (z <= MAX_TRACK_HEIGHT ? ((MAX_TRACK_HEIGHT - z) / kCoordsZStep + 1) : 2);

if (rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType == RtdSpecialType::maze)
{
for (int zAttempts = 0; zAttempts < numAttempts; ++zAttempts)
{
Expand Down Expand Up @@ -3586,7 +3586,7 @@ namespace OpenRCT2::Ui::Windows
int numAttempts = (z <= MAX_TRACK_HEIGHT ? ((MAX_TRACK_HEIGHT - z) / kCoordsZStep + 1) : 2);

const auto& rtd = ride->GetRideTypeDescriptor();
if (rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType == RtdSpecialType::maze)
{
for (int32_t zAttempts = 0; zAttempts < numAttempts; ++zAttempts)
{
Expand Down Expand Up @@ -4689,7 +4689,7 @@ namespace OpenRCT2::Ui::Windows

RideConstructionRemoveGhosts();
const auto& rtd = ride->GetRideTypeDescriptor();
if (rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType == RtdSpecialType::maze)
{
int32_t flags = GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST;
auto gameAction = MazeSetTrackAction(CoordsXYZD{ trackPos, 0 }, true, rideIndex, GC_SET_MAZE_TRACK_BUILD);
Expand Down Expand Up @@ -5051,7 +5051,7 @@ namespace OpenRCT2::Ui::Windows
int32_t z = _unkF440C5.z;

const auto& rtd = ride->GetRideTypeDescriptor();
if (rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType == RtdSpecialType::maze)
{
const int32_t flags = GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST;
const CoordsXYZD quadrants[kNumOrthogonalDirections] = {
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2-ui/windows/TrackDesignPlace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ namespace OpenRCT2::Ui::Windows
}

const auto& rtd = GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex);
if (rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType == RtdSpecialType::maze)
{
DrawMiniPreviewMaze(td, pass, origin, min, max);
}
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2-ui/windows/TrackList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ namespace OpenRCT2::Ui::Windows
if (GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex).HasFlag(RtdFlag::hasTrack))
{
const auto& rtd = GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex);
if (!rtd.HasFlag(RtdFlag::isMaze))
if (rtd.specialType != RtdSpecialType::maze)
{
if (_loadedTrackDesign->trackAndVehicle.rtdIndex == RIDE_TYPE_MINI_GOLF)
if (rtd.specialType == RtdSpecialType::miniGolf)
{
// Holes
ft = Formatter();
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/actions/RideCreateAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ GameActions::Result RideCreateAction::Execute() const
ride->price[0] = 0;
}

if (rtd.HasFlag(RtdFlag::isToilet))
if (rtd.specialType == RtdSpecialType::toilet)
{
if (ShopItemHasCommonPrice(ShopItem::Admission))
{
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/actions/RideSetPriceAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ GameActions::Result RideSetPriceAction::Execute() const
shopItem = ShopItem::Admission;

const auto& rtd = ride->GetRideTypeDescriptor();
if (!rtd.HasFlag(RtdFlag::isToilet))
if (rtd.specialType != RtdSpecialType::toilet)
{
shopItem = rideEntry->shop_item[0];
if (shopItem == ShopItem::None)
Expand Down Expand Up @@ -165,7 +165,7 @@ void RideSetPriceAction::RideSetCommonPrice(ShopItem shopItem) const
auto invalidate = false;
auto rideEntry = GetRideEntryByIndex(ride.subtype);
const auto& rtd = ride.GetRideTypeDescriptor();
if (rtd.HasFlag(RtdFlag::isToilet) && shopItem == ShopItem::Admission)
if (rtd.specialType == RtdSpecialType::toilet && shopItem == ShopItem::Admission)
{
if (ride.price[0] != _price)
{
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2/actions/RideSetVehicleAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ bool RideSetVehicleAction::RideIsVehicleTypeValid(const Ride& ride) const
const auto& rtd = ride.GetRideTypeDescriptor();
if (gameState.Cheats.ShowVehiclesFromOtherTrackTypes
&& !(
ride.GetRideTypeDescriptor().HasFlag(RtdFlag::isFlatRide) || rtd.HasFlag(RtdFlag::isMaze)
|| ride.type == RIDE_TYPE_MINI_GOLF))
ride.GetRideTypeDescriptor().HasFlag(RtdFlag::isFlatRide) || rtd.specialType == RtdSpecialType::maze
|| rtd.specialType == RtdSpecialType::miniGolf))
{
selectionShouldBeExpanded = true;
rideTypeIterator = 0;
Expand All @@ -255,7 +255,7 @@ bool RideSetVehicleAction::RideIsVehicleTypeValid(const Ride& ride) const
continue;

const auto& rtd = GetRideTypeDescriptor(rideTypeIterator);
if (rtd.HasFlag(RtdFlag::isMaze) || rideTypeIterator == RIDE_TYPE_MINI_GOLF)
if (rtd.specialType == RtdSpecialType::maze || rtd.specialType == RtdSpecialType::miniGolf)
continue;
}

Expand Down
Loading

0 comments on commit d9d5df5

Please sign in to comment.