From 37f471ff417ff62e3ad778434bc9edadfabb1b34 Mon Sep 17 00:00:00 2001 From: "elly1989@rocketmail.com" Date: Wed, 2 May 2012 04:44:16 +0000 Subject: [PATCH] Fixes a pAI requests runtime caused by clients disconnecting. Fixes a host of runtimes caused by lag delaying "transmissions" between telecomms machines. Various objects were being deconstructed during this lagtime resulting in a bunch of weird null errors. Tested for 24hours on another server. Seems to be all ok. Added some rudimentary checks to advanced proccall. Calling procs owned by objects is now a little less prone to runtimes. still a bunch of stuff to do to get it safe enough though. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3542 316c924e-a436-60f5-8080-3fe189b3f50e --- .../machinery/telecomms/telecomunications.dm | 9 +- code/modules/admin/verbs/debug.dm | 153 ++++++++++-------- .../modules/mob/living/silicon/pai/recruit.dm | 19 ++- 3 files changed, 100 insertions(+), 81 deletions(-) diff --git a/code/game/machinery/telecomms/telecomunications.dm b/code/game/machinery/telecomms/telecomunications.dm index 859cf9f372..f7b14b5982 100644 --- a/code/game/machinery/telecomms/telecomunications.dm +++ b/code/game/machinery/telecomms/telecomunications.dm @@ -103,11 +103,10 @@ if(machine.is_freq_listening(signal)) machine.traffic++ - spawn() - if(copysig && copy) - machine.receive_information(copy, src) - else - machine.receive_information(signal, src) + if(copysig && copy) + machine.receive_information(copy, src) + else + machine.receive_information(signal, src) if(send_count > 0 && is_freq_listening(signal)) traffic++ diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 262272738b..fefb1e4170 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -33,91 +33,108 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that /client/proc/callproc() set category = "Debug" set name = "Advanced ProcCall" + if(!holder) src << "Only administrators may use this command." return - var/target = null - var/lst[] // List reference - lst = new/list() // Make the list - var/returnval = null - var/class = null - switch(alert("Proc owned by something?",,"Yes","No")) - if("Yes") - class = input("Proc owned by...","Owner") in list("Obj","Mob","Area or Turf","Client","CANCEL ABORT STOP") + spawn(0) + var/target = null + var/targetselected = 0 + var/lst[] // List reference + lst = new/list() // Make the list + var/returnval = null + var/class = null + + switch(alert("Proc owned by something?",,"Yes","No")) + if("Yes") + targetselected = 1 + class = input("Proc owned by...","Owner",null) as null|anything in list("Obj","Mob","Area or Turf","Client") + switch(class) + if("Obj") + target = input("Enter target:","Target",usr) as obj in world + if("Mob") + target = input("Enter target:","Target",usr) as mob in world + if("Area or Turf") + target = input("Enter target:","Target",usr.loc) as area|turf in world + if("Client") + var/list/keys = list() + for(var/client/C) + keys += C + target = input("Please, select a player!", "Selection", null, null) as null|anything in keys + else + return + if("No") + target = null + targetselected = 0 + + var/procname = input("Proc path, eg: /proc/fake_blood","Path:", null) as text|null + if(!procname) return + + var/argnum = input("Number of arguments","Number:",0) as num|null + if(!argnum && (argnum!=0)) return + + lst.len = argnum // Expand to right length + //TODO: make a list to store whether each argument was initialised as null. + //Reason: So we can abort the proccall if say, one of our arguments was a mob which no longer exists + //this will protect us from a fair few errors ~Carn + + var/i + for(i=1, iError: callproc(): owner of proc no longer exists." + return + if(!hascall(target,procname)) + usr << "Error: callproc(): target has no such call [procname]." return - - if("text") - lst[i] = input("Enter new text:","Text",null) as text - - if("num") - lst[i] = input("Enter new number:","Num",0) as num - - if("type") - lst[i] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf) - - if("reference") - lst[i] = input("Select reference:","Reference",src) as mob|obj|turf|area in world - - if("mob reference") - lst[i] = input("Select reference:","Reference",usr) as mob in world - - if("file") - lst[i] = input("Pick file:","File") as file - - if("icon") - lst[i] = input("Pick icon:","Icon") as icon - - if("client") - var/list/keys = list() - for(var/mob/M in world) - keys += M.client - lst[i] = input("Please, select a player!", "Selection", null, null) as null|anything in keys - - if("mob's area") - var/mob/temp = input("Select mob", "Selection", usr) as mob in world - lst[i] = temp.loc - - - spawn(0) - if(target) log_admin("[key_name(src)] called [target]'s [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].") returnval = call(target,procname)(arglist(lst)) // Pass the lst as an argument list to the proc else + //this currently has no hascall protection. wasn't able to get it working. log_admin("[key_name(src)] called [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].") returnval = call(procname)(arglist(lst)) // Pass the lst as an argument list to the proc - usr << "\blue Proc returned: [returnval ? returnval : "null"]" - feedback_add_details("admin_verb","APC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + + usr << "[procname] returned: [returnval ? returnval : "null"]" + feedback_add_details("admin_verb","APC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! /client/proc/Cell() set category = "Debug" diff --git a/code/modules/mob/living/silicon/pai/recruit.dm b/code/modules/mob/living/silicon/pai/recruit.dm index cd87502366..3df4261736 100644 --- a/code/modules/mob/living/silicon/pai/recruit.dm +++ b/code/modules/mob/living/silicon/pai/recruit.dm @@ -193,13 +193,16 @@ var/datum/paiController/paiController // Global handler for pAI candidates if(c.key == O.key) hasSubmitted = 1 if(!hasSubmitted && O.client.be_pai) - spawn question(O.client) + question(O.client) proc/question(var/client/C) - asked.Add(C.key) - asked[C.key] = world.time - var/response = alert(C, "Someone is requesting a pAI personality. Would you like to play as a personal AI?", "pAI Request", "Yes", "No", "Never for this round") - if(response == "Yes") - recruitWindow(C.mob) - else if (response == "Never for this round") - C.be_pai = 0 \ No newline at end of file + spawn(0) + if(!C) return + asked.Add(C.key) + asked[C.key] = world.time + var/response = alert(C, "Someone is requesting a pAI personality. Would you like to play as a personal AI?", "pAI Request", "Yes", "No", "Never for this round") + if(!C) return //handle logouts that happen whilst the alert is waiting for a response. + if(response == "Yes") + recruitWindow(C.mob) + else if (response == "Never for this round") + C.be_pai = 0 \ No newline at end of file