Refactors most spans into span procs (#59645)

Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs.
Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines.

Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing.
Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc.

(Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
This commit is contained in:
Watermelon914
2021-06-14 13:03:53 -07:00
committed by GitHub
parent b9982f6970
commit 375a20e49b
1676 changed files with 15455 additions and 15226 deletions
+8 -8
View File
@@ -25,33 +25,33 @@
/obj/item/sharpener/attackby(obj/item/I, mob/user, params)
if(uses == 0)
to_chat(user, "<span class='warning'>The sharpening block is too worn to use again!</span>")
to_chat(user, span_warning("The sharpening block is too worn to use again!"))
return
if(I.force >= max || I.throwforce >= max) //So the whetstone never reduces force or throw_force
to_chat(user, "<span class='warning'>[I] is much too powerful to sharpen further!</span>")
to_chat(user, span_warning("[I] is much too powerful to sharpen further!"))
return
if(requires_sharpness && !I.get_sharpness())
to_chat(user, "<span class='warning'>You can only sharpen items that are already sharp, such as knives!</span>")
to_chat(user, span_warning("You can only sharpen items that are already sharp, such as knives!"))
return
if(is_type_in_list(I, list(/obj/item/melee/transforming/energy, /obj/item/dualsaber))) //You can't sharpen the photons in energy meelee weapons
to_chat(user, "<span class='warning'>You don't think \the [I] will be the thing getting modified if you use it on \the [src]!</span>")
to_chat(user, span_warning("You don't think \the [I] will be the thing getting modified if you use it on \the [src]!"))
return
//This block is used to check more things if the item has a relevant component.
var/signal_out = SEND_SIGNAL(I, COMSIG_ITEM_SHARPEN_ACT, increment, max) //Stores the bitflags returned by SEND_SIGNAL
if(signal_out & COMPONENT_BLOCK_SHARPEN_MAXED) //If the item's components enforce more limits on maximum power from sharpening, we fail
to_chat(user, "<span class='warning'>[I] is much too powerful to sharpen further!</span>")
to_chat(user, span_warning("[I] is much too powerful to sharpen further!"))
return
if(signal_out & COMPONENT_BLOCK_SHARPEN_BLOCKED)
to_chat(user, "<span class='warning'>[I] is not able to be sharpened right now!</span>")
to_chat(user, span_warning("[I] is not able to be sharpened right now!"))
return
if((signal_out & COMPONENT_BLOCK_SHARPEN_ALREADY) || (I.force > initial(I.force) && !signal_out)) //No sharpening stuff twice
to_chat(user, "<span class='warning'>[I] has already been refined before. It cannot be sharpened further!</span>")
to_chat(user, span_warning("[I] has already been refined before. It cannot be sharpened further!"))
return
if(!(signal_out & COMPONENT_BLOCK_SHARPEN_APPLIED)) //If the item has a relevant component and COMPONENT_BLOCK_SHARPEN_APPLIED is returned, the item only gets the throw force increase
I.force = clamp(I.force + increment, 0, max)
I.wound_bonus = I.wound_bonus + increment //wound_bonus has no cap
user.visible_message("<span class='notice'>[user] sharpens [I] with [src]!</span>", "<span class='notice'>You sharpen [I], making it much more deadly than before.</span>")
user.visible_message(span_notice("[user] sharpens [I] with [src]!"), span_notice("You sharpen [I], making it much more deadly than before."))
playsound(src, 'sound/items/unsheath.ogg', 25, TRUE)
I.sharpness = SHARP_EDGED //When you whetstone something, it becomes an edged weapon, even if it was previously dull or pointy
I.throwforce = clamp(I.throwforce + increment, 0, max)