0x004A5D94
| 1000 | |
| 1001 | // 0x004A5D94 |
| 1002 | static bool applyTrackModToTrack(const LocationOfInterest& interest, const uint8_t flags, RoutingResults* results, ModSection modSelection, uint8_t trackObjectId, uint8_t trackModObjectIds, currency32_t& totalCost, CompanyId companyId, bool& hasFailedAllPlacement) |
| 1003 | { |
| 1004 | // If not in single segment mode then we should add the reverse |
| 1005 | // direction of track to the results to prevent it being visited. |
| 1006 | // This is because track mods do not have directions so applying |
| 1007 | // to the reverse would do nothing (or worse double spend) |
| 1008 | if (results != nullptr) |
| 1009 | { |
| 1010 | LocationOfInterest reverseInterest = interest; |
| 1011 | reverseInterest.loc = interest.loc; |
| 1012 | const auto tad = interest.tad(); |
| 1013 | auto& trackSize = World::TrackData::getUnkTrack(tad._data); |
| 1014 | reverseInterest.loc += trackSize.pos; |
| 1015 | if (trackSize.rotationEnd < 12) |
| 1016 | { |
| 1017 | reverseInterest.loc -= World::Pos3{ World::kRotationOffset[trackSize.rotationEnd], 0 }; |
| 1018 | } |
| 1019 | reverseInterest.trackAndDirection ^= (1 << 2); // Reverse flag |
| 1020 | |
| 1021 | results->reachableLocs.tryAdd(reverseInterest); |
| 1022 | } |
| 1023 | |
| 1024 | auto* trackObj = ObjectManager::get<TrackObject>(trackObjectId); |
| 1025 | bool placementFailure = false; |
| 1026 | |
| 1027 | for (auto i = 0; i < 4; ++i) |
| 1028 | { |
| 1029 | if (!(trackModObjectIds & (1U << i))) |
| 1030 | { |
| 1031 | continue; |
| 1032 | } |
| 1033 | |
| 1034 | auto* trackModObj = ObjectManager::get<TrackExtraObject>(trackObj->mods[i]); |
| 1035 | |
| 1036 | const auto pieceFlags = TrackData::getTrackMiscData(interest.tad().id()).compatibleFlags; |
| 1037 | if ((trackModObj->trackPieces & pieceFlags) != pieceFlags) |
| 1038 | { |
| 1039 | //_1135F64 |= (1 << 0); placement failed at least once |
| 1040 | placementFailure = true; |
| 1041 | break; |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | if (!placementFailure) |
| 1046 | { |
| 1047 | auto trackStart = interest.loc; |
| 1048 | const auto tad = interest.tad(); |
| 1049 | if (tad.isReversed()) |
| 1050 | { |
| 1051 | auto& trackSize = World::TrackData::getUnkTrack(tad._data); |
| 1052 | trackStart += trackSize.pos; |
| 1053 | if (trackSize.rotationEnd < 12) |
| 1054 | { |
| 1055 | trackStart -= World::Pos3{ World::kRotationOffset[trackSize.rotationEnd], 0 }; |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | for (auto& trackPiece : TrackData::getTrackPiece(tad.id())) |
no test coverage detected