From d87cbeeba39a6641e7376d92bbf9d3d6a6c86328 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 16 Sep 2020 02:28:32 +0200 Subject: [PATCH] [MIRROR] Cyborg inventory runtime fix. (#813) * Cyborg inventory runtime fix. (#53741) Following the cyborg inventory refactor, code changed a bit. Cyborg inventory screens are inited in the HUD, however AI Shells don't generate a HUD until an AI assumes direct control. Damaging an AI shell before the AI created a HUD in it would cause runtimes as modules disabled and enabled. To remedy this, we now initialize the core inventory slots on the robit Init() and then update them as necessary in the HUD code later on if an AI ever deigns to grace your shell with their exalted presence instead of asking for it and then never using it. * Cyborg inventory runtime fix. Co-authored-by: Timberpoes --- code/_onclick/hud/robot.dm | 48 ++++++++++--------- .../modules/mob/living/silicon/robot/robot.dm | 16 ++++--- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index fcc46d5c0bb..7988d49f56b 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -93,7 +93,8 @@ /datum/hud/robot/New(mob/owner) ..() - var/mob/living/silicon/robot/mymobR = mymob + // i, Robit + var/mob/living/silicon/robot/robit = mymob var/obj/screen/using using = new/obj/screen/language_menu @@ -107,23 +108,26 @@ static_inventory += using //Module select - using = new /obj/screen/robot/module1() - using.screen_loc = ui_inv1 - using.hud = src - static_inventory += using - mymobR.inv1 = using + if(!robit.inv1) + robit.inv1 = new /obj/screen/robot/module1() - using = new /obj/screen/robot/module2() - using.screen_loc = ui_inv2 - using.hud = src - static_inventory += using - mymobR.inv2 = using + robit.inv1.screen_loc = ui_inv1 + robit.inv1.hud = src + static_inventory += robit.inv1 - using = new /obj/screen/robot/module3() - using.screen_loc = ui_inv3 - using.hud = src - static_inventory += using - mymobR.inv3 = using + if(!robit.inv2) + robit.inv2 = new /obj/screen/robot/module2() + + robit.inv2.screen_loc = ui_inv2 + robit.inv2.hud = src + static_inventory += robit.inv2 + + if(!robit.inv3) + robit.inv3 = new /obj/screen/robot/module3() + + robit.inv3.screen_loc = ui_inv3 + robit.inv3.hud = src + static_inventory += robit.inv3 //End of module select @@ -149,14 +153,14 @@ using.screen_loc = ui_borg_lamp using.hud = src static_inventory += using - mymobR.lamp_button = using + robit.lamp_button = using //Thrusters using = new /obj/screen/robot/thrusters() using.screen_loc = ui_borg_thrusters using.hud = src static_inventory += using - mymobR.thruster_button = using + robit.thruster_button = using //Intent action_intent = new /obj/screen/act_intent/robot() @@ -170,10 +174,10 @@ infodisplay += healths //Installed Module - mymobR.hands = new /obj/screen/robot/module() - mymobR.hands.screen_loc = ui_borg_module - mymobR.hands.hud = src - static_inventory += mymobR.hands + robit.hands = new /obj/screen/robot/module() + robit.hands.screen_loc = ui_borg_module + robit.hands.hud = src + static_inventory += robit.hands //Store module_store_icon = new /obj/screen/robot/store() diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index bb6ecfe8558..d7002537e8a 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -114,6 +114,10 @@ robot_modules_background.layer = HUD_LAYER //Objects that appear on screen are on layer ABOVE_HUD_LAYER, UI should be just below it. robot_modules_background.plane = HUD_PLANE + inv1 = new /obj/screen/robot/module1() + inv2 = new /obj/screen/robot/module2() + inv3 = new /obj/screen/robot/module3() + ident = rand(1, 999) previous_health = health @@ -188,12 +192,12 @@ if(T && istype(radio) && istype(radio.keyslot)) radio.keyslot.forceMove(T) radio.keyslot = null - qdel(wires) - qdel(module) - qdel(eye_lights) - wires = null - module = null - eye_lights = null + QDEL_NULL(wires) + QDEL_NULL(module) + QDEL_NULL(eye_lights) + QDEL_NULL(inv1) + QDEL_NULL(inv2) + QDEL_NULL(inv3) cell = null return ..()