]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/ent_cs.qc
Send health / armor values to entcs entities only when the coded values are different...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / ent_cs.qc
index 86acdc154064ac6d0bc80258e7fca234d369740c..ce5d3174a1f750cdc2e2f43b28406f57a5efb7f2 100644 (file)
@@ -40,7 +40,9 @@ STATIC_INIT(RegisterEntCSProps_renumber) { FOREACH(EntCSProps, true, it.m_id = i
 
 #ifdef SVQC
 #define ENTCS_PROP_RESOURCE(id, ispublic, checkprop, setprop, svsend, clreceive) \
-       bool id##_check(entity ent, entity player) { return (GetResourceAmount(ent, checkprop) != GetResourceAmount(player, checkprop)); } \
+       bool id##_check(entity ent, entity player) { \
+               return (floor(GetResourceAmount(ent, checkprop) / 10) != floor(GetResourceAmount(player, checkprop) / 10)); \
+       } \
        void id##_set(entity ent, entity player) { SetResourceAmountExplicit(ent, checkprop, GetResourceAmount(player, checkprop)); } \
        void id##_send(int chan, entity ent) { LAMBDA(svsend); } \
        REGISTER(EntCSProps, ENTCS_PROP, id, m_id, new_pure(entcs_prop)) { \
@@ -164,23 +166,23 @@ ENTCS_PROP(FRAGS, true, frags, ENTCS_SET_NORMAL,
 
        void entcs_attach(entity player)
        {
-               entity e = player.entcs = new(entcs_sender);
+               entity e = CS(player).entcs = new(entcs_sender);
                e.owner = player;
                setthink(e, entcs_think);
                e.nextthink = time;
                Net_LinkEntity(e, false, 0, entcs_send);
                if (!IS_REAL_CLIENT(player)) return;
                FOREACH_CLIENT(true, {
-                       assert(it.entcs);
-                       _entcs_send(it.entcs, msg_entity = player, BITS(23), MSG_ONE);
+                       assert(CS(it).entcs);
+                       _entcs_send(CS(it).entcs, msg_entity = player, BITS(23), MSG_ONE);
                });
        }
 
        void entcs_detach(entity player)
        {
-               if (!player.entcs) return;
-               delete(player.entcs);
-               player.entcs = NULL;
+               if (!CS(player).entcs) return;
+               delete(CS(player).entcs);
+               CS(player).entcs = NULL;
        }
 
 #endif