]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/ent_cs.qc
Restore old code in the hope it fixes #2205 for real. This commit together with the...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / ent_cs.qc
index 0a972277e6957672e3ba28d9fec875a2a6ebe700..f4ef79eda495f5e064ed81146b7e0fb24dacca9c 100644 (file)
@@ -10,12 +10,12 @@ REGISTRY(EntCSProps, BITS(16) - 1)
 REGISTER_REGISTRY(EntCSProps)
 REGISTRY_SORT(EntCSProps)
 REGISTRY_CHECK(EntCSProps)
-STATIC_INIT(RegisterEntCSProps_renumber) { FOREACH(EntCSProps, true, it.m_id = i); }
+STATIC_INIT(EntCSProps_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)
+STATIC_INIT(EntCSProps_setglobalids)
 {
        FOREACH(EntCSProps, true, {
                if (it.registered_id == "ENTCS_PROP_ENTNUM")
@@ -77,7 +77,7 @@ void entcs_force_origin(entity player)
        bool id##_check(entity ent, entity player) { \
                return (floor(GetResource(ent, checkprop) / decfactor) != floor(GetResource(player, checkprop) / decfactor)); \
        } \
-       void id##_set(entity ent, entity player) { SetResource(ent, checkprop, GetResource(player, checkprop)); } \
+       void id##_set(entity ent, entity player) { SetResourceExplicit(ent, checkprop, GetResource(player, checkprop)); } \
        void id##_send(int chan, entity ent) { LAMBDA(svsend); } \
        REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \
                this.m_public = ispublic; \
@@ -123,7 +123,7 @@ ENTCS_PROP_RESOURCE(HEALTH, false, RES_HEALTH, ENTCS_SET_NORMAL, DEC_FACTOR,
 
 ENTCS_PROP_RESOURCE(ARMOR, false, RES_ARMOR, ENTCS_SET_NORMAL, DEC_FACTOR,
        { WriteByte(chan, bound(0, GetResource(ent, RES_ARMOR) / DEC_FACTOR, 255)); },
-       { SetResource(ent, RES_ARMOR, ReadByte() * DEC_FACTOR); })
+       { SetResourceExplicit(ent, RES_ARMOR, ReadByte() * DEC_FACTOR); })
 #undef DEC_FACTOR
 
 ENTCS_PROP(NAME, true, netname, ENTCS_SET_MUTABLE_STRING,
@@ -181,7 +181,6 @@ ENTCS_PROP(FRAGS, true, frags, ENTCS_SET_NORMAL,
                WriteShort(chan, sf);
                FOREACH(EntCSProps, sf & BIT(it.m_id),
                {
-                       it.m_set(this, player);
                        it.m_send(chan, this);
                });
                return true;
@@ -195,9 +194,10 @@ ENTCS_PROP(FRAGS, true, frags, ENTCS_SET_NORMAL,
        void entcs_think(entity this)
        {
                this.nextthink = time + 0.033333333333;  // TODO: increase this to like 0.15 once the client can do smoothing
-               entity o = this.owner;
-               FOREACH(EntCSProps, it.m_check(this, o),
+               entity player = this.owner;
+               FOREACH(EntCSProps, it.m_check(this, player),
                {
+                       it.m_set(this, player);
                        this.SendFlags |= BIT(it.m_id);
                });
                setorigin(this, this.origin); // relink
@@ -210,6 +210,11 @@ ENTCS_PROP(FRAGS, true, frags, ENTCS_SET_NORMAL,
                setthink(e, entcs_think);
                e.nextthink = time;
                Net_LinkEntity(e, false, 0, entcs_send);
+               if (!IS_REAL_CLIENT(player)) return;
+               FOREACH_CLIENT(true, {
+                       assert(CS(it).entcs);
+                       _entcs_send(CS(it).entcs, msg_entity = player, BITS(23), MSG_ONE);
+               });
        }
 
        void entcs_detach(entity player)