From 165b516949db224d5cf5dc2441e8190191314c5d Mon Sep 17 00:00:00 2001 From: Erthilo Date: Thu, 10 May 2012 00:16:09 +0100 Subject: [PATCH] TG: 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. Revision: r3542 Author: elly1...@rocketmail.com Ported over BS12's piano code. I say ported, it's not like it's anything but a copy/paste though. Also changed the icon to the minimoog, to reflect on how FUTURISTIC it is. Revision: r3543 Author: petethegoat --- .../machinery/telecomms/telecommunications.dm | 9 +- code/game/magic/musician.dm | 6 +- code/modules/admin/verbs/debug.dm | 174 +++++++++--------- .../modules/mob/living/silicon/pai/recruit.dm | 21 ++- 4 files changed, 109 insertions(+), 101 deletions(-) diff --git a/code/game/machinery/telecomms/telecommunications.dm b/code/game/machinery/telecomms/telecommunications.dm index 6e9d41ea4d8..febb82e26bc 100644 --- a/code/game/machinery/telecomms/telecommunications.dm +++ b/code/game/machinery/telecomms/telecommunications.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/game/magic/musician.dm b/code/game/magic/musician.dm index 3bb9287e6c0..c46f7464752 100644 --- a/code/game/magic/musician.dm +++ b/code/game/magic/musician.dm @@ -5,9 +5,9 @@ tempo = 5 /obj/structure/device/piano - name = "space piano" + name = "space minimoog" icon = 'musician.dmi' - icon_state = "piano" + icon_state = "minimoog" anchored = 1 density = 1 var @@ -500,7 +500,7 @@ if(href_list["import"]) var/t = "" do - t = input(usr, "Please paste the entire song, formated:", text("[]", src.name), t) as message + t = input(usr, "Please paste the entire song, formatted:", text("[]", src.name), t) as message if (!in_range(src, usr)) return diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index a3448267046..388729b9b1b 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -33,107 +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 (TG Version)" + 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") - switch(alert("Would you like to enter a specific object, or search for it from the world?","Choose!","Specifc UID (Hexadecimal number)", "Search")) - if("Specifc UID (Hexadecimal number)") - var/UID = input("Type in UID, without the leading 0x","Type in UID") as text|null - if(!UID) return - if(length(UID) != 7) - usr << "ERROR. UID must be 7 digits" - var/temp_variable = locate("\[0x[UID]\]") - if(!temp_variable) - usr << "ERROR. Could not locate referenced object." - return - switch(alert("You have chosen [temp_variable], in [get_area(temp_variable)]. Are you sure?","You sure?","Yes","NONOCANCEL!")) - if("Yes") - lst[i] = temp_variable - if("NONOCANCEL!") - return - if("Search") - lst[i] = input("Select reference:","Reference") as null|mob|obj|turf|area in world - - if("mob reference") - lst[i] = input("Select reference:","Reference",usr) as mob in getmobs() - - 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 - sortList(keys) - 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 getmobs() - 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"]" + + 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/callprocgen() set category = "Debug" @@ -286,6 +287,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that t+= "CO2: [env.carbon_dioxide]\n" usr.show_message(t, 1) + //feedback_add_details("admin_verb","ASL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! /client/proc/cmd_admin_robotize(var/mob/M in world) set category = "Fun" @@ -327,6 +329,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that for(var/datum/paiCandidate/candidate in paiController.pai_candidates) if(candidate.key == choice.key) paiController.pai_candidates.Remove(candidate) + //feedback_add_details("admin_verb","MPAI") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! /client/proc/cmd_admin_alienize(var/mob/M in world) set category = "Fun" @@ -466,6 +469,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that del(O) log_admin("[key_name(src)] has deleted all instances of [hsbitem].") message_admins("[key_name_admin(src)] has deleted all instances of [hsbitem].", 0) +// feedback_add_details("admin_verb","DELA") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! /client/proc/cmd_debug_make_powernets() set category = "Debug" @@ -473,6 +477,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that makepowernets() log_admin("[key_name(src)] has remade the powernet. makepowernets() called.") message_admins("[key_name_admin(src)] has remade the powernets. makepowernets() called.", 0) +// feedback_add_details("admin_verb","MPWN") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! /client/proc/cmd_debug_tog_aliens() set category = "Server" @@ -481,6 +486,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that aliens_allowed = !aliens_allowed log_admin("[key_name(src)] has turned aliens [aliens_allowed ? "on" : "off"].") message_admins("[key_name_admin(src)] has turned aliens [aliens_allowed ? "on" : "off"].", 0) +// feedback_add_details("admin_verb","TAL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! /client/proc/cmd_admin_grantfullaccess(var/mob/M in world) set category = "Admin" diff --git a/code/modules/mob/living/silicon/pai/recruit.dm b/code/modules/mob/living/silicon/pai/recruit.dm index 32aa0cc312d..8f238e23135 100644 --- a/code/modules/mob/living/silicon/pai/recruit.dm +++ b/code/modules/mob/living/silicon/pai/recruit.dm @@ -205,13 +205,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, origin) + question(O.client) - proc/question(var/client/C, var/mob/origin) - asked.Add(C.key) - asked[C.key] = world.time - var/response = alert(C, "[origin] 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 + proc/question(var/client/C) + 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