From 83b075b804f22671ef1db2cac36874f25c3e5eee Mon Sep 17 00:00:00 2001 From: Fredrik Hatletvedt <32248439+Pespiri@users.noreply.github.com> Date: Thu, 20 Jun 2024 01:35:00 +0200 Subject: [PATCH] add macro for calculating radians (#317) * feat: add macro for calculating radians * style: silence unused variable warning * remove unnecessary float cast in macro --- src/consts.h | 11 +++++++---- src/network/connection.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/consts.h b/src/consts.h index e8dac2f1c..8052fe9c7 100644 --- a/src/consts.h +++ b/src/consts.h @@ -82,10 +82,13 @@ // PPS: 650 @ 5+1, 650 @ 5+3 #define PACKET_BUNDLING_BUFFERED 2 -#define DEG_0 0.f -#define DEG_90 -PI / 2 -#define DEG_180 PI -#define DEG_270 PI / 2 +// Get radian for a given angle from 0° to 360° (2*PI*r, solve for r given an angle, range -180° to 180°) +#define DEG_X(deg) ((((deg) < 180.0f ? 0 : 360.0f) - (deg)) * PI / 180.0f) + +#define DEG_0 DEG_X(0.0f) +#define DEG_90 DEG_X(90.0f) +#define DEG_180 DEG_X(180.0f) +#define DEG_270 DEG_X(270.0f) #define CONST_EARTH_GRAVITY 9.80665 diff --git a/src/network/connection.cpp b/src/network/connection.cpp index 1f60ad876..86b2b5998 100644 --- a/src/network/connection.cpp +++ b/src/network/connection.cpp @@ -547,7 +547,7 @@ void Connection::searchForServer() { } // receive incoming UDP packets - int len = m_UDP.read(m_Packet, sizeof(m_Packet)); + int len __attribute__((unused)) = m_UDP.read(m_Packet, sizeof(m_Packet)); #ifdef DEBUG_NETWORK m_Logger.trace(