0x004AD24C Updates the target signal (targetPos, targetRouting, targetTrackType) to reflect the state of the signal based on newRouting (and the track connections, tc).
| 4375 | // Updates the target signal (targetPos, targetRouting, targetTrackType) to reflect |
| 4376 | // the state of the signal based on newRouting (and the track connections, tc). |
| 4377 | static void updateJunctionSignalLights(World::Pos3 targetPos, uint16_t targetRouting, uint8_t targetTrackType, uint16_t newRouting, const World::Track::TrackConnections& tc) |
| 4378 | { |
| 4379 | TrackAndDirection::_TrackAndDirection tad{ 0, 0 }; |
| 4380 | tad._data = targetRouting & World::Track::AdditionalTaDFlags::basicTaDMask; |
| 4381 | sfl::static_vector<int8_t, 16> curvatures; // unk113621F |
| 4382 | for (const auto& otherConnection : tc.connections) |
| 4383 | { |
| 4384 | curvatures.push_back(TrackData::getCurvatureDegree((otherConnection & World::Track::AdditionalTaDFlags::basicTaDMask) >> 2)); |
| 4385 | } |
| 4386 | |
| 4387 | const auto newRoutingCurvature = TrackData::getCurvatureDegree((newRouting & World::Track::AdditionalTaDFlags::basicTaDMask) >> 2); |
| 4388 | |
| 4389 | int8_t minCurvature = curvatures[0]; // cl |
| 4390 | int8_t maxCurvature = curvatures[0]; // ch |
| 4391 | int8_t leastMagnitudeCurvature = curvatures[0]; // ah |
| 4392 | for (auto i = 1U; i < curvatures.size(); ++i) |
| 4393 | { |
| 4394 | const auto curvature = curvatures[i]; |
| 4395 | minCurvature = std::min(minCurvature, curvature); |
| 4396 | maxCurvature = std::max(maxCurvature, curvature); |
| 4397 | |
| 4398 | if (std::abs(curvature) < std::abs(leastMagnitudeCurvature)) |
| 4399 | { |
| 4400 | leastMagnitudeCurvature = curvature; |
| 4401 | } |
| 4402 | } |
| 4403 | |
| 4404 | uint32_t lightStateFlags = 0x10; |
| 4405 | if (leastMagnitudeCurvature != minCurvature) |
| 4406 | { |
| 4407 | lightStateFlags |= 1U << 30; |
| 4408 | if (newRoutingCurvature < leastMagnitudeCurvature) |
| 4409 | { |
| 4410 | lightStateFlags |= 1U << 28; |
| 4411 | } |
| 4412 | } |
| 4413 | if (leastMagnitudeCurvature != maxCurvature) |
| 4414 | { |
| 4415 | lightStateFlags |= 1U << 29; |
| 4416 | if (newRoutingCurvature > leastMagnitudeCurvature) |
| 4417 | { |
| 4418 | lightStateFlags |= 1U << 27; |
| 4419 | } |
| 4420 | } |
| 4421 | |
| 4422 | setSignalState(targetPos, tad, targetTrackType, lightStateFlags); |
| 4423 | } |
| 4424 | |
| 4425 | // 0x004ACEF1 |
| 4426 | static Sub4ACEE7Result sub_4ACEF1(VehicleHead& head, uint32_t unk1, uint32_t var_113612C, bool isPlaceDown) |
no test coverage detected