]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
entcs: don't send sv_entnum twice
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 28 Aug 2016 07:26:52 +0000 (17:26 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 28 Aug 2016 07:27:40 +0000 (17:27 +1000)
qcsrc/common/ent_cs.qc

index 41183d85b21d5c505b4becc57bba4f1df396971c..5b48ef668d0b443141c82435e863fb60c14996ac 100644 (file)
@@ -1,11 +1,7 @@
 #include "ent_cs.qh"
 
 // #define PROP(public, fld, sv, cl)
-#define ENTCS_NETPROPS(PROP) \
-       PROP(true, sv_entnum, \
-       { WriteByte(chan, etof(player) - 1); }, \
-       { this.sv_entnum = ReadByte(); }) \
-    \
+#define ENTCS_NETPROPS(PROP) PROP(false, sv_entnum, {}, {}) /* sentinel */ \
        PROP(false, origin, \
        { WriteShort(chan, this.origin.x);  WriteShort(chan, this.origin.y); \
          WriteShort(chan, this.origin.z); }, \
        int ENTCS_PUBLICMASK = 0;
        STATIC_INIT(ENTCS_PUBLICMASK)
        {
-               int i = 1;
-               #define X(public, fld, sv, cl) { if (public) ENTCS_PUBLICMASK |= BIT(i); } i += 1;
+               int i = 0;
+               #define X(public, fld, sv, cl) { \
+                       if (public) { \
+                               ENTCS_PUBLICMASK |= BIT(i); \
+                       } \
+                       i += 1; \
+               }
                ENTCS_NETPROPS(X);
        #undef X
                if (i >= BITS(16 - 1)) LOG_FATAL("Exceeded ENTCS_NETPROPS limit");
@@ -60,9 +61,8 @@
        bool _entcs_send(entity this, entity to, int sf, int chan)
        {
                entity player = this.owner;
-               sf |= BIT(0) | BIT(1);
-               if (IS_PLAYER(to) || to.caplayer)                                  // unless spectating,
-               {
+               sf |= BIT(0); // assume private
+               if (IS_PLAYER(to) || to.caplayer) {                                // unless spectating,
                        bool same_team = (to == player) || (teamplay && player.team == to.team);
                        if (!same_team && !radar_showennemies) sf &= ENTCS_PUBLICMASK; // no private updates
                }
                        WriteHeader(chan, CLIENT_ENTCS);
                WriteByte(chan, etof(player) - 1);
                WriteShort(chan, sf);
-               int i = 1;
-               #define X(public, fld, sv, cl) { if (sf & BIT(i)) sv; } i += 1;
+               int i = 0;
+               #define X(public, fld, sv, cl) { \
+                       if (sf & BIT(i)) { \
+                               sv; \
+                       } \
+                       i += 1; \
+               }
                ENTCS_NETPROPS(X);
        #undef X
                return true;
        {
                this.nextthink = time + 0.033333333333;  // TODO: increase this to like 0.15 once the client can do smoothing
                entity o = this.owner;
-               int i = 1;
-               #define X(public, fld, sv, cl) \
-                       if (o.fld != this.fld) \
-                       { \
+               int i = 0;
+               #define X(public, fld, sv, cl) { \
+                       if (o.fld != this.fld) { \
                                this.fld = o.fld; \
                                this.SendFlags |= BIT(i); \
                        } \
-                       i += 1;
+                       i += 1; \
+               }
                ENTCS_NETPROPS(X);
        #undef X
            setorigin(this, this.origin);  // relink
                int sf = ReadShort();
                this.has_sv_origin = false;
                this.m_entcs_private = boolean(sf & BIT(0));
-               int i = 1;
-               #define X(public, fld, sv, cl) { if (sf & BIT(i)) cl; } i += 1;
+               int i = 0;
+               #define X(public, fld, sv, cl) { \
+                       if (sf & BIT(i)) { \
+                               cl; \
+                       } \
+                       i += 1; \
+               }
                ENTCS_NETPROPS(X);
        #undef X
                this.iflags |= IFLAG_ORIGIN;