Files
Bubberstation/code/modules/modular_computers/hardware/ai_slot.dm
SkyratBot a608adb52e [MIRROR] Cleans up try_eject proc prototype and various proc usages to fix some runtimes (#1609)
* Feex (#54716)

[09:18:04] Runtime in card_slot.dm, line 72: Cannot execute 1.put in hands().

Usage of the try_eject proc is an eclectic mix of unimplemented behaviour and incorrect argument order, with behaviour that can cause runtimes.

Prototype for the try_eject proc wasn't even implemented properly by children. Nothing implemented it used the slots arg, so I modified the base prototype. Cleaned up various proc calls. Should no longer have incorrect arg-based runtimes.

* Cleans up try_eject proc prototype and various proc usages to fix some runtimes

Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
2020-11-07 15:43:03 +00:00

70 lines
2.1 KiB
Plaintext

/obj/item/computer_hardware/ai_slot
name = "intelliCard interface slot"
desc = "A module allowing this computer to interface with most common intelliCard modules. Necessary for some programs to run properly."
power_usage = 100 //W
icon_state = "card_mini"
w_class = WEIGHT_CLASS_SMALL
device_type = MC_AI
expansion_hw = TRUE
var/obj/item/aicard/stored_card = null
var/locked = FALSE
/obj/item/computer_hardware/ai_slot/handle_atom_del(atom/A)
if(A == stored_card)
try_eject(forced = TRUE)
. = ..()
/obj/item/computer_hardware/ai_slot/examine(mob/user)
. = ..()
if(stored_card)
. += "There appears to be an intelliCard loaded. There appears to be a pinhole protecting a manual eject button. A screwdriver could probably press it."
/obj/item/computer_hardware/ai_slot/try_insert(obj/item/I, mob/living/user = null)
if(!holder)
return FALSE
if(!istype(I, /obj/item/aicard))
return FALSE
if(stored_card)
to_chat(user, "<span class='warning'>You try to insert \the [I] into \the [src], but the slot is occupied.</span>")
return FALSE
if(user && !user.transferItemToLoc(I, src))
return FALSE
stored_card = I
to_chat(user, "<span class='notice'>You insert \the [I] into \the [src].</span>")
return TRUE
/obj/item/computer_hardware/ai_slot/try_eject(mob/living/user = null, forced = FALSE)
if(!stored_card)
to_chat(user, "<span class='warning'>There is no card in \the [src].</span>")
return FALSE
if(locked && !forced)
to_chat(user, "<span class='warning'>Safeties prevent you from removing the card until reconstruction is complete...</span>")
return FALSE
if(stored_card)
to_chat(user, "<span class='notice'>You remove [stored_card] from [src].</span>")
locked = FALSE
if(user)
user.put_in_hands(stored_card)
else
stored_card.forceMove(drop_location())
stored_card = null
return TRUE
return FALSE
/obj/item/computer_hardware/ai_slot/attackby(obj/item/I, mob/living/user)
if(..())
return
if(I.tool_behaviour == TOOL_SCREWDRIVER)
to_chat(user, "<span class='notice'>You press down on the manual eject button with \the [I].</span>")
try_eject(user, TRUE)
return