From: Martin Taibr Date: Fri, 2 Dec 2016 18:43:11 +0000 (+0100) Subject: Fix fireBullet(), increase MAX_SHOT_DISTANCE X-Git-Tag: xonotic-v0.8.2~341^2~5 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=ee2632301ca8c3068048721974e8752a14cc0ca8;p=xonotic%2Fxonotic-data.pk3dir.git Fix fireBullet(), increase MAX_SHOT_DISTANCE Previously, when the nearest target was beyond MAX_SHOT_DISTANCE, the trace ended and the code assumed a wall was hit. It then proceeded to penetrate the non-existent wall up to g_ballistics_mindistance, dropping out of said wall and penetrating the next non-existent wall, repeatedly, until the weapon's solidpenetration was exhausted after going through 50 such walls with overkill's MG, resulting in massive FPS drops and lag spikes on large maps. Now, if nothing is hit, we just bail out immediately. Additionally, I increased MAX_SHOT_DISTANCE to make sure hitscan weapons like MG and vortex don't stop mid air even on large maps. --- diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index b287b148f..b7a60df8a 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -175,7 +175,8 @@ ENDCLASS(OffhandWeapon) .OffhandWeapon offhand; #endif -const int MAX_SHOT_DISTANCE = 32768; +// distance from one corner of a 65536qu cube to the opposite corner is approx. 113512 qu +const int MAX_SHOT_DISTANCE = 120000; // weapon flags const int WEP_TYPE_OTHER = 0x00; // not for damaging people diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index b49ed88f5..2801971f2 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -399,6 +399,10 @@ void fireBullet(entity this, vector start, vector dir, float spread, float max_s start = trace_endpos; entity hit = trace_ent; + // traced up to MAX_SHOT_DISTANCE and didn't hit anything at all + if (trace_fraction == 1.0) + break; + // When hitting sky, stop. if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) break;