Closed Jabka666 closed 1 year ago
There is a lot of code duplication here: e.g. stopping/removing/dereferencing sounds could've been consolidated to a single function, as well as checking if the channel is non-zero before trying to pause/resume it. But it is still an improvement over the old code, and the fixes seem to work, so I'll go ahead and merge this.
I'm gonna improve that by removing CHN <> 0
checking. Any channel function returns a null parameter, so we don't need to check if channel exists. ChannelPlaying
will be used instead and only for loops
ChannelPlaying
checks fromRemoveNPC
,KillSounds
,ResumeSounds
andPauseSounds
function. We don't need to check if the sound is playing, enough to know does it exist or not;CoughCHN
,VomitCHN
andRadioCHN
toPauseSounds
,ResumeSounds
andKillSounds
function;UpdateSoundOrigin(2)
andUpdateStreamSoundOrigin
function, so we don't need to check manually if the sound is existing. First, we don't need to try apply channel functions to null channel and produce unnecessary calculations. Second, added sound playing check because we need to use these functions only when the sound is playing.FreeSound
,StopChannel
and etc. don't finally frees the memory, so I addedCHN = 0
lines.Failed to find stream Sound: Unknown Stream
console error appearing in: 1) SCP-079's chamber after finishingSpeech.ogg
sound; 2) Gate B area after playingAlphaWarheadsFail.ogg
sound; 3) I'm not sure, but sometimes I saw this error for SCP-096. I noticedn\SoundChn2_IsStream = 2
line that should haveTrue
value instead of2
. Maybe it shouldn't, who knows ¯_(ツ)_/¯ ; Always reset_isStream
parameter while removing a channel for preventing any confuses inUpdateStreamSounds
function. Also added more sound exist checks for preventingUnknow stream
error;ChannelVolume (Chn, 0)
line toUpdateSoundOrigin(2)
function to prevent sound from being assigned a negative volume when sound emitter out of range.Note:
RadioCHN
channel placed only inKillSounds
because placing inResumeSounds
andPauseSounds
doesn't affect on the channel. To do!