diff --git a/code/__HELPERS/roundend.dm b/code/__HELPERS/roundend.dm index f009ff9c00..1f1bab691e 100644 --- a/code/__HELPERS/roundend.dm +++ b/code/__HELPERS/roundend.dm @@ -64,6 +64,27 @@ 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 @@ -89,7 +110,6 @@ H.add_hud_to(M) CHECK_TICK - //Set news report and mode result mode.set_round_result() diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 0f06caa20d..54b693d543 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -631,6 +631,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 ee9b1ff31a..541c931593 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"