From: Mario Date: Wed, 27 Dec 2017 14:41:56 +0000 (+1000) Subject: Since viewlocation only applies to players, use a much cheaper loop through clients X-Git-Tag: xonotic-v0.8.5~2400 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a3b5728a6344a1637a53cac2e7473656d583913f;p=xonotic%2Fxonotic-data.pk3dir.git Since viewlocation only applies to players, use a much cheaper loop through clients --- diff --git a/qcsrc/common/triggers/trigger/viewloc.qc b/qcsrc/common/triggers/trigger/viewloc.qc index a99cdb4f2..41394ac43 100644 --- a/qcsrc/common/triggers/trigger/viewloc.qc +++ b/qcsrc/common/triggers/trigger/viewloc.qc @@ -13,13 +13,37 @@ REGISTER_NET_LINKED(ENT_CLIENT_VIEWLOC_TRIGGER) void viewloc_think(entity this) { - entity e; - // we abuse this method, rather than using normal .touch, because touch isn't reliable with multiple clients inside the same trigger, and can't "untouch" entities // set myself as current viewloc where possible +#if 1 + FOREACH_CLIENT(it.viewloc == this, + { + it.viewloc = NULL; + }); +#else + entity e; for(e = NULL; (e = findentity(e, viewloc, this)); ) e.viewloc = NULL; +#endif + +#if 1 + FOREACH_CLIENT(!it.viewloc && IS_PLAYER(it), + { + vector emin = it.absmin; + vector emax = it.absmax; + if(this.solid == SOLID_BSP) + { + emin -= '1 1 1'; + emax += '1 1 1'; + } + if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick + { + if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, it)) // accurate + it.viewloc = this; + } + }); +#else for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain) if(!e.viewloc) @@ -37,6 +61,7 @@ void viewloc_think(entity this) if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate e.viewloc = this; } +#endif this.nextthink = time; }