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
+2 -2
View File
@@ -63,7 +63,7 @@ INITIALIZE_IMMEDIATE(/mob/dead)
switch(csa.len)
if(0)
remove_verb(src, /mob/dead/proc/server_hop)
to_chat(src, "<span class='notice'>Server Hop has been disabled.</span>")
to_chat(src, span_notice("Server Hop has been disabled."))
if(1)
pick = csa[1]
else
@@ -78,7 +78,7 @@ INITIALIZE_IMMEDIATE(/mob/dead)
return
var/client/C = client
to_chat(C, "<span class='notice'>Sending you to [pick].</span>")
to_chat(C, span_notice("Sending you to [pick]."))
new /atom/movable/screen/splash(C)
notransform = TRUE
+2 -2
View File
@@ -18,11 +18,11 @@
to_chat(src, "<div class=\"motd\">[motd]</div>", handle_whitespace=FALSE)
if(GLOB.admin_notice)
to_chat(src, "<span class='notice'><b>Admin Notice:</b>\n \t [GLOB.admin_notice]</span>")
to_chat(src, span_notice("<b>Admin Notice:</b>\n \t [GLOB.admin_notice]"))
var/spc = CONFIG_GET(number/soft_popcap)
if(spc && living_player_count() >= spc)
to_chat(src, "<span class='notice'><b>Server Notice:</b>\n \t [CONFIG_GET(string/soft_popcap_message)]</span>")
to_chat(src, span_notice("<b>Server Notice:</b>\n \t [CONFIG_GET(string/soft_popcap_message)]"))
sight |= SEE_TURFS
+11 -11
View File
@@ -152,7 +152,7 @@
if(href_list["late_join"])
if(!SSticker?.IsRoundInProgress())
to_chat(usr, "<span class='boldwarning'>The round is either not ready, or has already finished...</span>")
to_chat(usr, span_boldwarning("The round is either not ready, or has already finished..."))
return
if(href_list["late_join"] == "override")
@@ -160,16 +160,16 @@
return
if(SSticker.queued_players.len || (relevant_cap && living_player_count() >= relevant_cap && !(ckey(key) in GLOB.admin_datums)))
to_chat(usr, "<span class='danger'>[CONFIG_GET(string/hard_popcap_message)]</span>")
to_chat(usr, span_danger("[CONFIG_GET(string/hard_popcap_message)]"))
var/queue_position = SSticker.queued_players.Find(usr)
if(queue_position == 1)
to_chat(usr, "<span class='notice'>You are next in line to join the game. You will be notified when a slot opens up.</span>")
to_chat(usr, span_notice("You are next in line to join the game. You will be notified when a slot opens up."))
else if(queue_position)
to_chat(usr, "<span class='notice'>There are [queue_position-1] players in front of you in the queue to join the game.</span>")
to_chat(usr, span_notice("There are [queue_position-1] players in front of you in the queue to join the game."))
else
SSticker.queued_players += usr
to_chat(usr, "<span class='notice'>You have been added to the queue to join the game. Your position in queue is [SSticker.queued_players.len].</span>")
to_chat(usr, span_notice("You have been added to the queue to join the game. Your position in queue is [SSticker.queued_players.len]."))
return
LateChoices()
@@ -178,16 +178,16 @@
if(href_list["SelectedJob"])
if(!SSticker?.IsRoundInProgress())
to_chat(usr, "<span class='danger'>The round is either not ready, or has already finished...</span>")
to_chat(usr, span_danger("The round is either not ready, or has already finished..."))
return
if(!GLOB.enter_allowed)
to_chat(usr, "<span class='notice'>There is an administrative lock on entering the game!</span>")
to_chat(usr, span_notice("There is an administrative lock on entering the game!"))
return
if(SSticker.queued_players.len && !(ckey(key) in GLOB.admin_datums))
if((living_player_count() >= relevant_cap) || (src != SSticker.queued_players[1]))
to_chat(usr, "<span class='warning'>Server is full.</span>")
to_chat(usr, span_warning("Server is full."))
return
AttemptLateSpawn(href_list["SelectedJob"])
@@ -228,11 +228,11 @@
observer.started_as_observer = TRUE
close_spawn_windows()
var/obj/effect/landmark/observer_start/O = locate(/obj/effect/landmark/observer_start) in GLOB.landmarks_list
to_chat(src, "<span class='notice'>Now teleporting.</span>")
to_chat(src, span_notice("Now teleporting."))
if (O)
observer.forceMove(O.loc)
else
to_chat(src, "<span class='notice'>Teleporting failed. Ahelp an admin please</span>")
to_chat(src, span_notice("Teleporting failed. Ahelp an admin please"))
stack_trace("There's no freaking observer landmark available on this map or you're making observers before the map is initialised")
observer.key = key
observer.client = client
@@ -521,7 +521,7 @@
has_antags = TRUE
if(client.prefs.job_preferences.len == 0)
if(!ineligible_for_roles)
to_chat(src, "<span class='danger'>You have no jobs enabled, along with return to lobby if job is unavailable. This makes you ineligible for any round start role, please update your job preferences.</span>")
to_chat(src, span_danger("You have no jobs enabled, along with return to lobby if job is unavailable. This makes you ineligible for any round start role, please update your job preferences."))
ineligible_for_roles = TRUE
ready = PLAYER_NOT_READY
if(has_antags)
+18 -18
View File
@@ -21,7 +21,7 @@
if(!poll)
return
if(!SSdbcore.Connect())
to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
to_chat(src, span_danger("Failed to establish database connection."))
return
switch(poll.poll_type)
if(POLLTYPE_OPTION)
@@ -311,15 +311,15 @@
*/
/mob/dead/new_player/proc/vote_on_poll_handler(datum/poll_question/poll, href_list)
if(!SSdbcore.Connect())
to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
to_chat(src, span_danger("Failed to establish database connection."))
return
if(!poll || !href_list)
return
if(IsAdminAdvancedProcCall())
log_game("[key_name(usr)] attempted to rig the vote by voting as [key]")
message_admins("[key_name_admin(usr)] attempted to rig the vote by voting as [key]")
to_chat(usr, "<span class='danger'>You don't seem to be [key].</span>")
to_chat(src, "<span class='danger'>Something went horribly wrong processing your vote. Please contact an administrator, they should have gotten a message about this</span>")
to_chat(usr, span_danger("You don't seem to be [key]."))
to_chat(src, span_danger("Something went horribly wrong processing your vote. Please contact an administrator, they should have gotten a message about this"))
return
var/admin_rank
if(client.holder)
@@ -347,11 +347,11 @@
if(query_validate_poll_vote.NextRow())
vote_id = text2num(query_validate_poll_vote.item[1])
if(vote_id && !poll.allow_revoting)
to_chat(usr, "<span class='danger'>Poll revoting is disabled and you've already replied to this poll.</span>")
to_chat(usr, span_danger("Poll revoting is disabled and you've already replied to this poll."))
qdel(query_validate_poll_vote)
return
else
to_chat(usr, "<span class='danger'>Selected poll is not open.</span>")
to_chat(usr, span_danger("Selected poll is not open."))
qdel(query_validate_poll_vote)
return
qdel(query_validate_poll_vote)
@@ -370,7 +370,7 @@
if(vote_success)
if(!vote_id)
poll.poll_votes++
to_chat(usr, "<span class='notice'>Vote successful.</span>")
to_chat(usr, span_notice("Vote successful."))
/**
* Processes vote form data and saves results to the database for an option type poll.
@@ -378,13 +378,13 @@
*/
/mob/dead/new_player/proc/vote_on_poll_option(datum/poll_question/poll, href_list, admin_rank, sql_poll_id, vote_id)
if(!SSdbcore.Connect())
to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
to_chat(src, span_danger("Failed to establish database connection."))
return
if(IsAdminAdvancedProcCall())
return
var/datum/poll_option/option = locate(href_list["voteoptionref"]) in poll.options
if(!option)
to_chat(src, "<span class='danger'>No option was selected.</span>")
to_chat(src, span_danger("No option was selected."))
return
var/datum/db_query/query_vote_option = SSdbcore.NewQuery({"
INSERT INTO [format_table_name("poll_vote")] (id, datetime, pollid, optionid, ckey, ip, adminrank)
@@ -410,13 +410,13 @@
*/
/mob/dead/new_player/proc/vote_on_poll_text(href_list, admin_rank, sql_poll_id, vote_id)
if(!SSdbcore.Connect())
to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
to_chat(src, span_danger("Failed to establish database connection."))
return
if(IsAdminAdvancedProcCall())
return
var/reply_text = href_list["replytext"]
if(!reply_text || (length(reply_text) > 2048))
to_chat(src, "<span class='danger'>The text you entered was blank or too long. Please correct the text and submit again.</span>")
to_chat(src, span_danger("The text you entered was blank or too long. Please correct the text and submit again."))
return
var/datum/db_query/query_vote_text = SSdbcore.NewQuery({"
INSERT INTO [format_table_name("poll_textreply")] (id, datetime, pollid, ckey, ip, replytext, adminrank)
@@ -442,7 +442,7 @@
*/
/mob/dead/new_player/proc/vote_on_poll_rating(datum/poll_question/poll, list/href_list, admin_rank, sql_poll_id)
if(!SSdbcore.Connect())
to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
to_chat(src, span_danger("Failed to establish database connection."))
return
if(IsAdminAdvancedProcCall())
return
@@ -485,14 +485,14 @@
*/
/mob/dead/new_player/proc/vote_on_poll_multi(datum/poll_question/poll, list/href_list, admin_rank, sql_poll_id)
if(!SSdbcore.Connect())
to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
to_chat(src, span_danger("Failed to establish database connection."))
return
if(IsAdminAdvancedProcCall())
return
if(length(href_list) > 2)
href_list.Cut(1,3) //first two values aren't options
else
to_chat(src, "<span class='danger'>No options were selected.</span>")
to_chat(src, span_danger("No options were selected."))
var/special_columns = list(
"datetime" = "NOW()",
@@ -503,7 +503,7 @@
var/vote_count = 0
for(var/h in href_list)
if(vote_count == poll.options_allowed)
to_chat(src, "<span class='danger'>Allowed option count exceeded, only the first [poll.options_allowed] selected options have been saved.</span>")
to_chat(src, span_danger("Allowed option count exceeded, only the first [poll.options_allowed] selected options have been saved."))
break
vote_count++
var/datum/poll_option/option = locate(h) in poll.options
@@ -532,13 +532,13 @@
*/
/mob/dead/new_player/proc/vote_on_poll_irv(datum/poll_question/poll, list/href_list, admin_rank, sql_poll_id)
if(!SSdbcore.Connect())
to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
to_chat(src, span_danger("Failed to establish database connection."))
return
if(IsAdminAdvancedProcCall())
return
var/list/votelist = splittext(href_list["IRVdata"], ",")
if(!length(votelist))
to_chat(src, "<span class='danger'>No ordering data found. Please try again or contact an administrator.</span>")
to_chat(src, span_danger("No ordering data found. Please try again or contact an administrator."))
var/list/special_columns = list(
"datetime" = "NOW()",
@@ -550,7 +550,7 @@
for(var/o in votelist)
var/datum/poll_option/option = locate(o) in option_copy
if (!option)
to_chat(src, "<span class='warning'>invalid votes were trimmed from your ballot, please revote .</span>")
to_chat(src, span_warning("invalid votes were trimmed from your ballot, please revote ."))
sql_votes += list(list(
"pollid" = sql_poll_id,
"optionid" = option.option_id,
+28 -28
View File
@@ -355,13 +355,13 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(!client)
return
if(!mind || QDELETED(mind.current))
to_chat(src, "<span class='warning'>You have no body.</span>")
to_chat(src, span_warning("You have no body."))
return
if(!can_reenter_corpse)
to_chat(src, "<span class='warning'>You cannot re-enter your body.</span>")
to_chat(src, span_warning("You cannot re-enter your body."))
return
if(mind.current.key && mind.current.key[1] != "@") //makes sure we don't accidentally kick any clients
to_chat(usr, "<span class='warning'>Another consciousness is in your body...It is resisting you.</span>")
to_chat(usr, span_warning("Another consciousness is in your body...It is resisting you."))
return
client.view_size.setDefault(getScreenSize(client.prefs.widescreenpref))//Let's reset so people can't become allseeing gods
SStgui.on_transfer(src, mind.current) // Transfer NanoUIs.
@@ -375,7 +375,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(!client)
return
if(!can_reenter_corpse)
to_chat(usr, "<span class='warning'>You're already stuck out of your body!</span>")
to_chat(usr, span_warning("You're already stuck out of your body!"))
return FALSE
var/response = tgui_alert(usr, "Are you sure you want to prevent (almost) all means of resuscitation? This cannot be undone. ","Are you sure you want to stay dead?",list("DNR","Save Me"))
@@ -389,14 +389,14 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
// Disassociates observer mind from the body mind
mind = null
to_chat(src, "<span class='boldnotice'>You can no longer be brought back into your body.</span>")
to_chat(src, span_boldnotice("You can no longer be brought back into your body."))
return TRUE
/mob/dead/observer/proc/notify_cloning(message, sound, atom/source, flashwindow = TRUE)
if(flashwindow)
window_flash(client)
if(message)
to_chat(src, "<span class='ghostalert'>[message]</span>")
to_chat(src, span_ghostalert("[message]"))
if(source)
var/atom/movable/screen/alert/A = throw_alert("[REF(source)]_notify_cloning", /atom/movable/screen/alert/notify_cloning)
if(A)
@@ -410,7 +410,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
A.add_overlay(source)
source.layer = old_layer
source.plane = old_plane
to_chat(src, "<span class='ghostalert'><a href=?src=[REF(src)];reenter=1>(Click to re-enter)</a></span>")
to_chat(src, span_ghostalert("<a href=?src=[REF(src)];reenter=1>(Click to re-enter)</a>"))
if(sound)
SEND_SOUND(src, sound(sound))
@@ -419,7 +419,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set name = "Teleport"
set desc= "Teleport to a location"
if(!isobserver(usr))
to_chat(usr, "<span class='warning'>Not when you're not dead!</span>")
to_chat(usr, span_warning("Not when you're not dead!"))
return
var/list/filtered = list()
for(var/V in GLOB.sortedAreas)
@@ -436,7 +436,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
L+=T
if(!L || !L.len)
to_chat(usr, "<span class='warning'>No area available.</span>")
to_chat(usr, span_warning("No area available."))
return
usr.abstract_move(pick(L))
@@ -513,7 +513,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
A.abstract_move(T)
A.update_parallax_contents()
else
to_chat(A, "<span class='danger'>This mob is not located in the game world.</span>")
to_chat(A, span_danger("This mob is not located in the game world."))
/mob/dead/observer/verb/change_view_range()
set category = "Ghost"
@@ -556,11 +556,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/memory()
set hidden = TRUE
to_chat(src, "<span class='danger'>You are dead! You have no mind to store memory!</span>")
to_chat(src, span_danger("You are dead! You have no mind to store memory!"))
/mob/dead/observer/add_memory()
set hidden = TRUE
to_chat(src, "<span class='danger'>You are dead! You have no mind to store memory!</span>")
to_chat(src, span_danger("You are dead! You have no mind to store memory!"))
/mob/dead/observer/verb/toggle_ghostsee()
set name = "Toggle Ghost Vision"
@@ -568,7 +568,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set category = "Ghost"
ghostvision = !(ghostvision)
update_sight()
to_chat(usr, "<span class='boldnotice'>You [(ghostvision?"now":"no longer")] have ghost vision.</span>")
to_chat(usr, span_boldnotice("You [(ghostvision?"now":"no longer")] have ghost vision."))
/mob/dead/observer/verb/toggle_darkness()
set name = "Toggle Darkness"
@@ -643,14 +643,14 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
return FALSE
if(ismegafauna(target))
to_chat(src, "<span class='warning'>This creature is too powerful for you to possess!</span>")
to_chat(src, span_warning("This creature is too powerful for you to possess!"))
return FALSE
if(can_reenter_corpse && mind?.current)
if(tgui_alert(usr, "Your soul is still tied to your former life as [mind.current.name], if you go forward there is no going back to that life. Are you sure you wish to continue?", "Move On", list("Yes", "No")) == "No")
return FALSE
if(target.key)
to_chat(src, "<span class='warning'>Someone has taken this body while you were choosing!</span>")
to_chat(src, span_warning("Someone has taken this body while you were choosing!"))
return FALSE
target.key = key
@@ -663,7 +663,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/pointed(atom/A as mob|obj|turf in view(client.view, src))
if(!..())
return FALSE
usr.visible_message("<span class='deadsay'><b>[src]</b> points to [A].</span>")
usr.visible_message(span_deadsay("<b>[src]</b> points to [A]."))
return TRUE
/mob/dead/observer/verb/view_manifest()
@@ -733,11 +733,11 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(data_huds_on) //remove old huds
remove_data_huds()
to_chat(src, "<span class='notice'>Data HUDs disabled.</span>")
to_chat(src, span_notice("Data HUDs disabled."))
data_huds_on = 0
else
show_data_huds()
to_chat(src, "<span class='notice'>Data HUDs enabled.</span>")
to_chat(src, span_notice("Data HUDs enabled."))
data_huds_on = 1
/mob/dead/observer/verb/toggle_health_scan()
@@ -746,10 +746,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set category = "Ghost"
if(health_scan) //remove old huds
to_chat(src, "<span class='notice'>Health scan disabled.</span>")
to_chat(src, span_notice("Health scan disabled."))
health_scan = FALSE
else
to_chat(src, "<span class='notice'>Health scan enabled.</span>")
to_chat(src, span_notice("Health scan enabled."))
health_scan = TRUE
/mob/dead/observer/verb/toggle_chem_scan()
@@ -758,10 +758,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set category = "Ghost"
if(chem_scan) //remove old huds
to_chat(src, "<span class='notice'>Chem scan disabled.</span>")
to_chat(src, span_notice("Chem scan disabled."))
chem_scan = FALSE
else
to_chat(src, "<span class='notice'>Chem scan enabled.</span>")
to_chat(src, span_notice("Chem scan enabled."))
chem_scan = TRUE
/mob/dead/observer/verb/toggle_gas_scan()
@@ -770,10 +770,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set category = "Ghost"
if(gas_scan)
to_chat(src, "<span class='notice'>Gas scan disabled.</span>")
to_chat(src, span_notice("Gas scan disabled."))
gas_scan = FALSE
else
to_chat(src, "<span class='notice'>Gas scan enabled.</span>")
to_chat(src, span_notice("Gas scan enabled."))
gas_scan = TRUE
/mob/dead/observer/verb/restore_ghost_appearance()
@@ -882,7 +882,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(isobserver(src))
SSpai.recruitWindow(src)
else
to_chat(usr, "<span class='warning'>Can't become a pAI candidate while not dead!</span>")
to_chat(usr, span_warning("Can't become a pAI candidate while not dead!"))
/mob/dead/observer/verb/mafia_game_signup()
set category = "Ghost"
@@ -895,7 +895,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(!client)
return
if(!isobserver(src))
to_chat(usr, "<span class='warning'>You must be a ghost to join mafia!</span>")
to_chat(usr, span_warning("You must be a ghost to join mafia!"))
return
var/datum/mafia_controller/game = GLOB.mafia_game //this needs to change if you want multiple mafia games up at once.
if(!game)
@@ -914,8 +914,8 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/examine_more(mob/user)
if(!isAdminObserver(user))
return ..()
. = list("<span class='notice'><i>You examine [src] closer, and note the following...</i></span>")
. += list("\t><span class='admin'>[ADMIN_FULLMONTY(src)]</span>")
. = list(span_notice("<i>You examine [src] closer, and note the following...</i>"))
. += list("\t>[span_admin("[ADMIN_FULLMONTY(src)]")]")
/mob/dead/observer/proc/set_invisibility(value)