diff --git a/code/modules/scripting/IDE.dm b/code/modules/scripting/IDE.dm index 340da55ae2..3ecfa4f505 100644 --- a/code/modules/scripting/IDE.dm +++ b/code/modules/scripting/IDE.dm @@ -8,7 +8,11 @@ client/verb/tcssave() if(Machine.SelectedServer) var/obj/machinery/telecomms/server/Server = Machine.SelectedServer - Server.setcode( winget(src, "tcscode", "text") ) // this actually saves the code from input to the server + var/tcscode=winget(src, "tcscode", "text") + var/msg="[mob.name] is adding script to server [Server]: [tcscode]" + diary << msg + message_admins("[mob.name] has uploaded a NTLS script to [Machine.SelectedServer] ([mob.x],[mob.y],[mob.z] - JMP)",0,1) + Server.setcode( tcscode ) // this actually saves the code from input to the server src << output(null, "tcserror") // clear the errors else src << output(null, "tcserror") diff --git a/code/modules/scripting/Implementations/Telecomms.dm b/code/modules/scripting/Implementations/Telecomms.dm index cbef3e0aff..428610d392 100644 --- a/code/modules/scripting/Implementations/Telecomms.dm +++ b/code/modules/scripting/Implementations/Telecomms.dm @@ -68,7 +68,6 @@ interpreter.SetVar("$medical", 1355) interpreter.SetVar("$engineering",1357) interpreter.SetVar("$security", 1359) - interpreter.SetVar("$mining", 1349) interpreter.SetVar("$supply", 1347) // Signal data @@ -119,7 +118,7 @@ @param replacestring: the string to replace the substring with */ - interpreter.SetProc("replace", /proc/replacetext) + interpreter.SetProc("replace", /proc/string_replacetext) /* -> Locates an element/substring inside of a list or string @@ -268,6 +267,9 @@ datum/signal newsign.data["vmessage"] = H.voice_message newsign.data["vname"] = H.voice_name newsign.data["vmask"] = 0 + newsign.data["level"] = list() + + var/pass = S.relay_information(newsign, "/obj/machinery/telecomms/hub") + if(!pass) + S.relay_information(newsign, "/obj/machinery/telecomms/broadcaster") // send this simple message to broadcasters - S.relay_information(newsign, "/obj/machinery/telecomms/broadcaster") // send this simple message to broadcasters - S.relay_information(newsign, "/obj/machinery/telecomms/hub") diff --git a/code/modules/scripting/Implementations/_Logic.dm b/code/modules/scripting/Implementations/_Logic.dm index fe3174fb36..af422c4f04 100644 --- a/code/modules/scripting/Implementations/_Logic.dm +++ b/code/modules/scripting/Implementations/_Logic.dm @@ -1,5 +1,5 @@ // Script -> BYOND code procs - +#define SCRIPT_MAX_REPLACEMENTS_ALLOWED 200 // --- List operations (lists known as vectors in n_script) --- // Clone of list() @@ -173,6 +173,8 @@ proc/n_repeat(var/string, var/amount) if(istext(string) && isnum(amount)) var/i var/newstring = "" + if(length(newstring)*amount >=1000) + return for(i=0, i<=amount, i++) if(i>=1000) break @@ -242,3 +244,48 @@ proc/n_inrange(var/num, var/min=-1, var/max=1) if(isnum(num)&&isnum(min)&&isnum(max)) return ((min <= num) && (num <= max)) // END OF BY DONKIE :( + +// Non-recursive +// Imported from Mono string.ReplaceUnchecked +/proc/string_replacetext(var/haystack,var/a,var/b) + if(istext(haystack)&&istext(a)&&istext(b)) + var/i = 1 + var/lenh=lentext(haystack) + var/lena=lentext(a) + //var/lenb=lentext(b) + var/count = 0 + var/list/dat = list() + while (i < lenh) + var/found = findtext(haystack, a, i, 0) + //diary << "findtext([haystack], [a], [i], 0)=[found]" + if (found == 0) // Not found + break + else + if (count < SCRIPT_MAX_REPLACEMENTS_ALLOWED) + dat+=found + count+=1 + else + //diary << "Script found [a] [count] times, aborted" + break + //diary << "Found [a] at [found]! Moving up..." + i = found + lena + if (count == 0) + return haystack + //var/nlen = lenh + ((lenb - lena) * count) + var/buf = copytext(haystack,1,dat[1]) // Prefill + var/lastReadPos = 0 + for (i = 1, i <= count, i++) + var/precopy = dat[i] - lastReadPos-1 + //internal static unsafe void CharCopy (String target, int targetIndex, String source, int sourceIndex, int count) + //fixed (char* dest = target, src = source) + //CharCopy (dest + targetIndex, src + sourceIndex, count); + //CharCopy (dest + curPos, source + lastReadPos, precopy); + buf+=copytext(haystack,lastReadPos,precopy) + diary << "buf+=copytext([haystack],[lastReadPos],[precopy])" + diary<<"[buf]" + lastReadPos = dat[i] + lena + //CharCopy (dest + curPos, replace, newValue.length); + buf+=b + diary<<"[buf]" + buf+=copytext(haystack,lastReadPos, 0) + return buf \ No newline at end of file