mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #474: Mini Golf window allows selecting nonexistent players
This commit is contained in:
parent
06dd935d36
commit
eb5fe27495
|
@ -14,6 +14,7 @@
|
|||
- Improved: [#19044] Added special thanks to RMC and Wiegand to the About page.
|
||||
- Change: [#19018] Renamed actions to fit the naming scheme.
|
||||
- Change: [#19091] [Plugin] Add game action information to callback arguments of custom actions.
|
||||
- Fix: [#474] Mini golf window shows more players than there actually are (original bug).
|
||||
- Fix: [#18467] “Selected only” Object Selection filter is active in Track Designs Manager, and cannot be toggled.
|
||||
- Fix: [#18905] Ride Construction window theme is not applied correctly.
|
||||
- Fix: [#18911] Mini Golf station does not draw correctly from all angles.
|
||||
|
|
|
@ -1724,6 +1724,33 @@ static void WindowRideMainResize(rct_window* w)
|
|||
WindowRideInitViewport(w);
|
||||
}
|
||||
|
||||
static size_t GetNumPeepsInTrain(const Ride& ride, int32_t trainIndex)
|
||||
{
|
||||
auto numPeepsInTrain = 0;
|
||||
const auto* vehicle = TryGetVehicle(ride.vehicles[trainIndex]);
|
||||
while (vehicle != nullptr)
|
||||
{
|
||||
numPeepsInTrain += vehicle->num_peeps;
|
||||
vehicle = TryGetVehicle(vehicle->next_vehicle_on_train);
|
||||
}
|
||||
return numPeepsInTrain;
|
||||
}
|
||||
|
||||
static bool TrainMustBeHidden(const Ride& ride, int32_t trainIndex)
|
||||
{
|
||||
if (!(ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
return true;
|
||||
|
||||
const auto* rideEntry = ride.GetRideEntry();
|
||||
if (rideEntry == nullptr)
|
||||
return false;
|
||||
|
||||
if (!(rideEntry->flags & RIDE_ENTRY_FLAG_HIDE_EMPTY_TRAINS))
|
||||
return false;
|
||||
|
||||
return GetNumPeepsInTrain(ride, trainIndex) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006AF825
|
||||
|
@ -1735,8 +1762,10 @@ static void WindowRideShowViewDropdown(rct_window* w, Widget* widget)
|
|||
if (ride == nullptr)
|
||||
return;
|
||||
|
||||
const auto& rtd = ride->GetRideTypeDescriptor();
|
||||
|
||||
int32_t numItems = 1;
|
||||
if (!ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_NO_VEHICLES))
|
||||
if (!rtd.HasFlag(RIDE_TYPE_FLAG_NO_VEHICLES))
|
||||
{
|
||||
numItems += ride->num_stations;
|
||||
numItems += ride->NumTrains;
|
||||
|
@ -1751,14 +1780,16 @@ static void WindowRideShowViewDropdown(rct_window* w, Widget* widget)
|
|||
gDropdownItems[0].Args = STR_OVERALL_VIEW;
|
||||
int32_t currentItem = 1;
|
||||
|
||||
const auto& rtd = ride->GetRideTypeDescriptor();
|
||||
|
||||
// Vehicles
|
||||
int32_t name = GetRideComponentName(rtd.NameConvention.vehicle).number;
|
||||
for (int32_t i = 1; i <= ride->NumTrains; i++)
|
||||
for (int32_t i = 0; i < ride->NumTrains; i++)
|
||||
{
|
||||
gDropdownItems[currentItem].Format = STR_DROPDOWN_MENU_LABEL;
|
||||
gDropdownItems[currentItem].Args = name | (currentItem << 16);
|
||||
if (TrainMustBeHidden(*ride, i))
|
||||
{
|
||||
Dropdown::SetDisabled(currentItem, true);
|
||||
}
|
||||
currentItem++;
|
||||
}
|
||||
|
||||
|
@ -1771,16 +1802,6 @@ static void WindowRideShowViewDropdown(rct_window* w, Widget* widget)
|
|||
currentItem++;
|
||||
}
|
||||
|
||||
// Set highlighted item
|
||||
if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
{
|
||||
for (int32_t i = 0; i < ride->NumTrains; i++)
|
||||
{
|
||||
// The +1 is to skip 'Overall view'
|
||||
Dropdown::SetDisabled(i + 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set checked item
|
||||
Dropdown::SetChecked(w->ride.view, true);
|
||||
}
|
||||
|
|
|
@ -561,6 +561,7 @@ void RideObject::ReadJson(IReadObjectContext* context, json_t& root)
|
|||
{ "noCollisionCrashes", RIDE_ENTRY_FLAG_DISABLE_COLLISION_CRASHES },
|
||||
{ "disablePainting", RIDE_ENTRY_FLAG_DISABLE_COLOUR_TAB },
|
||||
{ "riderControlsSpeed", RIDE_ENTRY_FLAG_RIDER_CONTROLS_SPEED },
|
||||
{ "hideEmptyTrains", RIDE_ENTRY_FLAG_HIDE_EMPTY_TRAINS },
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -492,6 +492,7 @@ enum
|
|||
// Must be set with swing mode 1 as well.
|
||||
RIDE_ENTRY_FLAG_ALTERNATIVE_SWING_MODE_2 = 1 << 20,
|
||||
RIDE_ENTRY_FLAG_RIDER_CONTROLS_SPEED = 1 << 21,
|
||||
RIDE_ENTRY_FLAG_HIDE_EMPTY_TRAINS = 1 << 22,
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
Loading…
Reference in New Issue