Merge pull request #11451 from Loganbacca/wireless

Wireless controller for machinery connections
This commit is contained in:
PsiOmegaDelta
2015-11-27 07:59:59 +01:00
16 changed files with 699 additions and 47 deletions
+71
View File
@@ -0,0 +1,71 @@
//-------------------------------
/*
Wireless controller
Used for connecting devices to each other (i.e. machinery, doors, emitters, etc.)
Unlike the radio controller, the wireless controller does not pass communications between devices. Once the devices
have been connected they call each others procs directly, they do not use the wireless controller to communicate.
See code\modules\wireless\interfaces.dm for details of how to connect devices.
*/
//-------------------------------
var/datum/controller/process/wireless/wirelessProcess
/datum/controller/process/wireless
var/list/receiver_list
var/list/pending_connections
var/list/retry_connections
var/list/failed_connections
/datum/controller/process/wireless/setup()
name = "wireless"
schedule_interval = 50
pending_connections = new()
retry_connections = new()
failed_connections = new()
receiver_list = new()
wirelessProcess = src
/datum/controller/process/wireless/proc/add_device(var/datum/wifi/receiver/R)
if(receiver_list)
receiver_list |= R
else
receiver_list = new()
receiver_list |= R
/datum/controller/process/wireless/proc/remove_device(var/datum/wifi/receiver/R)
if(receiver_list)
receiver_list -= R
/datum/controller/process/wireless/proc/add_request(var/datum/connection_request/C)
if(pending_connections)
pending_connections += C
else
pending_connections = new()
pending_connections += C
/datum/controller/process/wireless/doWork()
//process any connection requests waiting to be retried
if(retry_connections.len > 0)
//any that fail are moved into the failed connections list
process_queue(retry_connections, failed_connections)
//process any pending connection requests
if(pending_connections.len > 0)
//any that fail are moved to the retry queue
process_queue(pending_connections, retry_connections)
/datum/controller/process/wireless/proc/process_queue(var/list/process_conections, var/list/unsuccesful_connections)
for(var/datum/connection_request/C in process_conections)
var/target_found = 0
for(var/datum/wifi/receiver/R in receiver_list)
if(R.id == C.id)
var/datum/wifi/sender/S = C.source
S.connect_device(R)
R.connect_device(S)
target_found = 1
process_conections -= C
if(!target_found)
unsuccesful_connections += C
SCHECK
+4 -1
View File
@@ -25,7 +25,7 @@
usr.client.debug_variables(antag)
message_admins("Admin [key_name_admin(usr)] is debugging the [antag.role_text] template.")
/client/proc/debug_controller(controller in list("Master","Ticker","Ticker Process","Air","Jobs","Sun","Radio","Supply","Shuttles","Emergency Shuttle","Configuration","pAI", "Cameras", "Transfer Controller", "Gas Data","Event","Plants","Alarm","Nano","Chemistry"))
/client/proc/debug_controller(controller in list("Master","Ticker","Ticker Process","Air","Jobs","Sun","Radio","Supply","Shuttles","Emergency Shuttle","Configuration","pAI", "Cameras", "Transfer Controller", "Gas Data","Event","Plants","Alarm","Nano","Chemistry","Wireless"))
set category = "Debug"
set name = "Debug Controller"
set desc = "Debug the various periodic loop controllers for the game (be careful!)"
@@ -92,5 +92,8 @@
if("Chemistry")
debug_variables(chemistryProcess)
feedback_add_details("admin_verb", "DChem")
if("Wireless")
debug_variables(wirelessProcess)
feedback_add_details("admin_verb", "DWifi")
message_admins("Admin [key_name_admin(usr)] is debugging the [controller] controller.")
return