Fix AI core dropping wrong circuit on decon (#40742)

Also cleaned up a couple vars and added qdel handling.
This commit is contained in:
ShizCalev
2018-10-09 00:54:38 -04:00
committed by yogstation13-bot
parent 4303729250
commit 540269132c
5 changed files with 29 additions and 18 deletions

View File

@@ -259,7 +259,7 @@ Turf and target are separate in case you want to teleport some distance from a t
for(var/mob/living/silicon/ai/A in GLOB.alive_mob_list)
if(A.stat == DEAD)
continue
if(A.control_disabled == 1)
if(A.control_disabled)
continue
if(check_mind)
if(!A.mind)

View File

@@ -129,8 +129,8 @@
return
AI.forceMove(src)
occupier = AI
AI.control_disabled = 1
AI.radio_enabled = 0
AI.control_disabled = TRUE
AI.radio_enabled = FALSE
to_chat(AI, "You have been uploaded to a stationary terminal. Sadly, there is no remote access from here.")
to_chat(user, "<span class='boldnotice'>Transfer successful</span>: [AI.name] ([rand(1000,9999)].exe) installed and executed successfully. Local copy has been removed.")
card.AI = null

View File

@@ -688,8 +688,8 @@
to_chat(user, "<span class='warning'>No AI detected in the [name] onboard computer.</span>")
return
AI.ai_restore_power()//So the AI initially has power.
AI.control_disabled = 1
AI.radio_enabled = 0
AI.control_disabled = TRUE
AI.radio_enabled = FALSE
AI.disconnect_shell()
RemoveActions(AI, TRUE)
occupant = null
@@ -723,8 +723,8 @@
if(occupant || dna_lock) //Normal AIs cannot steal mechs!
to_chat(user, "<span class='warning'>Access denied. [name] is [occupant ? "currently occupied" : "secured with a DNA lock"].</span>")
return
AI.control_disabled = 0
AI.radio_enabled = 1
AI.control_disabled = FALSE
AI.radio_enabled = TRUE
to_chat(user, "<span class='boldnotice'>Transfer successful</span>: [AI.name] ([rand(1000,9999)].exe) installed and executed successfully. Local copy has been removed.")
card.AI = null
ai_enter_mech(AI, interaction)

View File

@@ -6,10 +6,10 @@
icon_state = "0"
desc = "The framework for an artificial intelligence core."
max_integrity = 500
var/state = 0
var/state = EMPTY_CORE
var/datum/ai_laws/laws
var/obj/item/circuitboard/circuit = null
var/obj/item/mmi/brain = null
var/obj/item/circuitboard/aicore/circuit
var/obj/item/mmi/brain
var/can_deconstruct = TRUE
/obj/structure/AIcore/Initialize()
@@ -17,6 +17,17 @@
laws = new
laws.set_laws_config()
/obj/structure/AIcore/handle_atom_del(atom/A)
if(A == circuit)
circuit = null
if((state != GLASS_CORE) && (state != AI_READY_CORE))
state = EMPTY_CORE
update_icon()
if(A == brain)
brain = null
. = ..()
/obj/structure/AIcore/Destroy()
if(circuit)
qdel(circuit)
@@ -307,16 +318,16 @@ That prevents a few funky behaviors.
if(istype(card))
if(card.flush)
to_chat(user, "<span class='boldannounce'>ERROR</span>: AI flush is in progress, cannot execute transfer protocol.")
return 0
return 1
return FALSE
return TRUE
/obj/structure/AIcore/transfer_ai(interaction, mob/user, mob/living/silicon/ai/AI, obj/item/aicard/card)
if(state != AI_READY_CORE || !..())
return
//Transferring a carded AI to a core.
if(interaction == AI_TRANS_FROM_CARD)
AI.control_disabled = 0
AI.radio_enabled = 1
AI.control_disabled = FALSE
AI.radio_enabled = TRUE
AI.forceMove(loc) // to replace the terminal.
to_chat(AI, "You have been uploaded to a stationary terminal. Remote device connection restored.")
to_chat(user, "<span class='boldnotice'>Transfer successful</span>: [AI.name] ([rand(1000,9999)].exe) installed and executed successfully. Local copy has been removed.")

View File

@@ -426,14 +426,14 @@
to_chat(src, "<span class='danger'>Error: Your last call bot command is still processing, please wait for the bot to finish calculating a route.</span>")
return
Bot = locate(href_list["callbot"]) in GLOB.alive_mob_list
if(!Bot || Bot.remote_disabled || src.control_disabled)
if(!Bot || Bot.remote_disabled || control_disabled)
return //True if there is no bot found, the bot is manually emagged, or the AI is carded with wireless off.
waypoint_mode = 1
to_chat(src, "<span class='notice'>Set your waypoint by clicking on a valid location free of obstructions.</span>")
return
if(href_list["interface"]) //Remotely connect to a bot!
Bot = locate(href_list["interface"]) in GLOB.alive_mob_list
if(!Bot || Bot.remote_disabled || src.control_disabled)
if(!Bot || Bot.remote_disabled || control_disabled)
return
Bot.attack_ai(src)
if(href_list["botrefresh"]) //Refreshes the bot control panel.
@@ -812,8 +812,8 @@
ShutOffDoomsdayDevice()
new /obj/structure/AIcore/deactivated(loc)//Spawns a deactivated terminal at AI location.
ai_restore_power()//So the AI initially has power.
control_disabled = 1//Can't control things remotely if you're stuck in a card!
radio_enabled = 0 //No talking on the built-in radio for you either!
control_disabled = TRUE //Can't control things remotely if you're stuck in a card!
radio_enabled = FALSE //No talking on the built-in radio for you either!
forceMove(card)
card.AI = src
to_chat(src, "You have been downloaded to a mobile storage device. Remote device connection severed.")