From 087ae7f9e8451c1a296f468bd414fc9267fe93ac Mon Sep 17 00:00:00 2001 From: Kashargul <144968721+Kashargul@users.noreply.github.com> Date: Sat, 11 Apr 2026 22:31:02 +0300 Subject: [PATCH] bunch of runtimes (#19383) * bunch of runtimes * fix that nif ref properly * . * Makes this more clear it's overriding * Update geiger.dm * Update geiger.dm * Implement TG attack_ui Makes get_item_by_slot actually work. It's the TG naming for our proc get_equipped_item(slot) * Fixes geiger and ore signals * These * Update inventory.dm * Unneeded * These * Leave this for another PR * Update bags.dm --------- Co-authored-by: Cameron Lennox --- code/__defines/qdel.dm | 4 +- .../changeling/helpers/generic_equip_procs.dm | 6 +- code/game/objects/items.dm | 2 +- code/game/objects/items/devices/geiger.dm | 2 +- .../items/devices/uplink_random_lists.dm | 2 +- .../objects/items/weapons/storage/bags.dm | 2 +- .../equipment_vendor.dm | 3 +- code/modules/mob/inventory.dm | 79 ++++++++++++------- .../mob/living/carbon/human/inventory.dm | 1 + .../living/carbon/human/species/species.dm | 15 +--- code/modules/nifsoft/nif.dm | 1 + code/modules/nifsoft/nif_tgui.dm | 5 ++ 12 files changed, 68 insertions(+), 54 deletions(-) diff --git a/code/__defines/qdel.dm b/code/__defines/qdel.dm index 1444de1421b..b6090ca8015 100644 --- a/code/__defines/qdel.dm +++ b/code/__defines/qdel.dm @@ -65,5 +65,5 @@ #define QDEL_LIST_NULL(x) if(x) { for(var/y in x) { qdel(y) } ; x = null } #define QDEL_LIST(L) if(L) { for(var/I in L) qdel(I); L.Cut(); } #define QDEL_LIST_IN(L, time) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(______qdel_list_wrapper), L), time, TIMER_STOPPABLE) -#define QDEL_LIST_ASSOC(L) if(L) { for(var/I in L) { qdel(L[I]); qdel(I); } L.Cut(); } -#define QDEL_LIST_ASSOC_VAL(L) if(L) { for(var/I in L) qdel(L[I]); L.Cut(); } +#define QDEL_LIST_ASSOC(L) if(L) { for(var/I, V in L) { qdel(V); qdel(I); } L.Cut(); } +#define QDEL_LIST_ASSOC_VAL(L) if(L) { for(var/I, V in L) qdel(V); L.Cut(); } diff --git a/code/datums/components/antags/changeling/helpers/generic_equip_procs.dm b/code/datums/components/antags/changeling/helpers/generic_equip_procs.dm index cc8ad5a68ca..6bae027157d 100644 --- a/code/datums/components/antags/changeling/helpers/generic_equip_procs.dm +++ b/code/datums/components/antags/changeling/helpers/generic_equip_procs.dm @@ -20,11 +20,11 @@ span_warning("We cast off our [M.wear_suit.name]"), span_warningplain("You hear the organic matter ripping and tearing!")) if(istype(M.wear_suit, armor_type)) - qdel(M.wear_suit) + remove_from_mob(M.wear_suit) if(istype(M.head, helmet_type)) - qdel(M.head) + remove_from_mob(M.head) if(istype(M.shoes, boot_type)) - qdel(M.shoes) + remove_from_mob(M.shoes) M.update_inv_wear_suit() M.update_inv_head() M.update_hair() diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index e86c9e71956..fd3632f08b5 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -438,7 +438,7 @@ for(var/datum/action/action_item_has as anything in actions) action_item_has.Remove(user) - if((item_flags & DROPDEL) && !QDELETED(src)) + if((item_flags & DROPDEL) && loc != user && !QDELETED(src)) qdel(src) SEND_SIGNAL(src, COMSIG_ITEM_DROPPED, user) diff --git a/code/game/objects/items/devices/geiger.dm b/code/game/objects/items/devices/geiger.dm index ec1c3b4f7a7..2406e9749b0 100644 --- a/code/game/objects/items/devices/geiger.dm +++ b/code/game/objects/items/devices/geiger.dm @@ -100,7 +100,7 @@ RegisterSignal(user, COMSIG_IN_RANGE_OF_IRRADIATION, PROC_REF(on_pre_potential_irradiation)) -/obj/item/geiger/dropped(mob/user, silent = FALSE) +/obj/item/geiger/dropped(mob/user) . = ..() UnregisterSignal(user, COMSIG_IN_RANGE_OF_IRRADIATION) diff --git a/code/game/objects/items/devices/uplink_random_lists.dm b/code/game/objects/items/devices/uplink_random_lists.dm index c5793f25006..444eb07bbc9 100644 --- a/code/game/objects/items/devices/uplink_random_lists.dm +++ b/code/game/objects/items/devices/uplink_random_lists.dm @@ -1,4 +1,4 @@ -GLOBAL_DATUM_INIT(default_uplink_selection, /datum/uplink_random_selection, new) +GLOBAL_DATUM_INIT(default_uplink_selection, /datum/uplink_random_selection/default, new) GLOBAL_DATUM_INIT(all_uplink_selection, /datum/uplink_random_selection/all, new) /datum/uplink_random_item diff --git a/code/game/objects/items/weapons/storage/bags.dm b/code/game/objects/items/weapons/storage/bags.dm index b68fac7f593..c6527668912 100644 --- a/code/game/objects/items/weapons/storage/bags.dm +++ b/code/game/objects/items/weapons/storage/bags.dm @@ -209,7 +209,7 @@ /obj/item/storage/bag/ore/equipped(mob/user) ..() user.AddComponent(/datum/component/recursive_move) - RegisterSignal(user, COMSIG_MOVABLE_ATTEMPTED_MOVE, /obj/item/storage/bag/ore/proc/autoload, user) + RegisterSignal(user, COMSIG_MOVABLE_ATTEMPTED_MOVE, /obj/item/storage/bag/ore/proc/autoload, override = TRUE) /obj/item/storage/bag/ore/dropped(mob/user) ..() diff --git a/code/modules/mining/ore_redemption_machine/equipment_vendor.dm b/code/modules/mining/ore_redemption_machine/equipment_vendor.dm index 173e37540eb..e635091125c 100644 --- a/code/modules/mining/ore_redemption_machine/equipment_vendor.dm +++ b/code/modules/mining/ore_redemption_machine/equipment_vendor.dm @@ -27,7 +27,8 @@ else QDEL_NULL(inserted_id) for(var/key, value in prize_list) - QDEL_NULL_LIST(value) + var/list/item_list = value + QDEL_LIST_ASSOC_VAL(item_list) . = ..() /datum/data/mining_equipment diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index c9dcec3ab81..4239e37fe96 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -21,18 +21,31 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( /mob var/obj/item/storage/s_active = null // Even ghosts can/should be able to peek into boxes on the ground -//This proc is called whenever someone clicks an inventory ui slot. -/mob/proc/attack_ui(var/slot) - var/obj/item/W = get_active_hand() +///Returns the thing we're currently holding +/mob/proc/get_active_held_item() //Currently just a proc for when we do change to /tg/'s item handling. + return get_active_hand() - var/obj/item/E = get_equipped_item(slot) - if (istype(E)) - if(istype(W)) - E.attackby(W,src) - else - E.attack_hand(src) - else - equip_to_slot_if_possible(W, slot) +/** + * This proc is called whenever someone clicks an inventory ui slot. + * + * Mostly tries to put the item into the slot if possible, or call attack hand + * on the item in the slot if the users active hand is empty + */ +/mob/proc/attack_ui(slot, params) + var/obj/item/W = get_active_held_item() + + if(istype(W)) + if(equip_to_slot_if_possible(W, slot,0,0,0)) + return TRUE + + if(!W) + // Activate the item + var/obj/item/I = get_item_by_slot(slot) + if(istype(I)) + var/list/modifiers = params2list(params) + I.attack_hand(src, modifiers) + + return FALSE /* Inventory manipulation */ @@ -143,12 +156,12 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( //Puts the item our active hand if possible. Failing that it tries our inactive hand. Returns 1 on success. //If both fail it drops it on the floor and returns 0. //This is probably the main one you need to know :) -/mob/proc/put_in_hands(var/obj/item/W) - if(!W) +/mob/proc/put_in_hands(var/obj/item/I) + if(!I) return 0 - W.forceMove(drop_location()) - W.reset_plane_and_layer() - W.dropped(src) + I.forceMove(drop_location()) + I.reset_plane_and_layer() + has_unequipped(I) return 0 // Removes an item from inventory and places it in the target atom. @@ -161,6 +174,13 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( return remove_from_mob(W, src.loc) return remove_from_mob(W, target) +/// This proc is called after an item has been removed from a mob but before it has been officially deslotted. +/mob/proc/has_unequipped(obj/item/item) //, silent = FALSE) //TODO: Add silent some other time. + SHOULD_CALL_PARENT(TRUE) + item.dropped(src) //, silent) + //update_equipment_speed_mods() + return TRUE + //Drops the item in our left hand /mob/proc/drop_l_hand(var/atom/Target) return 0 @@ -219,29 +239,28 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( ///Get the item on the mob in the storage slot identified by the id passed in /mob/proc/get_item_by_slot(slot_id) - return null + return get_equipped_item(slot_id) /mob/proc/getBackSlot() return SLOT_BACK //Attemps to remove an object on a mob. -/mob/proc/remove_from_mob(var/obj/O, var/atom/target) - if(!O) // Nothing to remove, so we succeed. +/mob/proc/remove_from_mob(var/obj/item_dropping, var/atom/target) + if(!item_dropping) // Nothing to remove, so we succeed. return 1 - src.u_equip(O) + src.u_equip(item_dropping) if (src.client) - src.client.screen -= O - O.reset_plane_and_layer() - O.screen_loc = null - if(istype(O, /obj/item)) - var/obj/item/I = O + src.client.screen -= item_dropping + item_dropping.reset_plane_and_layer() + item_dropping.screen_loc = null + if(isitem(item_dropping)) if(target) - I.forceMove(target) + item_dropping.forceMove(target) else - I.dropInto(drop_location()) - I.dropped(src) - //SEND_SIGNAL(item_dropping, COMSIG_ITEM_POST_UNEQUIP, O, target) - SEND_SIGNAL(src, COMSIG_MOB_UNEQUIPPED_ITEM, O, target) + item_dropping.dropInto(drop_location()) + has_unequipped(item_dropping) + //SEND_SIGNAL(item_dropping, COMSIG_ITEM_POST_UNEQUIP, item_dropping, target) + SEND_SIGNAL(src, COMSIG_MOB_UNEQUIPPED_ITEM, item_dropping, target) return TRUE //Returns the item equipped to the specified slot, if any. diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 4826f599cf9..f21aaaa0771 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -239,6 +239,7 @@ This saves us from having to call add_fingerprint() any time something is put in return W.loc = src + has_unequipped(W) //TG calls attempt_insert -> transferItemToLoc -> doUnEquip -> has_unequipped. This is where we do it instead since we don't have storage datums. switch(slot) if(slot_back) src.back = W diff --git a/code/modules/mob/living/carbon/human/species/species.dm b/code/modules/mob/living/carbon/human/species/species.dm index df24d67999e..031efd4996b 100644 --- a/code/modules/mob/living/carbon/human/species/species.dm +++ b/code/modules/mob/living/carbon/human/species/species.dm @@ -457,7 +457,7 @@ else H.equip_to_slot_or_del(box, slot_in_backpack) -/datum/species/proc/create_organs(var/mob/living/carbon/human/H) //Handles creation of mob organs. +/datum/species/proc/create_organs(mob/living/carbon/human/H) //Handles creation of mob organs. H.mob_size = mob_size for(var/obj/item/organ/organ in H.contents) @@ -794,19 +794,6 @@ for(var/u_type in unarmed_types) unarmed_attacks += new u_type() -/datum/species/create_organs(var/mob/living/carbon/human/H) - if(H.nif) - /*var/type = H.nif.type - var/durability = H.nif.durability - var/list/nifsofts = H.nif.nifsofts - var/list/nif_savedata = H.nif.save_data.Copy()*/ - ..() - H.nif = null //A previous call during the rejuvenation path deleted it, so we no longer should have it here - /*var/obj/item/nif/nif = new type(H,durability,nif_savedata) - nif.nifsofts = nifsofts*/ - else - ..() - /datum/species/proc/apply_components(var/mob/living/carbon/human/H) if(LAZYLEN(species_component)) for(var/component in species_component) diff --git a/code/modules/nifsoft/nif.dm b/code/modules/nifsoft/nif.dm index 5c61c422e4b..d4ea7fa8763 100644 --- a/code/modules/nifsoft/nif.dm +++ b/code/modules/nifsoft/nif.dm @@ -104,6 +104,7 @@ You can also set the stat of a NIF to NIF_TEMPFAIL without any issues to disable /obj/item/nif/proc/unregister_human() UnregisterSignal(human, COMSIG_MOB_DEATH) + human.nif = null //Destructor cleans up references /obj/item/nif/Destroy() diff --git a/code/modules/nifsoft/nif_tgui.dm b/code/modules/nifsoft/nif_tgui.dm index 6b06597aea7..02750bf1f52 100644 --- a/code/modules/nifsoft/nif_tgui.dm +++ b/code/modules/nifsoft/nif_tgui.dm @@ -29,6 +29,11 @@ return COMPONENT_INCOMPATIBLE . = ..() +/datum/component/nif_menu/Destroy(force) + if(screen_icon) + QDEL_NULL(screen_icon) + . = ..() + /datum/component/nif_menu/RegisterWithParent() . = ..() RegisterSignal(parent, COMSIG_MOB_CLIENT_LOGIN, PROC_REF(create_mob_button))