From bbd020b4366fe09793475175f9b347ac514a7db5 Mon Sep 17 00:00:00 2001 From: "elly1989@rocketmail.com" Date: Sun, 2 Sep 2012 22:32:24 +0000 Subject: [PATCH] Runtime fixes for: runtime error: bad icon operation proc name: New (/icon/New) usr: Charles Mycroft (/mob/living/carbon/human) src: /icon (/icon) call stack: /icon (/icon): New("plating", "metal1", null, null, null) the wall (185,137,1) (/turf/simulated/wall): clean blood() Space cleaner (/datum/reagent/space_cleaner): reaction turf(the wall (185,137,1) (/turf/simulated/wall), 11.6) /datum/reagents (/datum/reagents): reaction(the wall (185,137,1) (/turf/simulated/wall), 1, 10) runtime error: list index out of bounds proc name: Topic (/obj/structure/device/piano/Topic) source file: musician.dm,525 usr: Toto (/mob/living/carbon/human) src: the space minimoog (/obj/structure/device/piano) call stack: the space minimoog (/obj/structure/device/piano): Topic("src=\[0x200723e];modifyline=1", /list (/list)) Octisetti (/client): Topic("src=\[0x200723e];modifyline=1", /list (/list), the space minimoog (/obj/structure/device/piano)) Added sanitization to user inputs in piano/Topic() git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4605 316c924e-a436-60f5-8080-3fe189b3f50e --- code/game/atom_procs.dm | 68 ++- code/game/objects/structures/musician.dm | 677 +++++++++-------------- 2 files changed, 288 insertions(+), 457 deletions(-) diff --git a/code/game/atom_procs.dm b/code/game/atom_procs.dm index c300379f9f5..9cf41dd2622 100644 --- a/code/game/atom_procs.dm +++ b/code/game/atom_procs.dm @@ -345,48 +345,44 @@ /atom/proc/clean_blood() clean_prints() - if(istype(blood_DNA, /list)) del(blood_DNA) - .=1 + return 1 - //Cleaning blood off of mobs - if(istype(src, /mob/living/carbon)) - var/mob/living/carbon/M = src - if(ishuman(M)) - var/mob/living/carbon/human/H = M - if(H.gloves) - if(H.gloves.clean_blood()) - H.update_inv_gloves(0) - else - if(H.bloody_hands) - H.bloody_hands = 0 - H.update_inv_gloves(0) - M.update_icons() //apply the now updated overlays to the mob - - //Cleaning blood off of items - else if(istype(src, /obj/item)) - var/obj/item/O = src - if(O.blood_overlay) - O.overlays.Remove(O.blood_overlay) - - if(istype(src, /obj/item/clothing/gloves)) - var/obj/item/clothing/gloves/G = src - G.transfer_blood = 0 - - //Cleaning blood off of turfs - else if(istype(src, /turf/simulated)) - var/turf/simulated/T = src - if(T.icon_old) - var/icon/I = new /icon(T.icon_old, T.icon_state) - T.icon = I +/mob/living/carbon/clean_blood() + . = ..() + if(ishuman(src)) + var/mob/living/carbon/human/H = src + if(H.gloves) + if(H.gloves.clean_blood()) + H.update_inv_gloves(0) else - T.icon = initial(icon) - return + if(H.bloody_hands) + H.bloody_hands = 0 + H.update_inv_gloves(0) + update_icons() //apply the now updated overlays to the mob + +/obj/item/clean_blood() + . = ..() + if(blood_overlay) + overlays.Remove(blood_overlay) + if(istype(src, /obj/item/clothing/gloves)) + var/obj/item/clothing/gloves/G = src + G.transfer_blood = 0 + +/* +/turf/simulated/clean_blood() + . = ..() + if(icon_old) + var/icon/I = new /icon(icon_old, icon_state) + icon = I + else + icon = initial(icon) +*/ + /atom/MouseDrop(atom/over_object as mob|obj|turf|area) - spawn( 0 ) - + spawn(0) if (istype(over_object, /atom)) over_object.MouseDrop_T(src, usr) return diff --git a/code/game/objects/structures/musician.dm b/code/game/objects/structures/musician.dm index fcb530736d7..edc28e5041b 100644 --- a/code/game/objects/structures/musician.dm +++ b/code/game/objects/structures/musician.dm @@ -33,349 +33,178 @@ /*BYOND loads resource files at compile time if they are ''. This means you can't really manipulate them dynamically. Tried doing it dynamically at first but its more trouble than its worth. Would have saved many lines tho.*/ switch(note) - if("Cn1") - soundfile = 'sound/piano/Cn1.ogg' - if("C#1") - soundfile = 'sound/piano/C#1.ogg' - if("Db1") - soundfile = 'sound/piano/Db1.ogg' - if("Dn1") - soundfile = 'sound/piano/Dn1.ogg' - if("D#1") - soundfile = 'sound/piano/D#1.ogg' - if("Eb1") - soundfile = 'sound/piano/Eb1.ogg' - if("En1") - soundfile = 'sound/piano/En1.ogg' - if("E#1") - soundfile = 'sound/piano/E#1.ogg' - if("Fb1") - soundfile = 'sound/piano/Fb1.ogg' - if("Fn1") - soundfile = 'sound/piano/Fn1.ogg' - if("F#1") - soundfile = 'sound/piano/F#1.ogg' - if("Gb1") - soundfile = 'sound/piano/Gb1.ogg' - if("Gn1") - soundfile = 'sound/piano/Gn1.ogg' - if("G#1") - soundfile = 'sound/piano/G#1.ogg' - if("Ab1") - soundfile = 'sound/piano/Ab1.ogg' - if("An1") - soundfile = 'sound/piano/An1.ogg' - if("A#1") - soundfile = 'sound/piano/A#1.ogg' - if("Bb1") - soundfile = 'sound/piano/Bb1.ogg' - if("Bn1") - soundfile = 'sound/piano/Bn1.ogg' - if("B#1") - soundfile = 'sound/piano/B#1.ogg' - if("Cb2") - soundfile = 'sound/piano/Cb2.ogg' - if("Cn2") - soundfile = 'sound/piano/Cn2.ogg' - if("C#2") - soundfile = 'sound/piano/C#2.ogg' - if("Db2") - soundfile = 'sound/piano/Db2.ogg' - if("Dn2") - soundfile = 'sound/piano/Dn2.ogg' - if("D#2") - soundfile = 'sound/piano/D#2.ogg' - if("Eb2") - soundfile = 'sound/piano/Eb2.ogg' - if("En2") - soundfile = 'sound/piano/En2.ogg' - if("E#2") - soundfile = 'sound/piano/E#2.ogg' - if("Fb2") - soundfile = 'sound/piano/Fb2.ogg' - if("Fn2") - soundfile = 'sound/piano/Fn2.ogg' - if("F#2") - soundfile = 'sound/piano/F#2.ogg' - if("Gb2") - soundfile = 'sound/piano/Gb2.ogg' - if("Gn2") - soundfile = 'sound/piano/Gn2.ogg' - if("G#2") - soundfile = 'sound/piano/G#2.ogg' - if("Ab2") - soundfile = 'sound/piano/Ab2.ogg' - if("An2") - soundfile = 'sound/piano/An2.ogg' - if("A#2") - soundfile = 'sound/piano/A#2.ogg' - if("Bb2") - soundfile = 'sound/piano/Bb2.ogg' - if("Bn2") - soundfile = 'sound/piano/Bn2.ogg' - if("B#2") - soundfile = 'sound/piano/B#2.ogg' - if("Cb3") - soundfile = 'sound/piano/Cb3.ogg' - if("Cn3") - soundfile = 'sound/piano/Cn3.ogg' - if("C#3") - soundfile = 'sound/piano/C#3.ogg' - if("Db3") - soundfile = 'sound/piano/Db3.ogg' - if("Dn3") - soundfile = 'sound/piano/Dn3.ogg' - if("D#3") - soundfile = 'sound/piano/D#3.ogg' - if("Eb3") - soundfile = 'sound/piano/Eb3.ogg' - if("En3") - soundfile = 'sound/piano/En3.ogg' - if("E#3") - soundfile = 'sound/piano/E#3.ogg' - if("Fb3") - soundfile = 'sound/piano/Fb3.ogg' - if("Fn3") - soundfile = 'sound/piano/Fn3.ogg' - if("F#3") - soundfile = 'sound/piano/F#3.ogg' - if("Gb3") - soundfile = 'sound/piano/Gb3.ogg' - if("Gn3") - soundfile = 'sound/piano/Gn3.ogg' - if("G#3") - soundfile = 'sound/piano/G#3.ogg' - if("Ab3") - soundfile = 'sound/piano/Ab3.ogg' - if("An3") - soundfile = 'sound/piano/An3.ogg' - if("A#3") - soundfile = 'sound/piano/A#3.ogg' - if("Bb3") - soundfile = 'sound/piano/Bb3.ogg' - if("Bn3") - soundfile = 'sound/piano/Bn3.ogg' - if("B#3") - soundfile = 'sound/piano/B#3.ogg' - if("Cb4") - soundfile = 'sound/piano/Cb4.ogg' - if("Cn4") - soundfile = 'sound/piano/Cn4.ogg' - if("C#4") - soundfile = 'sound/piano/C#4.ogg' - if("Db4") - soundfile = 'sound/piano/Db4.ogg' - if("Dn4") - soundfile = 'sound/piano/Dn4.ogg' - if("D#4") - soundfile = 'sound/piano/D#4.ogg' - if("Eb4") - soundfile = 'sound/piano/Eb4.ogg' - if("En4") - soundfile = 'sound/piano/En4.ogg' - if("E#4") - soundfile = 'sound/piano/E#4.ogg' - if("Fb4") - soundfile = 'sound/piano/Fb4.ogg' - if("Fn4") - soundfile = 'sound/piano/Fn4.ogg' - if("F#4") - soundfile = 'sound/piano/F#4.ogg' - if("Gb4") - soundfile = 'sound/piano/Gb4.ogg' - if("Gn4") - soundfile = 'sound/piano/Gn4.ogg' - if("G#4") - soundfile = 'sound/piano/G#4.ogg' - if("Ab4") - soundfile = 'sound/piano/Ab4.ogg' - if("An4") - soundfile = 'sound/piano/An4.ogg' - if("A#4") - soundfile = 'sound/piano/A#4.ogg' - if("Bb4") - soundfile = 'sound/piano/Bb4.ogg' - if("Bn4") - soundfile = 'sound/piano/Bn4.ogg' - if("B#4") - soundfile = 'sound/piano/B#4.ogg' - if("Cb5") - soundfile = 'sound/piano/Cb5.ogg' - if("Cn5") - soundfile = 'sound/piano/Cn5.ogg' - if("C#5") - soundfile = 'sound/piano/C#5.ogg' - if("Db5") - soundfile = 'sound/piano/Db5.ogg' - if("Dn5") - soundfile = 'sound/piano/Dn5.ogg' - if("D#5") - soundfile = 'sound/piano/D#5.ogg' - if("Eb5") - soundfile = 'sound/piano/Eb5.ogg' - if("En5") - soundfile = 'sound/piano/En5.ogg' - if("E#5") - soundfile = 'sound/piano/E#5.ogg' - if("Fb5") - soundfile = 'sound/piano/Fb5.ogg' - if("Fn5") - soundfile = 'sound/piano/Fn5.ogg' - if("F#5") - soundfile = 'sound/piano/F#5.ogg' - if("Gb5") - soundfile = 'sound/piano/Gb5.ogg' - if("Gn5") - soundfile = 'sound/piano/Gn5.ogg' - if("G#5") - soundfile = 'sound/piano/G#5.ogg' - if("Ab5") - soundfile = 'sound/piano/Ab5.ogg' - if("An5") - soundfile = 'sound/piano/An5.ogg' - if("A#5") - soundfile = 'sound/piano/A#5.ogg' - if("Bb5") - soundfile = 'sound/piano/Bb5.ogg' - if("Bn5") - soundfile = 'sound/piano/Bn5.ogg' - if("B#5") - soundfile = 'sound/piano/B#5.ogg' - if("Cb6") - soundfile = 'sound/piano/Cb6.ogg' - if("Cn6") - soundfile = 'sound/piano/Cn6.ogg' - if("C#6") - soundfile = 'sound/piano/C#6.ogg' - if("Db6") - soundfile = 'sound/piano/Db6.ogg' - if("Dn6") - soundfile = 'sound/piano/Dn6.ogg' - if("D#6") - soundfile = 'sound/piano/D#6.ogg' - if("Eb6") - soundfile = 'sound/piano/Eb6.ogg' - if("En6") - soundfile = 'sound/piano/En6.ogg' - if("E#6") - soundfile = 'sound/piano/E#6.ogg' - if("Fb6") - soundfile = 'sound/piano/Fb6.ogg' - if("Fn6") - soundfile = 'sound/piano/Fn6.ogg' - if("F#6") - soundfile = 'sound/piano/F#6.ogg' - if("Gb6") - soundfile = 'sound/piano/Gb6.ogg' - if("Gn6") - soundfile = 'sound/piano/Gn6.ogg' - if("G#6") - soundfile = 'sound/piano/G#6.ogg' - if("Ab6") - soundfile = 'sound/piano/Ab6.ogg' - if("An6") - soundfile = 'sound/piano/An6.ogg' - if("A#6") - soundfile = 'sound/piano/A#6.ogg' - if("Bb6") - soundfile = 'sound/piano/Bb6.ogg' - if("Bn6") - soundfile = 'sound/piano/Bn6.ogg' - if("B#6") - soundfile = 'sound/piano/B#6.ogg' - if("Cb7") - soundfile = 'sound/piano/Cb7.ogg' - if("Cn7") - soundfile = 'sound/piano/Cn7.ogg' - if("C#7") - soundfile = 'sound/piano/C#7.ogg' - if("Db7") - soundfile = 'sound/piano/Db7.ogg' - if("Dn7") - soundfile = 'sound/piano/Dn7.ogg' - if("D#7") - soundfile = 'sound/piano/D#7.ogg' - if("Eb7") - soundfile = 'sound/piano/Eb7.ogg' - if("En7") - soundfile = 'sound/piano/En7.ogg' - if("E#7") - soundfile = 'sound/piano/E#7.ogg' - if("Fb7") - soundfile = 'sound/piano/Fb7.ogg' - if("Fn7") - soundfile = 'sound/piano/Fn7.ogg' - if("F#7") - soundfile = 'sound/piano/F#7.ogg' - if("Gb7") - soundfile = 'sound/piano/Gb7.ogg' - if("Gn7") - soundfile = 'sound/piano/Gn7.ogg' - if("G#7") - soundfile = 'sound/piano/G#7.ogg' - if("Ab7") - soundfile = 'sound/piano/Ab7.ogg' - if("An7") - soundfile = 'sound/piano/An7.ogg' - if("A#7") - soundfile = 'sound/piano/A#7.ogg' - if("Bb7") - soundfile = 'sound/piano/Bb7.ogg' - if("Bn7") - soundfile = 'sound/piano/Bn7.ogg' - if("B#7") - soundfile = 'sound/piano/B#7.ogg' - if("Cb8") - soundfile = 'sound/piano/Cb8.ogg' - if("Cn8") - soundfile = 'sound/piano/Cn8.ogg' - if("C#8") - soundfile = 'sound/piano/C#8.ogg' - if("Db8") - soundfile = 'sound/piano/Db8.ogg' - if("Dn8") - soundfile = 'sound/piano/Dn8.ogg' - if("D#8") - soundfile = 'sound/piano/D#8.ogg' - if("Eb8") - soundfile = 'sound/piano/Eb8.ogg' - if("En8") - soundfile = 'sound/piano/En8.ogg' - if("E#8") - soundfile = 'sound/piano/E#8.ogg' - if("Fb8") - soundfile = 'sound/piano/Fb8.ogg' - if("Fn8") - soundfile = 'sound/piano/Fn8.ogg' - if("F#8") - soundfile = 'sound/piano/F#8.ogg' - if("Gb8") - soundfile = 'sound/piano/Gb8.ogg' - if("Gn8") - soundfile = 'sound/piano/Gn8.ogg' - if("G#8") - soundfile = 'sound/piano/G#8.ogg' - if("Ab8") - soundfile = 'sound/piano/Ab8.ogg' - if("An8") - soundfile = 'sound/piano/An8.ogg' - if("A#8") - soundfile = 'sound/piano/A#8.ogg' - if("Bb8") - soundfile = 'sound/piano/Bb8.ogg' - if("Bn8") - soundfile = 'sound/piano/Bn8.ogg' - if("B#8") - soundfile = 'sound/piano/B#8.ogg' - if("Cb9") - soundfile = 'sound/piano/Cb9.ogg' - if("Cn9") - soundfile = 'sound/piano/Cn9.ogg' - else - return + if("Cn1") soundfile = 'sound/piano/Cn1.ogg' + if("C#1") soundfile = 'sound/piano/C#1.ogg' + if("Db1") soundfile = 'sound/piano/Db1.ogg' + if("Dn1") soundfile = 'sound/piano/Dn1.ogg' + if("D#1") soundfile = 'sound/piano/D#1.ogg' + if("Eb1") soundfile = 'sound/piano/Eb1.ogg' + if("En1") soundfile = 'sound/piano/En1.ogg' + if("E#1") soundfile = 'sound/piano/E#1.ogg' + if("Fb1") soundfile = 'sound/piano/Fb1.ogg' + if("Fn1") soundfile = 'sound/piano/Fn1.ogg' + if("F#1") soundfile = 'sound/piano/F#1.ogg' + if("Gb1") soundfile = 'sound/piano/Gb1.ogg' + if("Gn1") soundfile = 'sound/piano/Gn1.ogg' + if("G#1") soundfile = 'sound/piano/G#1.ogg' + if("Ab1") soundfile = 'sound/piano/Ab1.ogg' + if("An1") soundfile = 'sound/piano/An1.ogg' + if("A#1") soundfile = 'sound/piano/A#1.ogg' + if("Bb1") soundfile = 'sound/piano/Bb1.ogg' + if("Bn1") soundfile = 'sound/piano/Bn1.ogg' + if("B#1") soundfile = 'sound/piano/B#1.ogg' + if("Cb2") soundfile = 'sound/piano/Cb2.ogg' + if("Cn2") soundfile = 'sound/piano/Cn2.ogg' + if("C#2") soundfile = 'sound/piano/C#2.ogg' + if("Db2") soundfile = 'sound/piano/Db2.ogg' + if("Dn2") soundfile = 'sound/piano/Dn2.ogg' + if("D#2") soundfile = 'sound/piano/D#2.ogg' + if("Eb2") soundfile = 'sound/piano/Eb2.ogg' + if("En2") soundfile = 'sound/piano/En2.ogg' + if("E#2") soundfile = 'sound/piano/E#2.ogg' + if("Fb2") soundfile = 'sound/piano/Fb2.ogg' + if("Fn2") soundfile = 'sound/piano/Fn2.ogg' + if("F#2") soundfile = 'sound/piano/F#2.ogg' + if("Gb2") soundfile = 'sound/piano/Gb2.ogg' + if("Gn2") soundfile = 'sound/piano/Gn2.ogg' + if("G#2") soundfile = 'sound/piano/G#2.ogg' + if("Ab2") soundfile = 'sound/piano/Ab2.ogg' + if("An2") soundfile = 'sound/piano/An2.ogg' + if("A#2") soundfile = 'sound/piano/A#2.ogg' + if("Bb2") soundfile = 'sound/piano/Bb2.ogg' + if("Bn2") soundfile = 'sound/piano/Bn2.ogg' + if("B#2") soundfile = 'sound/piano/B#2.ogg' + if("Cb3") soundfile = 'sound/piano/Cb3.ogg' + if("Cn3") soundfile = 'sound/piano/Cn3.ogg' + if("C#3") soundfile = 'sound/piano/C#3.ogg' + if("Db3") soundfile = 'sound/piano/Db3.ogg' + if("Dn3") soundfile = 'sound/piano/Dn3.ogg' + if("D#3") soundfile = 'sound/piano/D#3.ogg' + if("Eb3") soundfile = 'sound/piano/Eb3.ogg' + if("En3") soundfile = 'sound/piano/En3.ogg' + if("E#3") soundfile = 'sound/piano/E#3.ogg' + if("Fb3") soundfile = 'sound/piano/Fb3.ogg' + if("Fn3") soundfile = 'sound/piano/Fn3.ogg' + if("F#3") soundfile = 'sound/piano/F#3.ogg' + if("Gb3") soundfile = 'sound/piano/Gb3.ogg' + if("Gn3") soundfile = 'sound/piano/Gn3.ogg' + if("G#3") soundfile = 'sound/piano/G#3.ogg' + if("Ab3") soundfile = 'sound/piano/Ab3.ogg' + if("An3") soundfile = 'sound/piano/An3.ogg' + if("A#3") soundfile = 'sound/piano/A#3.ogg' + if("Bb3") soundfile = 'sound/piano/Bb3.ogg' + if("Bn3") soundfile = 'sound/piano/Bn3.ogg' + if("B#3") soundfile = 'sound/piano/B#3.ogg' + if("Cb4") soundfile = 'sound/piano/Cb4.ogg' + if("Cn4") soundfile = 'sound/piano/Cn4.ogg' + if("C#4") soundfile = 'sound/piano/C#4.ogg' + if("Db4") soundfile = 'sound/piano/Db4.ogg' + if("Dn4") soundfile = 'sound/piano/Dn4.ogg' + if("D#4") soundfile = 'sound/piano/D#4.ogg' + if("Eb4") soundfile = 'sound/piano/Eb4.ogg' + if("En4") soundfile = 'sound/piano/En4.ogg' + if("E#4") soundfile = 'sound/piano/E#4.ogg' + if("Fb4") soundfile = 'sound/piano/Fb4.ogg' + if("Fn4") soundfile = 'sound/piano/Fn4.ogg' + if("F#4") soundfile = 'sound/piano/F#4.ogg' + if("Gb4") soundfile = 'sound/piano/Gb4.ogg' + if("Gn4") soundfile = 'sound/piano/Gn4.ogg' + if("G#4") soundfile = 'sound/piano/G#4.ogg' + if("Ab4") soundfile = 'sound/piano/Ab4.ogg' + if("An4") soundfile = 'sound/piano/An4.ogg' + if("A#4") soundfile = 'sound/piano/A#4.ogg' + if("Bb4") soundfile = 'sound/piano/Bb4.ogg' + if("Bn4") soundfile = 'sound/piano/Bn4.ogg' + if("B#4") soundfile = 'sound/piano/B#4.ogg' + if("Cb5") soundfile = 'sound/piano/Cb5.ogg' + if("Cn5") soundfile = 'sound/piano/Cn5.ogg' + if("C#5") soundfile = 'sound/piano/C#5.ogg' + if("Db5") soundfile = 'sound/piano/Db5.ogg' + if("Dn5") soundfile = 'sound/piano/Dn5.ogg' + if("D#5") soundfile = 'sound/piano/D#5.ogg' + if("Eb5") soundfile = 'sound/piano/Eb5.ogg' + if("En5") soundfile = 'sound/piano/En5.ogg' + if("E#5") soundfile = 'sound/piano/E#5.ogg' + if("Fb5") soundfile = 'sound/piano/Fb5.ogg' + if("Fn5") soundfile = 'sound/piano/Fn5.ogg' + if("F#5") soundfile = 'sound/piano/F#5.ogg' + if("Gb5") soundfile = 'sound/piano/Gb5.ogg' + if("Gn5") soundfile = 'sound/piano/Gn5.ogg' + if("G#5") soundfile = 'sound/piano/G#5.ogg' + if("Ab5") soundfile = 'sound/piano/Ab5.ogg' + if("An5") soundfile = 'sound/piano/An5.ogg' + if("A#5") soundfile = 'sound/piano/A#5.ogg' + if("Bb5") soundfile = 'sound/piano/Bb5.ogg' + if("Bn5") soundfile = 'sound/piano/Bn5.ogg' + if("B#5") soundfile = 'sound/piano/B#5.ogg' + if("Cb6") soundfile = 'sound/piano/Cb6.ogg' + if("Cn6") soundfile = 'sound/piano/Cn6.ogg' + if("C#6") soundfile = 'sound/piano/C#6.ogg' + if("Db6") soundfile = 'sound/piano/Db6.ogg' + if("Dn6") soundfile = 'sound/piano/Dn6.ogg' + if("D#6") soundfile = 'sound/piano/D#6.ogg' + if("Eb6") soundfile = 'sound/piano/Eb6.ogg' + if("En6") soundfile = 'sound/piano/En6.ogg' + if("E#6") soundfile = 'sound/piano/E#6.ogg' + if("Fb6") soundfile = 'sound/piano/Fb6.ogg' + if("Fn6") soundfile = 'sound/piano/Fn6.ogg' + if("F#6") soundfile = 'sound/piano/F#6.ogg' + if("Gb6") soundfile = 'sound/piano/Gb6.ogg' + if("Gn6") soundfile = 'sound/piano/Gn6.ogg' + if("G#6") soundfile = 'sound/piano/G#6.ogg' + if("Ab6") soundfile = 'sound/piano/Ab6.ogg' + if("An6") soundfile = 'sound/piano/An6.ogg' + if("A#6") soundfile = 'sound/piano/A#6.ogg' + if("Bb6") soundfile = 'sound/piano/Bb6.ogg' + if("Bn6") soundfile = 'sound/piano/Bn6.ogg' + if("B#6") soundfile = 'sound/piano/B#6.ogg' + if("Cb7") soundfile = 'sound/piano/Cb7.ogg' + if("Cn7") soundfile = 'sound/piano/Cn7.ogg' + if("C#7") soundfile = 'sound/piano/C#7.ogg' + if("Db7") soundfile = 'sound/piano/Db7.ogg' + if("Dn7") soundfile = 'sound/piano/Dn7.ogg' + if("D#7") soundfile = 'sound/piano/D#7.ogg' + if("Eb7") soundfile = 'sound/piano/Eb7.ogg' + if("En7") soundfile = 'sound/piano/En7.ogg' + if("E#7") soundfile = 'sound/piano/E#7.ogg' + if("Fb7") soundfile = 'sound/piano/Fb7.ogg' + if("Fn7") soundfile = 'sound/piano/Fn7.ogg' + if("F#7") soundfile = 'sound/piano/F#7.ogg' + if("Gb7") soundfile = 'sound/piano/Gb7.ogg' + if("Gn7") soundfile = 'sound/piano/Gn7.ogg' + if("G#7") soundfile = 'sound/piano/G#7.ogg' + if("Ab7") soundfile = 'sound/piano/Ab7.ogg' + if("An7") soundfile = 'sound/piano/An7.ogg' + if("A#7") soundfile = 'sound/piano/A#7.ogg' + if("Bb7") soundfile = 'sound/piano/Bb7.ogg' + if("Bn7") soundfile = 'sound/piano/Bn7.ogg' + if("B#7") soundfile = 'sound/piano/B#7.ogg' + if("Cb8") soundfile = 'sound/piano/Cb8.ogg' + if("Cn8") soundfile = 'sound/piano/Cn8.ogg' + if("C#8") soundfile = 'sound/piano/C#8.ogg' + if("Db8") soundfile = 'sound/piano/Db8.ogg' + if("Dn8") soundfile = 'sound/piano/Dn8.ogg' + if("D#8") soundfile = 'sound/piano/D#8.ogg' + if("Eb8") soundfile = 'sound/piano/Eb8.ogg' + if("En8") soundfile = 'sound/piano/En8.ogg' + if("E#8") soundfile = 'sound/piano/E#8.ogg' + if("Fb8") soundfile = 'sound/piano/Fb8.ogg' + if("Fn8") soundfile = 'sound/piano/Fn8.ogg' + if("F#8") soundfile = 'sound/piano/F#8.ogg' + if("Gb8") soundfile = 'sound/piano/Gb8.ogg' + if("Gn8") soundfile = 'sound/piano/Gn8.ogg' + if("G#8") soundfile = 'sound/piano/G#8.ogg' + if("Ab8") soundfile = 'sound/piano/Ab8.ogg' + if("An8") soundfile = 'sound/piano/An8.ogg' + if("A#8") soundfile = 'sound/piano/A#8.ogg' + if("Bb8") soundfile = 'sound/piano/Bb8.ogg' + if("Bn8") soundfile = 'sound/piano/Bn8.ogg' + if("B#8") soundfile = 'sound/piano/B#8.ogg' + if("Cb9") soundfile = 'sound/piano/Cb9.ogg' + if("Cn9") soundfile = 'sound/piano/Cn9.ogg' + else return - for(var/mob/M in hearers(15, src)) - M << sound(soundfile) + hearers(15, src) << sound(soundfile) /obj/structure/device/piano/proc/playsong() do @@ -481,92 +310,98 @@ onclose(usr, "piano") return - if(href_list["repeat"]) //Changing this from a toggle to a number of repeats to avoid infinite loops. - if(playing) return //So that people cant keep adding to repeat. If the do it intentionally, it could result in the server crashing. - var/tempnum = input("How many times do you want to repeat this piece? (max:10)") as num - if(tempnum > 10) - tempnum = 10 - repeat = tempnum - - else if(href_list["tempo"]) - song.tempo += text2num(href_list["tempo"]) - if(song.tempo < 1) - song.tempo = 1 - - else if(href_list["play"]) - if(song) - playing = 1 - spawn() playsong() - - else if(href_list["newsong"]) + if(href_list["newsong"]) song = new() + else if(song) + if(href_list["repeat"]) //Changing this from a toggle to a number of repeats to avoid infinite loops. + if(playing) return //So that people cant keep adding to repeat. If the do it intentionally, it could result in the server crashing. + var/tempnum = input("How many times do you want to repeat this piece? (max:10)") as num|null + if(tempnum > 10) + tempnum = 10 + if(tempnum < 0) + tempnum = 0 + repeat = round(tempnum) - else if(href_list["newline"]) - var/newline = input("Enter your line: ", "Piano") as text|null - if(!newline) - return - if(song.lines.len > 50) - return - if(lentext(newline) > 50) - newline = copytext(newline, 1, 50) - song.lines.Add(newline) + else if(href_list["tempo"]) + song.tempo += round(text2num(href_list["tempo"])) + if(song.tempo < 1) + song.tempo = 1 - else if(href_list["deleteline"]) - var/num = text2num(href_list["deleteline"]) - song.lines.Cut(num, num+1) + else if(href_list["play"]) + if(song) + playing = 1 + spawn() playsong() - else if(href_list["modifyline"]) - var/num = text2num(href_list["modifyline"]) - var/content = input("Enter your line: ", "Piano", song.lines[num]) as text|null - if(!content) - return - if(lentext(content) > 50) - content = copytext(content, 1, 50) - song.lines[num] = content - - else if(href_list["stop"]) - playing = 0 - - else if(href_list["help"]) - help = text2num(href_list["help"]) - 1 - - else if(href_list["edit"]) - edit = text2num(href_list["edit"]) - 1 - - else if(href_list["import"]) - var/t = "" - do - t = input(usr, "Please paste the entire song, formatted:", text("[]", src.name), t) as message - if (!in_range(src, usr)) + else if(href_list["newline"]) + var/newline = html_encode(input("Enter your line: ", "Piano") as text|null) + if(!newline) return + if(song.lines.len > 50) + return + if(lentext(newline) > 50) + newline = copytext(newline, 1, 50) + song.lines.Add(newline) - if(lentext(t) >= 3072) - var/cont = input(usr, "Your message is too long! Would you like to continue editing it?", "", "yes") in list("yes", "no") - if(cont == "no") - break - while(lentext(t) > 3072) + else if(href_list["deleteline"]) + var/num = round(text2num(href_list["deleteline"])) + if(num > song.lines.len || num < 1) + return + song.lines.Cut(num, num+1) - //split into lines - spawn() - var/list/lines = dd_text2list(t, "\n") - var/tempo = 5 - if(copytext(lines[1],1,6) == "BPM: ") - tempo = 600 / text2num(copytext(lines[1],6)) - lines.Cut(1,2) - if(lines.len > 50) - usr << "Too many lines!" - lines.Cut(51) - var/linenum = 1 - for(var/l in lines) - if(lentext(l) > 50) - usr << "Line [linenum] too long!" - lines.Remove(l) - else - linenum++ - song = new() - song.lines = lines - song.tempo = tempo - updateUsrDialog() + else if(href_list["modifyline"]) + var/num = round(text2num(href_list["modifyline"]),1) + var/content = html_encode(input("Enter your line: ", "Piano", song.lines[num]) as text|null) + if(!content) + return + if(lentext(content) > 50) + content = copytext(content, 1, 50) + if(num > song.lines.len || num < 1) + return + song.lines[num] = content + + else if(href_list["stop"]) + playing = 0 + + else if(href_list["help"]) + help = text2num(href_list["help"]) - 1 + + else if(href_list["edit"]) + edit = text2num(href_list["edit"]) - 1 + + else if(href_list["import"]) + var/t = "" + do + t = html_encode(input(usr, "Please paste the entire song, formatted:", text("[]", src.name), t) as message) + if (!in_range(src, usr)) + return + + if(lentext(t) >= 3072) + var/cont = input(usr, "Your message is too long! Would you like to continue editing it?", "", "yes") in list("yes", "no") + if(cont == "no") + break + while(lentext(t) > 3072) + + //split into lines + spawn() + var/list/lines = dd_text2list(t, "\n") + var/tempo = 5 + if(copytext(lines[1],1,6) == "BPM: ") + tempo = 600 / text2num(copytext(lines[1],6)) + lines.Cut(1,2) + if(lines.len > 50) + usr << "Too many lines!" + lines.Cut(51) + var/linenum = 1 + for(var/l in lines) + if(lentext(l) > 50) + usr << "Line [linenum] too long!" + lines.Remove(l) + else + linenum++ + song = new() + song.lines = lines + song.tempo = tempo + updateUsrDialog() add_fingerprint(usr) updateUsrDialog()