mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +01:00
Fix tape recorder printing out transcripts phat enough to crash your game. (#69121)
About The Pull Request Tape recorders can hold 10 minutes of say logs and then transcribe them. People say a lot of things in 10 minutes. These transcriptions can be quite large. These transcriptions have a lot of spans, which get sanitised away to nothingness JS-side. This causes a lot of client-side JS processing on paper for transcripts that go super saiyan beyond the character limit. This can hang peoples' games up when they're running SS13 on their Samsung SmartFridge. This PR paginates printed transcripts.
This commit is contained in:
@@ -283,9 +283,8 @@
|
||||
set name = "Print Transcript"
|
||||
set category = "Object"
|
||||
|
||||
if(!mytape.storedinfo.len)
|
||||
return
|
||||
if(!can_use(usr))
|
||||
var/list/transcribed_info = mytape.storedinfo
|
||||
if(!length(transcribed_info))
|
||||
return
|
||||
if(!mytape)
|
||||
return
|
||||
@@ -294,23 +293,49 @@
|
||||
return
|
||||
if(recording || playing)
|
||||
return
|
||||
if(!can_use(usr))
|
||||
return
|
||||
|
||||
var/transcribed_text = "<b>Transcript:</b><br><br>"
|
||||
var/page_count = 1
|
||||
|
||||
var/tape_name = mytape.name
|
||||
var/initial_tape_name = initial(mytape.name)
|
||||
var/paper_name = "paper- '[tape_name == initial_tape_name ? "Tape" : "[tape_name]"] Transcript'"
|
||||
|
||||
for(var/transcript_excerpt in transcribed_info)
|
||||
var/excerpt_length = length(transcript_excerpt)
|
||||
|
||||
// Very unexpected. Better abort non-gracefully.
|
||||
if(excerpt_length > MAX_PAPER_LENGTH)
|
||||
say("Error: Data corruption detected. Cannot print.")
|
||||
CRASH("Transcript entry has more than [MAX_PAPER_LENGTH] chars: [excerpt_length] chars")
|
||||
|
||||
// If we're going to overflow the paper's length, print the current transcribed text out first and reset to prevent us
|
||||
// going over the paper char count.
|
||||
if((length(transcribed_text) + excerpt_length) > MAX_PAPER_LENGTH)
|
||||
var/obj/item/paper/transcript_paper = new /obj/item/paper(get_turf(src))
|
||||
transcript_paper.add_raw_text(transcribed_text)
|
||||
transcript_paper.name = "[paper_name] page [page_count]"
|
||||
transcript_paper.update_appearance()
|
||||
transcribed_text = ""
|
||||
page_count++
|
||||
|
||||
transcribed_text += "[transcript_excerpt]<br>"
|
||||
|
||||
say("Transcript printed.")
|
||||
playsound(src, 'sound/items/taperecorder/taperecorder_print.ogg', 50, FALSE)
|
||||
var/obj/item/paper/transcript_paper = new /obj/item/paper(get_turf(src))
|
||||
var/t1 = "<B>Transcript:</B><BR><BR>"
|
||||
for(var/i in 1 to mytape.storedinfo.len)
|
||||
t1 += "[mytape.storedinfo[i]]<BR>"
|
||||
transcript_paper.add_raw_text(t1)
|
||||
var/tapename = mytape.name
|
||||
var/prototapename = initial(mytape.name)
|
||||
transcript_paper.name = "paper- '[tapename == prototapename ? "Tape" : "[tapename]"] Transcript'"
|
||||
transcript_paper.add_raw_text(transcribed_text)
|
||||
transcript_paper.name = "[paper_name] page [page_count]"
|
||||
transcript_paper.update_appearance()
|
||||
|
||||
say("Transcript printed, [page_count] pages.")
|
||||
playsound(src, 'sound/items/taperecorder/taperecorder_print.ogg', 50, FALSE)
|
||||
|
||||
// Can't put the entire stack into their hands if there's multple pages, but hey we can at least put one page in.
|
||||
usr.put_in_hands(transcript_paper)
|
||||
canprint = FALSE
|
||||
addtimer(VARSET_CALLBACK(src, canprint, TRUE), 30 SECONDS)
|
||||
|
||||
|
||||
//empty tape recorders
|
||||
/obj/item/taperecorder/empty
|
||||
starting_tape_type = null
|
||||
|
||||
Reference in New Issue
Block a user