Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sounds playing for objects not sent to the client #15734

Closed

Conversation

Emojigit
Copy link
Contributor

@Emojigit Emojigit commented Jan 29, 2025

This PR fixes sounds playing for objects not sent to the client. Does not fix, but make sense anyways.

To do

This PR is Ready for Review.

How to test

  1. Try to reproduce the bug1 without this patch. Sounds from nonexistent objects should be played at full volume.
  2. Apply this patch and try again. This should not happen again.
  3. Confirm that normal object sounds aren't affected by this patch.

Footnotes

  1. I don't know how to reproduce this bug reliably. However, if you're a regular player of LinuxForks, 1F616EMO Survival Server, or any servers with extensive Advtrains network, you should have encountered this at least once.

This PR fixes sounds playing for object not sent to the client.
@Emojigit Emojigit force-pushed the fork-20250130-fix-ghost-sounds branch from 6ece2ad to 790c032 Compare January 30, 2025 00:16
@sfan5 sfan5 added Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines Action / change needed Code still needs changes (PR) / more information requested (Issues) Bugfix 🐛 PRs that fix a bug labels Jan 30, 2025
@Emojigit
Copy link
Contributor Author

Well, not fixed ye...

@Emojigit Emojigit marked this pull request as draft January 30, 2025 13:25
@sfan5
Copy link
Collaborator

sfan5 commented Feb 4, 2025

Even if it doesn't fix the issue you're having the code changes make sense to me. How about merging it in this state?

@Emojigit
Copy link
Contributor Author

Emojigit commented Feb 8, 2025

Okay :-D

@Emojigit Emojigit marked this pull request as ready for review February 8, 2025 04:27
rebuild Outdated Show resolved Hide resolved
@sfan5 sfan5 removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Feb 8, 2025
sfan5
sfan5 previously approved these changes Feb 8, 2025
@Desour
Copy link
Member

Desour commented Feb 10, 2025

There's max_hear_distance, so in normal cases, these sounds only play if the object is near enough, so obj was also sent to the client. If the obj observers feature is used, this is of course not true (the doc also says that attached sounds don't work in this case).
The issue is usually probably rather that the object gets unloaded (e.g. because it gets removed, or it moves away, or the player moves away).

Tested.
/lua local obj = assert(core.add_entity(here:offset(0,0,10), "soundstuff:racecar")) local snd = core.sound_play("soundstuff_mono", {loop = true, object = obj, gain = 10, max_hear_distance = 10000}) core.after(3, function() obj:remove() core.sound_stop(snd) end)

The above code doesn't play a sound with PR, but it should. => PR introduced a bug. 👎
My guess is that the object gets sent to the client after the sound is sent. So I have doubts that the check introduced by this PR can work at all.

@Desour Desour added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Feb 10, 2025
@sfan5
Copy link
Collaborator

sfan5 commented Feb 10, 2025

As it turns out the server sends a position even with SoundLocation::Object, so the fallback code path is actually valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Action / change needed Code still needs changes (PR) / more information requested (Issues) Bugfix 🐛 PRs that fix a bug Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants