e.nextthink = time;
Net_LinkEntity(e, false, 0, entcs_send);
if (!IS_REAL_CLIENT(player)) return;
- FOR_EACH_CLIENT(e)
- {
- assert(e.entcs);
- _entcs_send(e.entcs, msg_entity = player, BITS(23), MSG_ONE);
- }
+ FOREACH_CLIENT(true, LAMBDA(
+ assert(it.entcs);
+ _entcs_send(it.entcs, msg_entity = player, BITS(23), MSG_ONE);
+ ));
}
void entcs_detach(entity player)
PlayerScore_Sort(scoreboard_pos, 1, 1, 1);
if(teamplay) { PlayerScore_TeamStats(); }
- entity p;
- FOR_EACH_CLIENT(p)
- {
+ FOREACH_CLIENT(true, LAMBDA(
// add personal score rank
- PS_GR_P_ADDVAL(p, PLAYERSTATS_RANK, p.score_dummyfield);
+ PS_GR_P_ADDVAL(it, PLAYERSTATS_RANK, it.score_dummyfield);
// scoreboard data
- if(p.scoreboard_pos)
+ if(it.scoreboard_pos)
{
// scoreboard is valid!
- PS_GR_P_ADDVAL(p, PLAYERSTATS_SCOREBOARD_VALID, 1);
+ PS_GR_P_ADDVAL(it, PLAYERSTATS_SCOREBOARD_VALID, 1);
// add scoreboard position
- PS_GR_P_ADDVAL(p, PLAYERSTATS_SCOREBOARD_POS, p.scoreboard_pos);
+ PS_GR_P_ADDVAL(it, PLAYERSTATS_SCOREBOARD_POS, it.scoreboard_pos);
// add scoreboard data
- PlayerScore_PlayerStats(p);
+ PlayerScore_PlayerStats(it);
// if the match ended normally, add winning info
if(finished)
{
- PS_GR_P_ADDVAL(p, PLAYERSTATS_WINS, p.winning);
- PS_GR_P_ADDVAL(p, PLAYERSTATS_MATCHES, 1);
+ PS_GR_P_ADDVAL(it, PLAYERSTATS_WINS, it.winning);
+ PS_GR_P_ADDVAL(it, PLAYERSTATS_MATCHES, 1);
}
}
// collect final player information
- PlayerStats_GameReport_FinalizePlayer(p);
- }
+ PlayerStats_GameReport_FinalizePlayer(it);
+ ));
if(autocvar_g_playerstats_gamereport_uri != "")
{
} \
} MACRO_END
-#define FOR_EACH_MONSTER(v) for (v = world; (v = findflags(v, flags, FL_MONSTER)) != world; )
+// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(yourcode));
#include "../common/effects/all.qh"
#include "../common/models/all.qh"
float bot_cmd_barrier()
{SELFPARAM();
- entity cl;
-
// 0 = no barrier, 1 = waiting, 2 = waiting finished
if(self.bot_barrier == 0) // initialization
if(self.bot_barrier == 1) // find other bots
{
- FOR_EACH_CLIENT(cl) if(cl.isbot)
- {
- if(cl.bot_cmdqueuebuf_allocated)
- if(cl.bot_barrier != 1)
- return CMD_STATUS_EXECUTING; // not all are at the barrier yet
- }
+ FOREACH_CLIENT(it.isbot, LAMBDA(
+ if(it.bot_cmdqueuebuf_allocated)
+ if(it.bot_barrier != 1)
+ return CMD_STATUS_EXECUTING; // not all are at the barrier yet
+ ));
// all bots hit the barrier!
- FOR_EACH_CLIENT(cl) if(cl.isbot)
- {
- cl.bot_barrier = 2; // acknowledge barrier
- }
+
+ // acknowledge barrier
+ FOREACH_CLIENT(it.isbot, LAMBDA(it.bot_barrier = 2));
bot_barriertime = time;
}
void bot_resetqueues()
{
- entity cl;
-
- FOR_EACH_CLIENT(cl) if(cl.isbot)
- {
- cl.bot_cmd_execution_index = 0;
- bot_clearqueue(cl);
+ FOREACH_CLIENT(it.isbot, LAMBDA(
+ it.bot_cmd_execution_index = 0;
+ bot_clearqueue(it);
// also, cancel all barriers
- cl.bot_barrier = 0;
- for(int i = 0; i < cl.bot_places_count; ++i)
+ it.bot_barrier = 0;
+ for(int i = 0; i < it.bot_places_count; ++i)
{
- strunzone(cl.(bot_placenames[i]));
- cl.(bot_placenames[i]) = string_null;
+ strunzone(it.(bot_placenames[i]));
+ it.(bot_placenames[i]) = string_null;
}
- cl.bot_places_count = 0;
- }
+ it.bot_places_count = 0;
+ ));
bot_barriertime = time;
}
if (arg_lower == "list") { print_to(caller, monsterlist_reply); return; }
- FOR_EACH_MONSTER(mon)
- {
- if (mon.realowner == caller) ++tmp_moncount;
- }
+ FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
+ if(it.realowner == caller)
+ ++tmp_moncount;
+ ));
if (!autocvar_g_monsters) { print_to(caller, "Monsters are disabled"); return; }
if (autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { print_to(caller, "Monster spawning is disabled"); return; }
if (MUTATOR_CALLHOOK(AllowMobButcher)) { LOG_INFO(ret_string, "\n"); return; }
int tmp_remcount = 0;
- entity tmp_entity;
- FOR_EACH_MONSTER(tmp_entity)
- {
- Monster_Remove(tmp_entity);
+ FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
+ Monster_Remove(it);
++tmp_remcount;
- }
+ ));
monsters_total = monsters_killed = totalspawned = 0;
race_ClearRecords();
PlayerScore_Sort(race_place, 0, 1, 0);
- entity e;
- FOR_EACH_CLIENT(e)
- {
- if(e.race_place)
+ FOREACH_CLIENT(true, LAMBDA(
+ if(it.race_place)
{
- s = PlayerScore_Add(e, SP_RACE_FASTEST, 0);
+ s = PlayerScore_Add(it, SP_RACE_FASTEST, 0);
if(!s)
- e.race_place = 0;
+ it.race_place = 0;
}
- cts_EventLog(ftos(e.race_place), e);
- }
+ cts_EventLog(ftos(it.race_place), it);
+ ));
if(g_race_qualifying == 2)
{
if (b == accuracy_byte(a.accuracy_hit[w], a.accuracy_fired[w])) return; // no change
int sf = 1 << (w % 24);
a.SendFlags |= sf;
- entity e; FOR_EACH_CLIENT(e) if (IS_SPEC(e)) if (e.enemy == this) {
- e.accuracy.SendFlags |= sf;
- }
+ FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, LAMBDA(it.accuracy.SendFlags |= sf));
}
bool accuracy_isgooddamage(entity attacker, entity targ)