0x004A6136
| 1162 | |
| 1163 | // 0x004A6136 |
| 1164 | static bool removeTrackModToTrack(const LocationOfInterest& interest, const uint8_t flags, RoutingResults* results, ModSection modSelection, uint8_t trackObjectId, uint8_t trackModObjectIds, currency32_t& totalCost, CompanyId companyId) |
| 1165 | { |
| 1166 | // If not in single segment mode then we should add the reverse |
| 1167 | // direction of track to the results to prevent it being visited. |
| 1168 | // This is because track mods do not have directions so applying |
| 1169 | // to the reverse would do nothing (or worse double spend) |
| 1170 | if (results != nullptr) |
| 1171 | { |
| 1172 | LocationOfInterest reverseInterest = interest; |
| 1173 | reverseInterest.loc = interest.loc; |
| 1174 | const auto tad = interest.tad(); |
| 1175 | auto& trackSize = World::TrackData::getUnkTrack(tad._data); |
| 1176 | reverseInterest.loc += trackSize.pos; |
| 1177 | if (trackSize.rotationEnd < 12) |
| 1178 | { |
| 1179 | reverseInterest.loc -= World::Pos3{ World::kRotationOffset[trackSize.rotationEnd], 0 }; |
| 1180 | } |
| 1181 | reverseInterest.trackAndDirection ^= (1 << 2); // Reverse flag |
| 1182 | |
| 1183 | results->reachableLocs.tryAdd(reverseInterest); |
| 1184 | } |
| 1185 | |
| 1186 | auto* trackObj = ObjectManager::get<TrackObject>(trackObjectId); |
| 1187 | |
| 1188 | auto trackStart = interest.loc; |
| 1189 | const auto tad = interest.tad(); |
| 1190 | if (tad.isReversed()) |
| 1191 | { |
| 1192 | auto& trackSize = World::TrackData::getUnkTrack(tad._data); |
| 1193 | trackStart += trackSize.pos; |
| 1194 | if (trackSize.rotationEnd < 12) |
| 1195 | { |
| 1196 | trackStart -= World::Pos3{ World::kRotationOffset[trackSize.rotationEnd], 0 }; |
| 1197 | } |
| 1198 | } |
| 1199 | |
| 1200 | for (auto& trackPiece : TrackData::getTrackPiece(tad.id())) |
| 1201 | { |
| 1202 | auto trackLoc = trackStart + World::Pos3{ Math::Vector::rotate(World::Pos2{ trackPiece.x, trackPiece.y }, tad.cardinalDirection()), 0 }; |
| 1203 | trackLoc.z += trackPiece.z; |
| 1204 | |
| 1205 | auto tile = TileManager::get(trackLoc); |
| 1206 | World::TrackElement* elTrack = nullptr; |
| 1207 | for (auto& el : tile) |
| 1208 | { |
| 1209 | elTrack = el.as<World::TrackElement>(); |
| 1210 | if (elTrack == nullptr) |
| 1211 | { |
| 1212 | continue; |
| 1213 | } |
| 1214 | if (elTrack->baseHeight() != trackLoc.z) |
| 1215 | { |
| 1216 | continue; |
| 1217 | } |
| 1218 | if (elTrack->rotation() != tad.cardinalDirection()) |
| 1219 | { |
| 1220 | continue; |
| 1221 | } |
no test coverage detected