Fix unreliable Sounds index retrieval
Our sound code is extremely confusing, so it's no wonder that the author of these functions could not find snd_get_sound_id, which is the handle into the Sounds vector. And it's no wonder that it was missed in review either.
Also some cleanup in the main function that was causing #5899
Fixes #5899
EDIT: By the way, I would love if someone could double check my tests and make sure doors are working as they are supposed to.
Oh nice work. I added this assert when I couldn't figure out the root cause... Having worked in the sound code, I do not envy the headache this probably caused you while figuring it out.
I took a cursory look at the changes and it looks good so far based on what I can remember. I'll give it a real review in the AM if no one else does first.