| 1184 | } |
| 1185 | |
| 1186 | void ReadWriteTilesChunk(GameState_t& gameState, OrcaStream& os) |
| 1187 | { |
| 1188 | auto* pathToSurfaceMap = _pathToSurfaceMap; |
| 1189 | auto* pathToQueueSurfaceMap = _pathToQueueSurfaceMap; |
| 1190 | auto* pathToRailingsMap = _pathToRailingsMap; |
| 1191 | |
| 1192 | auto found = os.readWriteChunk( |
| 1193 | ParkFileChunkType::titles, |
| 1194 | [pathToSurfaceMap, pathToQueueSurfaceMap, pathToRailingsMap, &os, &gameState](OrcaStream::ChunkStream& cs) { |
| 1195 | cs.readWrite(gameState.mapSize.x); |
| 1196 | cs.readWrite(gameState.mapSize.y); |
| 1197 | |
| 1198 | if (cs.getMode() == OrcaStream::Mode::writing) |
| 1199 | { |
| 1200 | auto tileElements = GetReorganisedTileElementsWithoutGhosts(); |
| 1201 | cs.write(static_cast<uint32_t>(tileElements.size())); |
| 1202 | cs.write(tileElements.data(), tileElements.size() * sizeof(TileElement)); |
| 1203 | return; |
| 1204 | } |
| 1205 | |
| 1206 | gameStateInitAll(gameState, gameState.mapSize); |
| 1207 | |
| 1208 | auto numElements = cs.read<uint32_t>(); |
| 1209 | std::vector<TileElement> tileElements; |
| 1210 | tileElements.resize(numElements); |
| 1211 | cs.read(tileElements.data(), tileElements.size() * sizeof(TileElement)); |
| 1212 | SetTileElements(gameState, std::move(tileElements)); |
| 1213 | |
| 1214 | TileElementIterator it; |
| 1215 | TileElementIteratorBegin(&it); |
| 1216 | while (TileElementIteratorNext(&it)) |
| 1217 | { |
| 1218 | if (it.element->getType() == TileElementType::Path) |
| 1219 | { |
| 1220 | auto* pathElement = it.element->asPath(); |
| 1221 | if (pathElement->HasLegacyPathEntry()) |
| 1222 | { |
| 1223 | auto pathEntryIndex = pathElement->GetLegacyPathEntryIndex(); |
| 1224 | if (pathToRailingsMap[pathEntryIndex] != kObjectEntryIndexNull) |
| 1225 | { |
| 1226 | if (pathElement->IsQueue()) |
| 1227 | pathElement->SetSurfaceEntryIndex(pathToQueueSurfaceMap[pathEntryIndex]); |
| 1228 | else |
| 1229 | pathElement->SetSurfaceEntryIndex(pathToSurfaceMap[pathEntryIndex]); |
| 1230 | |
| 1231 | pathElement->SetRailingsEntryIndex(pathToRailingsMap[pathEntryIndex]); |
| 1232 | } |
| 1233 | } |
| 1234 | } |
| 1235 | else if (it.element->getType() == TileElementType::Track) |
| 1236 | { |
| 1237 | auto* trackElement = it.element->asTrack(); |
| 1238 | auto trackType = trackElement->GetTrackType(); |
| 1239 | if (TrackTypeMustBeMadeInvisible(*trackElement, os.getHeader().targetVersion)) |
| 1240 | { |
| 1241 | it.element->setInvisible(true); |
| 1242 | } |
| 1243 | if (os.getHeader().targetVersion < kBlockBrakeImprovementsVersion) |
nothing calls this directly
no test coverage detected