mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Fixes NTSL scripts not working (#16351)
* Fixes NTSL scripts from not working. * Removes a runtime caused by previous code. * removes old message in favor of previous one in commit * Requested changes * Update IDE.dm
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
|
|
||||||
|
|
||||||
//Returns null if there is any bad text in the string
|
//Returns null if there is any bad text in the string
|
||||||
/proc/reject_bad_text(text, max_length = 512, ascii_only = TRUE, require_pretty=TRUE)
|
/proc/reject_bad_text(text, max_length = 512, ascii_only = TRUE, require_pretty=TRUE, allow_newline=FALSE, allow_code=FALSE)
|
||||||
if(require_pretty && isnotpretty(text))
|
if(require_pretty && isnotpretty(text))
|
||||||
return
|
return
|
||||||
var/char_count = 0
|
var/char_count = 0
|
||||||
@@ -80,9 +80,17 @@
|
|||||||
if(char_count > max_length)
|
if(char_count > max_length)
|
||||||
return
|
return
|
||||||
switch(text2ascii(char))
|
switch(text2ascii(char))
|
||||||
if(62, 60, 92, 47) // <, >, \, /
|
if(9, 62, 60, 92, 47) // tab, <, >, \, /
|
||||||
|
if(!allow_code)
|
||||||
|
return
|
||||||
|
if(10, 13) //Carriage returns (CR) and newline (NL)
|
||||||
|
if(!allow_newline)
|
||||||
|
return
|
||||||
|
if(0 to 8)
|
||||||
return
|
return
|
||||||
if(0 to 31)
|
if(11, 12)
|
||||||
|
return
|
||||||
|
if(14 to 31)
|
||||||
return
|
return
|
||||||
if(32)
|
if(32)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -52,15 +52,13 @@
|
|||||||
/obj/machinery/telecomms/server/proc/compile(mob/user = usr)
|
/obj/machinery/telecomms/server/proc/compile(mob/user = usr)
|
||||||
if(is_banned_from(user.ckey, "Network Admin"))
|
if(is_banned_from(user.ckey, "Network Admin"))
|
||||||
to_chat(user, span_warning("You are banned from using NTSL."))
|
to_chat(user, span_warning("You are banned from using NTSL."))
|
||||||
return
|
return "Unauthorized access."
|
||||||
if(Compiler)
|
if(Compiler)
|
||||||
if(!reject_bad_text(rawcode, 20000, require_pretty = FALSE))
|
if(!reject_bad_text(rawcode, 20000, require_pretty = FALSE, allow_newline = TRUE, allow_code = TRUE))
|
||||||
rawcode = null
|
rawcode = null
|
||||||
to_chat(user, span_warning("Server is out of memory. Please shorten your script."))
|
return "Please use galactic common characters only."
|
||||||
return
|
|
||||||
if(!COOLDOWN_FINISHED(src, compile_cooldown))
|
if(!COOLDOWN_FINISHED(src, compile_cooldown))
|
||||||
to_chat(user, span_warning("Recharging. Please wait"))
|
return "Servers are recharging, please wait."
|
||||||
return
|
|
||||||
var/list/compileerrors = Compiler.Compile(rawcode)
|
var/list/compileerrors = Compiler.Compile(rawcode)
|
||||||
COOLDOWN_START(src, compile_cooldown, 2 SECONDS)
|
COOLDOWN_START(src, compile_cooldown, 2 SECONDS)
|
||||||
if(!compileerrors.len && (compiledcode != rawcode))
|
if(!compileerrors.len && (compiledcode != rawcode))
|
||||||
|
|||||||
@@ -45,11 +45,17 @@
|
|||||||
src << output(null, "tcserror")
|
src << output(null, "tcserror")
|
||||||
src << output("Compiling on [Server.name]...", "tcserror")
|
src << output("Compiling on [Server.name]...", "tcserror")
|
||||||
|
|
||||||
var/list/compileerrors = Server.compile(mob) // then compile the code!
|
var/list/compileerrors = Server.compile(mob) // then compile the code! this can return a string or a list.
|
||||||
if(!telecomms_check(mob))
|
if(!telecomms_check(mob))
|
||||||
return
|
return
|
||||||
|
|
||||||
if(compileerrors.len)
|
if(!compileerrors)
|
||||||
|
src << output("<b>NTSL.exe Error</b>", "tcserror")
|
||||||
|
src << output("<font color = red>\t><b>A fatal error has occured. Please contact your local network adminstrator.</b></font color>", "tcserror")
|
||||||
|
else if(istext(compileerrors))
|
||||||
|
src << output("<b>NTSL.exe Error</b>", "tcserror")
|
||||||
|
src << output("<font color = red>\t><b>[compileerrors]</b></font color>", "tcserror")
|
||||||
|
else if(length(compileerrors))
|
||||||
src << output("<b>Compile Errors</b>", "tcserror")
|
src << output("<b>Compile Errors</b>", "tcserror")
|
||||||
var/i = 1
|
var/i = 1
|
||||||
for(var/scriptError/e in compileerrors)
|
for(var/scriptError/e in compileerrors)
|
||||||
@@ -75,7 +81,7 @@
|
|||||||
M << output("([compileerrors.len] errors)", "tcserror")
|
M << output("([compileerrors.len] errors)", "tcserror")
|
||||||
|
|
||||||
|
|
||||||
else // If no errors
|
else // Returned a blank list, means no errors.
|
||||||
src << output("<font color = blue>TCS compilation successful!</font color>", "tcserror")
|
src << output("<font color = blue>TCS compilation successful!</font color>", "tcserror")
|
||||||
src << output("Time of compile: [gameTimestamp("hh:mm:ss")]","tcserror")
|
src << output("Time of compile: [gameTimestamp("hh:mm:ss")]","tcserror")
|
||||||
//. ^ To make it obvious that it's done a new compile
|
//. ^ To make it obvious that it's done a new compile
|
||||||
|
|||||||
Reference in New Issue
Block a user