* Clears the provided element properly from a certain tile, and updates * the pointer (when needed) passed to this function to point to the next element. */
| 1388 | * the pointer (when needed) passed to this function to point to the next element. |
| 1389 | */ |
| 1390 | void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr) |
| 1391 | { |
| 1392 | auto& gameState = getGameState(); |
| 1393 | |
| 1394 | TileElement* element = *elementPtr; |
| 1395 | switch (element->getType()) |
| 1396 | { |
| 1397 | case TileElementType::Surface: |
| 1398 | element->baseHeight = kMinimumLandHeight; |
| 1399 | element->clearanceHeight = kMinimumLandHeight; |
| 1400 | element->owner = 0; |
| 1401 | element->asSurface()->SetSlope(kTileSlopeFlat); |
| 1402 | element->asSurface()->SetSurfaceObjectIndex(0); |
| 1403 | element->asSurface()->SetEdgeObjectIndex(0); |
| 1404 | element->asSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); |
| 1405 | element->asSurface()->SetOwnership(OWNERSHIP_UNOWNED); |
| 1406 | element->asSurface()->SetParkFences(0); |
| 1407 | element->asSurface()->SetWaterHeight(0); |
| 1408 | // Because this element is not completely removed, the pointer must be updated manually |
| 1409 | // The rest of the elements are removed from the array, so the pointer doesn't need to be updated. |
| 1410 | (*elementPtr)++; |
| 1411 | break; |
| 1412 | case TileElementType::Entrance: |
| 1413 | { |
| 1414 | int32_t rotation = element->getDirectionWithOffset(1); |
| 1415 | auto seqLoc = loc; |
| 1416 | switch (element->asEntrance()->GetSequenceIndex()) |
| 1417 | { |
| 1418 | case 1: |
| 1419 | seqLoc += CoordsDirectionDelta[rotation]; |
| 1420 | break; |
| 1421 | case 2: |
| 1422 | seqLoc -= CoordsDirectionDelta[rotation]; |
| 1423 | break; |
| 1424 | } |
| 1425 | auto parkEntranceRemoveAction = GameActions::ParkEntranceRemoveAction(CoordsXYZ{ seqLoc, element->getBaseZ() }); |
| 1426 | auto result = GameActions::ExecuteNested(&parkEntranceRemoveAction, gameState); |
| 1427 | // If asking nicely did not work, forcibly remove this to avoid an infinite loop. |
| 1428 | if (result.error != GameActions::Status::ok) |
| 1429 | { |
| 1430 | TileElementRemove(element); |
| 1431 | } |
| 1432 | break; |
| 1433 | } |
| 1434 | case TileElementType::Wall: |
| 1435 | { |
| 1436 | CoordsXYZD wallLocation = { loc.x, loc.y, element->getBaseZ(), element->getDirection() }; |
| 1437 | auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation); |
| 1438 | auto result = GameActions::ExecuteNested(&wallRemoveAction, gameState); |
| 1439 | // If asking nicely did not work, forcibly remove this to avoid an infinite loop. |
| 1440 | if (result.error != GameActions::Status::ok) |
| 1441 | { |
| 1442 | TileElementRemove(element); |
| 1443 | } |
| 1444 | } |
| 1445 | break; |
| 1446 | case TileElementType::LargeScenery: |
| 1447 | { |
no test coverage detected