From 3d53f888b1bc9625a5fb9dc8396fa2014e055771 Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Mon, 31 Jul 2017 14:35:16 -0500 Subject: [PATCH] Improves several Sound Loops' Performance --- code/datums/explosion.dm | 8 +++++--- code/game/gamemodes/meteor/meteors.dm | 5 ++++- code/game/machinery/dance_machine.dm | 4 +++- code/game/objects/structures/musician.dm | 4 +++- code/modules/power/gravitygenerator.dm | 3 ++- code/modules/ruins/objects_and_mobs/necropolis_gate.dm | 4 +++- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/code/datums/explosion.dm b/code/datums/explosion.dm index ae0398e59b..c22829b5d3 100644 --- a/code/datums/explosion.dm +++ b/code/datums/explosion.dm @@ -96,7 +96,9 @@ GLOBAL_LIST_EMPTY(explosions) if(!silent) var/frequency = get_rand_frequency() - var/ex_sound = get_sfx("explosion") + var/sound/explosion_sound = sound(get_sfx("explosion")) + var/sound/far_explosion_sound = sound('sound/effects/explosionfar.ogg') + for(var/mob/M in GLOB.player_list) // Double check for client var/turf/M_turf = get_turf(M) @@ -104,12 +106,12 @@ GLOBAL_LIST_EMPTY(explosions) var/dist = get_dist(M_turf, epicenter) // If inside the blast radius + world.view - 2 if(dist <= round(max_range + world.view - 2, 1)) - M.playsound_local(epicenter, ex_sound, 100, 1, frequency, falloff = 5) + M.playsound_local(epicenter, null, 100, 1, frequency, falloff = 5, S = explosion_sound) // You hear a far explosion if you're outside the blast radius. Small bombs shouldn't be heard all over the station. else if(dist <= far_dist) var/far_volume = Clamp(far_dist, 30, 50) // Volume is based on explosion size and dist far_volume += (dist <= far_dist * 0.5 ? 50 : 0) // add 50 volume if the mob is pretty close to the explosion - M.playsound_local(epicenter, 'sound/effects/explosionfar.ogg', far_volume, 1, frequency, falloff = 5) + M.playsound_local(epicenter, null, far_volume, 1, frequency, falloff = 5, S = far_explosion_sound) EX_PREPROCESS_CHECK_TICK //postpone processing for a bit diff --git a/code/game/gamemodes/meteor/meteors.dm b/code/game/gamemodes/meteor/meteors.dm index 167df98b50..65ea714761 100644 --- a/code/game/gamemodes/meteor/meteors.dm +++ b/code/game/gamemodes/meteor/meteors.dm @@ -185,6 +185,9 @@ GLOBAL_LIST_INIT(meteorsC, list(/obj/effect/meteor/dust)) //for space dust event /obj/effect/meteor/proc/meteor_effect() if(heavy) + var/sound/meteor_sound = sound(meteorsound) + var/random_frequency = get_rand_frequency() + for(var/mob/M in GLOB.player_list) if((M.orbiting) && (SSaugury.watchers[M])) continue @@ -193,7 +196,7 @@ GLOBAL_LIST_INIT(meteorsC, list(/obj/effect/meteor/dust)) //for space dust event continue var/dist = get_dist(M.loc, src.loc) shake_camera(M, dist > 20 ? 2 : 4, dist > 20 ? 1 : 3) - M.playsound_local(src.loc, meteorsound, 50, 1, get_rand_frequency(), 10) + M.playsound_local(src.loc, null, 50, 1, random_frequency, 10, S = meteor_sound) /////////////////////// //Meteor types diff --git a/code/game/machinery/dance_machine.dm b/code/game/machinery/dance_machine.dm index 8c9e300eaa..5100ece31f 100644 --- a/code/game/machinery/dance_machine.dm +++ b/code/game/machinery/dance_machine.dm @@ -456,10 +456,12 @@ if(charge<35) charge += 1 if(world.time < stop && active) + var/sound/song_played = sound(selection.song_path) + for(var/mob/M in range(10,src)) if(!(M in rangers)) rangers[M] = TRUE - M.playsound_local(get_turf(M), selection.song_path, 100, channel = CHANNEL_JUKEBOX) + M.playsound_local(get_turf(M), null, 100, channel = CHANNEL_JUKEBOX, S = song_played) if(prob(5+(allowed(M)*4)) && M.canmove) dance(M) for(var/mob/L in rangers) diff --git a/code/game/objects/structures/musician.dm b/code/game/objects/structures/musician.dm index b57ab68641..1331a5aeea 100644 --- a/code/game/objects/structures/musician.dm +++ b/code/game/objects/structures/musician.dm @@ -71,9 +71,11 @@ continue LAZYADD(hearing_mobs, M) last_hearcheck = world.time + + var/sound/music_played = sound(soundfile) for(var/i in hearing_mobs) var/mob/M = i - M.playsound_local(source, soundfile, 100, falloff = 5) + M.playsound_local(source, null, 100, falloff = 5, S = music_played) /datum/song/proc/updateDialog(mob/user) instrumentObj.updateDialog() // assumes it's an object in world, override if otherwise diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index 36804b6121..4b3b5bcd46 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -372,13 +372,14 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne // Shake everyone on the z level to let them know that gravity was enagaged/disenagaged. /obj/machinery/gravity_generator/main/proc/shake_everyone() var/turf/T = get_turf(src) + var/sound/alert_sound = sound('sound/effects/alert.ogg') for(var/mob/M in GLOB.mob_list) if(M.z != z) continue M.update_gravity(M.mob_has_gravity()) if(M.client) shake_camera(M, 15, 1) - M.playsound_local(T, 'sound/effects/alert.ogg', 100, 1, 0.5) + M.playsound_local(T, null, 100, 1, 0.5, S = alert_sound) /obj/machinery/gravity_generator/main/proc/gravity_in_level() var/turf/T = get_turf(src) diff --git a/code/modules/ruins/objects_and_mobs/necropolis_gate.dm b/code/modules/ruins/objects_and_mobs/necropolis_gate.dm index df404146bf..3bda50c221 100644 --- a/code/modules/ruins/objects_and_mobs/necropolis_gate.dm +++ b/code/modules/ruins/objects_and_mobs/necropolis_gate.dm @@ -175,10 +175,12 @@ GLOBAL_DATUM(necropolis_gate, /obj/structure/necropolis_gate/legion_gate) else message_admins("[user ? key_name_admin(user):"Unknown"] has released Legion!") log_game("[user ? key_name(user):"Unknown"] released Legion.") + + var/sound/legion_sound = sound('sound/creatures/legion_spawn.ogg') for(var/mob/M in GLOB.player_list) if(M.z == z) to_chat(M, "Discordant whispers flood your mind in a thousand voices. Each one speaks your name, over and over. Something horrible has been released.") - M.playsound_local(T, 'sound/creatures/legion_spawn.ogg', 100, FALSE, 0, FALSE, pressure_affected = FALSE) + M.playsound_local(T, null, 100, FALSE, 0, FALSE, pressure_affected = FALSE, S = legion_sound) flash_color(M, flash_color = "#FF0000", flash_time = 50) var/mutable_appearance/release_overlay = mutable_appearance('icons/effects/effects.dmi', "legiondoor") notify_ghosts("Legion has been released in the [get_area(src)]!", source = src, alert_overlay = release_overlay, action = NOTIFY_JUMP)