#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));
// 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>
return Ban_MaybeEnforceBan(client);
}
-string Ban_Enforce(float i, string reason)
+string Ban_Enforce(float j, string reason)
{
string s;
- entity e;
// Enforce our new ban
s = "";
- FOR_EACH_CLIENTSLOT(e)
- if (IS_REAL_CLIENT(e))
- if(Ban_IsClientBanned(e, i))
+ FOREACH_CLIENTSLOT(IS_REAL_CLIENT(it),
+ {
+ if(Ban_IsClientBanned(it, j))
{
if(reason != "")
{
reason = strcat(reason, ": affects ");
else
reason = strcat(reason, ", ");
- reason = strcat(reason, e.netname);
+ reason = strcat(reason, it.netname);
}
- s = strcat(s, "^1NOTE:^7 banned client ", e.netaddress, "^7 has to go\n");
- dropclient(e);
+ s = strcat(s, "^1NOTE:^7 banned client ", it.netaddress, "^7 has to go\n");
+ dropclient(it);
}
+ });
bprint(s);
return reason;
void Score_ClearAll()
{
- entity p, sk;
- float i, t;
- FOR_EACH_CLIENTSLOT(p)
+ entity sk;
+ float t;
+ FOREACH_CLIENTSLOT(true,
{
- sk = p.scorekeeper;
+ sk = it.scorekeeper;
if(!sk)
continue;
- for(i = 0; i < MAX_SCORE; ++i)
+ for(int j = 0; j < MAX_SCORE; ++j)
{
- if(sk.(scores[i]) != 0)
- if(scores_label[i] != "")
- sk.SendFlags |= pow(2, i);
- sk.(scores[i]) = 0;
+ if(sk.(scores[j]) != 0)
+ if(scores_label[j] != "")
+ sk.SendFlags |= pow(2, j);
+ sk.(scores[j]) = 0;
}
- }
+ });
for(t = 0; t < 16; ++t)
{
sk = teamscorekeepers[t];
if(!sk)
continue;
- for(i = 0; i < MAX_TEAMSCORE; ++i)
+ for(int j = 0; j < MAX_TEAMSCORE; ++j)
{
- if(sk.(teamscores[i]) != 0)
- if(teamscores_label[i] != "")
- sk.SendFlags |= pow(2, i);
- sk.(teamscores[i]) = 0;
+ if(sk.(teamscores[j]) != 0)
+ if(teamscores_label[j] != "")
+ sk.SendFlags |= pow(2, j);
+ sk.(teamscores[j]) = 0;
}
}
}
FOREACH_CLIENT(true, LAMBDA(it.(field) = 0));
- FOR_EACH_CLIENT(p) if(p.scorekeeper)
+ FOREACH_CLIENT(it.scorekeeper,
{
if(nospectators)
- if(p.frags == FRAGS_SPECTATOR)
+ if(it.frags == FRAGS_SPECTATOR)
continue;
- p.chain = plist;
- plist = p;
- }
+ it.chain = plist;
+ plist = it;
+ });
// Now plist points to the whole list.
pfirst = plast = world;