From f9b36a97c429a4d4ecb3cd2d320dd05f4f975c6f Mon Sep 17 00:00:00 2001 From: Jordie Date: Thu, 14 Dec 2017 20:43:26 +1100 Subject: [PATCH] Saves newscaster data and photos to round logs folder (#33504) * newscaster saves stories and photos * merge with round end changes * begone debug proc * some fixes --- code/__HELPERS/roundend.dm | 38 +++++++++++++++++++++------- code/controllers/subsystem/ticker.dm | 1 + code/game/machinery/newscaster.dm | 11 +++++++- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/code/__HELPERS/roundend.dm b/code/__HELPERS/roundend.dm index 66bd5d1a4ea..c8710d6570c 100644 --- a/code/__HELPERS/roundend.dm +++ b/code/__HELPERS/roundend.dm @@ -63,6 +63,26 @@ antag_info["objectives"] += list(list("objective_type"=O.type,"text"=O.explanation_text,"result"=result)) SSblackbox.record_feedback("associative", "antagonists", 1, antag_info) +/datum/controller/subsystem/ticker/proc/gather_newscaster() + var/json_file = file("[GLOB.log_directory]/newscaster.json") + var/list/file_data = list() + var/pos = 1 + for(var/datum/newscaster/feed_channel/channel in GLOB.news_network.network_channels) + if(!GLOB.news_network.network_channels.len) + break + file_data["[pos]"] = list("channel name" = "[channel.channel_name]", "author" = "[channel.author]", "censored" = channel.censored ? 1 : 0, "author censored" = channel.authorCensor ? 1 : 0, "messages" = list()) + if(!channel.messages.len) + continue + for(var/datum/newscaster/feed_message/message in channel.messages) + file_data["[pos]"]["messages"] |= list("author" = "[message.author]", "time stamp" = "[message.time_stamp]", "censored" = message.bodyCensor ? 1 : 0, "author censored" = message.authorCensor ? 1 : 0, "photo file" = "[message.photo_file]", "photo caption" = "[message.caption]", "body" = "[message.body]", "comments" = list()) + if(!message.comments.len) + continue + for(var/datum/newscaster/feed_comment/comment in message.comments) + file_data["[pos]"]["messages"]["comments"] = list("author" = "[comment.author]", "time stamp" = "[comment.time_stamp]", "body" = "[comment.body]") + pos++ + if(GLOB.news_network.wanted_issue.active) + file_data["wanted"] = list("author" = "[GLOB.news_network.wanted_issue.scannedUser]", "criminal" = "[GLOB.news_network.wanted_issue.criminal]", "description" = "[GLOB.news_network.wanted_issue.body]", "photo file" = "[GLOB.news_network.wanted_issue.photo_file]") + WRITE_FILE(json_file, json_encode(file_data)) /datum/controller/subsystem/ticker/proc/declare_completion() set waitfor = FALSE @@ -84,9 +104,9 @@ //Set news report and mode result mode.set_round_result() - + send2irc("Server", "Round just ended.") - + if(length(CONFIG_GET(keyed_string_list/cross_server))) send_news_report() @@ -142,15 +162,15 @@ parts += mode.special_report() CHECK_TICK - + //AI laws parts += law_report() - + CHECK_TICK //Antagonists parts += antag_report() - + CHECK_TICK //Medals parts += medal_report() @@ -202,7 +222,7 @@ /datum/controller/subsystem/ticker/proc/show_roundend_report(client/C,common_report) var/list/report_parts = list() - + report_parts += personal_report(C) report_parts += common_report @@ -212,7 +232,7 @@ roundend_report.set_content(report_parts.Join()) roundend_report.stylesheets = list() roundend_report.add_stylesheet("roundend",'html/browser/roundend.css') - + roundend_report.open(0) /datum/controller/subsystem/ticker/proc/personal_report(client/C) @@ -336,7 +356,7 @@ previous_category = A result += A.roundend_report() result += "

" - + if(all_antagonists.len) var/datum/antagonist/last = all_antagonists[all_antagonists.len] result += last.roundend_report_footer() @@ -409,4 +429,4 @@ else objective_parts += "Objective #[count]: [objective.explanation_text] Fail." count++ - return objective_parts.Join("
") \ No newline at end of file + return objective_parts.Join("
") diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 1a6c0fcd0e8..4e7c41d1400 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -597,6 +597,7 @@ SUBSYSTEM_DEF(ticker) world.Reboot() /datum/controller/subsystem/ticker/Shutdown() + gather_newscaster() //called here so we ensure the log is created even upon admin reboot if(!round_end_sound) round_end_sound = pick(\ 'sound/roundend/newroundsexy.ogg', diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index 18acd9ece79..730380225db 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -22,6 +22,7 @@ GLOBAL_LIST_EMPTY(allCasters) var/creationTime var/authorCensor var/bodyCensor + var/photo_file /datum/newscaster/feed_message/proc/returnAuthor(censor) if(censor == -1) @@ -97,6 +98,7 @@ GLOBAL_LIST_EMPTY(allCasters) var/scannedUser var/isAdminMsg var/icon/img + var/photo_file /datum/newscaster/feed_network var/list/datum/newscaster/feed_channel/network_channels = list() @@ -126,6 +128,7 @@ GLOBAL_LIST_EMPTY(allCasters) if(photo) newMsg.img = photo.img newMsg.caption = photo.scribble + newMsg.photo_file = save_photo(photo.img) for(var/datum/newscaster/feed_channel/FC in network_channels) if(FC.channel_name == channel_name) FC.messages += newMsg @@ -143,6 +146,7 @@ GLOBAL_LIST_EMPTY(allCasters) wanted_issue.isAdminMsg = adminMsg if(photo) wanted_issue.img = photo.img + wanted_issue.photo_file = save_photo(photo.img) if(newMessage) for(var/obj/machinery/newscaster/N in GLOB.allCasters) N.newsAlert() @@ -157,7 +161,12 @@ GLOBAL_LIST_EMPTY(allCasters) for(var/obj/machinery/newscaster/NEWSCASTER in GLOB.allCasters) NEWSCASTER.update_icon() - +/datum/newscaster/feed_network/proc/save_photo(icon/photo) + var/photo_file = copytext(md5("\icon[photo]"), 1, 6) + if(!fexists("[GLOB.log_directory]/photos/[photo_file].png")) + var/icon/p = icon(photo, frame = 1) + fcopy(p, "[GLOB.log_directory]/photos/[photo_file].png") + return photo_file /obj/item/wallframe/newscaster name = "newscaster frame"