MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / getTrackConnections

Function getTrackConnections

src/OpenLoco/src/Map/Track/Track.cpp:286–346  ·  view source on GitHub ↗

0x004A2638, 0x004A2601

Source from the content-addressed store, hash-verified

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 }

Callers 13

sub_48715CFunction · 0.85
removeTrackFunction · 0.85
sub_4ACEF1Function · 0.85
sub_4AC1C2Method · 0.85
opposingTrainAtSignalMethod · 0.85
createSignalFunction · 0.85

Calls 12

getElTrackConnectionFunction · 0.85
trackObjectIdMethod · 0.80
isAiAllocatedMethod · 0.80
push_backMethod · 0.80
stationIdMethod · 0.80
getFunction · 0.50
ownerMethod · 0.45
modsMethod · 0.45
isGhostMethod · 0.45
hasStationElementMethod · 0.45
nextMethod · 0.45
hasLevelCrossingMethod · 0.45

Tested by

no test coverage detected