]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/_all.qh
Deprecate FOR_EACH_CLIENT and FOR_EACH_CLIENTSLOT
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / _all.qh
index 2b67138bcbfafbfecc248badcf7cbe9a74a025d4..eb3a4845dc1d7dd63ad3fcac9aed9031b60ab63a 100644 (file)
@@ -20,8 +20,8 @@ const string STR_OBSERVER = "observer";
 #define IS_VEHICLE(v) (v.vehicle_flags & VHF_ISVEHICLE)
 #define IS_TURRET(v) (v.turret_flags & TUR_FLAG_ISTURRET)
 
-#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))
+// NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, LAMBDA(yourcode));
+// NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, LAMBDA(yourcode));
 // 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));
@@ -29,17 +29,19 @@ const string STR_OBSERVER = "observer";
 // NOTE: FOR_EACH_OBSERVER deprecated! Use the following instead: FOREACH_CLIENT(IS_OBSERVER(it), LAMBDA(yourcode));
 // NOTE: FOR_EACH_REALPLAYER deprecated! Use the following instead: FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(yourcode));
 
-#define FOREACH_CLIENT(cond, body) \
+#define FOREACH_CLIENTSLOT(cond, body) \
        MACRO_BEGIN { \
                for(int _i = 1; _i <= maxclients; ++_i) \
                { \
                        const noref int i = _i; \
                        const noref entity it = ftoe(i); \
-                       if(it == NULL || !IS_CLIENT(it)) continue; \
+                       if(it == NULL || wasfreed(it)) continue; \
                        if(cond) { LAMBDA(body) } \
                } \
        } MACRO_END
 
+#define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
+
 // NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(yourcode));
 
 #include <common/effects/all.qh>