Merge pull request #2046 from Citadel-Station-13/upstream-merge-29274
[MIRROR] Minor instrument code cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
#define MUSIC_MAXLINES 300
|
||||
#define MUSIC_MAXLINECHARS 50
|
||||
|
||||
/datum/song
|
||||
var/name = "Untitled"
|
||||
@@ -71,10 +72,10 @@
|
||||
/datum/song/proc/shouldStopPlaying(mob/user)
|
||||
if(instrumentObj)
|
||||
if(!user.canUseTopic(instrumentObj))
|
||||
return 1
|
||||
return TRUE
|
||||
return !instrumentObj.anchored // add special cases to stop in subclasses
|
||||
else
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
/datum/song/proc/playsong(mob/user)
|
||||
while(repeat >= 0)
|
||||
@@ -92,9 +93,9 @@
|
||||
for(var/note in splittext(notes[1], "-"))
|
||||
//to_chat(world, "note: [note]")
|
||||
if(!playing || shouldStopPlaying(user))//If the instrument is playing, or special case
|
||||
playing = 0
|
||||
playing = FALSE
|
||||
return
|
||||
if(lentext(note) == 0)
|
||||
if(!lentext(note))
|
||||
continue
|
||||
//to_chat(world, "Parse: [copytext(note,1,2)]")
|
||||
var/cur_note = text2ascii(note) - 96
|
||||
@@ -124,7 +125,7 @@
|
||||
else
|
||||
sleep(tempo)
|
||||
repeat--
|
||||
playing = 0
|
||||
playing = FALSE
|
||||
repeat = 0
|
||||
updateDialog(user)
|
||||
|
||||
@@ -173,7 +174,7 @@
|
||||
defined by tempo / x: <i>C,G/2,E/4</i><br>
|
||||
Combined, an example is: <i>E-E4/4,F#/2,G#/8,B/8,E3-E4/4</i>
|
||||
<br>
|
||||
Lines may be up to 50 characters.<br>
|
||||
Lines may be up to [MUSIC_MAXLINECHARS] characters.<br>
|
||||
A song may only contain up to [MUSIC_MAXLINES] lines.<br>
|
||||
"}
|
||||
else
|
||||
@@ -199,7 +200,7 @@
|
||||
lines.Cut(MUSIC_MAXLINES + 1)
|
||||
var/linenum = 1
|
||||
for(var/l in lines)
|
||||
if(lentext(l) > 50)
|
||||
if(lentext(l) > MUSIC_MAXLINECHARS)
|
||||
to_chat(usr, "Line [linenum] too long!")
|
||||
lines.Remove(l)
|
||||
else
|
||||
@@ -226,11 +227,11 @@
|
||||
if(!in_range(instrumentObj, usr))
|
||||
return
|
||||
|
||||
if(lentext(t) >= 3072)
|
||||
if(lentext(t) >= MUSIC_MAXLINES * MUSIC_MAXLINECHARS)
|
||||
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)
|
||||
while(lentext(t) > MUSIC_MAXLINES * MUSIC_MAXLINECHARS)
|
||||
ParseSong(t)
|
||||
|
||||
else if(href_list["help"])
|
||||
@@ -252,7 +253,7 @@
|
||||
tempo = sanitize_tempo(tempo + text2num(href_list["tempo"]))
|
||||
|
||||
else if(href_list["play"])
|
||||
playing = 1
|
||||
playing = TRUE
|
||||
spawn()
|
||||
playsong(usr)
|
||||
|
||||
@@ -262,8 +263,8 @@
|
||||
return
|
||||
if(lines.len > MUSIC_MAXLINES)
|
||||
return
|
||||
if(lentext(newline) > 50)
|
||||
newline = copytext(newline, 1, 50)
|
||||
if(lentext(newline) > MUSIC_MAXLINECHARS)
|
||||
newline = copytext(newline, 1, MUSIC_MAXLINECHARS)
|
||||
lines.Add(newline)
|
||||
|
||||
else if(href_list["deleteline"])
|
||||
@@ -277,14 +278,14 @@
|
||||
var/content = html_encode(input("Enter your line: ", instrumentObj.name, lines[num]) as text|null)
|
||||
if(!content || !in_range(instrumentObj, usr))
|
||||
return
|
||||
if(lentext(content) > 50)
|
||||
content = copytext(content, 1, 50)
|
||||
if(lentext(content) > MUSIC_MAXLINECHARS)
|
||||
content = copytext(content, 1, MUSIC_MAXLINECHARS)
|
||||
if(num > lines.len || num < 1)
|
||||
return
|
||||
lines[num] = content
|
||||
|
||||
else if(href_list["stop"])
|
||||
playing = 0
|
||||
playing = FALSE
|
||||
|
||||
updateDialog(usr)
|
||||
return
|
||||
@@ -303,7 +304,7 @@
|
||||
if(instrumentObj)
|
||||
return !isliving(instrumentObj.loc)
|
||||
else
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -360,7 +361,7 @@
|
||||
/obj/structure/piano/attackby(obj/item/O, mob/user, params)
|
||||
if (istype(O, /obj/item/weapon/wrench))
|
||||
if (!anchored && !isinspace())
|
||||
playsound(src.loc, O.usesound, 50, 1)
|
||||
playsound(src, O.usesound, 50, 1)
|
||||
to_chat(user, "<span class='notice'> You begin to tighten \the [src] to the floor...</span>")
|
||||
if (do_after(user, 20*O.toolspeed, target = src))
|
||||
user.visible_message( \
|
||||
@@ -369,7 +370,7 @@
|
||||
"<span class='italics'>You hear ratchet.</span>")
|
||||
anchored = TRUE
|
||||
else if(anchored)
|
||||
playsound(src.loc, O.usesound, 50, 1)
|
||||
playsound(src, O.usesound, 50, 1)
|
||||
to_chat(user, "<span class='notice'> You begin to loosen \the [src]'s casters...</span>")
|
||||
if (do_after(user, 40*O.toolspeed, target = src))
|
||||
user.visible_message( \
|
||||
|
||||
Reference in New Issue
Block a user