| 259 | } |
| 260 | |
| 261 | static TrackDesignAddStatus TrackDesignSaveAddLargeScenery(const CoordsXY& loc, LargeSceneryElement* tileElement) |
| 262 | { |
| 263 | auto entryIndex = tileElement->GetEntryIndex(); |
| 264 | auto& objectMgr = GetContext()->GetObjectManager(); |
| 265 | auto obj = objectMgr.GetLoadedObject<LargeSceneryObject>(entryIndex); |
| 266 | if (obj != nullptr && TrackDesignSaveIsSupportedObject(obj)) |
| 267 | { |
| 268 | auto sceneryEntry = reinterpret_cast<const LargeSceneryEntry*>(obj->GetLegacyData()); |
| 269 | auto& sceneryTiles = sceneryEntry->tiles; |
| 270 | |
| 271 | int32_t z = tileElement->baseHeight; |
| 272 | auto direction = tileElement->getDirection(); |
| 273 | auto sequence = tileElement->GetSequenceIndex(); |
| 274 | |
| 275 | auto sceneryOrigin = MapLargeSceneryGetOrigin({ loc.x, loc.y, z << 3, direction }, sequence, nullptr); |
| 276 | if (!sceneryOrigin.has_value()) |
| 277 | { |
| 278 | return TrackDesignAddStatus::Success(); |
| 279 | } |
| 280 | |
| 281 | // Iterate through each tile of the large scenery element |
| 282 | for (auto& tile : sceneryTiles) |
| 283 | { |
| 284 | CoordsXY offsetPos{ tile.offset }; |
| 285 | auto rotatedOffsetPos = offsetPos.Rotate(direction); |
| 286 | |
| 287 | CoordsXYZ tileLoc = { sceneryOrigin->x + rotatedOffsetPos.x, sceneryOrigin->y + rotatedOffsetPos.y, |
| 288 | sceneryOrigin->z + tile.offset.z }; |
| 289 | auto largeElement = MapGetLargeScenerySegment({ tileLoc, direction }, tile.index); |
| 290 | if (largeElement != nullptr) |
| 291 | { |
| 292 | if (tile.index == 0) |
| 293 | { |
| 294 | auto item = TrackDesignSaveCreateLargeSceneryDesc(*obj, tileLoc, *largeElement); |
| 295 | _trackSavedTileElementsDesc.push_back(std::move(item)); |
| 296 | } |
| 297 | TrackDesignSavePushTileElement(tileLoc, reinterpret_cast<TileElement*>(largeElement)); |
| 298 | } |
| 299 | } |
| 300 | return TrackDesignAddStatus::Success(); |
| 301 | } |
| 302 | |
| 303 | return TrackDesignAddStatus::Fail(STR_UNSUPPORTED_OBJECT_FORMAT); |
| 304 | } |
| 305 | |
| 306 | static TrackDesignSceneryElement TrackDesignSaveCreateWallDesc( |
| 307 | const Object& object, const CoordsXY& loc, const WallElement& wallElement) |
no test coverage detected