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
+1 -1
View File
@@ -509,7 +509,7 @@ SUBSYSTEM_DEF(air)
CHECK_TICK
var/msg = "HEY! LISTEN! [DisplayTimeText(world.timeofday - timer)] were wasted processing [starting_ats] turf(s) (connected to [ending_ats - starting_ats] other turfs) with atmos differences at round start."
to_chat(world, "<span class='boldannounce'>[msg]</span>")
to_chat(world, span_boldannounce("[msg]"))
warning(msg)
/turf/open/proc/resolve_active_graph()
+2 -2
View File
@@ -70,13 +70,13 @@ SUBSYSTEM_DEF(augury)
/datum/action/innate/augury/Activate()
SSaugury.watchers += owner
to_chat(owner, "<span class='notice'>You are now auto-following debris.</span>")
to_chat(owner, span_notice("You are now auto-following debris."))
active = TRUE
UpdateButtonIcon()
/datum/action/innate/augury/Deactivate()
SSaugury.watchers -= owner
to_chat(owner, "<span class='notice'>You are no longer auto-following debris.</span>")
to_chat(owner, span_notice("You are no longer auto-following debris."))
active = FALSE
UpdateButtonIcon()
+3 -3
View File
@@ -65,7 +65,7 @@ SUBSYSTEM_DEF(blackmarket)
var/obj/machinery/ltsrbt/pad = pick(telepads)
to_chat(recursive_loc_check(purchase.uplink.loc, /mob), "<span class='notice'>[purchase.uplink] flashes a message noting that the order is being processed by [pad].</span>")
to_chat(recursive_loc_check(purchase.uplink.loc, /mob), span_notice("[purchase.uplink] flashes a message noting that the order is being processed by [pad]."))
queued_purchases -= purchase
pad.add_to_queue(purchase)
@@ -76,7 +76,7 @@ SUBSYSTEM_DEF(blackmarket)
if (!targetturf)
continue
to_chat(recursive_loc_check(purchase.uplink.loc, /mob), "<span class='notice'>[purchase.uplink] flashes a message noting that the order is being teleported to [get_area(targetturf)] in 60 seconds.</span>")
to_chat(recursive_loc_check(purchase.uplink.loc, /mob), span_notice("[purchase.uplink] flashes a message noting that the order is being teleported to [get_area(targetturf)] in 60 seconds."))
// do_teleport does not want to teleport items from nullspace, so it just forceMoves and does sparks.
addtimer(CALLBACK(src, /datum/controller/subsystem/blackmarket/proc/fake_teleport, purchase.entry.spawn_item(), targetturf), 60 SECONDS)
@@ -91,7 +91,7 @@ SUBSYSTEM_DEF(blackmarket)
var/atom/movable/item = purchase.entry.spawn_item(pickedloc)
item.throw_at(purchase.uplink, 3, 3, spin = FALSE)
to_chat(recursive_loc_check(purchase.uplink.loc, /mob), "<span class='notice'>[purchase.uplink] flashes a message noting the order is being launched at the station from [dir2text(startSide)].</span>")
to_chat(recursive_loc_check(purchase.uplink.loc, /mob), span_notice("[purchase.uplink] flashes a message noting the order is being launched at the station from [dir2text(startSide)]."))
queued_purchases -= purchase
qdel(purchase)
+1 -1
View File
@@ -319,7 +319,7 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
/datum/db_query/proc/warn_execute(async = TRUE)
. = Execute(async)
if(!.)
to_chat(usr, "<span class='danger'>A SQL error occurred during this operation, check the server logs.</span>")
to_chat(usr, span_danger("A SQL error occurred during this operation, check the server logs."))
/datum/db_query/proc/Execute(async = TRUE, log_error = TRUE)
Activity("Execute")
+1 -1
View File
@@ -114,5 +114,5 @@ SUBSYSTEM_DEF(eigenstates)
///Prevents tool use on the item
/datum/controller/subsystem/eigenstates/proc/tool_interact(atom/source, mob/user, obj/item/item)
SIGNAL_HANDLER
to_chat(user, "<span class='notice'>The unstable nature of [source] makes it impossible to use [item] on [source.p_them()]!</span>")
to_chat(user, span_notice("The unstable nature of [source] makes it impossible to use [item] on [source.p_them()]!"))
return COMPONENT_BLOCK_TOOL_ATTACK
+4 -4
View File
@@ -85,7 +85,7 @@ SUBSYSTEM_DEF(job)
occupations = list()
var/list/all_jobs = subtypesof(/datum/job)
if(!all_jobs.len)
to_chat(world, "<span class='boldannounce'>Error setting up jobs, no job datums found</span>")
to_chat(world, span_boldannounce("Error setting up jobs, no job datums found"))
return FALSE
for(var/J in all_jobs)
@@ -503,7 +503,7 @@ SUBSYSTEM_DEF(job)
if(job.req_admin_notify)
to_chat(M, "<span class='infoplain'><b>You are playing a job that is important for Game Progression. If you have to disconnect, please notify the admins via adminhelp.</b></span>")
if(CONFIG_GET(number/minimal_access_threshold))
to_chat(M, "<span class='notice'><B>As this station was initially staffed with a [CONFIG_GET(flag/jobs_have_minimal_access) ? "full crew, only your job's necessities" : "skeleton crew, additional access may"] have been added to your ID card.</B></span>")
to_chat(M, span_notice("<B>As this station was initially staffed with a [CONFIG_GET(flag/jobs_have_minimal_access) ? "full crew, only your job's necessities" : "skeleton crew, additional access may"] have been added to your ID card.</B>"))
var/related_policy = get_policy(rank)
if(related_policy)
@@ -808,9 +808,9 @@ SUBSYSTEM_DEF(job)
var/where = new_captain.equip_in_one_of_slots(paper, slots, FALSE) || "at your feet"
if(acting_captain)
to_chat(new_captain, "<span class='notice'>Due to your position in the chain of command, you have been promoted to Acting Captain. You can find in important note about this [where].</span>")
to_chat(new_captain, span_notice("Due to your position in the chain of command, you have been promoted to Acting Captain. You can find in important note about this [where]."))
else
to_chat(new_captain, "<span class='notice'>You can find the code to obtain your spare ID from the secure safe on the Bridge [where].</span>")
to_chat(new_captain, span_notice("You can find the code to obtain your spare ID from the secure safe on the Bridge [where]."))
// Force-give their ID card bridge access.
var/obj/item/id_slot = new_captain.get_item_by_slot(ITEM_SLOT_ID)
+7 -7
View File
@@ -63,7 +63,7 @@ SUBSYSTEM_DEF(mapping)
var/old_config = config
config = global.config.defaultmap
if(!config || config.defaulted)
to_chat(world, "<span class='boldannounce'>Unable to load next or default map config, defaulting to Meta Station</span>")
to_chat(world, span_boldannounce("Unable to load next or default map config, defaulting to Meta Station"))
config = old_config
initialize_biomes()
loadWorld()
@@ -87,9 +87,9 @@ SUBSYSTEM_DEF(mapping)
// Load the virtual reality hub
if(CONFIG_GET(flag/virtual_reality))
to_chat(world, "<span class='boldannounce'>Loading virtual reality...</span>")
to_chat(world, span_boldannounce("Loading virtual reality..."))
load_new_z_level("_maps/RandomZLevels/VR/vrhub.dmm", "Virtual Reality Hub")
to_chat(world, "<span class='boldannounce'>Virtual reality loaded.</span>")
to_chat(world, span_boldannounce("Virtual reality loaded."))
// Generate mining ruins
loading_ruins = TRUE
@@ -202,7 +202,7 @@ Used by the AI doomsday and the self-destruct nuke.
z_list = SSmapping.z_list
#define INIT_ANNOUNCE(X) to_chat(world, "<span class='boldannounce'>[X]</span>"); log_world(X)
#define INIT_ANNOUNCE(X) to_chat(world, span_boldannounce("[X]")); log_world(X)
/datum/controller/subsystem/mapping/proc/LoadGroup(list/errorList, name, path, files, list/traits, list/default_traits, silent = FALSE)
. = list()
var/start_time = REALTIMEOFDAY
@@ -370,7 +370,7 @@ GLOBAL_LIST_EMPTY(the_station_areas)
message_admins("Randomly rotating map to [VM.map_name]")
. = changemap(VM)
if (. && VM.map_name != config.map_name)
to_chat(world, "<span class='boldannounce'>Map rotation has chosen [VM.map_name] for next round!</span>")
to_chat(world, span_boldannounce("Map rotation has chosen [VM.map_name] for next round!"))
/datum/controller/subsystem/mapping/proc/mapvote()
if(map_voted || SSmapping.next_map_config) //If voted or set by other means.
@@ -485,13 +485,13 @@ GLOBAL_LIST_EMPTY(the_station_areas)
if(!mapfile)
return
away_name = "[mapfile] custom"
to_chat(usr,"<span class='notice'>Loading [away_name]...</span>")
to_chat(usr,span_notice("Loading [away_name]..."))
var/datum/map_template/template = new(mapfile, "Away Mission")
away_level = template.load_new_z()
else
if(answer in GLOB.potentialRandomZlevels)
away_name = answer
to_chat(usr,"<span class='notice'>Loading [away_name]...</span>")
to_chat(usr,span_notice("Loading [away_name]..."))
var/datum/map_template/template = new(away_name, "Away Mission")
away_level = template.load_new_z()
else
+2 -2
View File
@@ -140,7 +140,7 @@ SUBSYSTEM_DEF(pai)
/datum/controller/subsystem/pai/proc/findPAI(obj/item/paicard/p, mob/user)
if(!(GLOB.ghost_role_flags & GHOSTROLE_SILICONS))
to_chat(user, "<span class='warning'>Due to growing incidents of SELF corrupted independent artificial intelligences, freeform personality devices have been temporarily banned in this sector.</span>")
to_chat(user, span_warning("Due to growing incidents of SELF corrupted independent artificial intelligences, freeform personality devices have been temporarily banned in this sector."))
return
if(!ghost_spam)
ghost_spam = TRUE
@@ -149,7 +149,7 @@ SUBSYSTEM_DEF(pai)
continue
if(!(ROLE_PAI in G.client.prefs.be_special))
continue
to_chat(G, "<span class='ghostalert'>[user] is requesting a pAI personality! Use the pAI button to submit yourself as one.</span>")
to_chat(G, span_ghostalert("[user] is requesting a pAI personality! Use the pAI button to submit yourself as one."))
addtimer(CALLBACK(src, .proc/spam_again), spam_delay)
var/list/available = list()
for(var/datum/pai_candidate/c in SSpai.candidates)
+2 -2
View File
@@ -64,7 +64,7 @@ SUBSYSTEM_DEF(server_maint)
var/cmob = C.mob
if (!isnewplayer(cmob) || !SSticker.queued_players.Find(cmob))
log_access("AFK: [key_name(C)]")
to_chat(C, "<span class='userdanger'>You have been inactive for more than [DisplayTimeText(afk_period)] and have been disconnected.</span><br><span class='danger'>You may reconnect via the button in the file menu or by <b><u><a href='byond://winset?command=.reconnect'>clicking here to reconnect</a></u></b>.</span>")
to_chat(C, span_userdanger("You have been inactive for more than [DisplayTimeText(afk_period)] and have been disconnected.</span><br><span class='danger'>You may reconnect via the button in the file menu or by <b><u><a href='byond://winset?command=.reconnect'>clicking here to reconnect</a></u></b>."))
QDEL_IN(C, 1) //to ensure they get our message before getting disconnected
continue
@@ -75,7 +75,7 @@ SUBSYSTEM_DEF(server_maint)
return
/datum/controller/subsystem/server_maint/Shutdown()
kick_clients_in_lobby("<span class='boldannounce'>The round came to an end with you in the lobby.</span>", TRUE) //second parameter ensures only afk clients are kicked
kick_clients_in_lobby(span_boldannounce("The round came to an end with you in the lobby."), TRUE) //second parameter ensures only afk clients are kicked
var/server = CONFIG_GET(string/server)
for(var/thing in GLOB.clients)
if(!thing)
+4 -4
View File
@@ -253,13 +253,13 @@ SUBSYSTEM_DEF(shuttle)
var/can_evac_or_fail_reason = SSshuttle.canEvac(user)
if(can_evac_or_fail_reason != TRUE)
to_chat(user, "<span class='alert'>[can_evac_or_fail_reason]</span>")
to_chat(user, span_alert("[can_evac_or_fail_reason]"))
return
call_reason = trim(html_encode(call_reason))
if(length(call_reason) < CALL_SHUTTLE_REASON_LENGTH && seclevel2num(get_security_level()) > SEC_LEVEL_GREEN)
to_chat(user, "<span class='alert'>You must provide a reason.</span>")
to_chat(user, span_alert("You must provide a reason."))
return
var/area/signal_origin = get_area(user)
@@ -282,7 +282,7 @@ SUBSYSTEM_DEF(shuttle)
var/area/A = get_area(user)
log_shuttle("[key_name(user)] has called the emergency shuttle.")
deadchat_broadcast(" has called the shuttle at <span class='name'>[A.name]</span>.", "<span class='name'>[user.real_name]</span>", user, message_type=DEADCHAT_ANNOUNCEMENT)
deadchat_broadcast(" has called the shuttle at [span_name("[A.name]")].", span_name("[user.real_name]"), user, message_type=DEADCHAT_ANNOUNCEMENT)
if(call_reason)
SSblackbox.record_feedback("text", "shuttle_reason", 1, "[call_reason]")
log_shuttle("Shuttle call reason: [call_reason]")
@@ -321,7 +321,7 @@ SUBSYSTEM_DEF(shuttle)
emergency.cancel(get_area(user))
log_shuttle("[key_name(user)] has recalled the shuttle.")
message_admins("[ADMIN_LOOKUPFLW(user)] has recalled the shuttle.")
deadchat_broadcast(" has recalled the shuttle from <span class='name'>[get_area_name(user, TRUE)]</span>.", "<span class='name'>[user.real_name]</span>", user, message_type=DEADCHAT_ANNOUNCEMENT)
deadchat_broadcast(" has recalled the shuttle from [span_name("[get_area_name(user, TRUE)]")].", span_name("[user.real_name]"), user, message_type=DEADCHAT_ANNOUNCEMENT)
return 1
/datum/controller/subsystem/shuttle/proc/canRecall()
+18 -18
View File
@@ -146,7 +146,7 @@ SUBSYSTEM_DEF(ticker)
start_at = world.time + (CONFIG_GET(number/lobby_countdown) * 10)
for(var/client/C in GLOB.clients)
window_flash(C, ignorepref = TRUE) //let them know lobby has opened up.
to_chat(world, "<span class='notice'><b>Welcome to [station_name()]!</b></span>")
to_chat(world, span_notice("<b>Welcome to [station_name()]!</b>"))
send2chat("New round starting on [SSmapping.config.map_name]!", CONFIG_GET(string/chat_announce_new_game))
current_state = GAME_STATE_PREGAME
//Everyone who wants to be an observer is now spawned
@@ -203,7 +203,7 @@ SUBSYSTEM_DEF(ticker)
/datum/controller/subsystem/ticker/proc/setup()
to_chat(world, "<span class='boldannounce'>Starting game...</span>")
to_chat(world, span_boldannounce("Starting game..."))
var/init_start = world.timeofday
mode = new /datum/game_mode/dynamic
@@ -224,7 +224,7 @@ SUBSYSTEM_DEF(ticker)
SSjob.ResetOccupations()
return FALSE
else
message_admins("<span class='notice'>DEBUG: Bypassing prestart checks...</span>")
message_admins(span_notice("DEBUG: Bypassing prestart checks..."))
CHECK_TICK
@@ -257,14 +257,14 @@ SUBSYSTEM_DEF(ticker)
round_start_time = world.time
SSdbcore.SetRoundStart()
to_chat(world, "<span class='notice'><B>Welcome to [station_name()], enjoy your stay!</B></span>")
to_chat(world, span_notice("<B>Welcome to [station_name()], enjoy your stay!</B>"))
SEND_SOUND(world, sound(SSstation.announcer.get_rand_welcome_sound()))
current_state = GAME_STATE_PLAYING
Master.SetRunLevel(RUNLEVEL_GAME)
if(SSevents.holidays)
to_chat(world, "<span class='notice'>and...</span>")
to_chat(world, span_notice("and..."))
for(var/holidayname in SSevents.holidays)
var/datum/holiday/holiday = SSevents.holidays[holidayname]
to_chat(world, "<h4>[holiday.greet()]</h4>")
@@ -303,9 +303,9 @@ SUBSYSTEM_DEF(ticker)
if(!iter_human.hardcore_survival_score)
continue
if(iter_human.mind?.special_role)
to_chat(iter_human, "<span class='notice'>You will gain [round(iter_human.hardcore_survival_score) * 2] hardcore random points if you greentext this round!</span>")
to_chat(iter_human, span_notice("You will gain [round(iter_human.hardcore_survival_score) * 2] hardcore random points if you greentext this round!"))
else
to_chat(iter_human, "<span class='notice'>You will gain [round(iter_human.hardcore_survival_score)] hardcore random points if you survive this round!</span>")
to_chat(iter_human, span_notice("You will gain [round(iter_human.hardcore_survival_score)] hardcore random points if you survive this round!"))
//These callbacks will fire after roundstart key transfer
/datum/controller/subsystem/ticker/proc/OnRoundstart(datum/callback/cb)
@@ -395,7 +395,7 @@ SUBSYSTEM_DEF(ticker)
for(var/mob/dead/new_player/new_player_mob as anything in GLOB.new_player_list)
var/mob/living/carbon/human/new_player_human = new_player_mob.new_character
if(new_player_human)
to_chat(new_player_mob, "<span class='notice'>Captainship not forced on anyone.</span>")
to_chat(new_player_mob, span_notice("Captainship not forced on anyone."))
CHECK_TICK
/datum/controller/subsystem/ticker/proc/decide_security_officer_departments(
@@ -457,7 +457,7 @@ SUBSYSTEM_DEF(ticker)
m = pick(memetips)
if(m)
to_chat(world, "<span class='oocplain'><span class='purple'><b>Tip of the round: </b>[html_encode(m)]</span></span>")
to_chat(world, span_purple("<span class='oocplain'><b>Tip of the round: </b>[html_encode(m)]</span>"))
/datum/controller/subsystem/ticker/proc/check_queue()
if(!queued_players.len)
@@ -466,7 +466,7 @@ SUBSYSTEM_DEF(ticker)
if(!hpc)
listclearnulls(queued_players)
for (var/mob/dead/new_player/NP in queued_players)
to_chat(NP, "<span class='userdanger'>The alive players limit has been released!<br><a href='?src=[REF(NP)];late_join=override'>[html_encode(">>Join Game<<")]</a></span>")
to_chat(NP, span_userdanger("The alive players limit has been released!<br><a href='?src=[REF(NP)];late_join=override'>[html_encode(">>Join Game<<")]</a>"))
SEND_SOUND(NP, sound('sound/misc/notice1.ogg'))
NP.LateChoices()
queued_players.len = 0
@@ -481,14 +481,14 @@ SUBSYSTEM_DEF(ticker)
listclearnulls(queued_players)
if(living_player_count() < hpc)
if(next_in_line?.client)
to_chat(next_in_line, "<span class='userdanger'>A slot has opened! You have approximately 20 seconds to join. <a href='?src=[REF(next_in_line)];late_join=override'>\>\>Join Game\<\<</a></span>")
to_chat(next_in_line, span_userdanger("A slot has opened! You have approximately 20 seconds to join. <a href='?src=[REF(next_in_line)];late_join=override'>\>\>Join Game\<\<</a>"))
SEND_SOUND(next_in_line, sound('sound/misc/notice1.ogg'))
next_in_line.LateChoices()
return
queued_players -= next_in_line //Client disconnected, remove he
queue_delay = 0 //No vacancy: restart timer
if(25 to INFINITY) //No response from the next in line when a vacancy exists, remove he
to_chat(next_in_line, "<span class='danger'>No response received. You have been removed from the line.</span>")
to_chat(next_in_line, span_danger("No response received. You have been removed from the line."))
queued_players -= next_in_line
queue_delay = 0
@@ -635,17 +635,17 @@ SUBSYSTEM_DEF(ticker)
var/skip_delay = check_rights()
if(delay_end && !skip_delay)
to_chat(world, "<span class='boldannounce'>An admin has delayed the round end.</span>")
to_chat(world, span_boldannounce("An admin has delayed the round end."))
return
to_chat(world, "<span class='boldannounce'>Rebooting World in [DisplayTimeText(delay)]. [reason]</span>")
to_chat(world, span_boldannounce("Rebooting World in [DisplayTimeText(delay)]. [reason]"))
var/start_wait = world.time
UNTIL(round_end_sound_sent || (world.time - start_wait) > (delay * 2)) //don't wait forever
sleep(delay - (world.time - start_wait))
if(delay_end && !skip_delay)
to_chat(world, "<span class='boldannounce'>Reboot was cancelled by an admin.</span>")
to_chat(world, span_boldannounce("Reboot was cancelled by an admin."))
return
if(end_string)
end_state = end_string
@@ -653,11 +653,11 @@ SUBSYSTEM_DEF(ticker)
var/statspage = CONFIG_GET(string/roundstatsurl)
var/gamelogloc = CONFIG_GET(string/gamelogurl)
if(statspage)
to_chat(world, "<span class='info'>Round statistics and logs can be viewed <a href=\"[statspage][GLOB.round_id]\">at this website!</a></span>")
to_chat(world, span_info("Round statistics and logs can be viewed <a href=\"[statspage][GLOB.round_id]\">at this website!</a>"))
else if(gamelogloc)
to_chat(world, "<span class='info'>Round logs can be located <a href=\"[gamelogloc]\">at this website!</a></span>")
to_chat(world, span_info("Round logs can be located <a href=\"[gamelogloc]\">at this website!</a>"))
log_game("<span class='boldannounce'>Rebooting World. [reason]</span>")
log_game(span_boldannounce("Rebooting World. [reason]"))
world.Reboot()
+4 -4
View File
@@ -152,7 +152,7 @@ SUBSYSTEM_DEF(vote)
/datum/controller/subsystem/vote/proc/initiate_vote(vote_type, initiator_key)
//Server is still intializing.
if(!Master.current_runlevel)
to_chat(usr, "<span class='warning'>Cannot start vote, server is not done initializing.</span>")
to_chat(usr, span_warning("Cannot start vote, server is not done initializing."))
return FALSE
var/lower_admin = FALSE
var/ckey = ckey(initiator_key)
@@ -163,10 +163,10 @@ SUBSYSTEM_DEF(vote)
if(started_time)
var/next_allowed_time = (started_time + CONFIG_GET(number/vote_delay))
if(mode)
to_chat(usr, "<span class='warning'>There is already a vote in progress! please wait for it to finish.</span>")
to_chat(usr, span_warning("There is already a vote in progress! please wait for it to finish."))
return FALSE
if(next_allowed_time > world.time && !lower_admin)
to_chat(usr, "<span class='warning'>A vote was initiated recently, you must wait [DisplayTimeText(next_allowed_time-world.time)] before a new vote can be started!</span>")
to_chat(usr, span_warning("A vote was initiated recently, you must wait [DisplayTimeText(next_allowed_time-world.time)] before a new vote can be started!"))
return FALSE
reset()
@@ -175,7 +175,7 @@ SUBSYSTEM_DEF(vote)
choices.Add("Restart Round","Continue Playing")
if("map")
if(!lower_admin && SSmapping.map_voted)
to_chat(usr, "<span class='warning'>The next map has already been selected.</span>")
to_chat(usr, span_warning("The next map has already been selected."))
return FALSE
// Randomizes the list so it isn't always METASTATION
var/list/maps = list()