Fix lost changes (#6633)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Raeschen <Raeschen@users.noreply.github.com>
Co-authored-by: FluffMedic <109300046+FluffMedic@users.noreply.github.com>
Co-authored-by: Victor Zisthus <56660717+VictorZisthus@users.noreply.github.com>
Co-authored-by: Razgriz1032 <Razgriz1032@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: CHOMPStation2 <58959929+CHOMPStation2@users.noreply.github.com>
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com>
Co-authored-by: CHOMPStation2 <chompsation2@gmail.com>
Co-authored-by: purplefoxy27 <38367315+purplefoxy27@users.noreply.github.com>
Co-authored-by: Casey <a.roaming.shadow@gmail.com>
Co-authored-by: Aroliacue <96730930+Aroliacue@users.noreply.github.com>
This commit is contained in:
Raeschen
2023-07-21 08:44:40 +02:00
committed by GitHub
co-authored by Raeschen FluffMedic Victor Zisthus Razgriz1032 dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> CHOMPStation2 Heroman3003 CHOMPStation2 purplefoxy27 Casey Aroliacue
parent 66ce5daf87
commit 071905fed5
50 changed files with 1073 additions and 147 deletions
+18 -8
View File
@@ -1,14 +1,12 @@
#define NEWSFILE "data/news.sav" //where the memos are saved
//#define NEWSFILE "data/news.sav" //where the memos are saved //ChompEDIT - moved to __defines/admin_ch
/client/
//var/last_news_hash = null // Stores a hash of the last news window it saw, which gets compared to the current one to see if it is different.
// Returns true if news was updated since last seen.
/client/proc/check_for_new_server_news()
var/savefile/F = get_server_news()
if(F)
if(md5(F["body"]) != prefs.lastnews)
return TRUE
if(servernews_hash != prefs.lastnews) //ChompEDIT
return TRUE
return FALSE
/client/proc/modify_server_news()
@@ -20,8 +18,15 @@
var/savefile/F = new(NEWSFILE)
if(F)
var/title = F["title"]
var/body = html2paper_markup(F["body"])
//ChompEDIT start - handle reads correctly
var/title
F["title"] >> title //This is done twice on purpose. For some reason BYOND misses the first read, if performed before the world starts
F["title"] >> title
var/body
F["body"] >> body
body = html2paper_markup(body)
//ChompEDIT end
var/new_title = sanitize(tgui_input_text(src,"Write a good title for the news update. Note: HTML is NOT supported.","Write News", title), extra = 0)
if(!new_title)
return
@@ -34,16 +39,21 @@
if(findtext(new_body,"<script",1,0) ) // Is this needed with santize()?
return
servernews_hash = md5("[new_title]" + "[new_body]") //ChompADD - update the servernews hash global
F["title"] << new_title
F["body"] << new_body
F["author"] << key
F["timestamp"] << time2text(world.realtime, "DDD, MMM DD YYYY")
message_admins("[key] modified the news to read:<br>[new_title]<br>[new_body]")
/proc/get_server_news()
/client/proc/get_server_news() //ChompEDIT - child of /client/
var/savefile/F = new(NEWSFILE)
if(F)
if(servernews_hash != prefs.lastnews) //ChompADD
prefs.lastnews = servernews_hash //ChompADD
SScharacter_setup.queue_preferences_save(prefs) //ChompADD
return F
// This is used when submitting the news input, so the safe markup can get past sanitize.
/proc/paper_markup2html(var/text)
text = replacetext(text, "\n", "<br>")