From aaeb18f433644e70a31086780bcb24a321c79dc0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 18 Jan 2023 19:29:01 +0300 Subject: [PATCH] engine: inline version of MSG_BigShort --- engine/common/net_buffer.c | 5 ----- engine/common/net_buffer.h | 10 +++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/engine/common/net_buffer.c b/engine/common/net_buffer.c index 34483ab9..567047f2 100644 --- a/engine/common/net_buffer.c +++ b/engine/common/net_buffer.c @@ -89,11 +89,6 @@ const char *svc_strings[svc_lastmsg+1] = "svc_exec", }; -unsigned short MSG_BigShort( unsigned short swap ) -{ - return (swap >> 8)|(swap << 8); -} - void MSG_InitMasks( void ) { uint startbit, endbit; diff --git a/engine/common/net_buffer.h b/engine/common/net_buffer.h index 50cb7361..62ded8dc 100644 --- a/engine/common/net_buffer.h +++ b/engine/common/net_buffer.h @@ -63,7 +63,15 @@ void MSG_ExciseBits( sizebuf_t *sb, int startbit, int bitstoremove ); _inline int MSG_TellBit( sizebuf_t *sb ) { return sb->iCurBit; } _inline const char *MSG_GetName( sizebuf_t *sb ) { return sb->pDebugName; } qboolean MSG_CheckOverflow( sizebuf_t *sb ); -unsigned short MSG_BigShort( unsigned short swap ); + +#if XASH_BIG_ENDIAN +#define MSG_BigShort( x ) ( x ) +#else +static inline uint16_t MSG_BigShort( const uint16_t x ) +{ + return (x >> 8) | (x << 8); +} +#endif // init writing void MSG_StartWriting( sizebuf_t *sb, void *pData, int nBytes, int iStartBit, int nBits );