0x0047C7FA
| 446 | |
| 447 | // 0x0047C7FA |
| 448 | static UpdateMotionResult updateRoadMotion(VehicleBase& component, int32_t distance, bool isVeh2UnkM15) |
| 449 | { |
| 450 | UpdateMotionResult result{}; |
| 451 | component.remainingDistance += distance; |
| 452 | bool hasMoved = false; |
| 453 | auto intermediatePosition = component.position; |
| 454 | while (component.remainingDistance >= 0x368A) |
| 455 | { |
| 456 | hasMoved = true; |
| 457 | auto newSubPosition = component.subPosition + 1U; |
| 458 | const auto subPositionDataSize = World::TrackData::getRoadSubPositon(component.trackAndDirection.road._data).size(); |
| 459 | // This means we have moved forward by a road piece |
| 460 | if (newSubPosition >= subPositionDataSize) |
| 461 | { |
| 462 | if (!updateRoadMotionNewRoadPiece(component, result.flags, isVeh2UnkM15)) |
| 463 | { |
| 464 | result.remainingDistance = component.remainingDistance - 0x3689; |
| 465 | component.remainingDistance = 0x3689; |
| 466 | result.flags |= UpdateVar1136114Flags::unk_m00; |
| 467 | break; |
| 468 | } |
| 469 | else |
| 470 | { |
| 471 | newSubPosition = 0; |
| 472 | } |
| 473 | } |
| 474 | // 0x0047C95B |
| 475 | component.subPosition = newSubPosition; |
| 476 | const auto& moveData = World::TrackData::getRoadSubPositon(component.trackAndDirection.road._data)[newSubPosition]; |
| 477 | const auto nextNewPosition = moveData.loc + World::Pos3(component.tileX, component.tileY, component.tileBaseZ * World::kSmallZStep); |
| 478 | component.remainingDistance -= kMovementNibbleToDistance[getMovementNibble(intermediatePosition, nextNewPosition)]; |
| 479 | intermediatePosition = nextNewPosition; |
| 480 | component.spriteYaw = moveData.yaw; |
| 481 | component.spritePitch = moveData.pitch; |
| 482 | if (component.isVehicleBogie()) |
| 483 | { |
| 484 | // collision checks |
| 485 | auto collideResult = checkForCollisions(*component.asVehicleBogie(), intermediatePosition); |
| 486 | if (collideResult != EntityId::null) |
| 487 | { |
| 488 | result.flags |= UpdateVar1136114Flags::crashed; |
| 489 | result.collidedEntityId = collideResult; |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | if (hasMoved) |
| 494 | { |
| 495 | component.moveTo(intermediatePosition); |
| 496 | } |
| 497 | return result; |
| 498 | } |
| 499 | |
| 500 | static UpdateMotionResult updateTrackMotion(VehicleBase& component, int32_t distance, bool isVeh2UnkM15) |
| 501 | { |
no test coverage detected