Skip to content

Fix fireBullet(), increase MAX_SHOT_DISTANCE

username-removed-84494 requested to merge martin-t/maxshotdist into master

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. I didn't notice any issues with the value (even trying out larger values) and i assume the original value of 32768 was chosen rather arbitrarily as it wouldn't fit into 16bits anyway.

Merge request reports