From 4805fc36afa9e74a6fe912dda0908c00675cb102 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 24 Dec 2015 15:39:12 +1000 Subject: [PATCH] Loops --- qcsrc/common/effects/all.qc | 2 +- qcsrc/server/sv_main.qc | 16 ++++++---------- qcsrc/server/weapons/tracing.qc | 32 ++++++++++++++++++++------------ 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/qcsrc/common/effects/all.qc b/qcsrc/common/effects/all.qc index 8c13a68f6..663526bcc 100644 --- a/qcsrc/common/effects/all.qc +++ b/qcsrc/common/effects/all.qc @@ -76,7 +76,7 @@ void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt) net_eff.eent_net_count = eff_cnt; net_eff.eent_eff_trail = eff.eent_eff_trail; - entity e; FOR_EACH_REALCLIENT(e) Net_Write_Effect(net_eff, e, 0); + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(Net_Write_Effect(net_eff, it, 0))); remove(net_eff); } diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 2433dc163..3ecd4714b 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -127,12 +127,10 @@ void CreatureFrame_All() void Pause_TryPause(bool ispaused) { int n = 0; - entity it; - FOR_EACH_REALPLAYER(it) - { + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA( if (PHYS_INPUT_BUTTON_CHAT(it) != ispaused) return; ++n; - } + )); if (!n) return; setpause(ispaused); } @@ -173,14 +171,12 @@ void StartFrame() LOG_INFO("CEFC time: ", ftos(t * 1000), "ms; "); int c_seeing = 0; int c_seen = 0; - entity cl; - FOR_EACH_CLIENT(cl) - { - if(IS_REAL_CLIENT(cl)) + FOREACH_CLIENT(true, LAMBDA( + if(IS_REAL_CLIENT(it)) ++c_seeing; - if(IS_PLAYER(cl)) + if(IS_PLAYER(it)) ++c_seen; - } + )); LOG_INFO("CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; "); LOG_INFO("CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0'), "\n"); diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index def2477c7..9827f0abe 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -277,23 +277,31 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f // Find all non-hit players the beam passed close by if(deathtype == WEP_VAPORIZER.m_id || deathtype == WEP_VORTEX.m_id) { + FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != self, LAMBDA( + if(!it.railgunhit) + if(!(IS_SPEC(it) && it.enemy == self)) + { + msg_entity = it; + // nearest point on the beam + beampos = start + dir * bound(0, (msg_entity.origin - start) * dir, length); + + f = bound(0, 1 - vlen(beampos - msg_entity.origin) / 512, 1); + if(f <= 0) + continue; + + snd = SND(NEXWHOOSH_RANDOM()); + + if(!pseudoprojectile) + pseudoprojectile = spawn(); // we need this so the sound uses the "entchannel4" volume + soundtoat(MSG_ONE, pseudoprojectile, beampos, CH_SHOTS, snd, VOL_BASE * f, ATTEN_NONE); + } + )); FOR_EACH_REALCLIENT(msg_entity) if(msg_entity != self) if(!msg_entity.railgunhit) if(!(IS_SPEC(msg_entity) && msg_entity.enemy == self)) // we use realclient, so spectators can hear the whoosh too { - // nearest point on the beam - beampos = start + dir * bound(0, (msg_entity.origin - start) * dir, length); - - f = bound(0, 1 - vlen(beampos - msg_entity.origin) / 512, 1); - if(f <= 0) - continue; - - snd = SND(NEXWHOOSH_RANDOM()); - - if(!pseudoprojectile) - pseudoprojectile = spawn(); // we need this so the sound uses the "entchannel4" volume - soundtoat(MSG_ONE, pseudoprojectile, beampos, CH_SHOTS, snd, VOL_BASE * f, ATTEN_NONE); + } if(pseudoprojectile) -- 2.39.2