* Attempt to connect a newly disconnected queue tile to the specified path tile */
| 400 | * Attempt to connect a newly disconnected queue tile to the specified path tile |
| 401 | */ |
| 402 | static bool FootpathReconnectQueueToPath( |
| 403 | const CoordsXY& footpathPos, TileElement* tileElement, int32_t action, int32_t direction) |
| 404 | { |
| 405 | if (((tileElement->asPath()->GetEdges() & (1 << direction)) == 0) ^ (action < 0)) |
| 406 | return false; |
| 407 | |
| 408 | auto targetQueuePos = footpathPos + CoordsDirectionDelta[direction]; |
| 409 | |
| 410 | if (action < 0) |
| 411 | { |
| 412 | if (WallInTheWay({ footpathPos, tileElement->getBaseZ(), tileElement->getClearanceZ() }, direction)) |
| 413 | return false; |
| 414 | |
| 415 | if (WallInTheWay( |
| 416 | { targetQueuePos, tileElement->getBaseZ(), tileElement->getClearanceZ() }, DirectionReverse(direction))) |
| 417 | return false; |
| 418 | } |
| 419 | |
| 420 | int32_t z = tileElement->getBaseZ(); |
| 421 | TileElement* targetFootpathElement = FootpathGetElement({ targetQueuePos, z - kLandHeightStep, z }, direction); |
| 422 | if (targetFootpathElement != nullptr && !targetFootpathElement->asPath()->IsQueue()) |
| 423 | { |
| 424 | auto targetQueueElement = targetFootpathElement->asPath(); |
| 425 | tileElement->asPath()->SetSlopeDirection(0); |
| 426 | if (action > 0) |
| 427 | { |
| 428 | tileElement->asPath()->SetEdges(tileElement->asPath()->GetEdges() & ~(1 << direction)); |
| 429 | targetQueueElement->SetEdges(targetQueueElement->GetEdges() & ~(1 << (DirectionReverse(direction) & 3))); |
| 430 | if (action >= 2) |
| 431 | tileElement->asPath()->SetSlopeDirection(direction); |
| 432 | } |
| 433 | else if (action < 0) |
| 434 | { |
| 435 | tileElement->asPath()->SetEdges(tileElement->asPath()->GetEdges() | (1 << direction)); |
| 436 | targetQueueElement->SetEdges(targetQueueElement->GetEdges() | (1 << (DirectionReverse(direction) & 3))); |
| 437 | } |
| 438 | if (action != 0) |
| 439 | MapInvalidateTileFull(targetQueuePos); |
| 440 | return true; |
| 441 | } |
| 442 | return false; |
| 443 | } |
| 444 | |
| 445 | static bool FootpathDisconnectQueueFromPath(const CoordsXY& footpathPos, TileElement* tileElement, int32_t action) |
| 446 | { |
no test coverage detected