snd_playing issue A8

Posted By: Dooley

snd_playing issue A8 - 06/26/19 17:59

This is more of a report than a question. I am updating my game from A7 to A8.

This issue only seems to matter in Published games, and will not appear when run through WED.

It happens if I use snd_playing() to check if a sound handle is currently playing. If I have not already assigned that handle to play a sound, then it seems it will crash the game.

Previously this worked okay, and I would run looping sounds by checking if the sound was playing first, then, if it had stopped, or had not started yet, I would play the sound. For some reason, using snd_loop caused other problems for me, especially when I had many of them playing, so I would play my looping sounds with snd_play, and just perform this check in the entity while loop. In a few cases, I had certain sounds that did not loop continually, but would play sporadically, like when you fire your jet pack, for instance. So the jet pack sound would loop as long as you were holding "space" but until you used it, it would not play the sound. This is the case in which I found this problem.

The fix seems to be to simply assign the handle with a snd_play when it is declared, so snd_playing recognizes the variable as a sound handle.
Posted By: Dooley

Re: snd_playing issue A8 - 06/26/19 19:17

Ah... this is only a problem if your variable is not initialized to 0.
Posted By: txesmi

Re: snd_playing issue A8 - 06/27/19 09:39

Next time you will know that everything should be initialized grin
Posted By: Dooley

Re: snd_playing issue A8 - 06/27/19 15:53

I'm wondering how A7 was able to handle this, but A8 is not. In any case, I figure it is probably good for the game, the old version might not have crashed right away, but maybe it opened up some memory leak because of this. There were some seemingly random crashes happening in the old version, that I never could pin down.
© 2024 lite-C Forums