0x0048963F
| 308 | |
| 309 | // 0x0048963F |
| 310 | void setSignalState(const World::Pos3& loc, const TrackAndDirection::_TrackAndDirection trackAndDirection, const uint8_t trackType, uint32_t flags) |
| 311 | { |
| 312 | const auto unk1 = flags & 0xFFFF; |
| 313 | assert(unk1 != 10); // Only happens if wrong function was called call getSignalState |
| 314 | auto trackStart = loc; |
| 315 | if (trackAndDirection.isReversed()) |
| 316 | { |
| 317 | auto& trackSize = World::TrackData::getUnkTrack(trackAndDirection._data); |
| 318 | trackStart += trackSize.pos; |
| 319 | if (trackSize.rotationEnd < 12) |
| 320 | { |
| 321 | trackStart -= World::Pos3{ World::kRotationOffset[trackSize.rotationEnd], 0 }; |
| 322 | } |
| 323 | flags ^= (1ULL << 31); |
| 324 | } |
| 325 | |
| 326 | auto& trackPieces = World::TrackData::getTrackPiece(trackAndDirection.id()); |
| 327 | for (auto& trackPiece : trackPieces) |
| 328 | { |
| 329 | auto signalLoc = trackStart + World::Pos3{ Math::Vector::rotate(World::Pos2{ trackPiece.x, trackPiece.y }, trackAndDirection.cardinalDirection()), 0 }; |
| 330 | signalLoc.z += trackPiece.z; |
| 331 | auto res = findSignalOnTrack(signalLoc, trackAndDirection, trackType, trackPiece.index); |
| 332 | |
| 333 | if (!res) |
| 334 | { |
| 335 | // This shouldn't happen I think. Either way useful in debug to know. |
| 336 | assert(false); |
| 337 | return; |
| 338 | } |
| 339 | |
| 340 | auto [elSignal, foundTrack] = *res; |
| 341 | |
| 342 | // edx |
| 343 | auto& signalSide = (flags & (1ULL << 31)) ? elSignal->getRight() : elSignal->getLeft(); |
| 344 | if (unk1 == 16) |
| 345 | { |
| 346 | uint8_t lightStates = 0; |
| 347 | if (flags & (1ULL << 30)) |
| 348 | { |
| 349 | lightStates |= 1 << 2; |
| 350 | if (flags & (1ULL << 28)) |
| 351 | { |
| 352 | lightStates |= 1 << 0; |
| 353 | } |
| 354 | } |
| 355 | if (flags & (1ULL << 29)) |
| 356 | { |
| 357 | lightStates |= 1 << 3; |
| 358 | if (flags & (1ULL << 27)) |
| 359 | { |
| 360 | lightStates |= 1 << 1; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | if (signalSide.allLights() != lightStates) |
| 365 | { |
| 366 | bool shouldInvalidate = false; |
| 367 | signalSide.setAllLights(lightStates); |
no test coverage detected