Merge remote-tracking branch 'upstream/develop' into new-save-format

This commit is contained in:
Gymnasiast 2021-09-26 19:56:04 +02:00
commit 8f97730a5e
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
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

@ -5740,6 +5740,32 @@ void Ride::IncreaseNumShelteredSections()
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());
}
}
}
std::vector<ride_id_t> GetTracklessRides()
{
// Iterate map and build list of seen ride IDs

View File

@ -469,6 +469,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)