diff --git a/code/__DEFINES/sound.dm b/code/__DEFINES/sound.dm index ef1db9a79bc..712c57b3b3e 100644 --- a/code/__DEFINES/sound.dm +++ b/code/__DEFINES/sound.dm @@ -6,6 +6,11 @@ #define CHANNEL_BUZZ 1020 #define CHANNEL_AMBIENCE 1019 +//THIS SHOULD ALWAYS BE THE LOWEST ONE! +//KEEP IT UPDATED + +#define CHANNEL_HIGHEST_AVAILABLE 1018 + #define SOUND_MINIMUM_PRESSURE 10 #define FALLOFF_SOUNDS 0.5 \ No newline at end of file diff --git a/code/game/sound.dm b/code/game/sound.dm index be785660602..39bf16bc697 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -5,6 +5,9 @@ var/turf/turf_source = get_turf(source) + //allocate a channel if necessary now so its the same for everyone + channel = channel || open_sound_channel() + // Looping through the player list has the added bonus of working for mobs inside containers var/sound/S = sound(get_sfx(soundin)) var/maxdistance = (world.view + extrarange) * 3 @@ -21,14 +24,14 @@ M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, channel, pressure_affected, S) /mob/proc/playsound_local(turf/turf_source, soundin, vol as num, vary, frequency, falloff, channel = 0, pressure_affected = TRUE, sound/S) - if(!src.client || !can_hear()) + if(!client || !can_hear()) return if(!S) S = sound(get_sfx(soundin)) S.wait = 0 //No queue - S.channel = channel + S.channel = channel || open_sound_channel() S.volume = vol if(vary) @@ -83,6 +86,12 @@ if(prefs.sound & SOUND_LOBBY) src << sound(ticker.login_music, repeat = 0, wait = 0, volume = 85, channel = CHANNEL_LOBBYMUSIC) // MAD JAMS +/proc/open_sound_channel() + var/static/next_channel = 1 //loop through the available 1024 - (the ones we reserve) channels and pray that its not still being used + . = ++next_channel + if(next_channel > CHANNEL_HIGHEST_AVAILABLE) + next_channel = 1 + /mob/proc/stop_sound_channel(chan) src << sound(null, repeat = 0, wait = 0, channel = chan) diff --git a/code/modules/spacepods/spacepod.dm b/code/modules/spacepods/spacepod.dm index 615b405daa2..e2a21f507fa 100644 --- a/code/modules/spacepods/spacepod.dm +++ b/code/modules/spacepods/spacepod.dm @@ -284,7 +284,7 @@ return var/sound/S = sound(mysound) S.wait = 0 //No queue - S.channel = 0 + S.channel = open_sound_channel() S.volume = 50 for(var/mob/M in passengers | pilot) M << S