- Clean up and simplify getincangle()/getincanglebam() functions and inline them.

This commit is contained in:
Mitchell Richters 2022-07-23 12:53:42 +10:00
parent 5dce9c8ff2
commit 79022e8afa
2 changed files with 9 additions and 37 deletions

View file

@ -28,41 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "build.h"
//---------------------------------------------------------------------------
//
// code fron gameexec/conrun
//
//---------------------------------------------------------------------------
int getincangle(int a, int na)
{
a &= 2047;
na &= 2047;
if(abs(a-na) >= 1024)
{
if(na > 1024) na -= 2048;
if(a > 1024) a -= 2048;
}
return na-a;
}
binangle getincanglebam(binangle a, binangle na)
{
int64_t cura = a.asbam();
int64_t newa = na.asbam();
if(abs(cura-newa) > INT32_MAX)
{
if(newa > INT32_MAX) newa -= UINT32_MAX;
if(cura > INT32_MAX) cura -= UINT32_MAX;
}
return bamang(uint32_t(newa-cura));
}
//---------------------------------------------------------------------------
//
// Input scale helper functions.

View file

@ -6,8 +6,15 @@
#include "gamestruct.h"
#include "packet.h"
int getincangle(int a, int na);
binangle getincanglebam(binangle a, binangle na);
inline constexpr binangle getincanglebam(binangle a, binangle na)
{
return na-a;
}
inline constexpr int getincangle(int a, int na)
{
return getincanglebam(buildang(a), buildang(na)).signedbuild();
}
struct PlayerHorizon
{