From: Mario Date: Tue, 8 Mar 2016 11:42:31 +0000 (+1000) Subject: Use macros for the vector reading functions X-Git-Tag: xonotic-v0.8.2~1148 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=caea34c07a9cb685775fe35509986f99cffb2681;p=xonotic%2Fxonotic-data.pk3dir.git Use macros for the vector reading functions --- diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index fd5c88889..4f5bbef61 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -159,8 +159,6 @@ string getcurrentmod(); #ifndef MENUQC #ifdef CSQC int ReadInt24_t(); -vector ReadInt48_t(); -vector ReadInt72_t(); #else void WriteInt24_t(float dest, float val); void WriteInt48_t(float dest, vector val); diff --git a/qcsrc/lib/net.qh b/qcsrc/lib/net.qh index b0320eadb..7ac732f8b 100644 --- a/qcsrc/lib/net.qh +++ b/qcsrc/lib/net.qh @@ -265,28 +265,14 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); } v += ReadByte(); // note: this is unsigned return v; } - vector ReadInt48_t() - { - vector v; - v.x = ReadInt24_t(); - v.y = ReadInt24_t(); - v.z = 0; - return v; - } - vector ReadInt72_t() - { - vector v; - v.x = ReadInt24_t(); - v.y = ReadInt24_t(); - v.z = ReadInt24_t(); - return v; - } + #define ReadInt48_t() vec3(ReadInt24_t(), ReadInt24_t(), 0) + #define ReadInt72_t() vec3(ReadInt24_t(), ReadInt24_t(), ReadInt24_t()) int _ReadSByte; #define ReadSByte() (_ReadSByte = ReadByte(), (_ReadSByte & BIT(7) ? -128 : 0) + (_ReadSByte & BITS(7))) #define ReadFloat() ReadCoord() - vector ReadVector() { vector v; v.x = ReadFloat(); v.y = ReadFloat(); v.z = ReadFloat(); return v; } - vector ReadVector2D() { vector v; v.x = ReadFloat(); v.y = ReadFloat(); v.z = 0; return v; } + #define ReadVector() vec3(ReadFloat(), ReadFloat(), ReadFloat()) + #define ReadVector2D() vec3(ReadFloat(), ReadFloat(), 0) float ReadApproxPastTime() {