MT-CTF / capturetheflag

Capture the Flag game using the Minetest Voxel Engine
https://ctf.rubenwardy.com
83 stars 89 forks source link

Handle positional sounds initating from a player's spot #1257

Closed Emojigit closed 9 months ago

Emojigit commented 9 months ago

This PR splits the sound-playing codes of ranged weapons into two: one for playing to the user and one for playing to the rest of the players.

The code playing sounds from a fixed position is kept but limited to non-users only. This is because the sounds are supposed to be coming from the fixed position where the gunshot starts. Alongside it, another code dedicated to playing sounds to the user is created to fix the sound position to the player's client-side position (because of lag, the server-side and client-side positions may vary, resulting in confusing sound positions).

You may log onto the official CTF server to feel the confusing gunshot sound position. Try to fire a pistol or rifle while running due left or right, and sounds will be played far away. After merging this PR, the issue should be fixed.

Codes in this PR increase the number of sound packets to be sent. Consider this before merging this PR if this would be a notable performance overhead. Otherwise, this PR is ready for review and merging.