Skip to content

Commit

Permalink
TG: Fixes a pAI requests runtime caused by clients disconnecting.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wishmandible committed May 9, 2012
1 parent d651a99 commit 165b516
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 98 deletions.
9 changes: 4 additions & 5 deletions code/game/machinery/telecomms/telecommunications.dm
Expand Up @@ -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++
Expand Down
6 changes: 3 additions & 3 deletions code/game/magic/musician.dm
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
166 changes: 86 additions & 80 deletions code/modules/admin/verbs/debug.dm
Expand Up @@ -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, i<argnum+1, i++) // Lists indexed from 1 forwards in byond

// Make a list with each index containing one variable, to be given to the proc
class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","icon","file","client","mob's area","CANCEL")
switch(class)
if("CANCEL ABORT STOP")
if("CANCEL")
return
if("Obj")
target = input("Enter target:","Target",usr) as obj in world
if("Mob")
target = input("Enter target:","Target",usr) as mob in getmobs()
if("Area or Turf")
target = input("Enter target:","Target",usr.loc) as area|turf in world
if("Client")
var/list/keys = list()
for(var/mob/M in world)
keys += M.client
target = input("Please, select a player!", "Selection", null, null) as null|anything in keys
if("No")
target = null

var/procname = input("Proc path, eg: /proc/fake_blood","Path:", null)
if("text")
lst[i] = input("Enter new text:","Text",null) as text

var/argnum = input("Number of arguments","Number:",0) as num
if("num")
lst[i] = input("Enter new number:","Num",0) as num

lst.len = argnum // Expand to right length
if("type")
lst[i] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)

var/i
for(i=1, i<argnum+1, i++) // Lists indexed from 1 forwards in byond
if("reference")
lst[i] = input("Select reference:","Reference",src) as mob|obj|turf|area in world

// Make a list with each index containing one variable, to be given to the proc
class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","icon","file","client","mob's area","CANCEL")
switch(class)
if("CANCEL")
return
if("mob reference")
lst[i] = input("Select reference:","Reference",usr) as mob in world

if("text")
lst[i] = input("Enter new text:","Text",null) as text
if("file")
lst[i] = input("Pick file:","File") as file

if("num")
lst[i] = input("Enter new number:","Num",0) as num
if("icon")
lst[i] = input("Pick icon:","Icon") as icon

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
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)
if(targetselected)
if(!target)
usr << "<font color='red'>Error: callproc(): owner of proc no longer exists.</font>"
return
if(!hascall(target,procname))
usr << "<font color='red'>Error: callproc(): target has no such call [procname].</font>"
return
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 << "<font color='blue'>[procname] returned: [returnval ? returnval : "null"]</font>"
//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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -466,13 +469,15 @@ 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"
set name = "Make Powernets"
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"
Expand All @@ -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"
Expand Down
23 changes: 13 additions & 10 deletions code/modules/mob/living/silicon/pai/recruit.dm
Expand Up @@ -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)

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
question(O.client)

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

0 comments on commit 165b516

Please sign in to comment.