Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text() away #19850

Merged
merged 7 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/__DEFINES/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ var/regex/filename_forbidden_chars = regex(@{""|[\\\n\t/?%*:|<>]|\.\."}, "g")

/// Removes everything enclose in < and > inclusive of the bracket, and limits the length of the message.
#define STRIP_HTML_FULL(text, limit) (html_tags.Replace(copytext(text, 1, limit), ""))

/// BYOND's string procs don't support being used on datum references (as in it doesn't look for a name for stringification)
/// We just use this macro to ensure that we will only pass strings to this BYOND-level function without developers needing to really worry about it.
#define LOWER_TEXT(thing) lowertext(UNLINT("[thing]"))
2 changes: 1 addition & 1 deletion code/__HELPERS/logging/talk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Arguments:
* * message - The message being logged
* * message_type - the type of log the message is(ATTACK, SAY, etc)
* * tag - tag that indicates the type of text(announcement, telepathy, etc)
* * tag - tag that indicates the type of text (announcement, telepathy, etc)
* * log_globally - boolean checking whether or not we write this log to the log file
* * forced_by - source that forced the dialogue if any
*/
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ Proc for attack log creation, because really why not

/proc/add_logs(mob/user, mob/target, what_done, var/admin=1, var/object=null, var/addition=null)
if(user && ismob(user))
user.attack_log += text("\[[time_stamp()]\] <span class='warning'>Has [what_done] [target ? "[target.name][(ismob(target) && target.ckey) ? "([target.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition]</span>")
user.attack_log += "\[[time_stamp()]\] <span class='warning'>Has [what_done] [target ? "[target.name][(ismob(target) && target.ckey) ? "([target.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition]</span>"
if(target && ismob(target))
target.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been [what_done] by [user ? "[user.name][(ismob(user) && user.ckey) ? "([user.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition]</font>")
target.attack_log += "\[[time_stamp()]\] <font color='orange'>Has been [what_done] by [user ? "[user.name][(ismob(user) && user.ckey) ? "([user.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition]</font>"
if(admin)
log_attack(SPAN_WARNING("[user ? "[user.name][(ismob(user) && user.ckey) ? "([user.ckey])" : ""]" : "NON-EXISTANT SUBJECT"] [what_done] [target ? "[target.name][(ismob(target) && target.ckey)? "([target.ckey])" : ""]" : "NON-EXISTANT SUBJECT"][object ? " with [object]" : " "][addition]"))

Expand Down
41 changes: 22 additions & 19 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -725,49 +725,52 @@

var/leng = length(string)

var/next_space = findtext_char(string, " ", next_backslash + 1)
var/next_space = findtext(string, " ", next_backslash + length(string[next_backslash]))
if(!next_space)
next_space = leng - next_backslash

if(!next_space) //trailing bs
if(!next_space) //trailing bs
return string

var/base = next_backslash == 1 ? "" : copytext(string, 1, next_backslash)
var/macro = lowertext(copytext(string, next_backslash + 1, next_space))
var/rest = next_backslash > leng ? "" : copytext(string, next_space + 1)
var/macro = LOWER_TEXT(copytext(string, next_backslash + length(string[next_backslash]), next_space))
var/rest = next_backslash > leng ? "" : copytext(string, next_space + length(string[next_space]))

//See http://www.byond.com/docs/ref/info.html#/DM/text/macros
//See https://secure.byond.com/docs/ref/info.html#/DM/text/macros
switch(macro)
//prefixes/agnostic
if("the")
rest = text("\the []", rest)
rest = "\the [rest]"
if("a")
rest = text("\a []", rest)
rest = "\a [rest]"
if("an")
rest = text("\an []", rest)
rest = "\an [rest]"
if("proper")
rest = text("\proper []", rest)
rest = "\proper [rest]"
if("improper")
rest = text("\improper []", rest)
rest = "\improper [rest]"
if("roman")
rest = text("\roman []", rest)
rest = "\roman [rest]"
//postfixes
if("th")
base = text("[]\th", rest)
base = "[rest]\th"
if("s")
base = text("[]\s", rest)
base = "[rest]\s"
if("he")
base = text("[]\he", rest)
base = "[rest]\he"
if("she")
base = text("[]\she", rest)
base = "[rest]\she"
if("his")
base = text("[]\his", rest)
base = "[rest]\his"
if("himself")
base = text("[]\himself", rest)
base = "[rest]\himself"
if("herself")
base = text("[]\herself", rest)
base = "[rest]\herself"
if("hers")
base = text("[]\hers", rest)
base = "[rest]\hers"
else // Someone fucked up, if you're not a macro just go home yeah?
// This does technically break parsing, but at least it's better then what it used to do
return base

. = base
if(rest)
Expand Down
10 changes: 5 additions & 5 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
textg = num2hex(255 - g, 0)
textb = num2hex(255 - b, 0)
if (length(textr) < 2)
textr = text("0[]", textr)
textr = "0[textr]"
if (length(textg) < 2)
textr = text("0[]", textg)
textr = "0[textg]"
if (length(textb) < 2)
textr = text("0[]", textb)
return text("#[][][]", textr, textg, textb)
textr = "0[textb]"
return "#[textr][textg][textb]"

//Returns the middle-most value
/proc/dd_range(var/low, var/high, var/num)
Expand Down Expand Up @@ -1116,7 +1116,7 @@ var/global/known_proc = /proc/get_type_ref_bytes
if(ispath(V))
return details && path_names ? "path([V])" : "path"
if(istext(V))
return details && text_lengths ? "text([length(V) ])" : "text"
return details && text_lengths ? "text ([length(V) ])" : "text"
if(isnum(V)) // Byond doesn't really differentiate between floats and ints, but we can sort of guess here
// also technically we could also say that 0 and 1 are boolean but that'd be quite silly
if(IsInteger(V) && V < 16777216 && V > -16777216)
Expand Down
12 changes: 6 additions & 6 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,17 @@
return 0
if (H.gloves)
if(src.fingerprintslast != H.key)
src.fingerprintshidden += text("\[[time_stamp()]\] (Wearing gloves). Real name: [], Key: []",H.real_name, H.key)
src.fingerprintshidden += "\[[time_stamp()]\] (Wearing gloves). Real name: [H.real_name], Key: [H.key]"
src.fingerprintslast = H.key
return 0
if (!( src.fingerprints ))
if(src.fingerprintslast != H.key)
src.fingerprintshidden += text("\[[time_stamp()]\] Real name: [], Key: []",H.real_name, H.key)
src.fingerprintshidden += "\[[time_stamp()]\] Real name: [H.real_name], Key: [H.key]"
src.fingerprintslast = H.key
return 1
else
if(src.fingerprintslast != M.key)
src.fingerprintshidden += text("\[[time_stamp()]\] Real name: [], Key: []",M.real_name, M.key)
src.fingerprintshidden += "\[[time_stamp()]\] Real name: [M.real_name], Key: [M.key]"
src.fingerprintslast = M.key
return

Expand Down Expand Up @@ -310,7 +310,7 @@
// Now, deal with gloves.
if (H.gloves && H.gloves != src)
if(fingerprintslast != H.key)
fingerprintshidden += text("\[[]\](Wearing gloves). Real name: [], Key: []",time_stamp(), H.real_name, H.key)
fingerprintshidden += "\[[time_stamp()]\](Wearing gloves). Real name: [H.real_name], Key: [H.key]"
fingerprintslast = H.key
H.gloves.add_fingerprint(M)

Expand All @@ -323,7 +323,7 @@

// Admin related.
if(fingerprintslast != H.key)
fingerprintshidden += text("\[[]\]Real name: [], Key: []",time_stamp(), H.real_name, H.key)
fingerprintshidden += "\[[time_stamp()]\]Real name: [H.real_name], Key: [H.key]"
fingerprintslast = H.key

// Make the list if it does not exist.
Expand Down Expand Up @@ -375,7 +375,7 @@
else
// Smudge up the prints a bit.
if(fingerprintslast != M.key)
fingerprintshidden += text("\[[]\]Real name: [], Key: []",time_stamp(), M.real_name, M.key)
fingerprintshidden += "\[[time_stamp()]\]Real name: [M.real_name], Key: [M.key]"
fingerprintslast = M.key

// Cleaning up.
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/cult/items/tome.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
attack_admins(M, user)

/obj/item/book/tome/proc/attack_admins(var/mob/living/M, var/mob/living/user)
M.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has had the [name] used on them by [user.name] ([user.ckey])</font>")
user.attack_log += text("\[[time_stamp()]\] <span class='warning'>Used [name] on [M.name] ([M.ckey])</span>")
M.attack_log += "\[[time_stamp()]\] <font color='orange'>Has had the [name] used on them by [user.name] ([user.ckey])</font>"
user.attack_log += "\[[time_stamp()]\] <span class='warning'>Used [name] on [M.name] ([M.ckey])</span>"
msg_admin_attack("[key_name_admin(user)] used [name] on [M.name] ([M.ckey]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)",ckey=key_name(user),ckey_target=key_name(M))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
/proc/log_ability_use(var/mob/living/silicon/ai/A, var/ability_name, var/atom/target = null, var/notify_admins = 1)
var/message
if(target)
message = text("used malf ability/function: [ability_name] on [target] ([target.x], [target.y], [target.z])")
message = "used malf ability/function: [ability_name] on [target] ([target.x], [target.y], [target.z])"
else
message = text("used malf ability/function: [ability_name].")
message = "used malf ability/function: [ability_name]."
admin_attack_log(A, null, message, null, message)
6 changes: 3 additions & 3 deletions code/game/machinery/ai_slipper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
return
if ( (get_dist(src, user) > 1 ))
if (!istype(user, /mob/living/silicon))
to_chat(user, text("Too far away."))
to_chat(user, "Too far away.")
user.unset_machine()
user << browse(null, "window=ai_slipper")
return
Expand All @@ -72,7 +72,7 @@
if (istype(loc, /turf))
loc = loc:loc
if (!istype(loc, /area))
to_chat(user, text("Turret badly positioned - loc.loc is [].", loc))
to_chat(user, "Turret badly positioned - loc.loc is [loc].")
return
var/area/area = loc
var/t = "<TT><B>AI Liquid Dispenser</B> ([area.name])<HR>"
Expand All @@ -81,7 +81,7 @@
t += "<I>(Swipe ID card to unlock control panel.)</I><BR>"
else
t += "Dispenser [(src.disabled ? "deactivated" : "activated")] - <A href='?src=[REF(src)];toggleOn=1'>[(src.disabled ? "Enable" : "Disable")]?</a><br>\n"
t += text("Uses Left: [uses]. <A href='?src=[REF(src)];toggleUse=1'>Activate the dispenser?</A><br>\n")
t += "Uses Left: [uses]. <A href='?src=[REF(src)];toggleUse=1'>Activate the dispenser?</A><br>\n"

user << browse(t, "window=computer;size=575x450")
onclose(user, "computer")
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/atmoalter/canister.dm
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ update_flag
if (src.destroyed)
ClearOverlays()
set_light(FALSE)
src.icon_state = text("[]-1", src.canister_color)
src.icon_state = "[src.canister_color]-1"
return

if(icon_state != "[canister_color]")
Expand Down
52 changes: 26 additions & 26 deletions code/game/machinery/body_scanner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -786,48 +786,48 @@
dat += "<font face=\"Verdana\">"
dat += "<b>Patient Status</b><br><HR>"
dat += "<font size=\"1\">"
dat += text("Name: []<br>", occ["name"])
dat += text("Status: []<br>", occ["stat"])
dat += text("Species: []<br>", occ["species"])
dat += text("Pulse: [] BPM<br>", occ["pulse"])
dat += text("Brain Activity: []<br>", occ["brain_activity"])
dat += text("Body Temperature: []&deg;C ", (occ["bodytemp"] - T0C))
dat += text("([]&deg;F)<br>", (occ["bodytemp"]*1.8-459.67))
dat += "Name: [occ["name"]]<br>"
dat += "Status: [occ["stat"]]<br>"
dat += "Species: [occ["species"]]<br>"
dat += "Pulse: [occ["pulse"]] BPM<br>"
dat += "Brain Activity: [occ["brain_activity"]]<br>"
dat += "Body Temperature: [(occ["bodytemp"] - T0C)]&deg;C "
dat += "([(occ["bodytemp"]*1.8-459.67)]&deg;F)<br>"

dat += "<b><br>Blood Status</b><br><HR>"
dat += text("Blood Pressure: []<br>", occ["blood_pressure"])
dat += text("Blood Oxygenation: []%<br>", occ["blood_oxygenation"])
dat += text("Blood Volume: []%<br>", occ["blood_volume"])
dat += text("Blood Type: []<br>", occ["blood_type"])
dat += "Blood Pressure: [occ["blood_pressure"]]<br>"
dat += "Blood Oxygenation: [occ["blood_oxygenation"]]%<br>"
dat += "Blood Volume: [occ["blood_volume"]]%<br>"
dat += "Blood Type: [occ["blood_type"]]<br>"

if(occ["inaprovaline_amount"])
dat += text("Inaprovaline: [] units<BR>", occ["inaprovaline_amount"])
dat += "Inaprovaline: [occ["inaprovaline_amount"]] units<BR>"
if(occ["soporific_amount"])
dat += text("Soporific: [] units<BR>", occ["soporific_amount"])
dat += "Soporific: [occ["soporific_amount"]] units<BR>"
if(occ["dermaline_amount"])
dat += text("[]\tDermaline: [] units</font><BR>", ("<font color='[occ["dermaline_amount"] < 20 ? "black" : "red"]'>"), occ["dermaline_amount"])
dat += "[("<font color='[occ["dermaline_amount"] < 20 ? "black" : "red"]'>")]\tDermaline: [occ["dermaline_amount"]] units</font><BR>"
if(occ["bicaridine_amount"])
dat += text("[]\tBicaridine: [] units</font><BR>", ("<font color='[occ["bicaridine_amount"] < 20 ? "black" : "red"]'>"), occ["bicaridine_amount"])
dat += "[("<font color='[occ["bicaridine_amount"] < 20 ? "black" : "red"]'>")]\tBicaridine: [occ["bicaridine_amount"]] units</font><BR>"
if(occ["dexalin_amount"])
dat += text("[]\tDexalin: [] units</font><BR>", ("<font color='[occ["dexalin_amount"] < 20 ? "black" : "red"]'>"), occ["dexalin_amount"])
dat += "[("<font color='[occ["dexalin_amount"] < 20 ? "black" : "red"]'>")]\tDexalin: [occ["dexalin_amount"]] units</font><BR>"
if(occ["thetamycin_amount"])
dat += text("[]\tThetamycin: [] units</font><BR>", ("<font color='[occ["thetamycin_amount"] < 20 ? "black" : "red"]'>"), occ["thetamycin_amount"])
dat += "[("<font color='[occ["thetamycin_amount"] < 20 ? "black" : "red"]'>")]\tThetamycin: [occ["thetamycin_amount"]] units</font><BR>"
if(occ["other_amount"])
dat += text("Other: [] units<BR>", occ["other_amount"])
dat += "Other: [occ["other_amount"]] units<BR>"

dat += "<b><br>Symptom Status</b><br><HR>"
dat += text("Radiation Level: [] Gy<br>", round(occ["rads"]))
dat += text("Genetic Damage: []<br>", occ["cloneloss"])
dat += "Radiation Level: [round(occ["rads"])] Gy<br>"
dat += "Genetic Damage: [occ["cloneloss"]]<br>"
if(occ["paralysis"])
dat += text("Est Paralysis Level: [] Seconds Left<br>", round(occ["paralysis"] / 4))
dat += "Est Paralysis Level: [round(occ["paralysis"] / 4)] Seconds Left<br>"
else
dat += text("Est Paralysis Level: None<br>")
dat += "Est Paralysis Level: None<br>"

dat += "<b><br>Damage Status</b><br><HR>"
dat += text("Brute Trauma: []<br>", occ["bruteloss"])
dat += text("Burn Severity: []<br>", occ["fireloss"])
dat += text("Oxygen Deprivation: []<br>", occ["oxyloss"])
dat += text("Toxin Exposure: []<br>", occ["toxloss"])
dat += "Brute Trauma: [occ["bruteloss"]]<br>"
dat += "Burn Severity: [occ["fireloss"]]<br>"
dat += "Oxygen Deprivation: [occ["oxyloss"]]<br>"
dat += "Toxin Exposure: [occ["toxloss"]]<br>"

dat += "<br><b>Body Status</b><HR>"

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
var/obj/machinery/computer/security/S = O.machine
if (S.current_camera == src)
to_chat(O, "[U] holds \a [itemname] up to one of the cameras ...")
O << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", itemname, info), text("window=[]", itemname)) //Force people watching to open the page so they can't see it again)
O << browse("<HTML><HEAD><TITLE>[itemname]</TITLE></HEAD><BODY><TT>[info]</TT></BODY></HTML>", "window=[itemname]") //Force people watching to open the page so they can't see it again)
return TRUE

else if (istype(attacking_item, /obj/item/camera_bug))
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/camera/tracking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
for (var/obj/machinery/camera/C in GLOB.cameranet.cameras)
var/list/tempnetwork = C.network&src.network
if (tempnetwork.len)
T[text("[][]", C.c_tag, (C.can_use() ? null : " (Deactivated)"))] = C
T["[C.c_tag][(C.can_use() ? null : " (Deactivated)")]"] = C

track = new()
track.cameras = T
Expand Down Expand Up @@ -113,7 +113,7 @@
var/name = M.name
if (name in TB.names)
TB.namecounts[name]++
name = text("[] ([])", name, TB.namecounts[name])
name = "[name] ([TB.namecounts[name]])"
else
TB.names.Add(name)
TB.namecounts[name] = 1
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
to_chat(user, "The access level of [id.registered_name]\'s card is not high enough. ")
return 0

var/choice = alert(user, text("Would you like to (un)authorize a shortened launch time? [] authorization\s are still needed. Use abort to cancel all authorizations.", src.auth_need - src.authorized.len), "Shuttle Launch", "Authorize", "Repeal", "Abort")
var/choice = alert(user, "Would you like to (un)authorize a shortened launch time? [(src.auth_need - src.authorized.len)] authorization\s are still needed. Use abort to cancel all authorizations.", "Shuttle Launch", "Authorize", "Repeal", "Abort")
if(evacuation_controller.is_prepared() && user.get_active_hand() != id)
return 0
switch(choice)
Expand Down
12 changes: 6 additions & 6 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -915,18 +915,18 @@ About the new airlock wires panel:
/obj/machinery/door/airlock/proc/electrify(var/duration, var/feedback = 0)
var/message = ""
if(isWireCut(WIRE_SHOCK) && arePowerSystemsOn())
message = text("The electrification wire is cut - Door permanently electrified.")
message ="The electrification wire is cut - Door permanently electrified."
electrified_until = -1
else if(duration && !arePowerSystemsOn())
message = text("The door is unpowered - Cannot electrify the door.")
message = "The door is unpowered - Cannot electrify the door."
electrified_until = 0
else if(!duration && electrified_until != 0)
message = "The door is now un-electrified."
electrified_until = 0
else if(duration) //electrify door for the given duration seconds
if(usr)
LAZYADD(shockedby, "\[[time_stamp()]\] - [usr](ckey:[usr.ckey])")
usr.attack_log += text("\[[time_stamp()]\] <span class='warning'>Electrified the [name] at [x] [y] [z]</span>")
usr.attack_log += "\[[time_stamp()]\] <span class='warning'>Electrified the [name] at [x] [y] [z]</span>"
else
LAZYADD(shockedby, "\[[time_stamp()]\] - EMP)")
message = "The door is now electrified [duration == -1 ? "permanently" : "for [duration] second\s"]."
Expand Down Expand Up @@ -956,7 +956,7 @@ About the new airlock wires panel:
var/message = ""
// Safeties! We don't need no stinking safeties!
if (src.isWireCut(WIRE_SAFETY))
message = text("The safety wire is cut - Cannot enable safeties.")
message = "The safety wire is cut - Cannot enable safeties."
else if (!activate && src.safe)
safe = FALSE
else if (activate && !src.safe)
Expand Down Expand Up @@ -1231,7 +1231,7 @@ About the new airlock wires panel:
if("timing")
// Door speed control
if(src.isWireCut(WIRE_TIMING))
to_chat(usr, text("The timing wire is cut - Cannot alter timing."))
to_chat(usr, "The timing wire is cut - Cannot alter timing.")
else if (activate && src.normalspeed)
normalspeed = FALSE
else if (!activate && !src.normalspeed)
Expand Down Expand Up @@ -1617,7 +1617,7 @@ About the new airlock wires panel:
if("timing")
// Door speed control
if(src.isWireCut(WIRE_TIMING))
to_chat(usr, text("The timing wire is cut - Cannot alter timing."))
to_chat(usr, "The timing wire is cut - Cannot alter timing.")
else if (activate && src.normalspeed)
normalspeed = FALSE
else if (!activate && !src.normalspeed)
Expand Down
Loading
Loading