Skip to content

Commit

Permalink
Cyborg inventory runtime fix. (tgstation#53741)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Timberpoes authored Sep 15, 2020
1 parent 115354b commit b8ce0aa
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
48 changes: 26 additions & 22 deletions code/_onclick/hud/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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()
Expand All @@ -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()
Expand Down
16 changes: 10 additions & 6 deletions code/modules/mob/living/silicon/robot/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ..()

Expand Down

0 comments on commit b8ce0aa

Please sign in to comment.