| 517 | // Iterates all individual tiles of a track piece to find tracks that need inspection |
| 518 | template<typename FilterFunction> |
| 519 | static void findAllUsableTrackPieces(LocationOfInterestQueue& additionalTrackToCheck, const TrackNetworkSearchFlags searchFlags, const LocationOfInterest& interest, FilterFunction&& filterFunction, RoutingResults& results) |
| 520 | { |
| 521 | if ((searchFlags & TrackNetworkSearchFlags::unk2) == TrackNetworkSearchFlags::none) |
| 522 | { |
| 523 | return; |
| 524 | } |
| 525 | |
| 526 | const auto tad = interest.tad(); |
| 527 | auto nextLoc = interest.loc; |
| 528 | if (tad.isReversed()) |
| 529 | { |
| 530 | auto& trackSize = World::TrackData::getUnkTrack(tad._data); |
| 531 | nextLoc += trackSize.pos; |
| 532 | if (trackSize.rotationEnd < 12) |
| 533 | { |
| 534 | nextLoc -= World::Pos3{ World::kRotationOffset[trackSize.rotationEnd], 0 }; |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | for (auto& piece : World::TrackData::getTrackPiece(tad.id())) |
| 539 | { |
| 540 | const auto connectFlags = piece.connectFlags[tad.cardinalDirection()]; |
| 541 | const auto pieceLoc = nextLoc + World::Pos3{ Math::Vector::rotate(World::Pos2{ piece.x, piece.y }, tad.cardinalDirection()), piece.z }; |
| 542 | auto tile = World::TileManager::get(pieceLoc); |
| 543 | for (auto& el : tile) |
| 544 | { |
| 545 | if (el.baseZ() != pieceLoc.z / 4) |
| 546 | { |
| 547 | continue; |
| 548 | } |
| 549 | |
| 550 | auto* elTrack = el.as<TrackElement>(); |
| 551 | if (elTrack == nullptr) |
| 552 | { |
| 553 | continue; |
| 554 | } |
| 555 | |
| 556 | if (elTrack->isAiAllocated() || elTrack->isGhost()) |
| 557 | { |
| 558 | continue; |
| 559 | } |
| 560 | |
| 561 | const auto& targetPiece = World::TrackData::getTrackPiece(elTrack->trackId())[elTrack->sequenceIndex()]; |
| 562 | const auto targetConnectFlags = targetPiece.connectFlags[elTrack->rotation()]; |
| 563 | if ((targetConnectFlags & connectFlags) == 0) |
| 564 | { |
| 565 | continue; |
| 566 | } |
| 567 | |
| 568 | // If identical then no need to keep checking |
| 569 | if (elTrack->rotation() == tad.cardinalDirection() |
| 570 | && elTrack->sequenceIndex() == piece.index |
| 571 | && elTrack->trackObjectId() == interest.trackType |
| 572 | && elTrack->trackId() == tad.id()) |
| 573 | { |
| 574 | continue; |
| 575 | } |
| 576 |
no test coverage detected