Fix track element ride type on import

Not yet tested because of other import errors.
This commit is contained in:
Gymnasiast 2021-09-25 22:54:02 +02:00
parent 5d2a367249
commit a9ba0fce9d
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
1 changed files with 31 additions and 1 deletions

View File

@ -72,7 +72,7 @@ static void UpdateFootpathsFromMapping(
namespace OpenRCT2
{
// Current version that is saved.
constexpr uint32_t PARK_FILE_CURRENT_VERSION = 0x3;
constexpr uint32_t PARK_FILE_CURRENT_VERSION = 0x4;
// The minimum version that is forwards compatible with the current version.
constexpr uint32_t PARK_FILE_MIN_VERSION = 0x2;
@ -147,6 +147,10 @@ namespace OpenRCT2
ReadWriteInterfaceChunk(os);
ReadWriteCheatsChunk(os);
ReadWriteRestrictedObjectsChunk(os);
if (os.GetHeader().TargetVersion < 0x4)
{
UpdateTrackElementsRideType();
}
// Initial cash will eventually be removed
gInitialCash = gCash;
@ -921,6 +925,32 @@ namespace OpenRCT2
}
}
void UpdateTrackElementsRideType()
{
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
{
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
{
TileElement* 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();
const auto* ride = get_ride(trackElement->GetRideIndex());
if (ride != nullptr)
{
trackElement->SetRideType(ride->type);
}
} while (!(tileElement++)->IsLastForTile());
}
}
}
void ReadWriteBannersChunk(OrcaStream& os)
{
os.ReadWriteChunk(ParkFileChunkType::BANNERS, [&os](OrcaStream::ChunkStream& cs) {