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.
.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
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;