mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 10:11:09 +00:00
[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>
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
switch(action)
|
switch(action)
|
||||||
if("ejectid")
|
if("ejectid")
|
||||||
if(id_card)
|
if(id_card)
|
||||||
card_slot.try_eject(TRUE, usr)
|
card_slot.try_eject(usr, TRUE)
|
||||||
if("selectid")
|
if("selectid")
|
||||||
if(!id_card)
|
if(!id_card)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -94,12 +94,20 @@
|
|||||||
|
|
||||||
// Called when component is removed from PC.
|
// Called when component is removed from PC.
|
||||||
/obj/item/computer_hardware/proc/on_remove(obj/item/modular_computer/M, mob/living/user = null)
|
/obj/item/computer_hardware/proc/on_remove(obj/item/modular_computer/M, mob/living/user = null)
|
||||||
try_eject(forced = 1)
|
try_eject(forced = TRUE)
|
||||||
|
|
||||||
// Called when someone tries to insert something in it - paper in printer, card in card reader, etc.
|
// 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)
|
/obj/item/computer_hardware/proc/try_insert(obj/item/I, mob/living/user = null)
|
||||||
return FALSE
|
return FALSE
|
||||||
|
|
||||||
// Called when someone tries to eject something from it - card from card reader, etc.
|
/**
|
||||||
/obj/item/computer_hardware/proc/try_eject(slot=0, mob/living/user = null, forced = 0)
|
* Implement this when your hardware contains an object that the user can eject.
|
||||||
|
*
|
||||||
|
* Examples include ejecting cells from battery modules, ejecting an ID card from a card reader
|
||||||
|
* or ejecting an Intellicard from an AI card slot.
|
||||||
|
* Arguments:
|
||||||
|
* * user - The mob requesting the eject.
|
||||||
|
* * forced - Whether this action should be forced in some way.
|
||||||
|
*/
|
||||||
|
/obj/item/computer_hardware/proc/try_eject(mob/living/user = null, forced = FALSE)
|
||||||
return FALSE
|
return FALSE
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
/obj/item/computer_hardware/ai_slot/handle_atom_del(atom/A)
|
/obj/item/computer_hardware/ai_slot/handle_atom_del(atom/A)
|
||||||
if(A == stored_card)
|
if(A == stored_card)
|
||||||
try_eject(0, null, TRUE)
|
try_eject(forced = TRUE)
|
||||||
. = ..()
|
. = ..()
|
||||||
|
|
||||||
/obj/item/computer_hardware/ai_slot/examine(mob/user)
|
/obj/item/computer_hardware/ai_slot/examine(mob/user)
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
return TRUE
|
return TRUE
|
||||||
|
|
||||||
|
|
||||||
/obj/item/computer_hardware/ai_slot/try_eject(mob/living/user = null,forced = FALSE)
|
/obj/item/computer_hardware/ai_slot/try_eject(mob/living/user = null, forced = FALSE)
|
||||||
if(!stored_card)
|
if(!stored_card)
|
||||||
to_chat(user, "<span class='warning'>There is no card in \the [src].</span>")
|
to_chat(user, "<span class='warning'>There is no card in \the [src].</span>")
|
||||||
return FALSE
|
return FALSE
|
||||||
@@ -65,5 +65,5 @@
|
|||||||
return
|
return
|
||||||
if(I.tool_behaviour == TOOL_SCREWDRIVER)
|
if(I.tool_behaviour == TOOL_SCREWDRIVER)
|
||||||
to_chat(user, "<span class='notice'>You press down on the manual eject button with \the [I].</span>")
|
to_chat(user, "<span class='notice'>You press down on the manual eject button with \the [I].</span>")
|
||||||
try_eject(,user,1)
|
try_eject(user, TRUE)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
. = ..()
|
. = ..()
|
||||||
|
|
||||||
/obj/item/computer_hardware/card_slot/Destroy()
|
/obj/item/computer_hardware/card_slot/Destroy()
|
||||||
try_eject()
|
try_eject(forced = TRUE)
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
/obj/item/computer_hardware/card_slot/GetAccess()
|
/obj/item/computer_hardware/card_slot/GetAccess()
|
||||||
|
|||||||
Reference in New Issue
Block a user