diff --git a/code/game/machinery/telecomms/presets.dm b/code/game/machinery/telecomms/presets.dm index 4cce0abc451..7d2a8f32019 100644 --- a/code/game/machinery/telecomms/presets.dm +++ b/code/game/machinery/telecomms/presets.dm @@ -115,9 +115,13 @@ //Servers /obj/machinery/telecomms/server/presets - network = "tcommsat" +/obj/machinery/telecomms/server/presets/New() + ..() + name = id + + /obj/machinery/telecomms/server/presets/science id = "Science Server" freq_listening = list(1351) diff --git a/code/modules/scripting/Interpreter/Interaction.dm b/code/modules/scripting/Interpreter/Interaction.dm index b13f1741c5a..2316cd81ab0 100644 --- a/code/modules/scripting/Interpreter/Interaction.dm +++ b/code/modules/scripting/Interpreter/Interaction.dm @@ -21,6 +21,7 @@ ASSERT(program) src.program = program CreateGlobalScope() + alertadmins = 0 // reset admin alerts /* Proc: Run @@ -29,7 +30,6 @@ Run() cur_recursion = 0 // reset recursion cur_statements = 0 // reset CPU tracking - alertadmins = 0 ASSERT(src.program) RunBlock(src.program) diff --git a/code/modules/scripting/Interpreter/Interpreter.dm b/code/modules/scripting/Interpreter/Interpreter.dm index 3e179ef59ee..9aacf4f19f0 100644 --- a/code/modules/scripting/Interpreter/Interpreter.dm +++ b/code/modules/scripting/Interpreter/Interpreter.dm @@ -37,7 +37,7 @@ cur_statements=0 // current amount of statements called alertadmins=0 // set to 1 if the admins shouldn't be notified of anymore issues max_iterations=100 // max number of uninterrupted loops possible - max_recursion=50 // max recursions without returning anything (or completing the code block) + max_recursion=10 // max recursions without returning anything (or completing the code block) cur_recursion=0 // current amount of recursion /* Var: persist @@ -84,6 +84,19 @@ globalScope = S return S +/* + Proc: AlertAdmins + Alerts the admins of a script that is bad. +*/ + AlertAdmins() + if(container && !alertadmins) + if(istype(container, /datum/TCS_Compiler)) + var/datum/TCS_Compiler/Compiler = container + var/obj/machinery/telecomms/server/Holder = Compiler.Holder + var/message = "Potential crash-inducing NTSL script detected at telecommunications server [Compiler.Holder] ([Holder.x], [Holder.y], [Holder.z])." + + alertadmins = 1 + message_admins(message, 1) /* Proc: RunBlock Runs each statement in a block of code. @@ -108,15 +121,7 @@ cur_statements++ if(cur_statements >= max_statements) RaiseError(new/runtimeError/MaxCPU()) - - if(container && !alertadmins) - if(istype(container, /datum/TCS_Compiler)) - var/datum/TCS_Compiler/Compiler = container - var/obj/machinery/telecomms/server/Holder = Compiler.Holder - var/message = "Potential crash-inducing NTSL script detected at telecommunications server [Compiler.Holder] ([Holder.x], [Holder.y], [Holder.z])." - - alertadmins = 1 - message_admins(message, 1) + AlertAdmins() break if(istype(S, /node/statement/VariableAssignment)) @@ -179,6 +184,7 @@ // If recursion gets too high (max 50 nested functions) throw an error if(cur_recursion >= max_recursion) + AlertAdmins() RaiseError(new/runtimeError/RecursionLimitReached()) return 0 @@ -331,3 +337,4 @@ //TODO: check for invalid name S.variables["[name]"] = value +