Merge pull request #4231 from monster860/concurrency

Telecomms concurrency fix
This commit is contained in:
Fox McCloud
2016-05-13 15:34:15 -04:00
4 changed files with 34 additions and 10 deletions

View File

@@ -60,6 +60,9 @@
return
interpreter.container = src
interpreter.CreateGlobalScope() // Reset the variables.
interpreter.curScope = interpreter.globalScope
interpreter.SetVar("PI", 3.141592653) // value of pi
interpreter.SetVar("E", 2.718281828) // value of e
@@ -127,7 +130,7 @@
@param time: time to sleep in deciseconds (1/10th second)
*/
interpreter.SetProc("sleep", /proc/delay)
interpreter.SetProc("sleep", "delay", signal, list("time"))
/*
-> Replaces a string with another string
@@ -255,6 +258,28 @@
signal.data["reject"] = 1
/* -- Actual language proc code -- */
/datum/signal/proc/delay(var/time)
var/obj/machinery/telecomms/server/S = data["server"]
var/datum/n_Interpreter/TCS_Interpreter/interpreter = S.Compiler.interpreter
// Backup the scope
var/datum/scope/globalScope = interpreter.globalScope
var/datum/scope/curScope = interpreter.curScope
var/list/scopes = interpreter.scopes.stack.Copy()
var/list/functions = interpreter.functions.stack.Copy()
var/datum/node/statement/FunctionDefinition/curFunction = interpreter.curFunction
var/status = interpreter.status
var/returnVal = interpreter.returnVal
// Sleep
sleep(time)
// Restore the scope
interpreter.returnVal = returnVal
interpreter.status = status
interpreter.curFunction = curFunction
interpreter.functions.stack = functions
interpreter.scopes.stack = scopes
interpreter.curScope = curScope
interpreter.globalScope = globalScope
/datum/signal/proc/mem(var/address, var/value)
if(istext(address))
var/obj/machinery/telecomms/server/S = data["server"]

View File

@@ -99,11 +99,6 @@
// --- Miscellaneous functions ---
// Clone of sleep()
/proc/delay(var/time)
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/delay() called tick#: [world.time]")
sleep(time)
// Clone of rand()
/proc/rand_chance(var/low = 0, var/high)
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/rand_chance() called tick#: [world.time]")