From dff9dabf068fae39f2fcbe2c2d6809fb8811d3bf Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Tue, 13 Mar 2018 05:46:27 -0500 Subject: [PATCH] [MIRROR] Fixes stopsounds properly (#5931) * Fixes stopsounds properly (#36341) * Revert "Merge pull request #36340 from vuonojenmustaturska/beelogreen" This reverts commit 259838f38cfda32619e34cf41d57df4d45b75363, reversing changes made to 111cd316a92f5f5840d96b1fc4bbe4cb7b1ce6fd. * Fixes stopsounds properly Also I forgot to actually block admins from bad protocols it just showed them a message that it was blocked but didn't block it * Fixes stopsounds properly --- code/__DEFINES/misc.dm | 2 -- code/modules/admin/verbs/playsound.dm | 20 ++++++++++++------- code/modules/client/preferences_toggles.dm | 4 ++-- code/modules/goonchat/browserOutput.dm | 3 +++ .../browserassets/js/browserOutput.js | 2 ++ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 469330d398..199535a04e 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -433,8 +433,6 @@ GLOBAL_LIST_INIT(ghost_others_options, list(GHOST_OTHERS_SIMPLE, GHOST_OTHERS_DE #define SUMMON_GUNS "guns" #define SUMMON_MAGIC "magic" -#define STOP_SOUNDS_URL "http://" - //Run the world with this parameter to enable a single run though of the game setup and tear down process with unit tests in between #define TEST_RUN_PARAMETER "test-run" //Force the log directory to be something specific in the data/logs folder diff --git a/code/modules/admin/verbs/playsound.dm b/code/modules/admin/verbs/playsound.dm index 3d96cbfc91..2f5cc59ec1 100644 --- a/code/modules/admin/verbs/playsound.dm +++ b/code/modules/admin/verbs/playsound.dm @@ -70,6 +70,7 @@ var/web_sound_input = input("Enter content URL (supported sites only, leave blank to stop playing)", "Play Internet Sound via youtube-dl") as text|null if(istext(web_sound_input)) var/web_sound_url = "" + var/stop_web_sounds = FALSE var/pitch if(length(web_sound_input)) @@ -120,17 +121,22 @@ else //pressed ok with blank log_admin("[key_name(src)] stopped web sound") message_admins("[key_name(src)] stopped web sound") - web_sound_url = STOP_SOUNDS_URL + web_sound_url = null + stop_web_sounds = TRUE - if(web_sound_url) - if(!findtext(web_sound_url, GLOB.is_http_protocol)) - to_chat(src, "BLOCKED: Content URL not using http(s) protocol") - to_chat(src, "The media provider returned a content URL that isn't using the HTTP or HTTPS protocol") + if(web_sound_url && !findtext(web_sound_url, GLOB.is_http_protocol)) + to_chat(src, "BLOCKED: Content URL not using http(s) protocol") + to_chat(src, "The media provider returned a content URL that isn't using the HTTP or HTTPS protocol") + return + if(web_sound_url || stop_web_sounds) for(var/m in GLOB.player_list) var/mob/M = m var/client/C = M.client if((C.prefs.toggles & SOUND_MIDI) && C.chatOutput && !C.chatOutput.broken && C.chatOutput.loaded) - C.chatOutput.sendMusic(web_sound_url, pitch) + if(!stop_web_sounds) + C.chatOutput.sendMusic(web_sound_url, pitch) + else + C.chatOutput.stopMusic() SSblackbox.record_feedback("tally", "admin_verb", 1, "Play Internet Sound") @@ -159,5 +165,5 @@ SEND_SOUND(M, sound(null)) var/client/C = M.client if(C && C.chatOutput && !C.chatOutput.broken && C.chatOutput.loaded) - C.chatOutput.sendMusic(STOP_SOUNDS_URL) + C.chatOutput.stopMusic() SSblackbox.record_feedback("tally", "admin_verb", 1, "Stop All Playing Sounds") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/client/preferences_toggles.dm b/code/modules/client/preferences_toggles.dm index 32328d555b..367a11c2cb 100644 --- a/code/modules/client/preferences_toggles.dm +++ b/code/modules/client/preferences_toggles.dm @@ -146,7 +146,7 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, togglemidis)() usr.stop_sound_channel(CHANNEL_ADMIN) var/client/C = usr.client if(C && C.chatOutput && !C.chatOutput.broken && C.chatOutput.loaded) - C.chatOutput.sendMusic(" ") + C.chatOutput.stopMusic() SSblackbox.record_feedback("nested tally", "preferences_verb", 1, list("Toggle Hearing Midis", "[usr.client.prefs.toggles & SOUND_MIDI ? "Enabled" : "Disabled"]")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! /datum/verbs/menu/Settings/Sound/togglemidis/Get_checked(client/C) return C.prefs.toggles & SOUND_MIDI @@ -235,7 +235,7 @@ TOGGLE_CHECKBOX(/datum/verbs/menu/Settings/Sound, toggleprayersounds)() SEND_SOUND(usr, sound(null)) var/client/C = usr.client if(C && C.chatOutput && !C.chatOutput.broken && C.chatOutput.loaded) - C.chatOutput.sendMusic(STOP_SOUNDS_URL) + C.chatOutput.stopMusic() SSblackbox.record_feedback("nested tally", "preferences_verb", 1, list("Stop Self Sounds")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/goonchat/browserOutput.dm b/code/modules/goonchat/browserOutput.dm index 7ac3724662..401e55c9e5 100644 --- a/code/modules/goonchat/browserOutput.dm +++ b/code/modules/goonchat/browserOutput.dm @@ -132,6 +132,9 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic music_data["musicRate"] = pitch ehjax_send(data = music_data) +/datum/chatOutput/proc/stopMusic() + ehjax_send(data = "stopMusic") + /datum/chatOutput/proc/setMusicVolume(volume = "") if(volume) adminMusicVolume = CLAMP(text2num(volume), 0, 100) diff --git a/code/modules/goonchat/browserassets/js/browserOutput.js b/code/modules/goonchat/browserassets/js/browserOutput.js index 77aae1148a..478ddcccdd 100644 --- a/code/modules/goonchat/browserassets/js/browserOutput.js +++ b/code/modules/goonchat/browserassets/js/browserOutput.js @@ -442,6 +442,8 @@ function ehjaxCallback(data) { } else if (data == 'roundrestart') { opts.restarting = true; internalOutput('
The connection has been closed because the server is restarting. Please wait while you automatically reconnect.
', 'internal'); + } else if (data == 'stopMusic') { + $('#adminMusic').prop('src', ''); } else { //Oh we're actually being sent data instead of an instruction var dataJ;