]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/_all.qh
Iter: prevent invalidation
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / _all.qh
index 2920a7659fec842c6b08e29b68129dbd52cc3ee6..3636f89848037cf7770455030fc5203bd9b2c7f6 100644 (file)
@@ -22,7 +22,7 @@ const string STR_OBSERVER = "observer";
 
 #define FOR_EACH_CLIENTSLOT(v) for (v = world; (v = nextent(v)) && (etof(v) <= maxclients); )
 #define FOR_EACH_CLIENT(v) FOR_EACH_CLIENTSLOT(v) if (IS_CLIENT(v))
-#define FOR_EACH_REALCLIENT(v) FOR_EACH_CLIENT(v) if (IS_REAL_CLIENT(v))
+// NOTE: FOR_EACH_REALCLIENT deprecated! Use the following instead: FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(yourcode));
 
 // NOTE: FOR_EACH_PLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(yourcode));
 // NOTE: FOR_EACH_SPEC deprecated! Use the following instead: FOREACH_CLIENT(IS_SPEC(it), LAMBDA(yourcode));
@@ -31,9 +31,10 @@ const string STR_OBSERVER = "observer";
 
 #define FOREACH_CLIENT(cond, body) \
        MACRO_BEGIN { \
-               for(int i = 1; i <= maxclients; ++i) \
+               for(int _i = 1; _i <= maxclients; ++_i) \
                { \
-                       entity it = ftoe(i); \
+                       const noref int i = _i; \
+                       const noref entity it = ftoe(i); \
                        if(it == NULL || !IS_CLIENT(it)) continue; \
                        if(cond) { LAMBDA(body) } \
                } \