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
+13 -13
View File
@@ -62,8 +62,8 @@
if(!kick_us_off)
return TRUE
rider.visible_message("<span class='warning'>[rider] falls off of [living_parent]!</span>", \
"<span class='warning'>You fall off of [living_parent]!</span>")
rider.visible_message(span_warning("[rider] falls off of [living_parent]!"), \
span_warning("You fall off of [living_parent]!"))
rider.Paralyze(1 SECONDS)
rider.Knockdown(4 SECONDS)
living_parent.unbuckle_mob(rider)
@@ -84,7 +84,7 @@
if(!keycheck(user))
if(ispath(keytype, /obj/item))
var/obj/item/key = keytype
to_chat(user, "<span class='warning'>You need a [initial(key.name)] to ride [movable_parent]!</span>")
to_chat(user, span_warning("You need a [initial(key.name)] to ride [movable_parent]!"))
return COMPONENT_DRIVER_BLOCK_MOVE
var/mob/living/living_parent = parent
var/turf/next = get_step(living_parent, direction)
@@ -105,12 +105,12 @@
rider.Move(targetm)
rider.Knockdown(3 SECONDS)
if(gentle)
rider.visible_message("<span class='warning'>[rider] is thrown clear of [movable_parent]!</span>", \
"<span class='warning'>You're thrown clear of [movable_parent]!</span>")
rider.visible_message(span_warning("[rider] is thrown clear of [movable_parent]!"), \
span_warning("You're thrown clear of [movable_parent]!"))
rider.throw_at(target, 8, 3, movable_parent, gentle = TRUE)
else
rider.visible_message("<span class='warning'>[rider] is thrown violently from [movable_parent]!</span>", \
"<span class='warning'>You're thrown violently from [movable_parent]!</span>")
rider.visible_message(span_warning("[rider] is thrown violently from [movable_parent]!"), \
span_warning("You're thrown violently from [movable_parent]!"))
rider.throw_at(target, 14, 5, movable_parent, gentle = FALSE)
/// If we're a cyborg or animal and we spin, we yeet whoever's on us off us
@@ -199,9 +199,9 @@
human_parent.unbuckle_mob(rider)
rider.Paralyze(1 SECONDS)
rider.Knockdown(4 SECONDS)
human_parent.visible_message("<span class='danger'>[rider] topples off of [human_parent] as they both fall to the ground!</span>", \
"<span class='warning'>You fall to the ground, bringing [rider] with you!</span>", "<span class='hear'>You hear two consecutive thuds.</span>", COMBAT_MESSAGE_RANGE, ignored_mobs=rider)
to_chat(rider, "<span class='danger'>[human_parent] falls to the ground, bringing you with [human_parent.p_them()]!</span>")
human_parent.visible_message(span_danger("[rider] topples off of [human_parent] as they both fall to the ground!"), \
span_warning("You fall to the ground, bringing [rider] with you!"), span_hear("You hear two consecutive thuds."), COMBAT_MESSAGE_RANGE, ignored_mobs=rider)
to_chat(rider, span_danger("[human_parent] falls to the ground, bringing you with [human_parent.p_them()]!"))
/datum/component/riding/creature/human/handle_vehicle_layer(dir)
var/atom/movable/AM = parent
@@ -235,8 +235,8 @@
AM.unbuckle_mob(dismounted_rider)
dismounted_rider.Paralyze(1 SECONDS)
dismounted_rider.Knockdown(4 SECONDS)
dismounted_rider.visible_message("<span class='warning'>[AM] pushes [dismounted_rider] off of [AM.p_them()]!</span>", \
"<span class='warning'>[AM] pushes you off of [AM.p_them()]!</span>")
dismounted_rider.visible_message(span_warning("[AM] pushes [dismounted_rider] off of [AM.p_them()]!"), \
span_warning("[AM] pushes you off of [AM.p_them()]!"))
//Now onto cyborg riding//
@@ -250,7 +250,7 @@
var/mob/living/carbon/carbonuser = user
if(!carbonuser.usable_hands)
Unbuckle(user)
to_chat(user, "<span class='warning'>You can't grab onto [robot_parent] with no hands!</span>")
to_chat(user, span_warning("You can't grab onto [robot_parent] with no hands!"))
/datum/component/riding/creature/cyborg/handle_vehicle_layer(dir)
var/atom/movable/robot_parent = parent
+12 -12
View File
@@ -16,43 +16,43 @@
if(!keycheck(user))
if(COOLDOWN_FINISHED(src, message_cooldown))
to_chat(user, "<span class='warning'>[vehicle_parent] has no key inserted!</span>")
to_chat(user, span_warning("[vehicle_parent] has no key inserted!"))
COOLDOWN_START(src, message_cooldown, 5 SECONDS)
return COMPONENT_DRIVER_BLOCK_MOVE
if(HAS_TRAIT(user, TRAIT_INCAPACITATED))
if(ride_check_flags & UNBUCKLE_DISABLED_RIDER)
vehicle_parent.unbuckle_mob(user, TRUE)
user.visible_message("<span class='danger'>[user] falls off \the [vehicle_parent].</span>",\
"<span class='danger'>You slip off \the [vehicle_parent] as your body slumps!</span>")
user.visible_message(span_danger("[user] falls off \the [vehicle_parent]."),\
span_danger("You slip off \the [vehicle_parent] as your body slumps!"))
user.Stun(3 SECONDS)
if(COOLDOWN_FINISHED(src, message_cooldown))
to_chat(user, "<span class='warning'>You cannot operate \the [vehicle_parent] right now!</span>")
to_chat(user, span_warning("You cannot operate \the [vehicle_parent] right now!"))
COOLDOWN_START(src, message_cooldown, 5 SECONDS)
return COMPONENT_DRIVER_BLOCK_MOVE
if(ride_check_flags & RIDER_NEEDS_LEGS && HAS_TRAIT(user, TRAIT_FLOORED))
if(ride_check_flags & UNBUCKLE_DISABLED_RIDER)
vehicle_parent.unbuckle_mob(user, TRUE)
user.visible_message("<span class='danger'>[user] falls off \the [vehicle_parent].</span>",\
"<span class='danger'>You fall off \the [vehicle_parent] while trying to operate it while unable to stand!</span>")
user.visible_message(span_danger("[user] falls off \the [vehicle_parent]."),\
span_danger("You fall off \the [vehicle_parent] while trying to operate it while unable to stand!"))
user.Stun(3 SECONDS)
if(COOLDOWN_FINISHED(src, message_cooldown))
to_chat(user, "<span class='warning'>You can't seem to manage that while unable to stand up enough to move \the [vehicle_parent]...</span>")
to_chat(user, span_warning("You can't seem to manage that while unable to stand up enough to move \the [vehicle_parent]..."))
COOLDOWN_START(src, message_cooldown, 5 SECONDS)
return COMPONENT_DRIVER_BLOCK_MOVE
if(ride_check_flags & RIDER_NEEDS_ARMS && HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
if(ride_check_flags & UNBUCKLE_DISABLED_RIDER)
vehicle_parent.unbuckle_mob(user, TRUE)
user.visible_message("<span class='danger'>[user] falls off \the [vehicle_parent].</span>",\
"<span class='danger'>You fall off \the [vehicle_parent] while trying to operate it without being able to hold on!</span>")
user.visible_message(span_danger("[user] falls off \the [vehicle_parent]."),\
span_danger("You fall off \the [vehicle_parent] while trying to operate it without being able to hold on!"))
user.Stun(3 SECONDS)
if(COOLDOWN_FINISHED(src, message_cooldown))
to_chat(user, "<span class='warning'>You can't seem to hold onto \the [vehicle_parent] to move it...</span>")
to_chat(user, span_warning("You can't seem to hold onto \the [vehicle_parent] to move it..."))
COOLDOWN_START(src, message_cooldown, 5 SECONDS)
return COMPONENT_DRIVER_BLOCK_MOVE
@@ -67,7 +67,7 @@
if(!istype(next) || !istype(current))
return //not happening.
if(!turf_check(next, current))
to_chat(user, "<span class='warning'>\The [movable_parent] can not go onto [next]!</span>")
to_chat(user, span_warning("\The [movable_parent] can not go onto [next]!"))
return
if(!Process_Spacemove(direction) || !isturf(movable_parent.loc))
return
@@ -185,7 +185,7 @@
if(keycheck(user) && the_secway.eddie_murphy)
if(COOLDOWN_FINISHED(src, message_cooldown))
the_secway.visible_message("<span class='warning'>[src] sputters and refuses to move!</span>")
the_secway.visible_message(span_warning("[src] sputters and refuses to move!"))
playsound(get_turf(the_secway), 'sound/effects/stall.ogg', 70)
COOLDOWN_START(src, message_cooldown, 0.75 SECONDS)
return COMPONENT_DRIVER_BLOCK_MOVE