0x0047A8F0
| 1528 | |
| 1529 | // 0x0047A8F0 |
| 1530 | static bool removeRoadModToTrack(const LocationOfInterest& interest, const uint8_t flags, RoutingResults* results, ModSection modSelection, uint8_t roadObjectId, uint8_t roadModObjectIds, currency32_t& totalCost, CompanyId companyId) |
| 1531 | { |
| 1532 | // If not in single segment mode then we should add the reverse |
| 1533 | // direction of track to the results to prevent it being visited. |
| 1534 | // This is because track mods do not have directions so applying |
| 1535 | // to the reverse would do nothing (or worse double spend) |
| 1536 | if (results != nullptr) |
| 1537 | { |
| 1538 | LocationOfInterest reverseInterest = interest; |
| 1539 | reverseInterest.loc = interest.loc; |
| 1540 | const auto rad = interest.rad(); |
| 1541 | auto& roadSize = World::TrackData::getUnkRoad(rad._data); |
| 1542 | reverseInterest.loc += roadSize.pos; |
| 1543 | if (roadSize.rotationEnd < 12) |
| 1544 | { |
| 1545 | reverseInterest.loc -= World::Pos3{ World::kRotationOffset[roadSize.rotationEnd], 0 }; |
| 1546 | } |
| 1547 | reverseInterest.trackAndDirection ^= (1 << 2); // Reverse flag |
| 1548 | |
| 1549 | results->reachableLocs.tryAdd(reverseInterest); |
| 1550 | } |
| 1551 | |
| 1552 | auto* roadObj = ObjectManager::get<RoadObject>(roadObjectId); |
| 1553 | |
| 1554 | auto roadStart = interest.loc; |
| 1555 | const auto rad = interest.rad(); |
| 1556 | if (rad.isReversed()) |
| 1557 | { |
| 1558 | auto& roadSize = World::TrackData::getUnkRoad(rad._data); |
| 1559 | roadStart += roadSize.pos; |
| 1560 | if (roadSize.rotationEnd < 12) |
| 1561 | { |
| 1562 | roadStart -= World::Pos3{ World::kRotationOffset[roadSize.rotationEnd], 0 }; |
| 1563 | } |
| 1564 | } |
| 1565 | |
| 1566 | for (auto& roadPiece : TrackData::getRoadPiece(rad.id())) |
| 1567 | { |
| 1568 | auto roadLoc = roadStart + World::Pos3{ Math::Vector::rotate(World::Pos2{ roadPiece.x, roadPiece.y }, rad.cardinalDirection()), 0 }; |
| 1569 | roadLoc.z += roadPiece.z; |
| 1570 | |
| 1571 | auto tile = TileManager::get(roadLoc); |
| 1572 | World::RoadElement* elRoad = nullptr; |
| 1573 | for (auto& el : tile) |
| 1574 | { |
| 1575 | elRoad = el.as<World::RoadElement>(); |
| 1576 | if (elRoad == nullptr) |
| 1577 | { |
| 1578 | continue; |
| 1579 | } |
| 1580 | if (elRoad->baseHeight() != roadLoc.z) |
| 1581 | { |
| 1582 | continue; |
| 1583 | } |
| 1584 | if (elRoad->rotation() != rad.cardinalDirection()) |
| 1585 | { |
| 1586 | continue; |
| 1587 | } |
no test coverage detected