[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
This commit is contained in:
CitadelStationBot
2018-03-13 05:46:27 -05:00
committed by Poojawa
parent 8dc9fcf816
commit dff9dabf06
5 changed files with 20 additions and 11 deletions

View File

@@ -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

View File

@@ -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, "<span class='boldwarning'>BLOCKED: Content URL not using http(s) protocol</span>")
to_chat(src, "<span class='warning'>The media provider returned a content URL that isn't using the HTTP or HTTPS protocol</span>")
if(web_sound_url && !findtext(web_sound_url, GLOB.is_http_protocol))
to_chat(src, "<span class='boldwarning'>BLOCKED: Content URL not using http(s) protocol</span>")
to_chat(src, "<span class='warning'>The media provider returned a content URL that isn't using the HTTP or HTTPS protocol</span>")
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!

View File

@@ -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!

View File

@@ -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)

View File

@@ -442,6 +442,8 @@ function ehjaxCallback(data) {
} else if (data == 'roundrestart') {
opts.restarting = true;
internalOutput('<div class="connectionClosed internal restarting">The connection has been closed because the server is restarting. Please wait while you automatically reconnect.</div>', 'internal');
} else if (data == 'stopMusic') {
$('#adminMusic').prop('src', '');
} else {
//Oh we're actually being sent data instead of an instruction
var dataJ;