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

Function calculateYaw4FromVector

src/OpenLoco/src/Vehicles/VehicleBody.cpp:701–881  ·  view source on GitHub ↗

0x004BF6DF For yaw of 7 bits

Source from the content-addressed store, hash-verified

699
700 // 0x004BF6DF For yaw of 7 bits
701 uint8_t calculateYaw4FromVector(int16_t xDiff, int16_t yDiff)
702 {
703 uint32_t i = 0;
704
705 if (xDiff < 0)
706 {
707 i += 17;
708 xDiff = -xDiff;
709 }
710
711 if (yDiff < 0)
712 {
713 i += 34;
714 yDiff = -yDiff;
715 }
716
717 uint32_t xy = std::numeric_limits<uint32_t>::max();
718 if (yDiff != 0)
719 {
720 xy = (static_cast<uint64_t>(xDiff) << 16) / yDiff;
721 }
722
723 if (xy >= 72308)
724 {
725 if (xy >= 183161)
726 {
727 if (xy >= 441808)
728 {
729 i += 15;
730 if (xy >= 1334016)
731 {
732 i++;
733 }
734 }
735 else
736 {
737 i += 13;
738 if (xy >= 261634)
739 {
740 i++;
741 }
742 }
743 }
744 else
745 {
746 if (xy >= 109340)
747 {
748 i += 11;
749 if (xy >= 138564)
750 {
751 i++;
752 }
753 }
754 else
755 {
756 i += 9;
757 if (xy >= 88365)
758 {

Callers 2

sub_4AC255Method · 0.85
updateWaterMotionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected