Skip to content

Commit

Permalink
partially fixes xeno examine paper bug
Browse files Browse the repository at this point in the history
  • Loading branch information
doom committed Oct 12, 2023
1 parent 75c825a commit fc04f35
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
35 changes: 35 additions & 0 deletions code/modules/mob/mob_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,41 @@ var/global/list/limb_types_by_name = list(
index++
return output_message

// proc that parses an html input string and scrambles the non-html string contents
/proc/stars_decode_html(message)
if(length(message) == 0)
return

// todo: sanitize string more to remove unnencessary <>.
// list of parsed strings that have been scrambled, used to then reinsert the scrambled strings in to the message
var/list/replaced_scrambled_strings = list()

// boolean value to know if the current indexed element needs to be added to the scrambled message.
var/parsing_message = FALSE

// the current string value that needs to be scrambled.
var/current_string_to_scramble = ""

for(var/character_index in 1 to length(message))
if(message[character_index] == ">")
parsing_message = TRUE
continue
else if(message[character_index] == "<")
parsing_message = FALSE
if(length(current_string_to_scramble) == 0)
continue
var/scrambled_string = stars(current_string_to_scramble)
replaced_scrambled_strings[current_string_to_scramble] += scrambled_string
current_string_to_scramble = null
continue
if(parsing_message)
current_string_to_scramble += message[character_index]

for(var/unscrambled_message_key in replaced_scrambled_strings)
message = replacetext(message, unscrambled_message_key, replaced_scrambled_strings[unscrambled_message_key])

return message

/proc/slur(phrase)
phrase = html_decode(phrase)
var/leng=length(phrase)
Expand Down
13 changes: 6 additions & 7 deletions code/modules/paperwork/paper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,22 @@
if(in_range(user, src) || istype(user, /mob/dead/observer))
if(!(istype(user, /mob/dead/observer) || istype(user, /mob/living/carbon/human) || isRemoteControlling(user)))
// Show scrambled paper if they aren't a ghost, human, or silicone.
if(photo_list)
for(var/photo in photo_list)
user << browse_rsc(photo_list[photo], photo)
show_browser(user, "<BODY class='paper'>[stars(info)][stamps]</BODY>", name, name, "size=650x700")
onclose(user, name)
read_paper(user, scramble=TRUE)
else
read_paper(user)
else
. += SPAN_NOTICE("It is too far away.")

/obj/item/paper/proc/read_paper(mob/user)
/obj/item/paper/proc/read_paper(mob/user, scramble=FALSE)

Check failure on line 87 in code/modules/paperwork/paper.dm

View workflow job for this annotation

GitHub Actions / Run Linters

an override of /obj/item/paper/proc/read_paper is missing keyword args
var/datum/asset/asset_datum = get_asset_datum(/datum/asset/simple/paper)
asset_datum.send(user)
if(photo_list)
for(var/photo in photo_list)
user << browse_rsc(photo_list[photo], photo)
show_browser(user, "<BODY class='paper'>[info][stamps]</BODY>", name, name, "size=650x700")
var/paper_info = info
if(scramble)
paper_info = stars_decode_html(info)
show_browser(user, "<BODY class='paper'>[paper_info][stamps]</BODY>", name, name, "size=650x700")
onclose(user, name)

/obj/item/paper/verb/rename()
Expand Down

0 comments on commit fc04f35

Please sign in to comment.