From d96d3f2b7af2006865ce8e3e7f82a81c6c518feb Mon Sep 17 00:00:00 2001 From: mochi Date: Sun, 31 May 2020 17:11:04 +0200 Subject: [PATCH 1/6] #13499: Command amplification no longer applies to non-comms line Make a copy of message_pieces when instancing message datum for radio speech to allow editing the radio line without affecting the actual line --- code/game/objects/items/devices/radio/radio.dm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 4c2aaa82c1e..764aee032f4 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -411,11 +411,16 @@ GLOBAL_LIST_INIT(default_medbay_channels, list( jobname = "Unknown" voicemask = TRUE + // Copy the message pieces so we can safely edit comms line without affecting the actual line + var/list/message_pieces_copy = list() + for(var/datum/multilingual_say_piece/S in message_pieces) + message_pieces_copy += new /datum/multilingual_say_piece(S.speaking, S.message) + // Make us a message datum! var/datum/tcomms_message/tcm = new tcm.sender_name = displayname tcm.sender_job = jobname - tcm.message_pieces = message_pieces + tcm.message_pieces = message_pieces_copy tcm.source_level = position.z tcm.freq = connection.frequency tcm.vmask = voicemask From 5138ab09b2b840ec10572db291547d2eb969b58b Mon Sep 17 00:00:00 2001 From: mochi Date: Sun, 31 May 2020 19:00:45 +0200 Subject: [PATCH 2/6] #13493: Nitroglycerin chemical reaction no longer yields reagent The nitroglycerin reaction causes the explosion which is fine, but it also tries to generate a reagent of the same name, which doesn't exist. This commit prevents reaction from trying to spawn the reagent. --- code/modules/reagents/chemistry/recipes/pyrotechnics.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm index f2740676314..b188afd968c 100644 --- a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm +++ b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm @@ -56,7 +56,7 @@ /datum/chemical_reaction/nitroglycerin name = "Nitroglycerin" id = "nitroglycerin" - result = "nitroglycerin" + result = null required_reagents = list("glycerol" = 1, "facid" = 1, "sacid" = 1) result_amount = 2 From 061a785d4093eb23c56f4c4b04f636e3696b96b8 Mon Sep 17 00:00:00 2001 From: mochi Date: Mon, 1 Jun 2020 01:23:24 +0200 Subject: [PATCH 3/6] #13365: Highlight regex no longer breaks HTML Highlighting specific terms with regex on caused the HTML code to break due to tags being affected by the highlighting mechanic. This commit fixes that, allowing regex highlighting to highlight the terms only without any issue. --- goon/browserassets/js/browserOutput.js | 35 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 40a69245188..d9af0b9eff5 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -176,20 +176,47 @@ function highlightTerms(el) { if(regexHasError) return; //just stop right there ig the regex is gonna except for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term if(opts.highlightTerms[i]) { + var term = opts.highlightTerms[i]; if(!opts.highlightRegexEnable){ - if(el.innerText.toString().toLowerCase().includes(opts.highlightTerms[i].toLowerCase())) //match normally + if(el.innerText.toString().toLowerCase().includes(term.toLowerCase())) //match normally el.innerHTML = ''+el.innerHTML+'' //encloseincludes continue; } var rexp; try{ - rexp = new RegExp(opts.highlightTerms[i],"gmi") + rexp = new RegExp(term,"gmi") } catch(e){ - el.innerHTML+='
Your highlight regex - '+opts.highlightTerms[i]+' - is malformed. Thrown exception: '+e+'' + el.innerHTML+='
Your highlight regex - '+term+' - is malformed. Thrown exception: '+e+'' regexHasError = true; return; } - el.innerHTML = el.innerHTML.replace(rexp,"$0") //i cant figure out a proper, non snowflakey way to let people select the group that gets highlighted + + // highlight using regex without destroying HTML + for (var j = 0; j < el.childNodes.length; j++) { + var child = el.childNodes[j]; + if (child.nodeType != Node.TEXT_NODE) { + if (child.className != "highlighted") + highlightTerms(child); + continue; + } + + var tx = child.textContent; + + var index = tx.toLowerCase().indexOf(term.toLowerCase()); + if (index > -1) { + var beforeNode = document.createTextNode(tx.substring(0, index)); + var highlightedNode = document.createElement("span"); + highlightedNode.innerText = term; + highlightedNode.className = "highlighted"; + highlightedNode.style.backgroundColor = opts.highlightColor; + var afterNode = document.createTextNode(tx.substring(index + term.length)); + + el.insertBefore(beforeNode, child); + el.insertBefore(highlightedNode, child); + el.insertBefore(afterNode, child); + el.removeChild(child); + } + } } } } From 5440f22a4dc38b1e6ee21d34061e8bab3767a7b3 Mon Sep 17 00:00:00 2001 From: mochi Date: Sat, 13 Jun 2020 14:12:57 +0200 Subject: [PATCH 4/6] Fix highlighted term losing its casing --- goon/browserassets/js/browserOutput.js | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index d9af0b9eff5..431fe18e010 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -72,7 +72,7 @@ var opts = { 'enableEmoji': true }; -var regexHasError = false; //variable to check if regex has excepted +var regexHasError = false; //variable to check if regex has excepted function outerHTML(el) { var wrap = document.createElement('div'); @@ -97,10 +97,10 @@ if (typeof String.prototype.trim !== 'function') { if (!String.prototype.includes) { String.prototype.includes = function(search, start) { 'use strict'; - + if (search instanceof RegExp) { throw TypeError('first argument must not be a RegExp'); - } + } if (start === undefined) { start = 0; } return this.indexOf(search, start) !== -1; }; @@ -124,7 +124,7 @@ function byondDecode(message) { // The replace for + is because FOR SOME REASON, BYOND replaces spaces with a + instead of %20, and a plus with %2b. // Marvelous. message = message.replace(/\+/g, "%20"); - try { + try { // This is a workaround for the above not always working when BYOND's shitty url encoding breaks. // Basically, sometimes BYOND's double encoding trick just arbitrarily produces something that makes decodeURIComponent // throw an "Invalid Encoding URI" URIError... the simplest way to work around this is to just ignore it and use unescape instead @@ -190,7 +190,7 @@ function highlightTerms(el) { regexHasError = true; return; } - + // highlight using regex without destroying HTML for (var j = 0; j < el.childNodes.length; j++) { var child = el.childNodes[j]; @@ -199,18 +199,18 @@ function highlightTerms(el) { highlightTerms(child); continue; } - + var tx = child.textContent; var index = tx.toLowerCase().indexOf(term.toLowerCase()); if (index > -1) { var beforeNode = document.createTextNode(tx.substring(0, index)); var highlightedNode = document.createElement("span"); - highlightedNode.innerText = term; + highlightedNode.innerText = tx.substring(index, index + term.length); highlightedNode.className = "highlighted"; highlightedNode.style.backgroundColor = opts.highlightColor; var afterNode = document.createTextNode(tx.substring(index + term.length)); - + el.insertBefore(beforeNode, child); el.insertBefore(highlightedNode, child); el.insertBefore(afterNode, child); @@ -630,7 +630,7 @@ $(function() { 'shideSpam': getCookie('hidespam'), 'darkChat': getCookie('darkChat'), }; - + if (savedConfig.sfontSize) { $messages.css('font-size', savedConfig.sfontSize); internalOutput('Loaded font size setting of: '+savedConfig.sfontSize+'', 'internal'); @@ -988,18 +988,18 @@ $(function() { } else { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } - + // synchronous requests are depricated in modern browsers - xmlHttp.open('GET', 'browserOutput.css', true); + xmlHttp.open('GET', 'browserOutput.css', true); xmlHttp.onload = function (e) { if (xmlHttp.status === 200) { // request successful - + // Generate Log var saved = ''; saved += $messages.html(); saved = saved.replace(/&/g, '&'); saved = saved.replace(/ Date: Fri, 7 Aug 2020 12:39:58 +0200 Subject: [PATCH 5/6] Fully revert browserOutput.js --- goon/browserassets/js/browserOutput.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 38bbb12d688..3cac81ca8e2 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -72,7 +72,7 @@ var opts = { 'enableEmoji': true }; -var regexHasError = false; //variable to check if regex has excepted +var regexHasError = false; //variable to check if regex has excepted function outerHTML(el) { var wrap = document.createElement('div'); @@ -97,10 +97,10 @@ if (typeof String.prototype.trim !== 'function') { if (!String.prototype.includes) { String.prototype.includes = function(search, start) { 'use strict'; - + if (search instanceof RegExp) { throw TypeError('first argument must not be a RegExp'); - } + } if (start === undefined) { start = 0; } return this.indexOf(search, start) !== -1; }; @@ -124,7 +124,7 @@ function byondDecode(message) { // The replace for + is because FOR SOME REASON, BYOND replaces spaces with a + instead of %20, and a plus with %2b. // Marvelous. message = message.replace(/\+/g, "%20"); - try { + try { // This is a workaround for the above not always working when BYOND's shitty url encoding breaks. // Basically, sometimes BYOND's double encoding trick just arbitrarily produces something that makes decodeURIComponent // throw an "Invalid Encoding URI" URIError... the simplest way to work around this is to just ignore it and use unescape instead @@ -217,13 +217,12 @@ function highlightTerms(el) { ind = next_tag; } } - + element.innerHTML = s; } - + for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term if(opts.highlightTerms[i]) { - var term = opts.highlightTerms[i]; if(!opts.highlightRegexEnable){ var innerTerms = opts.highlightTerms[i].split(" ") for(var a in innerTerms){ @@ -653,7 +652,7 @@ $(function() { 'shideSpam': getCookie('hidespam'), 'darkChat': getCookie('darkChat'), }; - + if (savedConfig.sfontSize) { $messages.css('font-size', savedConfig.sfontSize); internalOutput('Loaded font size setting of: '+savedConfig.sfontSize+'', 'internal'); @@ -1011,18 +1010,18 @@ $(function() { } else { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } - + // synchronous requests are depricated in modern browsers - xmlHttp.open('GET', 'browserOutput.css', true); + xmlHttp.open('GET', 'browserOutput.css', true); xmlHttp.onload = function (e) { if (xmlHttp.status === 200) { // request successful - + // Generate Log var saved = ''; saved += $messages.html(); saved = saved.replace(/&/g, '&'); saved = saved.replace(/ Date: Fri, 7 Aug 2020 13:34:09 +0200 Subject: [PATCH 6/6] use default null --- code/modules/reagents/chemistry/recipes/pyrotechnics.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm index b188afd968c..abdf0305934 100644 --- a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm +++ b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm @@ -56,7 +56,6 @@ /datum/chemical_reaction/nitroglycerin name = "Nitroglycerin" id = "nitroglycerin" - result = null required_reagents = list("glycerol" = 1, "facid" = 1, "sacid" = 1) result_amount = 2