MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / FootpathReconnectQueueToPath

Function FootpathReconnectQueueToPath

src/openrct2/world/Footpath.cpp:402–443  ·  view source on GitHub ↗

* Attempt to connect a newly disconnected queue tile to the specified path tile */

Source from the content-addressed store, hash-verified

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 {

Callers 1

Calls 11

WallInTheWayFunction · 0.85
DirectionReverseFunction · 0.85
FootpathGetElementFunction · 0.85
MapInvalidateTileFullFunction · 0.85
getClearanceZMethod · 0.80
SetSlopeDirectionMethod · 0.80
SetEdgesMethod · 0.80
GetEdgesMethod · 0.45
asPathMethod · 0.45
getBaseZMethod · 0.45
IsQueueMethod · 0.45

Tested by

no test coverage detected