| 204 | constexpr uint16_t kNullTad = 0xFFFFU; |
| 205 | |
| 206 | static uint16_t getElTrackConnection(const World::TrackElement& elTrack, uint8_t nextRotation, uint8_t baseZ, uint8_t queryMods) |
| 207 | { |
| 208 | if (elTrack.sequenceIndex() == 0) |
| 209 | { |
| 210 | auto trackAndDirection2 = (elTrack.trackId() << 3) | elTrack.rotation(); |
| 211 | if (nextRotation == TrackData::getUnkTrack(trackAndDirection2).rotationBegin) |
| 212 | { |
| 213 | const auto& trackPiece = TrackData::getTrackPiece(elTrack.trackId()); |
| 214 | if (baseZ == (elTrack.baseZ() - trackPiece[0].z / 4)) |
| 215 | { |
| 216 | if (elTrack.hasBridge()) |
| 217 | { |
| 218 | trackAndDirection2 |= elTrack.bridge() << 9; |
| 219 | trackAndDirection2 |= AdditionalTaDFlags::hasBridge; |
| 220 | } |
| 221 | |
| 222 | if ((queryMods & elTrack.mods()) != 0) |
| 223 | { |
| 224 | trackAndDirection2 |= AdditionalTaDFlags::hasMods; |
| 225 | } |
| 226 | |
| 227 | if (elTrack.hasSignal()) |
| 228 | { |
| 229 | auto* elSignal = elTrack.next()->as<SignalElement>(); |
| 230 | if (elSignal != nullptr) |
| 231 | { |
| 232 | if (!elSignal->isAiAllocated() && !elSignal->isGhost()) |
| 233 | { |
| 234 | trackAndDirection2 |= (1 << 15); |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | return trackAndDirection2; |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | if (!elTrack.isFlag6()) |
| 244 | { |
| 245 | return kNullTad; |
| 246 | } |
| 247 | |
| 248 | auto trackAndDirection2 = (elTrack.trackId() << 3) | (1 << 2) | elTrack.rotation(); |
| 249 | if (nextRotation != TrackData::getUnkTrack(trackAndDirection2).rotationBegin) |
| 250 | { |
| 251 | return kNullTad; |
| 252 | } |
| 253 | |
| 254 | const auto previousBaseZ = elTrack.baseZ() - (TrackData::getTrackPiece(elTrack.trackId())[elTrack.sequenceIndex()].z + TrackData::getUnkTrack(trackAndDirection2).pos.z) / 4; |
| 255 | if (previousBaseZ != baseZ) |
| 256 | { |
| 257 | return kNullTad; |
| 258 | } |
| 259 | |
| 260 | if (elTrack.hasBridge()) |
| 261 | { |
| 262 | trackAndDirection2 |= elTrack.bridge() << 9; |
| 263 | trackAndDirection2 |= AdditionalTaDFlags::hasBridge; |
no test coverage detected