]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
entcs: fix networking of wrong entcs fields (nevertheless miraculously it was working...
authorterencehill <piuntn@gmail.com>
Thu, 31 Jan 2019 13:50:35 +0000 (14:50 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 31 Jan 2019 13:50:35 +0000 (14:50 +0100)
qcsrc/common/ent_cs.qc
qcsrc/common/ent_cs.qh

index a641905c4ef06018bcf9391ffde994fd90a3b3e6..a15ebc2966323ac468d95c9e910036d5d58b0687 100644 (file)
@@ -12,6 +12,27 @@ REGISTRY_SORT(EntCSProps)
 REGISTRY_CHECK(EntCSProps)
 STATIC_INIT(RegisterEntCSProps_renumber) { FOREACH(EntCSProps, true, it.m_id = i); }
 
+// these entcs_props ids need to be referenced directly
+int ENTCS_PROP_ENTNUM_id = 0;
+int ENTCS_PROP_ORIGIN_id = 0;
+STATIC_INIT(RegisterEntCSProps_setglobalids)
+{
+       FOREACH(EntCSProps, true, {
+               if (it.registered_id == "ENTCS_PROP_ENTNUM")
+                       ENTCS_PROP_ENTNUM_id = it.m_id;
+               if (it.registered_id == "ENTCS_PROP_ORIGIN")
+                       ENTCS_PROP_ORIGIN_id = it.m_id;
+       });
+}
+
+#ifdef SVQC
+// Force an origin update, for player sounds
+void entcs_force_origin(entity player)
+{
+       CS(player).entcs.m_forceupdate = BIT(ENTCS_PROP_ORIGIN_id);
+}
+#endif
+
 .bool m_public;
 .bool(entity ent, entity player) m_check;
 .void(entity ent, entity player) m_set;
@@ -139,7 +160,7 @@ ENTCS_PROP(FRAGS, true, frags, ENTCS_SET_NORMAL,
        bool _entcs_send(entity this, entity to, int sf, int chan)
        {
                entity player = this.owner;
-               sf |= BIT(0); // assume private
+               sf |= BIT(ENTCS_PROP_ENTNUM_id); // assume private
                do {
                        if (IS_PLAYER(player))
                        {
@@ -257,7 +278,7 @@ ENTCS_PROP(FRAGS, true, frags, ENTCS_SET_NORMAL,
                e.sv_entnum = n;
                int sf = ReadShort();
                e.has_sv_origin = false;
-               e.m_entcs_private = boolean(sf & BIT(0));
+               e.m_entcs_private = boolean(sf & BIT(ENTCS_PROP_ENTNUM_id));
                FOREACH(EntCSProps, sf & BIT(it.m_id),
                {
                        it.m_receive(e);
index 3a9f084bcf7cfd8188a48534ce3c9bd0f4432619..c46d31b12b5b597577232717c14b542ea0805951 100644 (file)
@@ -36,14 +36,13 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
 
        void entcs_think(entity this);
 
-       void entcs_attach(entity e);
+       void entcs_attach(entity player);
 
-       void entcs_detach(entity e);
+       void entcs_detach(entity player);
 
        .int m_forceupdate;
 
-/** Force an origin update, for player sounds */
-       #define entcs_force_origin(e) (CS(e).entcs.m_forceupdate = BIT(2))
+       void entcs_force_origin(entity player);
 
 #endif