Merge pull request #15167 from ZehMatt/ride-id-fixes

Convert ride_id_t to a strong type
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2021-09-10 19:01:33 +02:00
commit c572c21649
55 files changed
+353 -341

No files matched your search

+2 -2
View File
@@ -50,9 +50,9 @@ set(OBJECTS_VERSION "1.0.21")
set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v${OBJECTS_VERSION}/objects.zip")
set(OBJECTS_SHA1 "c38af45d51a6e440386180feacf76c64720b6ac5")
set(REPLAYS_VERSION "0.0.50")
set(REPLAYS_VERSION "0.0.51")
set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v${REPLAYS_VERSION}/replays.zip")
set(REPLAYS_SHA1 "C569C73147F1C1554807B6FBE74C39A4F0E20EAF")
set(REPLAYS_SHA1 "01086A05A3291B296906AE215855BC7CDB045A6A")
option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.")
option(WITH_TESTS "Build tests")
+2 -2
View File
@@ -48,8 +48,8 @@
<TitleSequencesSha1>304d13a126c15bf2c86ff13b81a2f2cc1856ac8d</TitleSequencesSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip</ObjectsUrl>
<ObjectsSha1>c38af45d51a6e440386180feacf76c64720b6ac5</ObjectsSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.50/replays.zip</ReplaysUrl>
<ReplaysSha1>C569C73147F1C1554807B6FBE74C39A4F0E20EAF</ReplaysSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.51/replays.zip</ReplaysUrl>
<ReplaysSha1>01086A05A3291B296906AE215855BC7CDB045A6A</ReplaysSha1>
</PropertyGroup>
<ItemGroup>
+7 -6
View File
@@ -184,9 +184,9 @@ public:
case WD_BANNER:
return window_banner_open(id);
case WD_DEMOLISH_RIDE:
return window_ride_demolish_prompt_open(get_ride(id));
return window_ride_demolish_prompt_open(get_ride(static_cast<ride_id_t>(id)));
case WD_REFURBISH_RIDE:
return window_ride_refurbish_prompt_open(get_ride(id));
return window_ride_refurbish_prompt_open(get_ride(static_cast<ride_id_t>(id)));
case WD_NEW_CAMPAIGN:
return window_new_campaign_open(id);
case WD_SIGN:
@@ -264,7 +264,8 @@ public:
}
case WC_RIDE:
{
auto ride = get_ride(intent->GetSIntExtra(INTENT_EXTRA_RIDE_ID));
const auto rideId = static_cast<ride_id_t>(intent->GetSIntExtra(INTENT_EXTRA_RIDE_ID));
auto ride = get_ride(rideId);
return ride == nullptr ? nullptr : window_ride_main_open(ride);
}
case WC_TRACK_DESIGN_PLACE:
@@ -343,13 +344,13 @@ public:
if (w == nullptr || w->number != rideIndex)
{
window_close_construction_windows();
_currentRideIndex = rideIndex;
_currentRideIndex = static_cast<ride_id_t>(rideIndex);
w = OpenWindow(WC_RIDE_CONSTRUCTION);
}
else
{
ride_construction_invalidate_current_track();
_currentRideIndex = rideIndex;
_currentRideIndex = static_cast<ride_id_t>(rideIndex);
}
break;
}
@@ -395,7 +396,7 @@ public:
case INTENT_ACTION_INVALIDATE_VEHICLE_WINDOW:
{
auto vehicle = static_cast<Vehicle*>(intent.GetPointerExtra(INTENT_EXTRA_VEHICLE));
auto w = window_find_by_number(WC_RIDE, vehicle->ride);
auto w = window_find_by_number(WC_RIDE, EnumValue(vehicle->ride));
if (w == nullptr)
return;
@@ -84,7 +84,7 @@ rct_window* window_ride_demolish_prompt_open(Ride* ride)
w->widgets = window_ride_demolish_widgets;
w->enabled_widgets = (1ULL << WIDX_CLOSE) | (1ULL << WIDX_CANCEL) | (1ULL << WIDX_DEMOLISH);
WindowInitScrollWidgets(w);
w->number = ride->id;
w->rideId = ride->id;
_demolishRideCost = -ride_get_refund_price(ride);
return w;
@@ -109,7 +109,7 @@ rct_window* window_ride_refurbish_prompt_open(Ride* ride)
w->widgets = window_ride_refurbish_widgets;
w->enabled_widgets = (1ULL << WIDX_CLOSE) | (1ULL << WIDX_CANCEL) | (1ULL << WIDX_REFURBISH);
WindowInitScrollWidgets(w);
w->number = ride->id;
w->rideId = ride->id;
_demolishRideCost = -ride_get_refund_price(ride);
return w;
@@ -125,7 +125,7 @@ static void window_ride_demolish_mouseup(rct_window* w, rct_widgetindex widgetIn
{
case WIDX_DEMOLISH:
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
ride_action_modify(ride, RIDE_MODIFY_DEMOLISH, GAME_COMMAND_FLAG_APPLY);
break;
}
@@ -142,7 +142,7 @@ static void window_ride_refurbish_mouseup(rct_window* w, rct_widgetindex widgetI
{
case WIDX_REFURBISH:
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
ride_action_modify(ride, RIDE_MODIFY_RENEW, GAME_COMMAND_FLAG_APPLY);
break;
}
@@ -161,7 +161,7 @@ static void window_ride_demolish_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
WindowDrawWidgets(w, dpi);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
auto stringId = (gParkFlags & PARK_FLAGS_NO_MONEY) ? STR_DEMOLISH_RIDE_ID : STR_DEMOLISH_RIDE_ID_MONEY;
@@ -178,7 +178,7 @@ static void window_ride_refurbish_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
WindowDrawWidgets(w, dpi);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
auto stringId = (gParkFlags & PARK_FLAGS_NO_MONEY) ? STR_REFURBISH_RIDE_ID_NO_MONEY : STR_REFURBISH_RIDE_ID_MONEY;
@@ -972,7 +972,7 @@ static void window_editor_objective_options_rides_update(rct_window* w)
{
if (ride.IsRide())
{
w->list_item_positions[numItems] = ride.id;
w->list_item_positions[numItems] = EnumValue(ride.id);
numItems++;
}
}
@@ -1005,7 +1005,8 @@ static void window_editor_objective_options_rides_scrollmousedown(
if (i < 0 || i >= w->no_list_items)
return;
auto ride = get_ride(w->list_item_positions[i]);
const auto rideId = static_cast<ride_id_t>(w->list_item_positions[i]);
auto ride = get_ride(rideId);
if (ride != nullptr)
{
ride->lifecycle_flags ^= RIDE_LIFECYCLE_INDESTRUCTIBLE;
@@ -1098,7 +1099,8 @@ static void window_editor_objective_options_rides_scrollpaint(rct_window* w, rct
}
// Checkbox mark
auto ride = get_ride(w->list_item_positions[i]);
const auto rideId = static_cast<ride_id_t>(w->list_item_positions[i]);
auto ride = get_ride(rideId);
if (ride != nullptr)
{
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE)
+3 -2
View File
@@ -1456,7 +1456,7 @@ void window_guest_rides_update(rct_window* w)
{
if (ride.IsRide() && guest->HasRidden(&ride))
{
w->list_item_positions[curr_list_position] = ride.id;
w->list_item_positions[curr_list_position] = EnumValue(ride.id);
curr_list_position++;
}
}
@@ -1607,7 +1607,8 @@ void window_guest_rides_scroll_paint(rct_window* w, rct_drawpixelinfo* dpi, int3
stringId = STR_WINDOW_COLOUR_2_STRINGID;
}
auto ride = get_ride(w->list_item_positions[list_index]);
const auto rideId = static_cast<ride_id_t>(w->list_item_positions[list_index]);
auto ride = get_ride(rideId);
if (ride != nullptr)
{
auto ft = Formatter();
+3 -3
View File
@@ -182,7 +182,7 @@ public:
{
case GuestListFilterType::GuestsOnRide:
{
auto guestRide = get_ride(index);
auto guestRide = get_ride(static_cast<ride_id_t>(index));
if (guestRide != nullptr)
{
ft.Add<rct_string_id>(
@@ -198,7 +198,7 @@ public:
}
case GuestListFilterType::GuestsInQueue:
{
auto guestRide = get_ride(index);
auto guestRide = get_ride(static_cast<ride_id_t>(index));
if (guestRide != nullptr)
{
ft.Add<rct_string_id>(STR_QUEUING_FOR);
@@ -213,7 +213,7 @@ public:
}
case GuestListFilterType::GuestsThinkingAboutRide:
{
auto guestRide = get_ride(index);
auto guestRide = get_ride(static_cast<ride_id_t>(index));
if (guestRide != nullptr)
{
ft.Add<rct_string_id>(STR_NONE);
+3 -3
View File
@@ -130,7 +130,7 @@ rct_window* window_maze_construction_open()
WindowInitScrollWidgets(w);
w->number = _currentRideIndex;
w->rideId = _currentRideIndex;
window_push_others_right(w);
show_gridlines();
@@ -169,7 +169,7 @@ static void window_maze_construction_close(rct_window* w)
else
{
auto intent = Intent(WC_RIDE);
intent.putExtra(INTENT_EXTRA_RIDE_ID, ride->id);
intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(ride->id));
context_open_intent(&intent);
}
}
@@ -181,7 +181,7 @@ static void window_maze_construction_entrance_mouseup(rct_window* w, rct_widgeti
return;
gRideEntranceExitPlaceType = widgetIndex == WIDX_MAZE_ENTRANCE ? ENTRANCE_TYPE_RIDE_ENTRANCE : ENTRANCE_TYPE_RIDE_EXIT;
gRideEntranceExitPlaceRideIndex = static_cast<uint8_t>(w->number);
gRideEntranceExitPlaceRideIndex = w->rideId;
gRideEntranceExitPlaceStationIndex = 0;
input_set_flag(INPUT_FLAG_6, true);
+8 -5
View File
@@ -22,7 +22,9 @@
static constexpr const rct_string_id WINDOW_TITLE = STR_NONE;
static constexpr const int32_t WH = 109;
static constexpr const int32_t WW = 350;
constexpr uint16_t SELECTED_RIDE_UNDEFINED = 0xFFFF;
constexpr auto SELECTED_RIDE_UNDEFINED = RIDE_ID_NULL;
constexpr uint16_t SELECTED_ITEM_UNDEFINED = 0xFFFF;
// clang-format off
enum WINDOW_NEW_CAMPAIGN_WIDGET_IDX {
@@ -205,9 +207,9 @@ public:
else
{
int32_t numItems = 0;
for (auto rideId : RideList)
for (auto rideIndex : RideList)
{
auto curRide = get_ride(rideId);
auto curRide = get_ride(rideIndex);
if (curRide != nullptr)
{
// HACK until dropdown items have longer argument buffers
@@ -252,7 +254,8 @@ public:
break;
case WIDX_START_BUTTON:
{
auto gameAction = ParkMarketingAction(campaign.campaign_type, campaign.RideId, campaign.no_weeks);
auto gameAction = ParkMarketingAction(
campaign.campaign_type, static_cast<int32_t>(campaign.RideId), campaign.no_weeks);
gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
if (result->Error == GameActions::Status::Ok)
{
@@ -322,7 +325,7 @@ public:
widgets[WIDX_RIDE_DROPDOWN].type = WindowWidgetType::DropdownMenu;
widgets[WIDX_RIDE_DROPDOWN_BUTTON].type = WindowWidgetType::Button;
widgets[WIDX_RIDE_LABEL].text = STR_MARKETING_ITEM;
if (campaign.ShopItemId != SELECTED_RIDE_UNDEFINED)
if (campaign.ShopItemId != SELECTED_ITEM_UNDEFINED)
{
widgets[WIDX_RIDE_DROPDOWN].text = GetShopItemDescriptor(ShopItem(campaign.ShopItemId)).Naming.Plural;
}
+129 -122
View File
@@ -958,7 +958,7 @@ static void window_ride_draw_tab_main(rct_drawpixelinfo* dpi, rct_window* w)
rct_widgetindex widgetIndex = WIDX_TAB_1 + WINDOW_RIDE_PAGE_MAIN;
if (!(w->disabled_widgets & (1LL << widgetIndex)))
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
int32_t spriteIndex = 0;
@@ -1014,7 +1014,7 @@ static void window_ride_draw_tab_vehicle(rct_drawpixelinfo* dpi, rct_window* w)
screenCoords = ScreenCoordsXY{ widget->width() / 2, widget->height() - 12 };
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -1108,7 +1108,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);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -1192,12 +1192,13 @@ static void window_ride_update_overall_view(Ride* ride)
maxz = std::max(maxz, clearZ);
}
if (ride->id >= ride_overall_views.size())
const auto rideIndex = EnumValue(ride->id);
if (rideIndex >= ride_overall_views.size())
{
ride_overall_views.resize(ride->id + 1);
ride_overall_views.resize(rideIndex + 1);
}
auto& view = ride_overall_views[ride->id];
auto& view = ride_overall_views[rideIndex];
view.x = (minx + maxx) / 2 + 16;
view.y = (miny + maxy) / 2 + 16;
view.z = (minz + maxz) / 2 - 8;
@@ -1234,7 +1235,7 @@ static rct_window* window_ride_open(Ride* ride)
w->widgets = window_ride_page_widgets[WINDOW_RIDE_PAGE_MAIN];
w->enabled_widgets = window_ride_page_enabled_widgets[WINDOW_RIDE_PAGE_MAIN];
w->hold_down_widgets = window_ride_page_hold_down_widgets[WINDOW_RIDE_PAGE_MAIN];
w->number = ride->id;
w->rideId = ride->id;
w->page = WINDOW_RIDE_PAGE_MAIN;
w->vehicleIndex = 0;
@@ -1264,7 +1265,7 @@ rct_window* window_ride_main_open(Ride* ride)
return nullptr;
}
rct_window* w = window_bring_to_front_by_number(WC_RIDE, ride->id);
rct_window* w = window_bring_to_front_by_number(WC_RIDE, EnumValue(ride->id));
if (w == nullptr)
{
w = window_ride_open(ride);
@@ -1305,7 +1306,7 @@ static rct_window* window_ride_open_station(Ride* ride, StationIndex stationInde
if (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_NO_VEHICLES))
return window_ride_main_open(ride);
auto w = window_bring_to_front_by_number(WC_RIDE, ride->id);
auto w = window_bring_to_front_by_number(WC_RIDE, EnumValue(ride->id));
if (w == nullptr)
{
w = window_ride_open(ride);
@@ -1407,7 +1408,7 @@ rct_window* window_ride_open_vehicle(Vehicle* vehicle)
view++;
}
rct_window* w = window_find_by_number(WC_RIDE, ride->id);
rct_window* w = window_find_by_number(WC_RIDE, EnumValue(ride->id));
if (w != nullptr)
{
w->Invalidate();
@@ -1442,7 +1443,8 @@ rct_window* window_ride_open_vehicle(Vehicle* vehicle)
}
}
w = openedPeepWindow ? window_find_by_number(WC_RIDE, ride->id) : window_bring_to_front_by_number(WC_RIDE, ride->id);
w = openedPeepWindow ? window_find_by_number(WC_RIDE, EnumValue(ride->id))
: window_bring_to_front_by_number(WC_RIDE, EnumValue(ride->id));
}
if (w == nullptr)
@@ -1551,7 +1553,7 @@ static void window_ride_anchor_border_widgets(rct_window* w)
static std::optional<StationIndex> GetStationIndexFromViewSelection(const rct_window& w)
{
const auto* ride = get_ride(w.number);
const auto* ride = get_ride(static_cast<ride_id_t>(w.number));
if (ride == nullptr)
return {};
@@ -1584,7 +1586,7 @@ static void window_ride_init_viewport(rct_window* w)
if (w->page != WINDOW_RIDE_PAGE_MAIN)
return;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -1716,7 +1718,7 @@ static void window_ride_init_viewport(rct_window* w)
*/
static void window_ride_rename(rct_window* w)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
auto rideName = ride->GetName();
@@ -1750,11 +1752,11 @@ static void window_ride_main_mouseup(rct_window* w, rct_widgetindex widgetIndex)
break;
case WIDX_CONSTRUCTION:
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
ride_construct(ride);
if (window_find_by_number(WC_RIDE_CONSTRUCTION, ride->id) != nullptr)
if (window_find_by_number(WC_RIDE_CONSTRUCTION, EnumValue(ride->id)) != nullptr)
{
window_close(w);
}
@@ -1775,7 +1777,7 @@ static void window_ride_main_mouseup(rct_window* w, rct_widgetindex widgetIndex)
case WIDX_TEST_LIGHT:
case WIDX_OPEN_LIGHT:
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
RideStatus status;
@@ -1813,7 +1815,7 @@ static void window_ride_main_resize(rct_window* w)
{
minHeight += 20 + RCT1_LIGHT_OFFSET;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
#ifdef __SIMULATE_IN_RIDE_WINDOW__
@@ -1845,7 +1847,7 @@ static void window_ride_main_resize(rct_window* w)
static void window_ride_show_view_dropdown(rct_window* w, rct_widget* widget)
{
rct_widget* dropdownWidget = widget - 1;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -1961,7 +1963,7 @@ static void window_ride_set_dropdown(RideStatusDropdownInfo& info, RideStatus st
static void window_ride_show_open_dropdown(rct_window* w, rct_widget* widget)
{
RideStatusDropdownInfo info;
info.Ride = get_ride(w->number);
info.Ride = get_ride(w->rideId);
if (info.Ride == nullptr)
return;
@@ -2029,7 +2031,7 @@ static void populate_ride_type_dropdown()
static void window_ride_show_ride_type_dropdown(rct_window* w, rct_widget* widget)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -2125,7 +2127,7 @@ static void populate_vehicle_type_dropdown(Ride* ride)
static void window_ride_show_vehicle_type_dropdown(rct_window* w, rct_widget* widget)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -2192,7 +2194,7 @@ static void window_ride_main_dropdown(rct_window* w, rct_widgetindex widgetIndex
if (dropdownIndex == -1)
{
dropdownIndex = w->ride.view + 1;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
if (dropdownIndex != 0 && dropdownIndex <= ride->num_vehicles
@@ -2213,7 +2215,7 @@ static void window_ride_main_dropdown(rct_window* w, rct_widgetindex widgetIndex
break;
case WIDX_OPEN:
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
auto status = RideStatus::Closed;
@@ -2250,7 +2252,7 @@ static void window_ride_main_dropdown(rct_window* w, rct_widgetindex widgetIndex
uint8_t rideType = RideDropdownData[rideLabelId].ride_type_id;
if (rideType < RIDE_TYPE_COUNT)
{
auto rideSetSetting = RideSetSettingAction(w->number, RideSetSetting::RideType, rideType);
auto rideSetSetting = RideSetSettingAction(w->rideId, RideSetSetting::RideType, rideType);
rideSetSetting.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
// Reset ghost track if ride construction window is open, prevents a crash
// Will get set to the correct Alternative variable during set_default_next_piece.
@@ -2276,7 +2278,7 @@ static void window_ride_main_update(rct_window* w)
widget_invalidate(w, WIDX_TAB_1);
// Update status
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
if (!(ride->window_invalidate_flags & RIDE_INVALIDATE_RIDE_MAIN))
@@ -2311,7 +2313,7 @@ static void window_ride_main_textinput(rct_window* w, rct_widgetindex widgetInde
if (widgetIndex != WIDX_RENAME || text == nullptr)
return;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
ride_set_name(ride, text, 0);
@@ -2345,7 +2347,7 @@ static void window_ride_main_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -2477,7 +2479,7 @@ static void window_ride_main_invalidate(rct_window* w)
static rct_string_id window_ride_get_status_overall_view(rct_window* w, Formatter& ft)
{
auto stringId = STR_NONE;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
ride->FormatStatusTo(ft);
@@ -2496,7 +2498,7 @@ static rct_string_id window_ride_get_status_overall_view(rct_window* w, Formatte
*/
static rct_string_id window_ride_get_status_vehicle(rct_window* w, Formatter& ft)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return STR_EMPTY;
@@ -2544,7 +2546,7 @@ static rct_string_id window_ride_get_status_vehicle(rct_window* w, Formatter& ft
*/
static rct_string_id window_ride_get_status_station(rct_window* w, Formatter& ft)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return STR_NONE;
@@ -2595,7 +2597,7 @@ static rct_string_id window_ride_get_status_station(rct_window* w, Formatter& ft
*/
static rct_string_id window_ride_get_status(rct_window* w, Formatter& ft)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (w->ride.view == 0)
return window_ride_get_status_overall_view(w, ft);
if (ride != nullptr && w->ride.view <= ride->num_vehicles)
@@ -2625,7 +2627,7 @@ static void window_ride_main_paint(rct_window* w, rct_drawpixelinfo* dpi)
}
// View dropdown
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -2707,7 +2709,7 @@ static void window_ride_vehicle_resize(rct_window* w)
*/
static void window_ride_vehicle_mousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -2750,7 +2752,7 @@ static void window_ride_vehicle_dropdown(rct_window* w, rct_widgetindex widgetIn
case WIDX_VEHICLE_TYPE_DROPDOWN:
if (dropdownIndex >= 0 && static_cast<std::size_t>(dropdownIndex) < VehicleDropdownData.size())
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
auto newRideType = VehicleDropdownData[dropdownIndex].subtype_id;
@@ -2775,7 +2777,7 @@ static void window_ride_vehicle_update(rct_window* w)
static OpenRCT2String window_ride_vehicle_tooltip(
rct_window* const w, const rct_widgetindex widgetIndex, rct_string_id fallback)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return { STR_NONE, {} };
@@ -2842,7 +2844,7 @@ static void window_ride_vehicle_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -2922,7 +2924,7 @@ static void window_ride_vehicle_paint(rct_window* w, rct_drawpixelinfo* dpi)
WindowDrawWidgets(w, dpi);
window_ride_draw_tab_images(dpi, w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -2997,7 +2999,7 @@ static rct_vehicle_paintinfo _sprites_to_draw[144];
*/
static void window_ride_vehicle_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3090,7 +3092,7 @@ static void window_ride_vehicle_scrollpaint(rct_window* w, rct_drawpixelinfo* dp
*/
static void window_ride_mode_tweak_increase(rct_window* w)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3106,7 +3108,7 @@ static void window_ride_mode_tweak_increase(rct_window* w)
uint8_t increment = ride->mode == RideMode::Dodgems ? 10 : 1;
set_operating_setting(
w->number, RideSetSetting::Operation, std::clamp<int16_t>(ride->operation_option + increment, minValue, maxValue));
w->rideId, RideSetSetting::Operation, std::clamp<int16_t>(ride->operation_option + increment, minValue, maxValue));
}
/**
@@ -3115,7 +3117,7 @@ static void window_ride_mode_tweak_increase(rct_window* w)
*/
static void window_ride_mode_tweak_decrease(rct_window* w)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3130,7 +3132,7 @@ static void window_ride_mode_tweak_decrease(rct_window* w)
uint8_t decrement = ride->mode == RideMode::Dodgems ? 10 : 1;
set_operating_setting(
w->number, RideSetSetting::Operation, std::clamp<int16_t>(ride->operation_option - decrement, minValue, maxValue));
w->rideId, RideSetSetting::Operation, std::clamp<int16_t>(ride->operation_option - decrement, minValue, maxValue));
}
/**
@@ -3142,7 +3144,7 @@ static void window_ride_mode_dropdown(rct_window* w, rct_widget* widget)
rct_widget* dropdownWidget;
dropdownWidget = widget - 1;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3181,7 +3183,7 @@ static void window_ride_mode_dropdown(rct_window* w, rct_widget* widget)
*/
static void window_ride_load_dropdown(rct_window* w, rct_widget* widget)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3204,7 +3206,8 @@ static void window_ride_load_dropdown(rct_window* w, rct_widget* widget)
*/
static void window_ride_operating_mouseup(rct_window* w, rct_widgetindex widgetIndex)
{
auto ride = get_ride(w->number);
const auto rideId = w->rideId;
auto ride = get_ride(rideId);
if (ride == nullptr)
return;
@@ -3226,23 +3229,21 @@ static void window_ride_operating_mouseup(rct_window* w, rct_widgetindex widgetI
window_ride_set_page(w, widgetIndex - WIDX_TAB_1);
break;
case WIDX_LOAD_CHECKBOX:
set_operating_setting(w->number, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_WAIT_FOR_LOAD);
set_operating_setting(rideId, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_WAIT_FOR_LOAD);
break;
case WIDX_LEAVE_WHEN_ANOTHER_ARRIVES_CHECKBOX:
set_operating_setting(
w->number, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES);
rideId, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES);
break;
case WIDX_MINIMUM_LENGTH_CHECKBOX:
set_operating_setting(
w->number, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH);
set_operating_setting(rideId, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH);
break;
case WIDX_MAXIMUM_LENGTH_CHECKBOX:
set_operating_setting(
w->number, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_WAIT_FOR_MAXIMUM_LENGTH);
set_operating_setting(rideId, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_WAIT_FOR_MAXIMUM_LENGTH);
break;
case WIDX_SYNCHRONISE_WITH_ADJACENT_STATIONS_CHECKBOX:
set_operating_setting(
w->number, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS);
rideId, RideSetSetting::Departure, ride->depart_flags ^ RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS);
break;
}
}
@@ -3262,7 +3263,8 @@ static void window_ride_operating_resize(rct_window* w)
*/
static void window_ride_operating_mousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget)
{
auto ride = get_ride(w->number);
const auto rideId = w->rideId;
auto ride = get_ride(rideId);
if (ride == nullptr)
return;
@@ -3279,42 +3281,42 @@ static void window_ride_operating_mousedown(rct_window* w, rct_widgetindex widge
upper_bound = gCheatsUnlockOperatingLimits ? 255 : ride->GetRideTypeDescriptor().LiftData.maximum_speed;
lower_bound = gCheatsUnlockOperatingLimits ? 0 : ride->GetRideTypeDescriptor().LiftData.minimum_speed;
set_operating_setting(
w->number, RideSetSetting::LiftHillSpeed,
rideId, RideSetSetting::LiftHillSpeed,
std::clamp<int16_t>(ride->lift_hill_speed + 1, lower_bound, upper_bound));
break;
case WIDX_LIFT_HILL_SPEED_DECREASE:
upper_bound = gCheatsUnlockOperatingLimits ? 255 : ride->GetRideTypeDescriptor().LiftData.maximum_speed;
lower_bound = gCheatsUnlockOperatingLimits ? 0 : ride->GetRideTypeDescriptor().LiftData.minimum_speed;
set_operating_setting(
w->number, RideSetSetting::LiftHillSpeed,
rideId, RideSetSetting::LiftHillSpeed,
std::clamp<int16_t>(ride->lift_hill_speed - 1, lower_bound, upper_bound));
break;
case WIDX_MINIMUM_LENGTH_INCREASE:
upper_bound = 250;
lower_bound = 0;
set_operating_setting(
w->number, RideSetSetting::MinWaitingTime,
rideId, RideSetSetting::MinWaitingTime,
std::clamp<int16_t>(ride->min_waiting_time + 1, lower_bound, upper_bound));
break;
case WIDX_MINIMUM_LENGTH_DECREASE:
upper_bound = 250;
lower_bound = 0;
set_operating_setting(
w->number, RideSetSetting::MinWaitingTime,
rideId, RideSetSetting::MinWaitingTime,
std::clamp<int16_t>(ride->min_waiting_time - 1, lower_bound, upper_bound));
break;
case WIDX_MAXIMUM_LENGTH_INCREASE:
upper_bound = 250;
lower_bound = 0;
set_operating_setting(
w->number, RideSetSetting::MaxWaitingTime,
rideId, RideSetSetting::MaxWaitingTime,
std::clamp<int16_t>(ride->max_waiting_time + 1, lower_bound, upper_bound));
break;
case WIDX_MAXIMUM_LENGTH_DECREASE:
upper_bound = 250;
lower_bound = 0;
set_operating_setting(
w->number, RideSetSetting::MaxWaitingTime,
rideId, RideSetSetting::MaxWaitingTime,
std::clamp<int16_t>(ride->max_waiting_time - 1, lower_bound, upper_bound));
break;
case WIDX_MODE_DROPDOWN:
@@ -3327,13 +3329,13 @@ static void window_ride_operating_mousedown(rct_window* w, rct_widgetindex widge
upper_bound = gCheatsUnlockOperatingLimits ? 255 : MAX_CIRCUITS_PER_RIDE;
lower_bound = 1;
set_operating_setting(
w->number, RideSetSetting::NumCircuits, std::clamp<int16_t>(ride->num_circuits + 1, lower_bound, upper_bound));
rideId, RideSetSetting::NumCircuits, std::clamp<int16_t>(ride->num_circuits + 1, lower_bound, upper_bound));
break;
case WIDX_OPERATE_NUMBER_OF_CIRCUITS_DECREASE:
upper_bound = gCheatsUnlockOperatingLimits ? 255 : MAX_CIRCUITS_PER_RIDE;
lower_bound = 1;
set_operating_setting(
w->number, RideSetSetting::NumCircuits, std::clamp<int16_t>(ride->num_circuits - 1, lower_bound, upper_bound));
rideId, RideSetSetting::NumCircuits, std::clamp<int16_t>(ride->num_circuits - 1, lower_bound, upper_bound));
break;
}
}
@@ -3347,7 +3349,8 @@ static void window_ride_operating_dropdown(rct_window* w, rct_widgetindex widget
if (dropdownIndex == -1)
return;
auto ride = get_ride(w->number);
const auto rideId = w->rideId;
auto ride = get_ride(rideId);
if (ride == nullptr)
return;
@@ -3371,12 +3374,12 @@ static void window_ride_operating_dropdown(rct_window* w, rct_widgetindex widget
}
}
if (rideMode != RideMode::NullMode)
set_operating_setting(w->number, RideSetSetting::Mode, static_cast<uint8_t>(rideMode));
set_operating_setting(rideId, RideSetSetting::Mode, static_cast<uint8_t>(rideMode));
break;
}
case WIDX_LOAD_DROPDOWN:
set_operating_setting(
w->number, RideSetSetting::Departure, (ride->depart_flags & ~RIDE_DEPART_WAIT_FOR_LOAD_MASK) | dropdownIndex);
rideId, RideSetSetting::Departure, (ride->depart_flags & ~RIDE_DEPART_WAIT_FOR_LOAD_MASK) | dropdownIndex);
break;
}
}
@@ -3391,7 +3394,7 @@ static void window_ride_operating_update(rct_window* w)
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_3);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr && ride->window_invalidate_flags & RIDE_INVALIDATE_RIDE_OPERATING)
{
ride->window_invalidate_flags &= ~RIDE_INVALIDATE_RIDE_OPERATING;
@@ -3417,7 +3420,7 @@ static void window_ride_operating_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3658,7 +3661,7 @@ static void window_ride_operating_paint(rct_window* w, rct_drawpixelinfo* dpi)
WindowDrawWidgets(w, dpi);
window_ride_draw_tab_images(dpi, w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3690,7 +3693,7 @@ static void window_ride_operating_paint(rct_window* w, rct_drawpixelinfo* dpi)
*/
static void window_ride_locate_mechanic(rct_window* w)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3780,7 +3783,7 @@ static void window_ride_maintenance_resize(rct_window* w)
*/
static void window_ride_maintenance_mousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3884,7 +3887,7 @@ static void window_ride_maintenance_dropdown(rct_window* w, rct_widgetindex widg
if (dropdownIndex == -1)
return;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -3895,7 +3898,7 @@ static void window_ride_maintenance_dropdown(rct_window* w, rct_widgetindex widg
switch (widgetIndex)
{
case WIDX_INSPECTION_INTERVAL_DROPDOWN:
set_operating_setting(w->number, RideSetSetting::InspectionInterval, dropdownIndex);
set_operating_setting(w->rideId, RideSetSetting::InspectionInterval, dropdownIndex);
break;
case WIDX_FORCE_BREAKDOWN:
@@ -3990,7 +3993,7 @@ static void window_ride_maintenance_update(rct_window* w)
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_4);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr && ride->window_invalidate_flags & RIDE_INVALIDATE_RIDE_MAINTENANCE)
{
ride->window_invalidate_flags &= ~RIDE_INVALIDATE_RIDE_MAINTENANCE;
@@ -4013,7 +4016,7 @@ static void window_ride_maintenance_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -4055,7 +4058,7 @@ static void window_ride_maintenance_paint(rct_window* w, rct_drawpixelinfo* dpi)
WindowDrawWidgets(w, dpi);
window_ride_draw_tab_images(dpi, w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -4210,7 +4213,7 @@ static void window_ride_set_track_colour_scheme(rct_window* w, const ScreenCoord
return;
if (info.Element->GetType() != TILE_ELEMENT_TYPE_TRACK)
return;
if (info.Element->AsTrack()->GetRideIndex() != w->number)
if (info.Element->AsTrack()->GetRideIndex() != w->rideId)
return;
if (info.Element->AsTrack()->GetColourScheme() == newColourScheme)
return;
@@ -4288,7 +4291,7 @@ static void window_ride_colour_mousedown(rct_window* w, rct_widgetindex widgetIn
int32_t i, numItems;
rct_string_id stringId;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -4421,6 +4424,7 @@ static void window_ride_colour_dropdown(rct_window* w, rct_widgetindex widgetInd
if (dropdownIndex == -1)
return;
const auto rideId = w->rideId;
switch (widgetIndex)
{
case WIDX_TRACK_COLOUR_SCHEME_DROPDOWN:
@@ -4430,28 +4434,28 @@ static void window_ride_colour_dropdown(rct_window* w, rct_widgetindex widgetInd
case WIDX_TRACK_MAIN_COLOUR:
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::TrackColourMain, dropdownIndex, w->ride_colour);
rideId, RideSetAppearanceType::TrackColourMain, dropdownIndex, w->ride_colour);
GameActions::Execute(&rideSetAppearanceAction);
}
break;
case WIDX_TRACK_ADDITIONAL_COLOUR:
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::TrackColourAdditional, dropdownIndex, w->ride_colour);
rideId, RideSetAppearanceType::TrackColourAdditional, dropdownIndex, w->ride_colour);
GameActions::Execute(&rideSetAppearanceAction);
}
break;
case WIDX_TRACK_SUPPORT_COLOUR:
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::TrackColourSupports, dropdownIndex, w->ride_colour);
rideId, RideSetAppearanceType::TrackColourSupports, dropdownIndex, w->ride_colour);
GameActions::Execute(&rideSetAppearanceAction);
}
break;
case WIDX_MAZE_STYLE_DROPDOWN:
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::MazeStyle, dropdownIndex, w->ride_colour);
rideId, RideSetAppearanceType::MazeStyle, dropdownIndex, w->ride_colour);
GameActions::Execute(&rideSetAppearanceAction);
}
break;
@@ -4467,7 +4471,7 @@ static void window_ride_colour_dropdown(rct_window* w, rct_widgetindex widgetInd
if (ddIndex == dropdownIndex)
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::EntranceStyle, ddIndex, 0);
rideId, RideSetAppearanceType::EntranceStyle, ddIndex, 0);
GameActions::Execute(&rideSetAppearanceAction);
break;
}
@@ -4479,7 +4483,7 @@ static void window_ride_colour_dropdown(rct_window* w, rct_widgetindex widgetInd
case WIDX_VEHICLE_COLOUR_SCHEME_DROPDOWN:
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::VehicleColourScheme, dropdownIndex, 0);
rideId, RideSetAppearanceType::VehicleColourScheme, dropdownIndex, 0);
GameActions::Execute(&rideSetAppearanceAction);
w->vehicleIndex = 0;
}
@@ -4491,21 +4495,21 @@ static void window_ride_colour_dropdown(rct_window* w, rct_widgetindex widgetInd
case WIDX_VEHICLE_MAIN_COLOUR:
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::VehicleColourBody, dropdownIndex, w->vehicleIndex);
rideId, RideSetAppearanceType::VehicleColourBody, dropdownIndex, w->vehicleIndex);
GameActions::Execute(&rideSetAppearanceAction);
}
break;
case WIDX_VEHICLE_ADDITIONAL_COLOUR_1:
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::VehicleColourTrim, dropdownIndex, w->vehicleIndex);
rideId, RideSetAppearanceType::VehicleColourTrim, dropdownIndex, w->vehicleIndex);
GameActions::Execute(&rideSetAppearanceAction);
}
break;
case WIDX_VEHICLE_ADDITIONAL_COLOUR_2:
{
auto rideSetAppearanceAction = RideSetAppearanceAction(
w->number, RideSetAppearanceType::VehicleColourTernary, dropdownIndex, w->vehicleIndex);
rideId, RideSetAppearanceType::VehicleColourTernary, dropdownIndex, w->vehicleIndex);
GameActions::Execute(&rideSetAppearanceAction);
}
break;
@@ -4562,7 +4566,7 @@ static void window_ride_colour_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -4788,7 +4792,7 @@ static void window_ride_colour_paint(rct_window* w, rct_drawpixelinfo* dpi)
rct_drawpixelinfo clippedDpi;
rct_widget* widget;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -4888,7 +4892,7 @@ static void window_ride_colour_paint(rct_window* w, rct_drawpixelinfo* dpi)
*/
static void window_ride_colour_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -4951,11 +4955,11 @@ static std::vector<ObjectEntryIndex> window_ride_current_music_style_order;
*/
static void window_ride_toggle_music(rct_window* w)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
int32_t activateMusic = (ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC) ? 0 : 1;
set_operating_setting(w->number, RideSetSetting::Music, activateMusic);
set_operating_setting(w->rideId, RideSetSetting::Music, activateMusic);
}
}
@@ -5027,7 +5031,7 @@ static void window_ride_music_mousedown(rct_window* w, rct_widgetindex widgetInd
return;
auto dropdownWidget = widget - 1;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -5106,7 +5110,7 @@ static void window_ride_music_dropdown(rct_window* w, rct_widgetindex widgetInde
&& static_cast<size_t>(dropdownIndex) < window_ride_current_music_style_order.size())
{
auto musicStyle = window_ride_current_music_style_order[dropdownIndex];
set_operating_setting(w->number, RideSetSetting::MusicType, musicStyle);
set_operating_setting(w->rideId, RideSetSetting::MusicType, musicStyle);
}
}
@@ -5136,7 +5140,7 @@ static void window_ride_music_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -5227,7 +5231,7 @@ static void setup_scenery_selection(rct_window* w)
while (tool_set(w, WIDX_BACKGROUND, Tool::Crosshair))
;
gTrackDesignSaveRideIndex = w->number;
gTrackDesignSaveRideIndex = w->rideId;
track_design_save_init();
gGamePaused |= GAME_PAUSED_SAVING_TRACK;
@@ -5290,7 +5294,7 @@ static void TrackDesignCallback(int32_t result, [[maybe_unused]] const utf8* pat
*/
static void window_ride_measurements_design_save(rct_window* w)
{
Ride* ride = get_ride(w->number);
Ride* ride = get_ride(w->rideId);
_trackDesign = ride->SaveToTrackDesign();
if (!_trackDesign)
{
@@ -5382,7 +5386,7 @@ static void window_ride_measurements_mousedown(rct_window* w, rct_widgetindex wi
if (widgetIndex != WIDX_SAVE_TRACK_DESIGN)
return;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -5508,7 +5512,8 @@ static void window_ride_measurements_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
const auto rideId = w->rideId;
auto ride = get_ride(rideId);
if (ride == nullptr)
return;
@@ -5517,7 +5522,7 @@ static void window_ride_measurements_invalidate(rct_window* w)
window_ride_measurements_widgets[WIDX_SAVE_TRACK_DESIGN].tooltip = STR_SAVE_TRACK_DESIGN_NOT_POSSIBLE;
window_ride_measurements_widgets[WIDX_SAVE_TRACK_DESIGN].type = WindowWidgetType::Empty;
if (gTrackDesignSaveMode && gTrackDesignSaveRideIndex == w->number)
if (gTrackDesignSaveMode && gTrackDesignSaveRideIndex == rideId)
{
window_ride_measurements_widgets[WIDX_SELECT_NEARBY_SCENERY].type = WindowWidgetType::Button;
window_ride_measurements_widgets[WIDX_RESET_SELECTION].type = WindowWidgetType::Button;
@@ -5570,7 +5575,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi
}
else
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -5894,7 +5899,7 @@ static void window_ride_graphs_update(rct_window* w)
x = w->scrolls[0].h_left;
if (!(w->list_information_type & 0x8000))
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
RideMeasurement* measurement{};
@@ -5919,7 +5924,7 @@ static void window_ride_graphs_scrollgetheight(rct_window* w, int32_t scrollInde
*width = window_ride_graphs_widgets[WIDX_GRAPH].width() - 2;
// Get measurement size
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
RideMeasurement* measurement{};
@@ -5948,7 +5953,7 @@ static OpenRCT2String window_ride_graphs_tooltip(rct_window* w, const rct_widget
{
if (widgetIndex == WIDX_GRAPH)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
auto [measurement, message] = ride->GetMeasurement();
@@ -5988,7 +5993,7 @@ static void window_ride_graphs_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -6054,7 +6059,7 @@ static void window_ride_graphs_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi
gfx_clear(dpi, ColourMapA[COLOUR_SATURATED_GREEN].darker);
auto widget = &window_ride_graphs_widgets[WIDX_GRAPH];
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
{
return;
@@ -6247,7 +6252,8 @@ static void update_same_price_throughout_flags(ShopItem shop_item)
*/
static void window_ride_income_toggle_primary_price(rct_window* w)
{
auto ride = get_ride(w->number);
const auto rideId = w->rideId;
auto ride = get_ride(rideId);
if (ride == nullptr)
return;
@@ -6273,7 +6279,7 @@ static void window_ride_income_toggle_primary_price(rct_window* w)
update_same_price_throughout_flags(shop_item);
auto rideSetPriceAction = RideSetPriceAction(w->number, ride->price[0], true);
auto rideSetPriceAction = RideSetPriceAction(rideId, ride->price[0], true);
GameActions::Execute(&rideSetPriceAction);
}
@@ -6283,7 +6289,8 @@ static void window_ride_income_toggle_primary_price(rct_window* w)
*/
static void window_ride_income_toggle_secondary_price(rct_window* w)
{
auto ride = get_ride(w->number);
const auto rideId = w->rideId;
auto ride = get_ride(rideId);
if (ride == nullptr)
return;
@@ -6297,13 +6304,13 @@ static void window_ride_income_toggle_secondary_price(rct_window* w)
update_same_price_throughout_flags(shop_item);
auto rideSetPriceAction = RideSetPriceAction(w->number, ride->price[1], false);
auto rideSetPriceAction = RideSetPriceAction(rideId, ride->price[1], false);
GameActions::Execute(&rideSetPriceAction);
}
static void window_ride_income_set_primary_price(rct_window* w, money16 price)
{
auto rideSetPriceAction = RideSetPriceAction(w->number, price, true);
auto rideSetPriceAction = RideSetPriceAction(w->rideId, price, true);
GameActions::Execute(&rideSetPriceAction);
}
@@ -6316,7 +6323,7 @@ static void window_ride_income_increase_primary_price(rct_window* w)
if (!window_ride_income_can_modify_primary_price(w))
return;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -6336,7 +6343,7 @@ static void window_ride_income_decrease_primary_price(rct_window* w)
if (!window_ride_income_can_modify_primary_price(w))
return;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -6349,7 +6356,7 @@ static void window_ride_income_decrease_primary_price(rct_window* w)
static money16 window_ride_income_get_secondary_price(rct_window* w)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return 0;
@@ -6359,13 +6366,13 @@ static money16 window_ride_income_get_secondary_price(rct_window* w)
static void window_ride_income_set_secondary_price(rct_window* w, money16 price)
{
auto rideSetPriceAction = RideSetPriceAction((w->number & 0x00FF), price, false);
auto rideSetPriceAction = RideSetPriceAction(w->rideId, price, false);
GameActions::Execute(&rideSetPriceAction);
}
static bool window_ride_income_can_modify_primary_price(rct_window* w)
{
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return false;
@@ -6430,7 +6437,7 @@ static void window_ride_income_mouseup(rct_window* w, rct_widgetindex widgetInde
if (!window_ride_income_can_modify_primary_price(w))
return;
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
money_to_string(static_cast<money32>(ride->price[0]), _moneyInputText, MONEY_STRING_MAXLENGTH, true);
@@ -6500,7 +6507,7 @@ static void window_ride_income_update(rct_window* w)
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_9);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr && ride->window_invalidate_flags & RIDE_INVALIDATE_RIDE_INCOME)
{
ride->window_invalidate_flags &= ~RIDE_INVALIDATE_RIDE_INCOME;
@@ -6547,7 +6554,7 @@ static void window_ride_income_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -6658,7 +6665,7 @@ static void window_ride_income_paint(rct_window* w, rct_drawpixelinfo* dpi)
WindowDrawWidgets(w, dpi);
window_ride_draw_tab_images(dpi, w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
@@ -6826,7 +6833,7 @@ static void window_ride_customer_update(rct_window* w)
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_10);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr && ride->window_invalidate_flags & RIDE_INVALIDATE_RIDE_CUSTOMER)
{
ride->window_invalidate_flags &= ~RIDE_INVALIDATE_RIDE_CUSTOMER;
@@ -6849,7 +6856,7 @@ static void window_ride_customer_invalidate(rct_window* w)
window_ride_set_pressed_tab(w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride != nullptr)
{
auto ft = Formatter::Common();
@@ -6885,7 +6892,7 @@ static void window_ride_customer_paint(rct_window* w, rct_drawpixelinfo* dpi)
WindowDrawWidgets(w, dpi);
window_ride_draw_tab_images(dpi, w);
auto ride = get_ride(w->number);
auto ride = get_ride(w->rideId);
if (ride == nullptr)
return;
+7 -7
View File
@@ -495,9 +495,9 @@ static int32_t ride_get_alternative_type(Ride* ride)
}
/* move to ride.c */
static void close_ride_window_for_construction(rct_windownumber number)
static void close_ride_window_for_construction(ride_id_t rideId)
{
rct_window* w = window_find_by_number(WC_RIDE, number);
rct_window* w = window_find_by_number(WC_RIDE, EnumValue(rideId));
if (w != nullptr && w->page == 1)
window_close(w);
}
@@ -543,7 +543,7 @@ rct_window* window_ride_construction_open()
w->colours[1] = COLOUR_DARK_BROWN;
w->colours[2] = COLOUR_DARK_BROWN;
w->number = rideIndex;
w->rideId = rideIndex;
window_push_others_right(w);
show_gridlines();
@@ -620,7 +620,7 @@ static void window_ride_construction_close(rct_window* w)
ride->SetToDefaultInspectionInterval();
auto intent = Intent(WC_RIDE);
intent.putExtra(INTENT_EXTRA_RIDE_ID, ride->id);
intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(ride->id));
context_open_intent(&intent);
}
else
@@ -1937,7 +1937,7 @@ static void window_ride_construction_mouseup_demolish(rct_window* w)
_currentTrackPieceType, 0,
{ _currentTrackBegin.x, _currentTrackBegin.y, _currentTrackBegin.z, _currentTrackPieceDirection });
const auto rideId = w->number;
const auto rideId = w->rideId;
trackRemoveAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) {
if (result->Error != GameActions::Status::Ok)
{
@@ -1987,7 +1987,7 @@ static void window_ride_construction_entrance_click(rct_window* w)
else
{
gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_ENTRANCE;
gRideEntranceExitPlaceRideIndex = static_cast<ride_id_t>(w->number);
gRideEntranceExitPlaceRideIndex = w->rideId;
gRideEntranceExitPlaceStationIndex = 0;
input_set_flag(INPUT_FLAG_6, true);
ride_construction_invalidate_current_track();
@@ -2017,7 +2017,7 @@ static void window_ride_construction_exit_click(rct_window* w)
else
{
gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_EXIT;
gRideEntranceExitPlaceRideIndex = w->number & 0xFF;
gRideEntranceExitPlaceRideIndex = w->rideId;
gRideEntranceExitPlaceStationIndex = 0;
input_set_flag(INPUT_FLAG_6, true);
ride_construction_invalidate_current_track();
+1 -1
View File
@@ -443,7 +443,7 @@ static void window_ride_list_scrollmousedown(rct_window* w, int32_t scrollIndex,
else
{
auto intent = Intent(WC_RIDE);
intent.putExtra(INTENT_EXTRA_RIDE_ID, rideIndex);
intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(rideIndex));
context_open_intent(&intent);
}
}
+1 -1
View File
@@ -1931,7 +1931,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Details
// Ride
auto trackElement = tileElement->AsTrack();
int16_t rideId = trackElement->GetRideIndex();
ride_id_t rideId = trackElement->GetRideIndex();
auto ride = get_ride(rideId);
if (ride != nullptr)
{
+7 -4
View File
@@ -268,7 +268,8 @@ static void window_track_place_toolupdate(rct_window* w, rct_widgetindex widgetI
// Check if tool map position has changed since last update
if (mapCoords == _windowTrackPlaceLast)
{
place_virtual_track(_trackDesign.get(), PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(0), { mapCoords, 0 });
place_virtual_track(
_trackDesign.get(), PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(PreviewRideId), { mapCoords, 0 });
return;
}
@@ -308,7 +309,7 @@ static void window_track_place_toolupdate(rct_window* w, rct_widgetindex widgetI
widget_invalidate(w, WIDX_PRICE);
}
place_virtual_track(_trackDesign.get(), PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(0), trackLoc);
place_virtual_track(_trackDesign.get(), PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(PreviewRideId), trackLoc);
}
/**
@@ -348,7 +349,7 @@ static void window_track_place_tooldown(rct_window* w, rct_widgetindex widgetInd
if (track_design_are_entrance_and_exit_placed())
{
auto intent = Intent(WC_RIDE);
intent.putExtra(INTENT_EXTRA_RIDE_ID, result->rideIndex);
intent.putExtra(INTENT_EXTRA_RIDE_ID, static_cast<int32_t>(result->rideIndex));
context_open_intent(&intent);
auto wnd = window_find_by_class(WC_TRACK_DESIGN_PLACE);
window_close(wnd);
@@ -469,7 +470,9 @@ static int32_t window_track_place_get_base_z(const CoordsXY& loc)
if (surfaceElement->GetWaterHeight() > 0)
z = std::max(z, surfaceElement->GetWaterHeight());
return z + place_virtual_track(_trackDesign.get(), PTD_OPERATION_GET_PLACE_Z, true, GetOrAllocateRide(0), { loc, z });
return z
+ place_virtual_track(
_trackDesign.get(), PTD_OPERATION_GET_PLACE_Z, true, GetOrAllocateRide(PreviewRideId), { loc, z });
}
/**
@@ -192,14 +192,10 @@ void setup_in_use_selection_flags()
}
} while (tile_element_iterator_next(&iter));
for (ride_id_t ride_index = 0; ride_index < MAX_RIDES; ride_index++)
for (auto& ride : GetRideManager())
{
auto ride = get_ride(ride_index);
if (ride != nullptr)
{
ObjectEntryIndex type = ride->subtype;
Editor::SetSelectedObject(ObjectType::Ride, type, OBJECT_SELECTION_FLAG_SELECTED);
}
ObjectEntryIndex type = ride.subtype;
Editor::SetSelectedObject(ObjectType::Ride, type, OBJECT_SELECTION_FLAG_SELECTED);
}
// Apply selected object status for hacked vehicles that may not have an associated ride
+1 -1
View File
@@ -70,7 +70,7 @@ GameActions::Result::Ptr ParkMarketingAction::Execute() const
campaign.Flags = MarketingCampaignFlags::FIRST_WEEK;
if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE)
{
campaign.RideId = _item;
campaign.RideId = static_cast<ride_id_t>(_item);
}
else if (campaign.Type == ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE)
{
+10 -8
View File
@@ -131,14 +131,16 @@ GameActions::Result::Ptr RideDemolishAction::DemolishRide(Ride* ride) const
ride->ValidateStations();
ride_clear_leftover_entrances(ride);
News::DisableNewsItems(News::ItemType::Ride, _rideIndex);
UnlinkAllBannersForRide(_rideIndex);
const auto rideId = ride->id;
News::DisableNewsItems(News::ItemType::Ride, EnumValue(rideId));
RideUse::GetHistory().RemoveValue(_rideIndex);
UnlinkAllBannersForRide(ride->id);
RideUse::GetHistory().RemoveValue(ride->id);
for (auto peep : EntityList<Guest>())
{
peep->RemoveRideFromMemory(_rideIndex);
peep->RemoveRideFromMemory(ride->id);
}
MarketingCancelCampaignsForRide(_rideIndex);
@@ -157,9 +159,9 @@ GameActions::Result::Ptr RideDemolishAction::DemolishRide(Ride* ride) const
gParkValue = GetContext()->GetGameState()->GetPark().CalculateParkValue();
// Close windows related to the demolished ride
window_close_by_number(WC_RIDE_CONSTRUCTION, _rideIndex);
window_close_by_number(WC_RIDE, _rideIndex);
window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, _rideIndex);
window_close_by_number(WC_RIDE_CONSTRUCTION, EnumValue(rideId));
window_close_by_number(WC_RIDE, EnumValue(rideId));
window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, EnumValue(rideId));
window_close_by_class(WC_NEW_CAMPAIGN);
// Refresh windows that display the ride name
@@ -272,7 +274,7 @@ GameActions::Result::Ptr RideDemolishAction::RefurbishRide(Ride* ride) const
res->Position = { location, tile_element_height(location) };
}
window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, _rideIndex);
window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, EnumValue(_rideIndex));
return res;
}
@@ -54,7 +54,7 @@ GameActions::Result::Ptr RideEntranceExitPlaceAction::Query() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid game command for ride %d", static_cast<int32_t>(_rideIndex));
log_warning("Invalid game command for ride %d", EnumValue(_rideIndex));
return MakeResult(GameActions::Status::InvalidParameters, errorTitle);
}
@@ -132,7 +132,7 @@ GameActions::Result::Ptr RideEntranceExitPlaceAction::Execute() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid game command for ride %d", static_cast<int32_t>(_rideIndex));
log_warning("Invalid game command for ride %d", EnumValue(_rideIndex));
return MakeResult(GameActions::Status::InvalidParameters, errorTitle);
}
@@ -74,7 +74,7 @@ GameActions::Result::Ptr RideEntranceExitRemoveAction::Query() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid ride id %d for entrance/exit removal", static_cast<int32_t>(_rideIndex));
log_warning("Invalid ride id %d for entrance/exit removal", EnumValue(_rideIndex));
return std::make_unique<GameActions::Result>(GameActions::Status::InvalidParameters, STR_NONE);
}
@@ -99,8 +99,8 @@ GameActions::Result::Ptr RideEntranceExitRemoveAction::Query() const
if (entranceElement == nullptr)
{
log_warning(
"Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y,
static_cast<int32_t>(_rideIndex), _stationNum);
"Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y, EnumValue(_rideIndex),
_stationNum);
return MakeResult(GameActions::Status::InvalidParameters, STR_NONE);
}
@@ -112,7 +112,7 @@ GameActions::Result::Ptr RideEntranceExitRemoveAction::Execute() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid ride id %d for entrance/exit removal", static_cast<int32_t>(_rideIndex));
log_warning("Invalid ride id %d for entrance/exit removal", EnumValue(_rideIndex));
return std::make_unique<GameActions::Result>(GameActions::Status::InvalidParameters, STR_NONE);
}
@@ -130,8 +130,8 @@ GameActions::Result::Ptr RideEntranceExitRemoveAction::Execute() const
if (entranceElement == nullptr)
{
log_warning(
"Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y,
static_cast<int32_t>(_rideIndex), _stationNum);
"Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y, EnumValue(_rideIndex),
_stationNum);
return MakeResult(GameActions::Status::InvalidParameters, STR_NONE);
}
@@ -139,7 +139,7 @@ GameActions::Result::Ptr RideSetAppearanceAction::Execute() const
gfx_invalidate_screen();
break;
}
window_invalidate_by_number(WC_RIDE, _rideIndex);
window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex));
auto res = std::make_unique<GameActions::Result>();
if (!ride->overall_view.IsNull())
+1 -1
View File
@@ -180,7 +180,7 @@ void RideSetPriceAction::RideSetCommonPrice(ShopItem shopItem) const
}
if (invalidate)
{
window_invalidate_by_number(WC_RIDE, ride.id);
window_invalidate_by_number(WC_RIDE, EnumValue(ride.id));
}
}
}
@@ -45,7 +45,7 @@ GameActions::Result::Ptr RideSetSettingAction::Query() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid ride: #%d.", static_cast<int32_t>(_rideIndex));
log_warning("Invalid ride: #%d.", EnumValue(_rideIndex));
return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE);
}
@@ -153,7 +153,7 @@ GameActions::Result::Ptr RideSetSettingAction::Execute() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid ride: #%d.", static_cast<int32_t>(_rideIndex));
log_warning("Invalid ride: #%d.", EnumValue(_rideIndex));
return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE);
}
@@ -233,7 +233,7 @@ GameActions::Result::Ptr RideSetSettingAction::Execute() const
auto location = ride->overall_view.ToTileCentre();
res->Position = { location, tile_element_height(location) };
}
window_invalidate_by_number(WC_RIDE, _rideIndex);
window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex));
return res;
}
+6 -6
View File
@@ -59,7 +59,7 @@ GameActions::Result::Ptr RideSetStatusAction::Query() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
log_warning("Invalid game command for ride %u", EnumValue(_rideIndex));
res->Error = GameActions::Status::InvalidParameters;
res->ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN;
res->ErrorMessage = STR_NONE;
@@ -68,7 +68,7 @@ GameActions::Result::Ptr RideSetStatusAction::Query() const
if (_status >= RideStatus::Count)
{
log_warning("Invalid ride status %u for ride %u", uint32_t(_status), uint32_t(_rideIndex));
log_warning("Invalid ride status %u for ride %u", EnumValue(_status), EnumValue(_rideIndex));
res->Error = GameActions::Status::InvalidParameters;
res->ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN;
res->ErrorMessage = STR_NONE;
@@ -154,7 +154,7 @@ GameActions::Result::Ptr RideSetStatusAction::Execute() const
ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING;
ride->race_winner = SPRITE_INDEX_NULL;
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST;
window_invalidate_by_number(WC_RIDE, _rideIndex);
window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex));
break;
case RideStatus::Simulating:
{
@@ -176,7 +176,7 @@ GameActions::Result::Ptr RideSetStatusAction::Execute() const
ride->last_issue_time = 0;
ride->GetMeasurement();
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST;
window_invalidate_by_number(WC_RIDE, _rideIndex);
window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex));
break;
}
case RideStatus::Testing:
@@ -195,7 +195,7 @@ GameActions::Result::Ptr RideSetStatusAction::Execute() const
// Fix #3183: Make sure we close the construction window so the ride finishes any editing code before opening
// otherwise vehicles get added to the ride incorrectly (such as to a ghost station)
rct_window* constructionWindow = window_find_by_number(WC_RIDE_CONSTRUCTION, _rideIndex);
rct_window* constructionWindow = window_find_by_number(WC_RIDE_CONSTRUCTION, EnumValue(_rideIndex));
if (constructionWindow != nullptr)
{
window_close(constructionWindow);
@@ -223,7 +223,7 @@ GameActions::Result::Ptr RideSetStatusAction::Execute() const
ride->last_issue_time = 0;
ride->GetMeasurement();
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST;
window_invalidate_by_number(WC_RIDE, _rideIndex);
window_invalidate_by_number(WC_RIDE, EnumValue(_rideIndex));
break;
}
default:
@@ -199,7 +199,7 @@ GameActions::Result::Ptr RideSetVehicleAction::Execute() const
}
auto intent = Intent(INTENT_ACTION_RIDE_PAINT_RESET_VEHICLE);
intent.putExtra(INTENT_EXTRA_RIDE_ID, _rideIndex);
intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(_rideIndex));
context_broadcast_intent(&intent);
gfx_invalidate_screen();
+5 -5
View File
@@ -85,13 +85,13 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid ride for track placement, rideIndex = %d", static_cast<int32_t>(_rideIndex));
log_warning("Invalid ride for track placement, rideIndex = %d", EnumValue(_rideIndex));
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters, STR_NONE);
}
rct_ride_entry* rideEntry = get_ride_entry(ride->subtype);
if (rideEntry == nullptr)
{
log_warning("Invalid ride subtype for track placement, rideIndex = %d", static_cast<int32_t>(_rideIndex));
log_warning("Invalid ride subtype for track placement, rideIndex = %d", EnumValue(_rideIndex));
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters, STR_NONE);
}
@@ -379,14 +379,14 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const
auto ride = get_ride(_rideIndex);
if (ride == nullptr)
{
log_warning("Invalid ride for track placement, rideIndex = %d", static_cast<int32_t>(_rideIndex));
log_warning("Invalid ride for track placement, rideIndex = %d", EnumValue(_rideIndex));
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters);
}
rct_ride_entry* rideEntry = get_ride_entry(ride->subtype);
if (rideEntry == nullptr)
{
log_warning("Invalid ride subtype for track placement, rideIndex = %d", static_cast<int32_t>(_rideIndex));
log_warning("Invalid ride subtype for track placement, rideIndex = %d", EnumValue(_rideIndex));
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::InvalidParameters);
}
@@ -550,7 +550,7 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const
auto* trackElement = TileElementInsert<TrackElement>(mapLoc, quarterTile.GetBaseQuarterOccupied());
if (trackElement == nullptr)
{
log_warning("Cannot create track element for ride = %d", static_cast<int32_t>(_rideIndex));
log_warning("Cannot create track element for ride = %d", EnumValue(_rideIndex));
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::NoFreeElements);
}
-33
View File
@@ -214,39 +214,6 @@ template<> struct DataSerializerTraits_t<NetworkPlayerId_t>
}
};
template<> struct DataSerializerTraits_t<NetworkRideId_t>
{
static void encode(OpenRCT2::IStream* stream, const NetworkRideId_t& val)
{
uint32_t temp = static_cast<uint32_t>(val.id);
temp = ByteSwapBE(temp);
stream->Write(&temp);
}
static void decode(OpenRCT2::IStream* stream, NetworkRideId_t& val)
{
uint32_t temp;
stream->Read(&temp);
val.id = static_cast<decltype(val.id)>(ByteSwapBE(temp));
}
static void log(OpenRCT2::IStream* stream, const NetworkRideId_t& val)
{
char rideId[28] = {};
snprintf(rideId, sizeof(rideId), "%u", val.id);
stream->Write(rideId, strlen(rideId));
auto ride = get_ride(val.id);
if (ride != nullptr)
{
auto rideName = ride->GetName();
stream->Write(" \"", 2);
stream->Write(rideName.c_str(), rideName.size());
stream->Write("\"", 1);
}
}
};
template<typename T> struct DataSerializerTraits_t<DataSerialiserTag<T>>
{
static void encode(OpenRCT2::IStream* stream, const DataSerialiserTag<T>& tag)
@@ -194,7 +194,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
int32_t res = set_operating_setting(ride_index, RideSetSetting::RideType, type);
int32_t res = set_operating_setting(static_cast<ride_id_t>(ride_index), RideSetSetting::RideType, type);
if (res == MONEY32_UNDEFINED)
{
if (!gCheatsAllowArbitraryRideTypeChanges)
@@ -224,7 +224,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
auto ride = get_ride(ride_index);
auto ride = get_ride(static_cast<ride_id_t>(ride_index));
if (mode >= static_cast<uint8_t>(RideMode::Count))
{
console.WriteFormatLine("Invalid ride mode.");
@@ -256,7 +256,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
auto ride = get_ride(ride_index);
auto ride = get_ride(static_cast<ride_id_t>(ride_index));
if (mass <= 0)
{
console.WriteFormatLine("Friction value must be strictly positive");
@@ -294,7 +294,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
auto ride = get_ride(ride_index);
auto ride = get_ride(static_cast<ride_id_t>(ride_index));
if (excitement <= 0)
{
console.WriteFormatLine("Excitement value must be strictly positive");
@@ -325,7 +325,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
auto ride = get_ride(ride_index);
auto ride = get_ride(static_cast<ride_id_t>(ride_index));
if (intensity <= 0)
{
console.WriteFormatLine("Intensity value must be strictly positive");
@@ -356,7 +356,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
auto ride = get_ride(ride_index);
auto ride = get_ride(static_cast<ride_id_t>(ride_index));
if (nausea <= 0)
{
console.WriteFormatLine("Nausea value must be strictly positive");
@@ -426,7 +426,7 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
auto rideSetPrice = RideSetPriceAction(rideId, price, true);
auto rideSetPrice = RideSetPriceAction(static_cast<ride_id_t>(rideId), price, true);
GameActions::Execute(&rideSetPrice);
}
}
+6 -2
View File
@@ -45,10 +45,14 @@ struct rct_window
int16_t max_width{};
int16_t min_height{};
int16_t max_height{};
rct_windownumber number{};
union
{
rct_windownumber number{};
ride_id_t rideId;
};
uint16_t flags{};
rct_scroll scrolls[3];
uint8_t list_item_positions[1024]{};
uint32_t list_item_positions[1024]{};
uint16_t no_list_items{}; // 0 for no items
int16_t selected_list_item{}; // -1 for none selected
union
+4 -1
View File
@@ -16,6 +16,8 @@
extern thread_local uint8_t gCommonFormatArgs[80];
enum class ride_id_t : uint16_t;
class Formatter
{
std::array<uint8_t, 80> Buffer{};
@@ -83,6 +85,7 @@ public:
std::is_same_v<typename std::remove_cv<TSpecified>::type, int32_t> ||
std::is_same_v<typename std::remove_cv<TSpecified>::type, money32> ||
std::is_same_v<typename std::remove_cv<TSpecified>::type, money64> ||
std::is_same_v<typename std::remove_cv<TSpecified>::type, ride_id_t> ||
std::is_same_v<typename std::remove_cv<TSpecified>::type, rct_string_id> ||
std::is_same_v<typename std::remove_cv<TSpecified>::type, uint16_t> ||
std::is_same_v<typename std::remove_cv<TSpecified>::type, uint32_t> ||
@@ -92,7 +95,7 @@ public:
// clang-format on
uint64_t convertedValue;
if constexpr (std::is_integral_v<TSpecified>)
if constexpr (std::is_integral_v<TSpecified> || std::is_enum_v<TSpecified>)
{
convertedValue = static_cast<uint64_t>(value);
}
+1 -1
View File
@@ -211,7 +211,7 @@ std::optional<CoordsXYZ> News::GetSubjectLocation(News::ItemType type, int32_t s
{
case News::ItemType::Ride:
{
Ride* ride = get_ride(subject);
Ride* ride = get_ride(static_cast<ride_id_t>(subject));
if (ride == nullptr || ride->overall_view.IsNull())
{
break;
+1 -1
View File
@@ -37,7 +37,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 "8"
#define NETWORK_STREAM_VERSION "9"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;
+2 -1
View File
@@ -126,10 +126,11 @@ template<typename T, size_t _TypeID> struct NetworkObjectId_t
};
#pragma pack(pop)
using NetworkRideId_t = ride_id_t;
// NOTE: When adding new types make sure to have no duplicate _TypeID's otherwise
// there is no way to specialize templates if they have the exact symbol.
using NetworkPlayerId_t = NetworkObjectId_t<int32_t, 0>;
using NetworkRideId_t = NetworkObjectId_t<ride_id_t, 1>;
using NetworkCheatType_t = NetworkObjectId_t<int32_t, 2>;
enum class NetworkStatisticsGroup : uint32_t
+16 -11
View File
@@ -1822,7 +1822,8 @@ Ride* Guest::FindBestRideToGoOn()
Ride* mostExcitingRide = nullptr;
for (auto& ride : GetRideManager())
{
if (rideConsideration.size() > ride.id && rideConsideration[ride.id])
const auto rideIndex = EnumValue(ride.id);
if (rideConsideration.size() > rideIndex && rideConsideration[rideIndex])
{
if (!(ride.lifecycle_flags & RIDE_LIFECYCLE_QUEUE_FULL))
{
@@ -1853,7 +1854,7 @@ std::bitset<MAX_RIDES> Guest::FindRidesToGoOn()
{
if (!HasRidden(&ride))
{
rideConsideration[ride.id] = true;
rideConsideration[EnumValue(ride.id)] = true;
}
}
}
@@ -1874,7 +1875,7 @@ std::bitset<MAX_RIDES> Guest::FindRidesToGoOn()
for (auto* trackElement : TileElementsView<TrackElement>(location))
{
auto rideIndex = trackElement->GetRideIndex();
rideConsideration[rideIndex] = true;
rideConsideration[EnumValue(rideIndex)] = true;
}
}
}
@@ -1884,7 +1885,7 @@ std::bitset<MAX_RIDES> Guest::FindRidesToGoOn()
{
if (ride.highest_drop_height > 66 || ride.excitement >= RIDE_RATING(8, 00))
{
rideConsideration[ride.id] = true;
rideConsideration[EnumValue(ride.id)] = true;
}
}
}
@@ -3105,7 +3106,7 @@ template<typename T> static void peep_head_for_nearest_ride(Guest* peep, bool co
{
if (predicate(ride))
{
rideConsideration[ride.id] = true;
rideConsideration[EnumValue(ride.id)] = true;
}
}
}
@@ -3133,18 +3134,18 @@ template<typename T> static void peep_head_for_nearest_ride(Guest* peep, bool co
if (!predicate(*ride))
continue;
rideConsideration[rideIndex] = true;
rideConsideration[EnumValue(ride->id)] = true;
}
}
}
}
// Filter the considered rides
uint8_t potentialRides[MAX_RIDES];
ride_id_t potentialRides[MAX_RIDES];
size_t numPotentialRides = 0;
for (auto& ride : GetRideManager())
{
if (rideConsideration[ride.id])
if (rideConsideration[EnumValue(ride.id)])
{
if (!(ride.lifecycle_flags & RIDE_LIFECYCLE_QUEUE_FULL))
{
@@ -3657,7 +3658,7 @@ void Guest::UpdateRideAdvanceThroughEntrance()
ride->FormatNameTo(ft);
if (gConfigNotifications.ride_warnings)
{
News::AddItemToQueue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, CurrentRide, ft);
News::AddItemToQueue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, EnumValue(CurrentRide), ft);
}
}
@@ -3811,7 +3812,7 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride* ride)
if (queueTime != ride->stations[CurrentRideStation].QueueTime)
{
ride->stations[CurrentRideStation].QueueTime = queueTime;
window_invalidate_by_number(WC_RIDE, CurrentRide);
window_invalidate_by_number(WC_RIDE, EnumValue(CurrentRide));
}
if (PeepFlags & PEEP_FLAGS_TRACKING)
@@ -6811,6 +6812,10 @@ void Guest::InsertNewThought(PeepThoughtType thought_type, ShopItem shopItem)
InsertNewThought(thought_type, static_cast<uint16_t>(shopItem));
}
void Guest::InsertNewThought(PeepThoughtType thought_type, ride_id_t rideId)
{
InsertNewThought(thought_type, static_cast<uint16_t>(rideId));
}
/**
*
* rct2: 0x699F5A
@@ -7454,7 +7459,7 @@ void Guest::RemoveRideFromMemory(ride_id_t rideId)
break;
// Ride ids and shop item ids might have the same value, look only for ride thoughts.
if (IsThoughtShopItemRelated(entry.type) || entry.item != rideId)
if (IsThoughtShopItemRelated(entry.type) || entry.rideId != rideId)
{
it++;
continue;
+2 -2
View File
@@ -2095,8 +2095,8 @@ int32_t guest_path_finding(Guest* peep)
if (!(adjustedEdges & (1 << chosenDirection)))
continue;
ride_id_t rideIndex, pathSearchResult;
pathSearchResult = footpath_element_destination_in_direction(loc, pathElement, chosenDirection, &rideIndex);
ride_id_t rideIndex = RIDE_ID_NULL;
auto pathSearchResult = footpath_element_destination_in_direction(loc, pathElement, chosenDirection, &rideIndex);
switch (pathSearchResult)
{
case PATH_SEARCH_DEAD_END:
+1
View File
@@ -774,6 +774,7 @@ public:
void UpdateEasterEggInteractions();
void InsertNewThought(PeepThoughtType thought_type);
void InsertNewThought(PeepThoughtType thought_type, ShopItem thought_arguments);
void InsertNewThought(PeepThoughtType thought_type, ride_id_t rideId);
void InsertNewThought(PeepThoughtType thought_type, uint16_t thought_arguments);
static Guest* Generate(const CoordsXYZ& coords);
bool UpdateQueuePosition(PeepActionType previous_action);
+8 -5
View File
@@ -716,7 +716,8 @@ namespace RCT1
{
if (_s4.rides[i].type != RideType::Null)
{
ImportRide(GetOrAllocateRide(i), &_s4.rides[i], i);
const auto rideId = static_cast<ride_id_t>(i);
ImportRide(GetOrAllocateRide(rideId), &_s4.rides[i], rideId);
}
}
}
@@ -2482,10 +2483,12 @@ namespace RCT1
{
if (_s4.scenario_slot_index == SC_URBAN_PARK && _isScenario)
{
const auto merryGoRoundId = static_cast<ride_id_t>(0);
// First, make the queuing peep exit
for (auto peep : EntityList<Guest>())
{
if (peep->State == PeepState::QueuingFront && peep->CurrentRide == 0)
if (peep->State == PeepState::QueuingFront && peep->CurrentRide == merryGoRoundId)
{
peep->RemoveFromQueue();
peep->SetState(PeepState::Falling);
@@ -2494,7 +2497,7 @@ namespace RCT1
}
// Now, swap the entrance and exit.
auto ride = get_ride(0);
auto ride = get_ride(merryGoRoundId);
if (ride != nullptr)
{
auto entranceCoords = ride->stations[0].Exit;
@@ -2666,13 +2669,13 @@ namespace RCT1
{
auto* dst = CreateEntityAt<::Vehicle>(srcBase.sprite_index);
auto* src = static_cast<const RCT1::Vehicle*>(&srcBase);
const auto* ride = get_ride(src->ride);
const auto* ride = get_ride(static_cast<ride_id_t>(src->ride));
if (ride == nullptr)
return;
uint8_t vehicleEntryIndex = RCT1::GetVehicleSubEntryIndex(src->vehicle_type);
dst->ride = src->ride;
dst->ride = static_cast<ride_id_t>(src->ride);
dst->ride_subtype = RCTEntryIndexToOpenRCT2EntryIndex(ride->subtype);
dst->vehicle_type = vehicleEntryIndex;
+2 -2
View File
@@ -1046,7 +1046,7 @@ ride_id_t RCT12RideIdToOpenRCT2RideId(const RCT12RideId rideId)
if (rideId == RCT12_RIDE_ID_NULL)
return RIDE_ID_NULL;
return rideId;
return static_cast<ride_id_t>(rideId);
}
RCT12RideId OpenRCT2RideIdToRCT12RideId(const ride_id_t rideId)
@@ -1054,7 +1054,7 @@ RCT12RideId OpenRCT2RideIdToRCT12RideId(const ride_id_t rideId)
if (rideId == RIDE_ID_NULL)
return RCT12_RIDE_ID_NULL;
return rideId;
return static_cast<RCT12RideId>(rideId);
}
static bool RCT12IsFormatChar(codepoint_t c)
+1 -1
View File
@@ -966,7 +966,7 @@ template<typename T> std::vector<ride_id_t> RCT12GetRidesBeenOn(T* srcPeep)
{
if (srcPeep->rides_been_on[i / 8] & (1 << (i % 8)))
{
ridesBeenOn.push_back(i);
ridesBeenOn.push_back(static_cast<ride_id_t>(i));
}
}
return ridesBeenOn;
+10 -9
View File
@@ -170,7 +170,7 @@ static void ride_all_has_any_track_elements(std::array<bool, RCT12_MAX_RIDES_IN_
if (it.element->IsGhost())
continue;
rideIndexArray[it.element->AsTrack()->GetRideIndex()] = true;
rideIndexArray[EnumValue(it.element->AsTrack()->GetRideIndex())] = true;
}
}
@@ -609,7 +609,7 @@ void S6Exporter::ExportRides()
const Ride nullRide{};
for (int32_t index = 0; index < RCT12_MAX_RIDES_IN_PARK; index++)
{
const auto* src = get_ride(index);
const auto* src = get_ride(static_cast<ride_id_t>(index));
if (src == nullptr)
{
src = &nullRide;
@@ -931,9 +931,9 @@ void S6Exporter::ExportRideMeasurements()
{
// Get all the ride measurements
std::vector<Ride*> ridesWithMeasurements;
for (ride_id_t i = 0; i < RCT12_MAX_RIDES_IN_PARK; i++)
for (size_t i = 0; i < RCT12_MAX_RIDES_IN_PARK; i++)
{
auto ride = get_ride(i);
auto ride = get_ride(static_cast<ride_id_t>(i));
if (ride != nullptr && ride->measurement != nullptr)
{
ridesWithMeasurements.push_back(ride);
@@ -958,8 +958,8 @@ void S6Exporter::ExportRideMeasurements()
ExportRideMeasurement(_s6.ride_measurements[i], *src->measurement.get());
auto rideId = src->id;
dst.ride_index = rideId;
_s6.rides[rideId].measurement_index = i;
dst.ride_index = static_cast<uint8_t>(rideId);
_s6.rides[dst.ride_index].measurement_index = i;
i++;
}
}
@@ -1224,7 +1224,7 @@ template<> void S6Exporter::ExportEntity(RCT2SpriteVehicle* dst, const Vehicle*
dst->remaining_distance = src->remaining_distance;
dst->velocity = src->velocity;
dst->acceleration = src->acceleration;
dst->ride = src->ride;
dst->ride = static_cast<uint8_t>(src->ride);
dst->vehicle_type = src->vehicle_type;
dst->colours = src->colours;
dst->track_progress = src->track_progress;
@@ -1330,7 +1330,8 @@ template<> void S6Exporter::ExportEntity(RCT2SpritePeep* dst, const Guest* src)
{
for (auto rideId : *rideHistory)
{
dst->rides_been_on[rideId / 8] |= (1 << (rideId % 8));
const auto rideIndex = EnumValue(rideId);
dst->rides_been_on[rideIndex / 8] |= (1 << (rideIndex % 8));
}
}
dst->item_extra_flags = static_cast<uint32_t>(src->GetItemFlags() >> 32);
@@ -1840,7 +1841,7 @@ void S6Exporter::ExportTileElement(RCT12TileElement* dst, const TileElement* src
// Skipping IsHighlighted()
// This has to be done last, since the maze entry shares fields with the colour and sequence fields.
auto ride = get_ride(dst2->GetRideIndex());
auto ride = get_ride(static_cast<ride_id_t>(dst2->GetRideIndex()));
if (ride)
{
if (ride->type == RIDE_TYPE_MAZE)
+7 -5
View File
@@ -530,8 +530,9 @@ public:
auto src = &_s6.rides[index];
if (src->type != RIDE_TYPE_NULL)
{
auto dst = GetOrAllocateRide(index);
ImportRide(dst, src, index);
const auto rideId = static_cast<ride_id_t>(index);
auto dst = GetOrAllocateRide(rideId);
ImportRide(dst, src, rideId);
}
}
}
@@ -872,7 +873,8 @@ public:
{
if (src.ride_index != RCT12_RIDE_ID_NULL)
{
auto ride = get_ride(src.ride_index);
const auto rideId = static_cast<ride_id_t>(src.ride_index);
auto ride = get_ride(rideId);
if (ride != nullptr)
{
ride->measurement = std::make_unique<RideMeasurement>();
@@ -1061,7 +1063,7 @@ public:
{
if (sprite.unknown.sprite_identifier == RCT12SpriteIdentifier::Peep)
{
if (sprite.peep.current_ride == rideIndex
if (sprite.peep.current_ride == static_cast<RCT12RideId>(rideIndex)
&& (static_cast<PeepState>(sprite.peep.state) == PeepState::OnRide
|| static_cast<PeepState>(sprite.peep.state) == PeepState::EnteringRide))
{
@@ -1597,7 +1599,7 @@ template<> void S6Importer::ImportEntity<Vehicle>(const RCT12SpriteBase& baseSrc
dst->remaining_distance = src->remaining_distance;
dst->velocity = src->velocity;
dst->acceleration = src->acceleration;
dst->ride = src->ride;
dst->ride = static_cast<ride_id_t>(src->ride);
dst->vehicle_type = src->vehicle_type;
dst->colours = src->colours;
dst->track_progress = src->track_progress;
+21 -17
View File
@@ -147,21 +147,23 @@ ride_id_t GetNextFreeRideId()
Ride* GetOrAllocateRide(ride_id_t index)
{
if (_rides.size() <= index)
const auto idx = static_cast<size_t>(index);
if (_rides.size() <= idx)
{
_rides.resize(index + 1);
_rides.resize(idx + 1);
}
auto result = &_rides[index];
auto result = &_rides[idx];
result->id = index;
return result;
}
Ride* get_ride(ride_id_t index)
{
if (index < _rides.size())
const auto idx = static_cast<size_t>(index);
if (idx < _rides.size())
{
auto& ride = _rides[index];
auto& ride = _rides[idx];
if (ride.type != RIDE_TYPE_NULL)
{
assert(ride.id == index);
@@ -1503,7 +1505,7 @@ void ride_breakdown_add_news_item(Ride* ride)
{
Formatter ft;
ride->FormatNameTo(ft);
News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_IS_BROKEN_DOWN, ride->id, ft);
News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_IS_BROKEN_DOWN, EnumValue(ride->id), ft);
}
}
@@ -1530,7 +1532,7 @@ static void ride_breakdown_status_update(Ride* ride)
{
Formatter ft;
ride->FormatNameTo(ft);
News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_IS_STILL_NOT_FIXED, ride->id, ft);
News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_IS_STILL_NOT_FIXED, EnumValue(ride->id), ft);
}
}
}
@@ -2181,7 +2183,7 @@ static void ride_entrance_exit_connected(Ride* ride)
ride->FormatNameTo(ft);
if (gConfigNotifications.ride_warnings)
{
News::AddItemToQueue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, ride->id, ft);
News::AddItemToQueue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, EnumValue(ride->id), ft);
}
ride->connected_message_throttle = 3;
}
@@ -2193,7 +2195,7 @@ static void ride_entrance_exit_connected(Ride* ride)
ride->FormatNameTo(ft);
if (gConfigNotifications.ride_warnings)
{
News::AddItemToQueue(News::ItemType::Ride, STR_EXIT_NOT_CONNECTED, ride->id, ft);
News::AddItemToQueue(News::ItemType::Ride, STR_EXIT_NOT_CONNECTED, EnumValue(ride->id), ft);
}
ride->connected_message_throttle = 3;
}
@@ -2262,7 +2264,7 @@ static void ride_shop_connected(Ride* ride)
{
Formatter ft;
ride->FormatNameTo(ft);
News::AddItemToQueue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, ride->id, ft);
News::AddItemToQueue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, EnumValue(ride->id), ft);
}
ride->connected_message_throttle = 3;
@@ -3795,13 +3797,13 @@ bool Ride::Test(RideStatus newStatus, bool isApplying)
if (type == RIDE_TYPE_NULL)
{
log_warning("Invalid ride type for ride %u", id);
log_warning("Invalid ride type for ride %u", EnumValue(id));
return false;
}
if (newStatus != RideStatus::Simulating)
{
window_close_by_number(WC_RIDE_CONSTRUCTION, id);
window_close_by_number(WC_RIDE_CONSTRUCTION, EnumValue(id));
}
StationIndex stationIndex = ride_mode_check_station_present(this);
@@ -3928,9 +3930,11 @@ bool Ride::Open(bool isApplying)
// to set the track to its final state and clean up ghosts.
// We can't just call close as it would cause a stack overflow during shop creation
// with auto open on.
if (WC_RIDE_CONSTRUCTION == gCurrentToolWidget.window_classification && id == gCurrentToolWidget.window_number
if (WC_RIDE_CONSTRUCTION == gCurrentToolWidget.window_classification && EnumValue(id) == gCurrentToolWidget.window_number
&& (input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
window_close_by_number(WC_RIDE_CONSTRUCTION, id);
{
window_close_by_number(WC_RIDE_CONSTRUCTION, EnumValue(id));
}
StationIndex stationIndex = ride_mode_check_station_present(this);
if (stationIndex == STATION_INDEX_NULL)
@@ -4637,7 +4641,7 @@ void invalidate_test_results(Ride* ride)
}
}
}
window_invalidate_by_number(WC_RIDE, ride->id);
window_invalidate_by_number(WC_RIDE, static_cast<uint32_t>(ride->id));
}
/**
@@ -5085,7 +5089,7 @@ void Ride::UpdateMaxVehicles()
{
num_cars_per_train = numCarsPerTrain;
num_vehicles = numVehicles;
window_invalidate_by_number(WC_RIDE, id);
window_invalidate_by_number(WC_RIDE, EnumValue(id));
}
}
@@ -5154,7 +5158,7 @@ void Ride::Crash(uint8_t vehicleIndex)
{
Formatter ft;
FormatNameTo(ft);
News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_HAS_CRASHED, id, ft);
News::AddItemToQueue(News::ItemType::Ride, STR_RIDE_HAS_CRASHED, EnumValue(id), ft);
}
}
+2 -2
View File
@@ -122,7 +122,7 @@ static rct_window* ride_create_or_find_construction_window(ride_id_t rideIndex)
{
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
auto intent = Intent(INTENT_ACTION_RIDE_CONSTRUCTION_FOCUS);
intent.putExtra(INTENT_EXTRA_RIDE_ID, rideIndex);
intent.putExtra(INTENT_EXTRA_RIDE_ID, EnumValue(rideIndex));
windowManager->BroadcastIntent(intent);
return window_find_by_class(WC_RIDE_CONSTRUCTION);
}
@@ -239,7 +239,7 @@ void ride_clear_for_construction(Ride* ride)
ride->RemoveVehicles();
ride_clear_blocked_tiles(ride);
auto w = window_find_by_number(WC_RIDE, ride->id);
auto w = window_find_by_number(WC_RIDE, EnumValue(ride->id));
if (w != nullptr)
window_event_resize_call(w);
}
+5 -5
View File
@@ -159,10 +159,10 @@ static void ride_ratings_update_state_0(RideRatingUpdateState& state)
{
ride_id_t currentRide = state.CurrentRide;
currentRide++;
if (currentRide >= MAX_RIDES)
currentRide = static_cast<ride_id_t>(EnumValue(currentRide) + 1);
if (currentRide >= static_cast<ride_id_t>(MAX_RIDES))
{
currentRide = 0;
currentRide = {};
}
auto ride = get_ride(currentRide);
@@ -285,7 +285,7 @@ static void ride_ratings_update_state_3(RideRatingUpdateState& state)
ride_ratings_calculate(state, ride);
ride_ratings_calculate_value(ride);
window_invalidate_by_number(WC_RIDE, state.CurrentRide);
window_invalidate_by_number(WC_RIDE, EnumValue(state.CurrentRide));
state.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
}
@@ -753,7 +753,7 @@ static void ride_ratings_calculate(RideRatingUpdateState& state, Ride* ride)
// Create event args object
auto obj = DukObject(ctx);
obj.Set("rideId", ride->id);
obj.Set("rideId", EnumValue(ride->id));
obj.Set("excitement", originalExcitement);
obj.Set("intensity", originalIntensity);
obj.Set("nausea", originalNausea);
+3 -2
View File
@@ -13,11 +13,12 @@
#include <cstdint>
#include <limits>
#include <type_traits>
using ride_id_t = uint16_t;
enum class ride_id_t : uint16_t;
struct Ride;
constexpr const ride_id_t RIDE_ID_NULL = std::numeric_limits<ride_id_t>::max();
constexpr const ride_id_t RIDE_ID_NULL = static_cast<ride_id_t>(std::numeric_limits<std::underlying_type_t<ride_id_t>>::max());
/**
* Couples a ride type and subtype together.
+5 -3
View File
@@ -57,6 +57,7 @@
#include "RideData.h"
#include "Track.h"
#include "TrackData.h"
#include "TrackDesign.h"
#include "TrackDesignRepository.h"
#include "Vehicle.h"
@@ -319,7 +320,7 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride)
}
}
place_virtual_track(this, PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(0), { 4096, 4096, 0 });
place_virtual_track(this, PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(PreviewRideId), { 4096, 4096, 0 });
// Resave global vars for scenery reasons.
_trackPreviewOrigin = startPos;
@@ -438,7 +439,7 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
// Save global vars as they are still used by scenery????
int32_t startZ = _trackPreviewOrigin.z;
place_virtual_track(this, PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(0), { 4096, 4096, 0 });
place_virtual_track(this, PTD_OPERATION_DRAW_OUTLINES, true, GetOrAllocateRide(PreviewRideId), { 4096, 4096, 0 });
_trackPreviewOrigin = { startLoc.x, startLoc.y, startZ };
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
@@ -1931,7 +1932,8 @@ static bool track_design_place_preview(TrackDesign* td6, money32* cost, Ride** o
int32_t mapSize = gMapSize << 4;
_currentTrackPieceDirection = 0;
int32_t z = place_virtual_track(td6, PTD_OPERATION_GET_PLACE_Z, true, GetOrAllocateRide(0), { mapSize, mapSize, 16 });
int32_t z = place_virtual_track(
td6, PTD_OPERATION_GET_PLACE_Z, true, GetOrAllocateRide(PreviewRideId), { mapSize, mapSize, 16 });
if (_trackDesignPlaceStateHasScenery)
{
+2
View File
@@ -191,6 +191,8 @@ enum
MAZE_ELEMENT_TYPE_EXIT = (1 << 7)
};
static constexpr ride_id_t PreviewRideId = static_cast<ride_id_t>(0);
extern bool gTrackDesignSceneryToggle;
extern bool _trackDesignDrawingPreview;
+6 -5
View File
@@ -1600,7 +1600,7 @@ void Vehicle::UpdateMeasurements()
curRide->lifecycle_flags |= RIDE_LIFECYCLE_NO_RAW_STATS;
curRide->lifecycle_flags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS;
ClearUpdateFlag(VEHICLE_UPDATE_FLAG_TESTING);
window_invalidate_by_number(WC_RIDE, ride);
window_invalidate_by_number(WC_RIDE, EnumValue(ride));
return;
}
@@ -3114,7 +3114,7 @@ static void test_finish(Ride& ride)
totalTime = std::max(totalTime, 1u);
ride.average_speed = ride.average_speed / totalTime;
window_invalidate_by_number(WC_RIDE, ride.id);
window_invalidate_by_number(WC_RIDE, EnumValue(ride.id));
}
void Vehicle::UpdateTestFinish()
@@ -3164,7 +3164,7 @@ static void test_reset(Ride& ride, StationIndex curStation)
}
ride.total_air_time = 0;
ride.current_test_station = curStation;
window_invalidate_by_number(WC_RIDE, ride.id);
window_invalidate_by_number(WC_RIDE, EnumValue(ride.id));
}
void Vehicle::TestReset()
@@ -3570,7 +3570,7 @@ void Vehicle::CheckIfMissing()
curRide->FormatNameTo(ft);
ft.Add<rct_string_id>(GetRideComponentName(GetRideTypeDescriptor(curRide->type).NameConvention.station).singular);
News::AddItemToQueue(News::ItemType::Ride, STR_NEWS_VEHICLE_HAS_STALLED, ride, ft);
News::AddItemToQueue(News::ItemType::Ride, STR_NEWS_VEHICLE_HAS_STALLED, EnumValue(ride), ft);
}
}
@@ -5305,7 +5305,8 @@ static void ride_train_crash(Ride* ride, uint16_t numFatalities)
{
ride->FormatNameTo(ft);
News::AddItemToQueue(
News::ItemType::Ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, ride->id, ft);
News::ItemType::Ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, EnumValue(ride->id),
ft);
}
if (gParkRatingCasualtyPenalty < 500)
+1 -1
View File
@@ -893,7 +893,7 @@ DukValue ScriptEngine::GameActionResultToDuk(const GameAction& action, const std
auto& rideCreateResult = static_cast<RideCreateGameActionResult&>(*result.get());
if (rideCreateResult.rideIndex != RIDE_ID_NULL)
{
obj.Set("ride", rideCreateResult.rideIndex);
obj.Set("ride", EnumValue(rideCreateResult.rideIndex));
}
}
else if (action.GetType() == GameCommand::HireNewStaffMember)
+1 -1
View File
@@ -46,7 +46,7 @@ namespace OpenRCT2
namespace OpenRCT2::Scripting
{
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 36;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 37;
// Versions marking breaking changes.
static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33;
@@ -135,18 +135,18 @@ namespace OpenRCT2::Scripting
}
}
ride_id_t ScVehicle::ride_get() const
int32_t ScVehicle::ride_get() const
{
auto vehicle = GetVehicle();
return vehicle != nullptr ? vehicle->ride : 0;
return EnumValue(vehicle != nullptr ? vehicle->ride : RIDE_ID_NULL);
}
void ScVehicle::ride_set(ride_id_t value)
void ScVehicle::ride_set(int32_t value)
{
ThrowIfGameStateNotMutable();
auto vehicle = GetVehicle();
if (vehicle != nullptr)
{
vehicle->ride = value;
vehicle->ride = static_cast<ride_id_t>(value);
}
}
@@ -35,8 +35,8 @@ namespace OpenRCT2::Scripting
uint8_t spriteType_get() const;
void spriteType_set(uint8_t value);
ride_id_t ride_get() const;
void ride_set(ride_id_t value);
int32_t ride_get() const;
void ride_set(int32_t value);
uint8_t numSeats_get() const;
void numSeats_set(uint8_t value);
@@ -27,7 +27,7 @@ namespace OpenRCT2::Scripting
int32_t ScRide::id_get() const
{
return _rideId;
return EnumValue(_rideId);
}
std::shared_ptr<ScRideObject> ScRide::object_get()
@@ -431,7 +431,7 @@ namespace OpenRCT2::Scripting
{
auto el = _element->AsPath();
if (el->IsQueue() && el->GetRideIndex() != RIDE_ID_NULL)
duk_push_int(ctx, el->GetRideIndex());
duk_push_int(ctx, EnumValue(el->GetRideIndex()));
else
duk_push_null(ctx);
break;
@@ -439,13 +439,13 @@ namespace OpenRCT2::Scripting
case TILE_ELEMENT_TYPE_TRACK:
{
auto el = _element->AsTrack();
duk_push_int(ctx, el->GetRideIndex());
duk_push_int(ctx, EnumValue(el->GetRideIndex()));
break;
}
case TILE_ELEMENT_TYPE_ENTRANCE:
{
auto el = _element->AsEntrance();
duk_push_int(ctx, el->GetRideIndex());
duk_push_int(ctx, EnumValue(el->GetRideIndex()));
break;
}
default:
@@ -456,7 +456,7 @@ namespace OpenRCT2::Scripting
}
return DukValue::take_from_stack(ctx);
}
void ScTileElement::ride_set(ride_id_t value)
void ScTileElement::ride_set(int32_t value)
{
ThrowIfGameStateNotMutable();
switch (_element->GetType())
@@ -466,7 +466,7 @@ namespace OpenRCT2::Scripting
auto el = _element->AsPath();
if (!el->HasAddition())
{
el->SetRideIndex(value);
el->SetRideIndex(static_cast<ride_id_t>(value));
Invalidate();
}
break;
@@ -474,14 +474,14 @@ namespace OpenRCT2::Scripting
case TILE_ELEMENT_TYPE_TRACK:
{
auto el = _element->AsTrack();
el->SetRideIndex(value);
el->SetRideIndex(static_cast<ride_id_t>(value));
Invalidate();
break;
}
case TILE_ELEMENT_TYPE_ENTRANCE:
{
auto el = _element->AsEntrance();
el->SetRideIndex(value);
el->SetRideIndex(static_cast<ride_id_t>(value));
Invalidate();
break;
}
@@ -85,7 +85,7 @@ namespace OpenRCT2::Scripting
void sequence_set(uint8_t value);
DukValue ride_get() const;
void ride_set(ride_id_t value);
void ride_set(int32_t value);
DukValue station_get() const;
void station_set(uint8_t value);
+1 -1
View File
@@ -64,7 +64,7 @@ protected:
return nullptr;
}
static bool FindPath(TileCoordsXYZ* pos, const TileCoordsXYZ& goal, int expectedSteps, int targetRideID)
static bool FindPath(TileCoordsXYZ* pos, const TileCoordsXYZ& goal, int expectedSteps, ride_id_t targetRideID)
{
// Our start position is in tile coordinates, but we need to give the peep spawn
// position in actual world coords (32 units per tile X/Y, 8 per Z level).