diff --git a/code/game/machinery/telecomms/traffic_control.dm b/code/game/machinery/telecomms/traffic_control.dm index 323ce8e02a..bb495decc3 100644 --- a/code/game/machinery/telecomms/traffic_control.dm +++ b/code/game/machinery/telecomms/traffic_control.dm @@ -160,6 +160,9 @@ screen = 0 if("editcode") + if(editingcode == usr) return + if(usr in viewingcode) return + if(!editingcode) editingcode = usr winshow(editingcode, "Telecomms IDE", 1) // show the IDE diff --git a/code/modules/scripting/Implementations/Telecomms.dm b/code/modules/scripting/Implementations/Telecomms.dm index cec1f9911a..6ab82d9d0f 100644 --- a/code/modules/scripting/Implementations/Telecomms.dm +++ b/code/modules/scripting/Implementations/Telecomms.dm @@ -35,25 +35,6 @@ interpreter.persist = 1 interpreter.Compiler= src - // Set up all the preprocessor bullshit - //TCS_Setup(program) - // Apply preprocessor global variables - program.SetVar("PI" , 3.141592653) // value of pi - program.SetVar("E" , 2.718281828) // value of e - program.SetVar("SQURT2" , 1.414213562) // value of the square root of 2 - program.SetVar("FALSE" , 0) // boolean shortcut to 0 - program.SetVar("TRUE" , 1) // boolean shortcut to 1 - - program.SetVar("NORTH" , NORTH) // NORTH (1) - program.SetVar("SOUTH" , SOUTH) // SOUTH (2) - program.SetVar("EAST" , EAST) // EAST (4) - program.SetVar("WEST" , WEST) // WEST (8) - - program.SetVar("HONK" , "clown griff u") - program.SetVar("CODERS" , "hide the fun") - program.SetVar("GRIFF" , pick("HALP IM BEING GRIFFED", "HALP AI IS MALF", "HALP GRIFFE", "HALP TRAITORS", "HALP WIZ GRIEFE ME")) - - return returnerrors /* -- Execute the compiled code -- */ @@ -66,6 +47,29 @@ if(!interpreter) return + interpreter.SetVar("PI" , 3.141592653) // value of pi + interpreter.SetVar("E" , 2.718281828) // value of e + interpreter.SetVar("SQURT2" , 1.414213562) // value of the square root of 2 + interpreter.SetVar("FALSE" , 0) // boolean shortcut to 0 + interpreter.SetVar("TRUE" , 1) // boolean shortcut to 1 + + interpreter.SetVar("NORTH" , NORTH) // NORTH (1) + interpreter.SetVar("SOUTH" , SOUTH) // SOUTH (2) + interpreter.SetVar("EAST" , EAST) // EAST (4) + interpreter.SetVar("WEST" , WEST) // WEST (8) + + // Channel macros + interpreter.SetVar("$common", 1459) + interpreter.SetVar("$science", 1351) + interpreter.SetVar("$command", 1353) + interpreter.SetVar("$medical", 1355) + interpreter.SetVar("$engineering",1357) + interpreter.SetVar("$security", 1359) + interpreter.SetVar("$mining", 1349) + interpreter.SetVar("$cargo", 1347) + + // Signal data + interpreter.SetVar("$content", signal.data["message"]) interpreter.SetVar("$freq" , signal.frequency) interpreter.SetVar("$source" , signal.data["name"]) @@ -157,22 +161,22 @@ interpreter.Run() // Backwards-apply variables onto signal data - /* html_encode() EVERYTHING. fucking players can't be trusted with SHIT */ + /* sanitize EVERYTHING. fucking players can't be trusted with SHIT */ - signal.data["message"] = html_encode(interpreter.GetVar("$content")) + signal.data["message"] = trim(copytext(sanitize(interpreter.GetVar("$content")), 1, MAX_MESSAGE_LEN)) signal.frequency = interpreter.GetVar("$freq") var/setname = "" var/obj/machinery/telecomms/server/S = signal.data["server"] if(interpreter.GetVar("$source") in S.stored_names) - setname = html_encode(interpreter.GetVar("$source")) + setname = interpreter.GetVar("$source") else - setname = "[html_encode(interpreter.GetVar("$source"))]" + setname = "[trim(copytext(sanitize(interpreter.GetVar("$source")), 1, MAX_MESSAGE_LEN))]" if(signal.data["name"] != setname) signal.data["realname"] = setname signal.data["name"] = setname - signal.data["job"] = html_encode(interpreter.GetVar("$job")) + signal.data["job"] = trim(copytext(sanitize(interpreter.GetVar("$job")), 1, MAX_MESSAGE_LEN)) signal.data["reject"] = !(interpreter.GetVar("$pass")) // set reject to the opposite of $pass /* -- Actual language proc code -- */ @@ -205,6 +209,9 @@ datum/signal hradio = new // sets the hradio as a radio intercom if(!freq) freq = 1459 + if(findtext(num2text(freq), ".")) // if the frequency has been set as a decimal + freq *= 10 // shift the decimal one place + if(!job) job = "None" diff --git a/code/modules/scripting/Interpreter/Interpreter.dm b/code/modules/scripting/Interpreter/Interpreter.dm index f13c8f3b03..e9860176f3 100644 --- a/code/modules/scripting/Interpreter/Interpreter.dm +++ b/code/modules/scripting/Interpreter/Interpreter.dm @@ -32,6 +32,7 @@ returnVal max_iterations=100 // max iterations without any kind of delay + cur_iterations=0 // current iteration max_recursion=50 // max recursions without returning anything (or completing the code block) cur_recursion=0 // current amount of recursion /* @@ -211,9 +212,14 @@ */ RunWhile(node/statement/WhileLoop/stmt) var/i=1 + if(!cur_iterations) + cur_iterations = 1 while(Eval(stmt.cond) && Iterate(stmt.block, i++)) + cur_iterations++ continue status &= ~BREAKING + cur_iterations -= i + if(cur_iterations <= 0) cur_iterations = 0 /* Proc:Iterate @@ -221,7 +227,7 @@ */ Iterate(node/BlockDefinition/block, count) RunBlock(block) - if(max_iterations > 0 && count >= max_iterations) + if(max_iterations > 0 && (count >= max_iterations || cur_iterations + 1 >= max_iterations)) RaiseError(new/runtimeError/IterationLimitReached()) return 0 if(status & (BREAKING|RETURNING)) diff --git a/interface/skin.dmf b/interface/skin.dmf index 05f92eb93b..3656ac18b2 100644 --- a/interface/skin.dmf +++ b/interface/skin.dmf @@ -244,7 +244,7 @@ menu "menu" window "Telecomms IDE" elem "Telecomms IDE" type = MAIN - pos = 281,0 + pos = 303,13 size = 652x582 anchor1 = none anchor2 = none @@ -285,8 +285,8 @@ window "Telecomms IDE" type = BUTTON pos = 180,464 size = 60x20 - anchor1 = none - anchor2 = none + anchor1 = 28,80 + anchor2 = 37,83 font-family = "" font-size = 0 font-style = "" @@ -313,8 +313,8 @@ window "Telecomms IDE" type = BUTTON pos = 120,464 size = 60x20 - anchor1 = none - anchor2 = none + anchor1 = 18,80 + anchor2 = 28,83 font-family = "" font-size = 0 font-style = "" @@ -341,8 +341,8 @@ window "Telecomms IDE" type = OUTPUT pos = 0,488 size = 648x94 - anchor1 = none - anchor2 = none + anchor1 = 0,84 + anchor2 = 99,100 font-family = "sans-serif" font-size = 9 font-style = "" @@ -367,8 +367,8 @@ window "Telecomms IDE" type = BUTTON pos = 60,464 size = 60x20 - anchor1 = none - anchor2 = none + anchor1 = 9,80 + anchor2 = 18,83 font-family = "" font-size = 0 font-style = "" @@ -395,8 +395,8 @@ window "Telecomms IDE" type = BUTTON pos = 0,464 size = 60x20 - anchor1 = none - anchor2 = none + anchor1 = 0,80 + anchor2 = 9,83 font-family = "" font-size = 0 font-style = "" @@ -423,8 +423,8 @@ window "Telecomms IDE" type = INPUT pos = 0,0 size = 652x464 - anchor1 = none - anchor2 = none + anchor1 = 0,0 + anchor2 = 100,80 font-family = "Courier" font-size = 10 font-style = ""