0x004A2638, 0x004A2601
| 284 | |
| 285 | // 0x004A2638, 0x004A2601 |
| 286 | TrackConnections getTrackConnections(const World::Pos3& nextTrackPos, const uint8_t nextRotation, const CompanyId company, const uint8_t trackObjectId, const uint8_t requiredMods, const uint8_t queryMods) |
| 287 | { |
| 288 | TrackConnections result{}; |
| 289 | |
| 290 | uint8_t baseZ = nextTrackPos.z / 4; |
| 291 | |
| 292 | const auto tile = World::TileManager::get(nextTrackPos); |
| 293 | for (const auto& el : tile) |
| 294 | { |
| 295 | auto* elTrack = el.as<TrackElement>(); |
| 296 | if (elTrack == nullptr) |
| 297 | { |
| 298 | continue; |
| 299 | } |
| 300 | |
| 301 | if (elTrack->owner() != company) |
| 302 | { |
| 303 | continue; |
| 304 | } |
| 305 | |
| 306 | if (elTrack->trackObjectId() != trackObjectId) |
| 307 | { |
| 308 | continue; |
| 309 | } |
| 310 | |
| 311 | if ((elTrack->mods() & requiredMods) != requiredMods) |
| 312 | { |
| 313 | continue; |
| 314 | } |
| 315 | |
| 316 | if (elTrack->isGhost() || elTrack->isAiAllocated()) |
| 317 | { |
| 318 | continue; |
| 319 | } |
| 320 | |
| 321 | const auto connection = getElTrackConnection(*elTrack, nextRotation, baseZ, queryMods); |
| 322 | if (connection == kNullTad) |
| 323 | { |
| 324 | continue; |
| 325 | } |
| 326 | |
| 327 | result.connections.push_back(connection); |
| 328 | if (elTrack->hasStationElement()) |
| 329 | { |
| 330 | auto* elStation = elTrack->next()->as<StationElement>(); |
| 331 | if (elStation != nullptr) |
| 332 | { |
| 333 | if (!elStation->isAiAllocated() && !elStation->isGhost()) |
| 334 | { |
| 335 | result.stationId = elStation->stationId(); |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | if (elTrack->hasLevelCrossing()) |
| 341 | { |
| 342 | result.hasLevelCrossing = 1; |
| 343 | } |
no test coverage detected