1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Fix arbitrary ride type cheat not working

This commit is contained in:
Michael Steenbeek
2021-09-26 16:21:34 +02:00
committed by GitHub
parent 9dd9b27db4
commit f7d61c67e6
3 changed files with 32 additions and 0 deletions

View File

@@ -223,6 +223,7 @@ GameActions::Result::Ptr RideSetSettingAction::Execute() const
break;
case RideSetSetting::RideType:
ride->type = _value;
ride->UpdateRideTypeForAllPieces();
gfx_invalidate_screen();
break;
}

View File

@@ -5734,3 +5734,29 @@ void Ride::IncreaseNumShelteredSections()
num_sheltered_sections &= ~ShelteredSectionsBits::NumShelteredSectionsMask;
num_sheltered_sections |= newNumShelteredSections;
}
void Ride::UpdateRideTypeForAllPieces()
{
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
{
auto* tileElement = map_get_first_element_at(TileCoordsXY(x, y));
if (tileElement == nullptr)
continue;
do
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue;
auto* trackElement = tileElement->AsTrack();
if (trackElement->GetRideIndex() != id)
continue;
trackElement->SetRideType(type);
} while (!(tileElement++)->IsLastForTile());
}
}
}

View File

@@ -468,6 +468,11 @@ public:
void IncreaseNumShelteredSections();
void RemoveVehicles();
/**
* Updates all pieces of the ride to match the internal ride type. (Track pieces can have different ride types from the ride
* they belong to, to enable “merging”.)
*/
void UpdateRideTypeForAllPieces();
};
#pragma pack(push, 1)