diff --git a/src/openrct2/ParkFile.cpp b/src/openrct2/ParkFile.cpp index 3ee06b62a6..dca76d817c 100644 --- a/src/openrct2/ParkFile.cpp +++ b/src/openrct2/ParkFile.cpp @@ -13,6 +13,7 @@ #include "object/ObjectManager.h" #include "object/ObjectRepository.h" #include "scenario/Scenario.h" +#include "world/Entrance.h" #include "world/Map.h" #include "world/Park.h" @@ -297,6 +298,7 @@ void ParkFile::Load(const std::string_view& path) void ParkFile::Import() { ReadTilesChunk(); + ReadGeneralChunk(); } ParkFile::Header ParkFile::ReadHeader(std::istream& fs) @@ -358,6 +360,39 @@ std::string ParkFile::ReadString() return buffer; } +void ParkFile::ReadGeneralChunk() +{ + if (SeekChunk(ParkFileChunkType::GENERAL)) + { + gScenarioTicks = ReadValue(); + gDateMonthTicks = ReadValue(); + gDateMonthsElapsed = ReadValue(); + gScenarioSrand0 = ReadValue(); + gScenarioSrand1 = ReadValue(); + gInitialCash = ReadValue(); + gGuestInitialCash = ReadValue(); + gGuestInitialHunger = ReadValue(); + gGuestInitialThirst = ReadValue(); + + size_t numPeepSpawns = ReadArray(); + for (size_t i = 0; i < numPeepSpawns; i++) + { + gPeepSpawns[i].x = ReadValue(); + gPeepSpawns[i].y = ReadValue(); + gPeepSpawns[i].z = ReadValue(); + gPeepSpawns[i].direction = ReadValue(); + ReadNextArrayElement(); + } + + gLandPrice = ReadValue(); + gConstructionRightsPrice = ReadValue(); + } + else + { + throw std::runtime_error("No general chunk found."); + } +} + void ParkFile::ReadTilesChunk() { if (SeekChunk(ParkFileChunkType::TILES)) @@ -371,6 +406,7 @@ void ParkFile::ReadTilesChunk() ReadBuffer(gTileElements, numElements * sizeof(TileElement)); map_update_tile_pointers(); + UpdateParkEntranceLocations(); } else { diff --git a/src/openrct2/ParkFile.h b/src/openrct2/ParkFile.h index 1cf8bfa91b..4a72acb413 100644 --- a/src/openrct2/ParkFile.h +++ b/src/openrct2/ParkFile.h @@ -70,6 +70,7 @@ namespace OpenRCT2 void WriteGeneralChunk(); void WriteTilesChunk(); + void ReadGeneralChunk(); void ReadTilesChunk(); Header ReadHeader(std::istream& fs); diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index b5fbc0b81f..23e69feaa5 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -214,6 +214,33 @@ void fix_park_entrance_locations(void) gParkEntrances.end()); } +void UpdateParkEntranceLocations() +{ + reset_park_entrance(); + + size_t entranceIndex = 0; + tile_element_iterator it; + tile_element_iterator_begin(&it); + while (tile_element_iterator_next(&it)) + { + auto entranceElement = it.element->AsEntrance(); + if (entranceElement != nullptr && entranceElement->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE + && entranceElement->GetSequenceIndex() == 0 && !entranceElement->IsGhost()) + { + auto& entrance = gParkEntrances[entranceIndex]; + entrance.x = it.x * 32; + entrance.y = it.y * 32; + entrance.z = it.element->base_height * 8; + entrance.direction = it.element->GetDirection(); + entranceIndex++; + if (entranceIndex >= MAX_PARK_ENTRANCES) + { + break; + } + } + } +} + uint8_t EntranceElement::GetStationIndex() const { return StationIndex; diff --git a/src/openrct2/world/Entrance.h b/src/openrct2/world/Entrance.h index f8dbfbcd63..585871dd1c 100644 --- a/src/openrct2/world/Entrance.h +++ b/src/openrct2/world/Entrance.h @@ -56,5 +56,6 @@ void maze_entrance_hedge_replacement(const CoordsXYE& entrance); void maze_entrance_hedge_removal(const CoordsXYE& entrance); void fix_park_entrance_locations(); +void UpdateParkEntranceLocations(); #endif