mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-13 09:05:11 +01:00
Replaces use of handle_atom_del() with Exited() in modular computer hardware. And fixes an issue. (#57387)
Title. The issue being hardware/on_remove() calling /try_eject() even if the holder is being destroyed, which is quirky. I also replaced an instance of /New() with /Initialize() and deleted a troublesome /Destroy(). handle_atom_del() is awful. Nearly every (minus the storage component; it's a tangled trial of mental gymnastic) behavior implemented there can pretty much be moved to Exited() and it'll work just as fine, if not better against edge cases such as recall spells. But that's not the scope of this PR. I'm here to fix #57161.
This commit is contained in:
@@ -93,8 +93,9 @@
|
||||
return
|
||||
|
||||
// Called when component is removed from PC.
|
||||
/obj/item/computer_hardware/proc/on_remove(obj/item/modular_computer/M, mob/living/user = null)
|
||||
try_eject(forced = TRUE)
|
||||
/obj/item/computer_hardware/proc/on_remove(obj/item/modular_computer/M, mob/living/user)
|
||||
if(M.physical || !QDELETED(M))
|
||||
try_eject(forced = TRUE)
|
||||
|
||||
// Called when someone tries to insert something in it - paper in printer, card in card reader, etc.
|
||||
/obj/item/computer_hardware/proc/try_insert(obj/item/I, mob/living/user = null)
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
device_type = MC_AI
|
||||
expansion_hw = TRUE
|
||||
|
||||
var/obj/item/aicard/stored_card = null
|
||||
var/obj/item/aicard/stored_card
|
||||
var/locked = FALSE
|
||||
|
||||
/obj/item/computer_hardware/ai_slot/handle_atom_del(atom/A)
|
||||
///What happens when the intellicard is removed (or deleted) from the module, through try_eject() or not.
|
||||
/obj/item/computer_hardware/ai_slot/Exited(atom/A, atom/newloc)
|
||||
if(A == stored_card)
|
||||
try_eject(forced = TRUE)
|
||||
. = ..()
|
||||
stored_card = null
|
||||
return ..()
|
||||
|
||||
/obj/item/computer_hardware/ai_slot/examine(mob/user)
|
||||
. = ..()
|
||||
@@ -55,7 +56,6 @@
|
||||
user.put_in_hands(stored_card)
|
||||
else
|
||||
stored_card.forceMove(drop_location())
|
||||
stored_card = null
|
||||
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
@@ -4,25 +4,28 @@
|
||||
icon_state = "cell_con"
|
||||
critical = 1
|
||||
malfunction_probability = 1
|
||||
var/obj/item/stock_parts/cell/battery = null
|
||||
var/obj/item/stock_parts/cell/battery
|
||||
device_type = MC_CELL
|
||||
|
||||
/obj/item/computer_hardware/battery/get_cell()
|
||||
return battery
|
||||
|
||||
/obj/item/computer_hardware/battery/New(loc, battery_type = null)
|
||||
/obj/item/computer_hardware/battery/Initialize(mapload, battery_type)
|
||||
. = ..()
|
||||
if(battery_type)
|
||||
battery = new battery_type(src)
|
||||
..()
|
||||
|
||||
/obj/item/computer_hardware/battery/Destroy()
|
||||
. = ..()
|
||||
QDEL_NULL(battery)
|
||||
battery = null
|
||||
return ..()
|
||||
|
||||
/obj/item/computer_hardware/battery/handle_atom_del(atom/A)
|
||||
///What happens when the battery is removed (or deleted) from the module, through try_eject() or not.
|
||||
/obj/item/computer_hardware/battery/Exited(atom/A, atom/newloc)
|
||||
if(A == battery)
|
||||
try_eject(forced = TRUE)
|
||||
. = ..()
|
||||
battery = null
|
||||
if(holder?.enabled && !holder.use_power())
|
||||
holder.shutdown_computer()
|
||||
return ..()
|
||||
|
||||
/obj/item/computer_hardware/battery/try_insert(obj/item/I, mob/living/user = null)
|
||||
if(!holder)
|
||||
@@ -47,31 +50,18 @@
|
||||
|
||||
return TRUE
|
||||
|
||||
|
||||
/obj/item/computer_hardware/battery/try_eject(mob/living/user = null, forced = FALSE)
|
||||
/obj/item/computer_hardware/battery/try_eject(mob/living/user, forced = FALSE)
|
||||
if(!battery)
|
||||
to_chat(user, "<span class='warning'>There is no power cell connected to \the [src].</span>")
|
||||
return FALSE
|
||||
else
|
||||
if(user)
|
||||
user.put_in_hands(battery)
|
||||
to_chat(user, "<span class='notice'>You detach \the [battery] from \the [src].</span>")
|
||||
else
|
||||
battery.forceMove(drop_location())
|
||||
to_chat(user, "<span class='notice'>You detach \the [battery] from \the [src].</span>")
|
||||
battery = null
|
||||
|
||||
if(holder)
|
||||
if(holder.enabled && !holder.use_power())
|
||||
holder.shutdown_computer()
|
||||
|
||||
return TRUE
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/obj/item/stock_parts/cell/computer
|
||||
name = "standard battery"
|
||||
desc = "A standard power cell, commonly seen in high-end portable microcomputers or low-end laptops."
|
||||
@@ -80,7 +70,6 @@
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
maxcharge = 750
|
||||
|
||||
|
||||
/obj/item/stock_parts/cell/computer/advanced
|
||||
name = "advanced battery"
|
||||
desc = "An advanced power cell, often used in most laptops. It is too large to be fitted into smaller devices."
|
||||
|
||||
@@ -6,12 +6,26 @@
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
device_type = MC_CARD
|
||||
|
||||
var/obj/item/card/id/stored_card = null
|
||||
var/obj/item/card/id/stored_card
|
||||
|
||||
/obj/item/computer_hardware/card_slot/handle_atom_del(atom/A)
|
||||
///What happens when the ID card is removed (or deleted) from the module, through try_eject() or not.
|
||||
/obj/item/computer_hardware/card_slot/Exited(atom/A, atom/newloc)
|
||||
if(A == stored_card)
|
||||
try_eject(null, TRUE)
|
||||
. = ..()
|
||||
stored_card = null
|
||||
if(holder)
|
||||
if(holder.active_program)
|
||||
holder.active_program.event_idremoved(0)
|
||||
for(var/p in holder.idle_threads)
|
||||
var/datum/computer_file/program/computer_program = p
|
||||
computer_program.event_idremoved(1)
|
||||
|
||||
holder.update_slot_icon()
|
||||
|
||||
if(ishuman(holder.loc))
|
||||
var/mob/living/carbon/human/human_wearer = holder.loc
|
||||
if(human_wearer.wear_id == holder)
|
||||
human_wearer.sec_hud_set_ID()
|
||||
return ..()
|
||||
|
||||
/obj/item/computer_hardware/card_slot/Destroy()
|
||||
try_eject(forced = TRUE)
|
||||
@@ -81,23 +95,6 @@
|
||||
user.put_in_hands(stored_card)
|
||||
else
|
||||
stored_card.forceMove(drop_location())
|
||||
stored_card = null
|
||||
|
||||
if(holder)
|
||||
if(holder.active_program)
|
||||
holder.active_program.event_idremoved(0)
|
||||
|
||||
for(var/p in holder.idle_threads)
|
||||
var/datum/computer_file/program/computer_program = p
|
||||
computer_program.event_idremoved(1)
|
||||
|
||||
holder.update_slot_icon()
|
||||
|
||||
var/holder_loc = holder.loc
|
||||
if(ishuman(holder_loc))
|
||||
var/mob/living/carbon/human/human_wearer = holder_loc
|
||||
if(human_wearer.wear_id == holder)
|
||||
human_wearer.sec_hud_set_ID()
|
||||
|
||||
to_chat(user, "<span class='notice'>You remove the card from \the [src].</span>")
|
||||
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
|
||||
|
||||
Reference in New Issue
Block a user