//
// PlayerObject::convertToClosestRotation from 0x436f90 to 0x43704e (190 bytes)
//
// 3 xrefs:
// > PlayerObject::updateSlopeRotation @ 0x4375a6
// > PlayerObject::updateRotation @ 0x437700
// > PlayerObject::updateMove @ 0x43e3f2
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:48:19 +0000
//
int __fastcall PlayerObject::convertToClosestRotation(PlayerObject *this, float a2)
{
int v4; // r1
float v5; // s15
float i; // s14
if ( !PlayerObject::isFlying(this) && !*((_BYTE *)this + 1957) && !*((_BYTE *)this + 1958) && !*((_BYTE *)this + 1996) )
{
v4 = (int)(*(float (__fastcall **)(PlayerObject *))(*(_DWORD *)this + 184))(this) % 360;
v5 = (float)v4;
if ( a2 <= (float)v4 )
{
i = a2;
if ( a2 < (float)v4 )
{
while ( 1 )
{
a2 = a2 + 90.0;
if ( a2 >= v5 )
break;
i = a2;
}
}
}
else
{
for ( i = a2; ; i = a2 )
{
a2 = a2 - 90.0;
if ( a2 <= v5 )
break;
}
}
if ( fabsf(v5 - a2) >= fabsf(v5 - i) )
a2 = i;
}
return LODWORD(a2);
}