]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Improve server performance a bit
authorMario <mario@smbclan.net>
Wed, 23 Dec 2015 10:39:36 +0000 (20:39 +1000)
committerMario <mario@smbclan.net>
Wed, 23 Dec 2015 10:39:36 +0000 (20:39 +1000)
qcsrc/lib/iter.qh
qcsrc/lib/net.qh
qcsrc/server/sv_main.qc

index 790c3929d197f58faf5a42d31fcacad9de09f4e9..223522504c1a4b65edad2cb0dca4f9d71f0901a2 100644 (file)
 #if defined(CSQC)
        entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #402;
        entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #403;
+       entity(.float fld, float match, .entity tofield) _findchainfloat_tofield = #403;
        entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #450;
 #elif defined(SVQC)
        entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #402;
        entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #403;
+       entity(.float fld, float match, .entity tofield) _findchainfloat_tofield = #403;
        entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #450;
 #elif defined(MENUQC)
        entity(.string fld, string match, .entity tofield) _findchainstring_tofield = #26;
        entity(.entity fld, entity match, .entity tofield) findchainentity_tofield = #27;
+       entity(.float fld, float match, .entity tofield) _findchainfloat_tofield = #27;
        entity(.float fld, float match, .entity tofield) _findchainflags_tofield = #88;
 #endif
 
                } \
        } MACRO_END
 
-#define FOREACH_ENTITY_FLAGS(fld, flags, body) \
+#define FOREACH_ENTITY_FLOAT(fld, match, body) \
        MACRO_BEGIN { \
                int i = 0; \
-               for (entity it = _findchainflags_tofield(fld, flags, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
+               for (entity it = _findchainfloat_tofield(fld, match, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
+               { \
+                       LAMBDA(body) \
+               } \
+       } MACRO_END
+
+#define FOREACH_ENTITY_FLAGS(fld, match, body) \
+       MACRO_BEGIN { \
+               int i = 0; \
+               for (entity it = _findchainflags_tofield(fld, match, _FOREACH_ENTITY_next); it; (it = it._FOREACH_ENTITY_next, ++i)) \
                { \
                        LAMBDA(body) \
                } \
index 9782ba31311caa0de35cb8ae4c78d736049a6b77..d870ef1f9639ee91b252f64b5da1f3414b5aacb4 100644 (file)
@@ -147,8 +147,9 @@ STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
 
        void UncustomizeEntitiesRun()
        {
-               for (entity e = NULL; (e = findfloat(e, uncustomizeentityforclient_set, 1)); )
-                       WITH(entity, self, e, e.uncustomizeentityforclient());
+               FOREACH_ENTITY_FLOAT(uncustomizeentityforclient_set, true, LAMBDA(
+                       WITH(entity, self, it, it.uncustomizeentityforclient());
+               ));
        }
 
        STRING_ITERATOR(g_buf, string_null, 0);
index ded24016f2dc424f0310196b347a6d4c7a2de98d..cb348848950cf0d7733e9d164119aaae393d488a 100644 (file)
@@ -116,15 +116,12 @@ void CreatureFrame_FallDamage(entity this)
 
 void CreatureFrame_All()
 {
-       for(entity e = world; (e = findfloat(e, damagedbycontents, true)); )
-       {
-               if (e.movetype == MOVETYPE_NOCLIP) { continue; }
-
-               CreatureFrame_Liquids(e);
-               CreatureFrame_FallDamage(e);
-
-        e.oldvelocity = e.velocity;
-       }
+       FOREACH_ENTITY_FLOAT(damagedbycontents, true, LAMBDA(
+               if(it.movetype == MOVETYPE_NOCLIP) continue;
+               CreatureFrame_Liquids(it);
+               CreatureFrame_FallDamage(it);
+               it.oldvelocity = it.velocity;
+       ));
 }
 
 void Pause_TryPause(bool ispaused)
@@ -191,8 +188,7 @@ void StartFrame()
        }
 #endif
 
-       for(entity e = world; (e = findfloat(e, csqcprojectile_clientanimate, 1)); )
-               CSQCProjectile_Check(e);
+       FOREACH_ENTITY_FLOAT(csqcprojectile_clientanimate, true, LAMBDA(CSQCProjectile_Check(it)));
 
        if(RedirectionThink())
                return;