telecomms concurrency fix

This commit is contained in:
monster860
2016-04-17 17:14:46 -04:00
parent 7b44c12f62
commit fc09967ca8
4 changed files with 34 additions and 10 deletions
+2 -1
View File
@@ -621,7 +621,8 @@ var/message_delay = 0 // To make sure restarting the recentmessages list is kept
//#### Sending the signal to all subspace receivers ####//
for(var/obj/machinery/telecomms/receiver/R in telecomms_list)
R.receive_signal(signal)
spawn(0)
R.receive_signal(signal)
if(do_sleep)
sleep(rand(10,25))
@@ -402,11 +402,13 @@ var/global/list/default_medbay_channels = list(
//#### Sending the signal to all subspace receivers ####//
for(var/obj/machinery/telecomms/receiver/R in telecomms_list)
R.receive_signal(signal)
spawn(0)
R.receive_signal(signal)
// Allinone can act as receivers.
for(var/obj/machinery/telecomms/allinone/R in telecomms_list)
R.receive_signal(signal)
spawn(0)
R.receive_signal(signal)
// Receiving code can be located in Telecommunications.dm
return signal.data["done"] && position.z in signal.data["level"]
@@ -455,7 +457,8 @@ var/global/list/default_medbay_channels = list(
signal.frequency = connection.frequency // Quick frequency set
for(var/obj/machinery/telecomms/receiver/R in telecomms_list)
R.receive_signal(signal)
spawn(0)
R.receive_signal(signal)
sleep(rand(10,25)) // wait a little...
@@ -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"]
@@ -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]")