From e6d19faeba2340eb2dc2bd21d7957eb41bd9a418 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Sun, 29 Mar 2015 23:49:15 -0400 Subject: [PATCH 1/6] Cleans up mob/inventory.dm, fixes removed_from_mob() not calling dropped() on items. Updates u_equip() accordingly in the other inventory.dm files as well, and moves some random inventory procs from mob.dm to mob/inventory.dm. --- code/modules/mob/inventory.dm | 106 ++++++++++++++---- .../mob/living/carbon/human/inventory.dm | 60 ++++------ .../mob/living/carbon/human/update_icons.dm | 3 +- code/modules/mob/mob.dm | 71 ------------ 4 files changed, 106 insertions(+), 134 deletions(-) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 653e33b2ddf..303f1665de7 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -1,15 +1,81 @@ +//This proc is called whenever someone clicks an inventory ui slot. +/mob/proc/attack_ui(slot) + var/obj/item/W = get_active_hand() + if(istype(W)) + equip_to_slot_if_possible(W, slot) + +/mob/proc/put_in_any_hand_if_possible(obj/item/W as obj, del_on_fail = 0, disable_warning = 1, redraw_mob = 1) + if(equip_to_slot_if_possible(W, slot_l_hand, del_on_fail, disable_warning, redraw_mob)) + return 1 + else if(equip_to_slot_if_possible(W, slot_r_hand, del_on_fail, disable_warning, redraw_mob)) + return 1 + return 0 + +//This is a SAFE proc. Use this instead of equip_to_slot()! +//set del_on_fail to have it delete W if it fails to equip +//set disable_warning to disable the 'you are unable to equip that' warning. +//unset redraw_mob to prevent the mob from being redrawn at the end. +/mob/proc/equip_to_slot_if_possible(obj/item/W as obj, slot, del_on_fail = 0, disable_warning = 0, redraw_mob = 1) + if(!istype(W)) return 0 + + if(!W.mob_can_equip(src, slot)) + if(del_on_fail) + del(W) + else + if(!disable_warning) + src << "\red You are unable to equip that." //Only print if del_on_fail is false + return 0 + + equip_to_slot(W, slot, redraw_mob) //This proc should not ever fail. + return 1 + +//This is an UNSAFE proc. It merely handles the actual job of equipping. All the checks on whether you can or can't eqip need to be done before! Use mob_can_equip() for that task. +//In most cases you will want to use equip_to_slot_if_possible() +/mob/proc/equip_to_slot(obj/item/W as obj, slot) + return + +//This is just a commonly used configuration for the equip_to_slot_if_possible() proc, used to equip people when the rounds tarts and when events happen and such. +/mob/proc/equip_to_slot_or_del(obj/item/W as obj, slot) + return equip_to_slot_if_possible(W, slot, 1, 1, 0) + +//The list of slots by priority. equip_to_appropriate_slot() uses this list. Doesn't matter if a mob type doesn't have a slot. +var/list/slot_equipment_priority = list( \ + slot_back,\ + slot_wear_id,\ + slot_w_uniform,\ + slot_wear_suit,\ + slot_wear_mask,\ + slot_head,\ + slot_shoes,\ + slot_gloves,\ + slot_l_ear,\ + slot_r_ear,\ + slot_glasses,\ + slot_belt,\ + slot_s_store,\ + slot_tie,\ + slot_l_store,\ + slot_r_store\ + ) + +//puts the item "W" into an appropriate slot in a human's inventory +//returns 0 if it cannot, 1 if successful +/mob/proc/equip_to_appropriate_slot(obj/item/W) + if(!istype(W)) return 0 + + for(var/slot in slot_equipment_priority) + if(equip_to_slot_if_possible(W, slot, del_on_fail=0, disable_warning=1, redraw_mob=1)) + return 1 + + return 0 + //These procs handle putting s tuff in your hand. It's probably best to use these rather than setting l_hand = ...etc //as they handle all relevant stuff like adding it to the player's screen and updating their overlays. //Returns the thing in our active hand /mob/proc/get_active_hand() - if(issilicon(src)) - if(isrobot(src)) - if(src:module_active) - return src:module_active - else - if(hand) return l_hand - else return r_hand + if(hand) return l_hand + else return r_hand //Returns the thing in our inactive hand /mob/proc/get_inactive_hand() @@ -84,28 +150,20 @@ return drop_item() return 0 - +// Removes an item from inventory and places it in the target atom /mob/proc/drop_from_inventory(var/obj/item/W, var/atom/Target = null) if(W) if(!Target) Target = loc - if(client) client.screen -= W - u_equip(W) + remove_from_mob(W) if(!W) return 1 // self destroying objects (tk, grabs) - W.layer = initial(W.layer) - W.loc = Target - - var/turf/T = get_turf(Target) - if(isturf(T)) - T.Entered(W) - - W.dropped(src) + + W.forceMove(Target) update_icons() return 1 return 0 - //Drops the item in our left hand /mob/proc/drop_l_hand(var/atom/Target) if(l_hand) @@ -166,7 +224,12 @@ return -/mob/proc/u_equip(W as obj) +//Removes the object from any slots the mob might have, calling the appropriate icon update proc. +//Does nothing else. +//DO NOT CALL THIS PROC DIRECTLY. It is meant to be called only by other inventory procs. +//As far as I can tell the proc exists so that mobs with different inventory slots can override +//the search through all the slots, without having to duplicate the rest of the item dropping. +/mob/proc/u_equip(obj/W as obj) if (W == r_hand) r_hand = null update_inv_r_hand(0) @@ -215,6 +278,9 @@ src.client.screen -= O O.layer = initial(O.layer) O.screen_loc = null + if(istype(O, /obj/item)) + var/obj/item/I = O + I.dropped() return 1 diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 7846a1ac260..43b66d9cccc 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -76,19 +76,13 @@ if(slot_tie) return 1 -/mob/living/carbon/human/u_equip(obj/item/W as obj) +/mob/living/carbon/human/u_equip(obj/W as obj) if(!W) return 0 - var/success - if (W == wear_suit) if(s_store) drop_from_inventory(s_store) - if(W) - success = 1 wear_suit = null - if(W.flags_inv & HIDESHOES) - update_inv_shoes(0) update_inv_wear_suit() else if (W == w_uniform) if (r_store) @@ -100,43 +94,43 @@ if (belt) drop_from_inventory(belt) w_uniform = null - success = 1 update_inv_w_uniform() else if (W == gloves) gloves = null - success = 1 update_inv_gloves() else if (W == glasses) glasses = null - success = 1 update_inv_glasses() else if (W == head) head = null - if((W.flags & BLOCKHAIR) || (W.flags & BLOCKHEADHAIR)|| (W.flags_inv & HIDEMASK)) + + var/update_hair = 0 + if((W.flags & BLOCKHAIR) || (W.flags & BLOCKHEADHAIR)) + update_hair = 1 + else if(istype(W, /obj/item)) + var/obj/item/I = W + if(I.flags_inv & HIDEMASK) + update_hair = 1 + if(update_hair) update_hair(0) //rebuild hair update_inv_ears(0) update_inv_wear_mask(0) - success = 1 + update_inv_head() else if (W == l_ear) l_ear = null - success = 1 update_inv_ears() else if (W == r_ear) r_ear = null - success = 1 update_inv_ears() else if (W == shoes) shoes = null - success = 1 update_inv_shoes() else if (W == belt) belt = null - success = 1 update_inv_belt() else if (W == wear_mask) wear_mask = null - success = 1 if((W.flags & BLOCKHAIR) || (W.flags & BLOCKHEADHAIR)) update_hair(0) //rebuild hair update_inv_ears(0) @@ -147,51 +141,34 @@ update_inv_wear_mask() else if (W == wear_id) wear_id = null - success = 1 update_inv_wear_id() else if (W == r_store) r_store = null - success = 1 update_inv_pockets() else if (W == l_store) l_store = null - success = 1 update_inv_pockets() else if (W == s_store) s_store = null - success = 1 update_inv_s_store() else if (W == back) back = null - success = 1 update_inv_back() else if (W == handcuffed) handcuffed = null - success = 1 update_inv_handcuffed() else if (W == legcuffed) legcuffed = null - success = 1 update_inv_legcuffed() else if (W == r_hand) r_hand = null - success = 1 update_inv_r_hand() else if (W == l_hand) l_hand = null - success = 1 update_inv_l_hand() else return 0 - - if(success) - if (W) - if (client) - client.screen -= W - W.loc = loc - W.dropped(src) - //if(W) - //W.layer = initial(W.layer) + update_action_buttons() return 1 @@ -304,7 +281,7 @@ update_inv_s_store(redraw_mob) if(slot_in_backpack) if(src.get_active_hand() == W) - src.u_equip(W) + src.remove_from_mob(W) W.loc = src.back if(slot_tie) var/obj/item/clothing/under/uniform = src.w_uniform @@ -324,6 +301,10 @@ return +/* + MouseDrop human inventory menu +*/ + /obj/effect/equip_e name = "equip e" var/mob/source = null @@ -757,15 +738,12 @@ It can still be worn/put on as normal. W.add_fingerprint(source) if(slot_to_process == slot_l_store) //pockets! Needs to process the other one too. Snowflake code, wooo! It's not like anyone will rewrite this anytime soon. If I'm wrong then... CONGRATULATIONS! ;) if(target.r_store) - target.u_equip(target.r_store) //At this stage l_store is already processed by the code above, we only need to process r_store. + target.remove_from_mob(target.r_store) //At this stage l_store is already processed by the code above, we only need to process r_store. else if(item && target.has_organ_for_slot(slot_to_process)) //Placing an item on the mob if(item.mob_can_equip(target, slot_to_process, 0)) - source.u_equip(item) + source.remove_from_mob(item) target.equip_to_slot_if_possible(item, slot_to_process, 0, 1, 1) - item.dropped(source) - source.update_icons() - target.update_icons() if(source && target) if(source.machine == target) diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index 0bdcf6d4275..bb195831190 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -752,13 +752,12 @@ proc/get_damage_icon_part(damage_state, body_part) standing.overlays += bloodsies overlays_standing[SUIT_LAYER] = standing - update_tail_showing(0) else overlays_standing[SUIT_LAYER] = null - update_tail_showing(0) + update_inv_shoes(0) update_collar(0) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 1b92c92ae60..0ab9b162d10 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -117,77 +117,6 @@ /mob/proc/restrained() return -//This proc is called whenever someone clicks an inventory ui slot. -/mob/proc/attack_ui(slot) - var/obj/item/W = get_active_hand() - if(istype(W)) - equip_to_slot_if_possible(W, slot) - -/mob/proc/put_in_any_hand_if_possible(obj/item/W as obj, del_on_fail = 0, disable_warning = 1, redraw_mob = 1) - if(equip_to_slot_if_possible(W, slot_l_hand, del_on_fail, disable_warning, redraw_mob)) - return 1 - else if(equip_to_slot_if_possible(W, slot_r_hand, del_on_fail, disable_warning, redraw_mob)) - return 1 - return 0 - -//This is a SAFE proc. Use this instead of equip_to_slot()! -//set del_on_fail to have it delete W if it fails to equip -//set disable_warning to disable the 'you are unable to equip that' warning. -//unset redraw_mob to prevent the mob from being redrawn at the end. -/mob/proc/equip_to_slot_if_possible(obj/item/W as obj, slot, del_on_fail = 0, disable_warning = 0, redraw_mob = 1) - if(!istype(W)) return 0 - - if(!W.mob_can_equip(src, slot)) - if(del_on_fail) - del(W) - else - if(!disable_warning) - src << "\red You are unable to equip that." //Only print if del_on_fail is false - return 0 - - equip_to_slot(W, slot, redraw_mob) //This proc should not ever fail. - return 1 - -//This is an UNSAFE proc. It merely handles the actual job of equipping. All the checks on whether you can or can't eqip need to be done before! Use mob_can_equip() for that task. -//In most cases you will want to use equip_to_slot_if_possible() -/mob/proc/equip_to_slot(obj/item/W as obj, slot) - return - -//This is just a commonly used configuration for the equip_to_slot_if_possible() proc, used to equip people when the rounds tarts and when events happen and such. -/mob/proc/equip_to_slot_or_del(obj/item/W as obj, slot) - return equip_to_slot_if_possible(W, slot, 1, 1, 0) - -//The list of slots by priority. equip_to_appropriate_slot() uses this list. Doesn't matter if a mob type doesn't have a slot. -var/list/slot_equipment_priority = list( \ - slot_back,\ - slot_wear_id,\ - slot_w_uniform,\ - slot_wear_suit,\ - slot_wear_mask,\ - slot_head,\ - slot_shoes,\ - slot_gloves,\ - slot_l_ear,\ - slot_r_ear,\ - slot_glasses,\ - slot_belt,\ - slot_s_store,\ - slot_tie,\ - slot_l_store,\ - slot_r_store\ - ) - -//puts the item "W" into an appropriate slot in a human's inventory -//returns 0 if it cannot, 1 if successful -/mob/proc/equip_to_appropriate_slot(obj/item/W) - if(!istype(W)) return 0 - - for(var/slot in slot_equipment_priority) - if(equip_to_slot_if_possible(W, slot, del_on_fail=0, disable_warning=1, redraw_mob=1)) - return 1 - - return 0 - /mob/proc/reset_view(atom/A) if (client) if (istype(A, /atom/movable)) From 1b4e13aabc4bca45ee04681d6e5158e07e9fb243 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Mon, 30 Mar 2015 05:25:43 -0400 Subject: [PATCH 2/6] Removes unnecessary and cruft procs from mob/inventory.dm --- code/_onclick/hud/screen_objects.dm | 15 +- .../gamemodes/revolution/rp-revolution.dm | 4 +- code/game/machinery/kitchen/juicer.dm | 4 +- code/game/machinery/kitchen/microwave.dm | 2 +- code/game/machinery/kitchen/smartfridge.dm | 2 +- code/game/objects/items/robot/robot_parts.dm | 2 +- code/game/objects/items/stacks/stack.dm | 2 +- .../objects/items/weapons/tanks/tank_types.dm | 2 +- code/game/objects/structures/extinguisher.dm | 2 +- code/game/objects/structures/target_stake.dm | 2 +- code/game/turfs/simulated/floor.dm | 2 +- code/modules/admin/verbs/debug.dm | 52 +++--- code/modules/customitems/item_spawning.dm | 8 +- code/modules/hydroponics/biogenerator.dm | 4 +- code/modules/hydroponics/hydro_tray.dm | 4 +- code/modules/hydroponics/seed_machines.dm | 4 +- code/modules/mob/inventory.dm | 176 +----------------- code/modules/mob/living/carbon/human/life.dm | 2 +- code/modules/mob/living/living_defense.dm | 4 +- code/modules/mob/mob_movement.dm | 4 +- code/modules/power/antimatter/computer.dm | 2 +- .../projectiles/guns/projectile/pneumatic.dm | 2 +- code/modules/projectiles/targeting.dm | 2 +- code/modules/reagents/Chemistry-Machinery.dm | 2 +- 24 files changed, 70 insertions(+), 235 deletions(-) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 400bf051ad3..b12602ccb26 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -379,7 +379,8 @@ if(!usr.stat && isturf(usr.loc) && !usr.restrained()) usr:toggle_throw_mode() if("drop") - usr.drop_item_v() + if(usr.client) + usr.client.drop_item() if("module") if(isrobot(usr)) @@ -429,7 +430,7 @@ if("Allow Walking") if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes. return - if(!istype(usr.equipped(),/obj/item/weapon/gun)) + if(!istype(usr.get_active_hand(),/obj/item/weapon/gun)) usr << "You need your gun in your active hand to do that!" return usr.client.AllowTargetMove() @@ -438,7 +439,7 @@ if("Disallow Walking") if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes. return - if(!istype(usr.equipped(),/obj/item/weapon/gun)) + if(!istype(usr.get_active_hand(),/obj/item/weapon/gun)) usr << "You need your gun in your active hand to do that!" return usr.client.AllowTargetMove() @@ -447,7 +448,7 @@ if("Allow Running") if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes. return - if(!istype(usr.equipped(),/obj/item/weapon/gun)) + if(!istype(usr.get_active_hand(),/obj/item/weapon/gun)) usr << "You need your gun in your active hand to do that!" return usr.client.AllowTargetRun() @@ -456,7 +457,7 @@ if("Disallow Running") if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes. return - if(!istype(usr.equipped(),/obj/item/weapon/gun)) + if(!istype(usr.get_active_hand(),/obj/item/weapon/gun)) usr << "You need your gun in your active hand to do that!" return usr.client.AllowTargetRun() @@ -465,7 +466,7 @@ if("Allow Item Use") if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes. return - if(!istype(usr.equipped(),/obj/item/weapon/gun)) + if(!istype(usr.get_active_hand(),/obj/item/weapon/gun)) usr << "You need your gun in your active hand to do that!" return usr.client.AllowTargetClick() @@ -475,7 +476,7 @@ if("Disallow Item Use") if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes. return - if(!istype(usr.equipped(),/obj/item/weapon/gun)) + if(!istype(usr.get_active_hand(),/obj/item/weapon/gun)) usr << "You need your gun in your active hand to do that!" return usr.client.AllowTargetClick() diff --git a/code/game/gamemodes/revolution/rp-revolution.dm b/code/game/gamemodes/revolution/rp-revolution.dm index 815b3be3cb3..242f6b1d529 100644 --- a/code/game/gamemodes/revolution/rp-revolution.dm +++ b/code/game/gamemodes/revolution/rp-revolution.dm @@ -151,9 +151,9 @@ // spawn (100) // if (rev_mob.r_store) -// rev_mob.equip_if_possible(new /obj/item/weapon/paper/communist_manifesto(rev_mob), rev_mob.slot_l_store) +// rev_mob.equip_to_slot_or_del(new /obj/item/weapon/paper/communist_manifesto(rev_mob), rev_mob.slot_l_store) // if (rev_mob.l_store) -// rev_mob.equip_if_possible(new /obj/item/weapon/paper/communist_manifesto(rev_mob), rev_mob.slot_r_store) +// rev_mob.equip_to_slot_or_del(new /obj/item/weapon/paper/communist_manifesto(rev_mob), rev_mob.slot_r_store) /datum/game_mode/rp_revolution/check_win() diff --git a/code/game/machinery/kitchen/juicer.dm b/code/game/machinery/kitchen/juicer.dm index a5a15fb8767..6a116237f33 100644 --- a/code/game/machinery/kitchen/juicer.dm +++ b/code/game/machinery/kitchen/juicer.dm @@ -38,7 +38,7 @@ if (beaker) return 1 else - user.before_take_item(O) + user.remove_from_mob(O) O.loc = src beaker = O src.verbs += /obj/machinery/juicer/verb/detach @@ -48,7 +48,7 @@ if (!is_type_in_list(O, allowed_items)) user << "It looks as not containing any juice." return 1 - user.before_take_item(O) + user.remove_from_mob(O) O.loc = src src.updateUsrDialog() return 0 diff --git a/code/game/machinery/kitchen/microwave.dm b/code/game/machinery/kitchen/microwave.dm index 4af48a539b4..bec0006de95 100644 --- a/code/game/machinery/kitchen/microwave.dm +++ b/code/game/machinery/kitchen/microwave.dm @@ -112,7 +112,7 @@ "\blue [user] has added one of [O] to \the [src].", \ "\blue You add one of [O] to \the [src].") else - // user.before_take_item(O) //This just causes problems so far as I can tell. -Pete + // user.remove_from_mob(O) //This just causes problems so far as I can tell. -Pete user.drop_item() O.loc = src user.visible_message( \ diff --git a/code/game/machinery/kitchen/smartfridge.dm b/code/game/machinery/kitchen/smartfridge.dm index 52ca3debd9b..15f76f191fd 100644 --- a/code/game/machinery/kitchen/smartfridge.dm +++ b/code/game/machinery/kitchen/smartfridge.dm @@ -169,7 +169,7 @@ user << "\The [src] is full." return 1 else - user.before_take_item(O) + user.remove_from_mob(O) O.loc = src if(item_quants[O.name]) item_quants[O.name]++ diff --git a/code/game/objects/items/robot/robot_parts.dm b/code/game/objects/items/robot/robot_parts.dm index 25461eae377..065d7dd969e 100644 --- a/code/game/objects/items/robot/robot_parts.dm +++ b/code/game/objects/items/robot/robot_parts.dm @@ -110,7 +110,7 @@ B.loc = get_turf(src) user << "You armed the robot frame." if (user.get_inactive_hand()==src) - user.before_take_item(src) + user.remove_from_mob(src) user.put_in_inactive_hand(B) del(src) else diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 69b6e97533e..cd133ff8e31 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -177,7 +177,7 @@ spawn(0) //delete the empty stack once the current context yields if (amount <= 0) //check again in case someone transferred stuff to us if(usr) - usr.before_take_item(src) + usr.remove_from_mob(src) del(src) return 1 diff --git a/code/game/objects/items/weapons/tanks/tank_types.dm b/code/game/objects/items/weapons/tanks/tank_types.dm index 02d50e0d267..3f2bbb18265 100644 --- a/code/game/objects/items/weapons/tanks/tank_types.dm +++ b/code/game/objects/items/weapons/tanks/tank_types.dm @@ -103,7 +103,7 @@ if ((!F.status)||(F.ptank)) return src.master = F F.ptank = src - user.before_take_item(src) + user.remove_from_mob(src) src.loc = F return diff --git a/code/game/objects/structures/extinguisher.dm b/code/game/objects/structures/extinguisher.dm index 40ba963efd0..44bf1ace10f 100644 --- a/code/game/objects/structures/extinguisher.dm +++ b/code/game/objects/structures/extinguisher.dm @@ -17,7 +17,7 @@ return if(istype(O, /obj/item/weapon/extinguisher)) if(!has_extinguisher && opened) - user.drop_item(O) + user.remove_from_mob(O) contents += O has_extinguisher = O user << "You place [O] in [src]." diff --git a/code/game/objects/structures/target_stake.dm b/code/game/objects/structures/target_stake.dm index bf80024a5e2..fa45f657369 100644 --- a/code/game/objects/structures/target_stake.dm +++ b/code/game/objects/structures/target_stake.dm @@ -26,7 +26,7 @@ if(istype(W, /obj/item/target)) density = 0 W.density = 1 - user.drop_item(src) + user.remove_from_mob(W) W.loc = loc W.layer = 3.1 pinned_target = W diff --git a/code/game/turfs/simulated/floor.dm b/code/game/turfs/simulated/floor.dm index 62facb8e4de..a74bd90f293 100644 --- a/code/game/turfs/simulated/floor.dm +++ b/code/game/turfs/simulated/floor.dm @@ -456,7 +456,7 @@ turf/simulated/floor/proc/update_icon() if(istype(C,/obj/item/weapon/light/bulb)) //only for light tiles if(is_light_floor()) if(get_lightfloor_state()) - user.drop_item(C) + user.remove_from_mob(C) del(C) set_lightfloor_state(0) //fixing it by bashing it with a light bulb, fun eh? update_icon() diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 71d50c1e8b6..9b3d757691e 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -736,19 +736,19 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that M.equip_syndicate_commando() if("nanotrasen representative") - M.equip_if_possible(new /obj/item/clothing/under/rank/centcom(M), slot_w_uniform) - M.equip_if_possible(new /obj/item/clothing/shoes/laceup(M), slot_shoes) - M.equip_if_possible(new /obj/item/clothing/gloves/white(M), slot_gloves) - M.equip_if_possible(new /obj/item/device/radio/headset/heads/hop(M), slot_l_ear) + M.equip_to_slot_or_del(new /obj/item/clothing/under/rank/centcom(M), slot_w_uniform) + M.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup(M), slot_shoes) + M.equip_to_slot_or_del(new /obj/item/clothing/gloves/white(M), slot_gloves) + M.equip_to_slot_or_del(new /obj/item/device/radio/headset/heads/hop(M), slot_l_ear) var/obj/item/device/pda/heads/pda = new(M) pda.owner = M.real_name pda.ownjob = "NanoTrasen Navy Representative" pda.name = "PDA-[M.real_name] ([pda.ownjob])" - M.equip_if_possible(pda, slot_r_store) - M.equip_if_possible(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store) - M.equip_if_possible(new /obj/item/weapon/clipboard(M), slot_belt) + M.equip_to_slot_or_del(pda, slot_r_store) + M.equip_to_slot_or_del(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store) + M.equip_to_slot_or_del(new /obj/item/weapon/clipboard(M), slot_belt) var/obj/item/weapon/card/id/W = new(M) W.name = "[M.real_name]'s ID Card" @@ -758,23 +758,23 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that W.access += list("VIP Guest","Custodian","Thunderdome Overseer","Intel Officer","Medical Officer","Death Commando","Research Officer") W.assignment = "NanoTrasen Navy Representative" W.registered_name = M.real_name - M.equip_if_possible(W, slot_wear_id) + M.equip_to_slot_or_del(W, slot_wear_id) if("nanotrasen officer") - M.equip_if_possible(new /obj/item/clothing/under/rank/centcom_officer(M), slot_w_uniform) - M.equip_if_possible(new /obj/item/clothing/shoes/laceup(M), slot_shoes) - M.equip_if_possible(new /obj/item/clothing/gloves/white(M), slot_gloves) - M.equip_if_possible(new /obj/item/device/radio/headset/heads/captain(M), slot_l_ear) - M.equip_if_possible(new /obj/item/clothing/head/beret/centcom/officer(M), slot_head) + M.equip_to_slot_or_del(new /obj/item/clothing/under/rank/centcom_officer(M), slot_w_uniform) + M.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup(M), slot_shoes) + M.equip_to_slot_or_del(new /obj/item/clothing/gloves/white(M), slot_gloves) + M.equip_to_slot_or_del(new /obj/item/device/radio/headset/heads/captain(M), slot_l_ear) + M.equip_to_slot_or_del(new /obj/item/clothing/head/beret/centcom/officer(M), slot_head) var/obj/item/device/pda/heads/pda = new(M) pda.owner = M.real_name pda.ownjob = "NanoTrasen Navy Officer" pda.name = "PDA-[M.real_name] ([pda.ownjob])" - M.equip_if_possible(pda, slot_r_store) - M.equip_if_possible(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store) - M.equip_if_possible(new /obj/item/weapon/gun/energy(M), slot_belt) + M.equip_to_slot_or_del(pda, slot_r_store) + M.equip_to_slot_or_del(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store) + M.equip_to_slot_or_del(new /obj/item/weapon/gun/energy(M), slot_belt) var/obj/item/weapon/card/id/centcom/W = new(M) W.name = "[M.real_name]'s ID Card" @@ -782,24 +782,24 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that W.access += get_all_centcom_access() W.assignment = "NanoTrasen Navy Officer" W.registered_name = M.real_name - M.equip_if_possible(W, slot_wear_id) + M.equip_to_slot_or_del(W, slot_wear_id) if("nanotrasen captain") - M.equip_if_possible(new /obj/item/clothing/under/rank/centcom_captain(M), slot_w_uniform) - M.equip_if_possible(new /obj/item/clothing/shoes/laceup(M), slot_shoes) - M.equip_if_possible(new /obj/item/clothing/gloves/white(M), slot_gloves) - M.equip_if_possible(new /obj/item/device/radio/headset/heads/captain(M), slot_l_ear) - M.equip_if_possible(new /obj/item/clothing/head/beret/centcom/captain(M), slot_head) + M.equip_to_slot_or_del(new /obj/item/clothing/under/rank/centcom_captain(M), slot_w_uniform) + M.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup(M), slot_shoes) + M.equip_to_slot_or_del(new /obj/item/clothing/gloves/white(M), slot_gloves) + M.equip_to_slot_or_del(new /obj/item/device/radio/headset/heads/captain(M), slot_l_ear) + M.equip_to_slot_or_del(new /obj/item/clothing/head/beret/centcom/captain(M), slot_head) var/obj/item/device/pda/heads/pda = new(M) pda.owner = M.real_name pda.ownjob = "NanoTrasen Navy Captain" pda.name = "PDA-[M.real_name] ([pda.ownjob])" - M.equip_if_possible(pda, slot_r_store) - M.equip_if_possible(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store) - M.equip_if_possible(new /obj/item/weapon/gun/energy(M), slot_belt) + M.equip_to_slot_or_del(pda, slot_r_store) + M.equip_to_slot_or_del(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store) + M.equip_to_slot_or_del(new /obj/item/weapon/gun/energy(M), slot_belt) var/obj/item/weapon/card/id/centcom/W = new(M) W.name = "[M.real_name]'s ID Card" @@ -807,7 +807,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that W.access += get_all_centcom_access() W.assignment = "NanoTrasen Navy Captain" W.registered_name = M.real_name - M.equip_if_possible(W, slot_wear_id) + M.equip_to_slot_or_del(W, slot_wear_id) if("emergency response team") M.equip_to_slot_or_del(new /obj/item/clothing/under/rank/centcom_officer(M), slot_w_uniform) diff --git a/code/modules/customitems/item_spawning.dm b/code/modules/customitems/item_spawning.dm index 38f50bf742b..8d575538a45 100644 --- a/code/modules/customitems/item_spawning.dm +++ b/code/modules/customitems/item_spawning.dm @@ -60,7 +60,7 @@ //replace old ID del(C) - ok = M.equip_if_possible(I, slot_wear_id, 0) //if 1, last argument deletes on fail + ok = M.equip_to_slot_if_possible(I, slot_wear_id, 0) //if 1, last argument deletes on fail break else if(istype(Item,/obj/item/weapon/storage/belt)) if(M.ckey == "jakksergal" && M.real_name == "Nashi Ra'hal" && M.mind.role_alt_title && M.mind.role_alt_title != "Nurse" && M.mind.role_alt_title != "Chemist") @@ -72,13 +72,13 @@ for(var/obj/item/weapon/storage/belt/B in M) del(B) M.belt=null - ok = M.equip_if_possible(I, slot_belt, 0) + ok = M.equip_to_slot_if_possible(I, slot_belt, 0) break if(istype(M.belt,/obj/item/device/pda)) for(var/obj/item/device/pda/Pda in M) M.belt=null - M.equip_if_possible(Pda, slot_l_store, 0) - ok = M.equip_if_possible(I, slot_belt, 0) + M.equip_to_slot_if_possible(Pda, slot_l_store, 0) + ok = M.equip_to_slot_if_possible(I, slot_belt, 0) else if(istype(M.back,/obj/item/weapon/storage) && M.back:contents.len < M.back:storage_slots) // Try to place it in something on the mob's back Item.loc = M.back ok = 1 diff --git a/code/modules/hydroponics/biogenerator.dm b/code/modules/hydroponics/biogenerator.dm index 263f797a95d..119c49fe41a 100644 --- a/code/modules/hydroponics/biogenerator.dm +++ b/code/modules/hydroponics/biogenerator.dm @@ -36,7 +36,7 @@ if(beaker) user << "\red The biogenerator is already loaded." else - user.before_take_item(O) + user.remove_from_mob(O) O.loc = src beaker = O updateUsrDialog() @@ -68,7 +68,7 @@ if(i >= 10) user << "\red The biogenerator is full! Activate it." else - user.before_take_item(O) + user.remove_from_mob(O) O.loc = src user << "\blue You put [O.name] in [src.name]" update_icon() diff --git a/code/modules/hydroponics/hydro_tray.dm b/code/modules/hydroponics/hydro_tray.dm index eafff17b073..9ef693a94de 100644 --- a/code/modules/hydroponics/hydro_tray.dm +++ b/code/modules/hydroponics/hydro_tray.dm @@ -633,7 +633,7 @@ if(!seed) var/obj/item/seeds/S = O - user.drop_item(O) + user.remove_from_mob(O) if(!S.seed) user << "The packet seems to be empty. You throw it away." @@ -691,7 +691,7 @@ else if ( istype(O, /obj/item/weapon/plantspray) ) var/obj/item/weapon/plantspray/spray = O - user.drop_item(O) + user.remove_from_mob(O) toxins += spray.toxicity pestlevel -= spray.pest_kill_str weedlevel -= spray.weed_kill_str diff --git a/code/modules/hydroponics/seed_machines.dm b/code/modules/hydroponics/seed_machines.dm index 8b4295d72be..1b5034f4170 100644 --- a/code/modules/hydroponics/seed_machines.dm +++ b/code/modules/hydroponics/seed_machines.dm @@ -88,7 +88,7 @@ if(S.seed && S.seed.immutable > 0) user << "That seed is not compatible with our genetics technology." else - user.drop_item(W) + user.remove_from_mob(W) W.loc = src seed = W user << "You load [W] into [src]." @@ -120,7 +120,7 @@ user << "That disk does not have any gene data loaded." return - user.drop_item(W) + user.remove_from_mob(W) W.loc = src loaded_disk = W user << "You load [W] into [src]." diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 303f1665de7..34423228f44 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -143,13 +143,6 @@ var/list/slot_equipment_priority = list( \ W.dropped() return 0 - - -/mob/proc/drop_item_v() //this is dumb. - if(stat == CONSCIOUS && isturf(loc)) - return drop_item() - return 0 - // Removes an item from inventory and places it in the target atom /mob/proc/drop_from_inventory(var/obj/item/W, var/atom/Target = null) if(W) @@ -166,64 +159,17 @@ var/list/slot_equipment_priority = list( \ //Drops the item in our left hand /mob/proc/drop_l_hand(var/atom/Target) - if(l_hand) - if(client) client.screen -= l_hand - l_hand.layer = initial(l_hand.layer) - - if(Target) l_hand.loc = Target.loc - else l_hand.loc = loc - - var/turf/T = get_turf(loc) - if(isturf(T)) - T.Entered(l_hand) - - l_hand.dropped(src) - l_hand = null - update_inv_l_hand() - return 1 - return 0 + return drop_from_inventory(l_hand, Target) //Drops the item in our right hand /mob/proc/drop_r_hand(var/atom/Target) - if(r_hand) - if(client) client.screen -= r_hand - r_hand.layer = initial(r_hand.layer) - - if(Target) r_hand.loc = Target.loc - else r_hand.loc = loc - - var/turf/T = get_turf(Target) - if(istype(T)) - T.Entered(r_hand) - - r_hand.dropped(src) - r_hand = null - update_inv_r_hand() - return 1 - return 0 + return drop_from_inventory(r_hand, Target) //Drops the item in our active hand. /mob/proc/drop_item(var/atom/Target) if(hand) return drop_l_hand(Target) else return drop_r_hand(Target) - - - - - - - - -//TODO: phase out this proc -/mob/proc/before_take_item(var/obj/item/W) //TODO: what is this? - W.loc = null - W.layer = initial(W.layer) - u_equip(W) - update_icons() - return - - //Removes the object from any slots the mob might have, calling the appropriate icon update proc. //Does nothing else. //DO NOT CALL THIS PROC DIRECTLY. It is meant to be called only by other inventory procs. @@ -244,34 +190,18 @@ var/list/slot_equipment_priority = list( \ update_inv_wear_mask(0) return +//This differs from remove_from_mob() in that it checks canremove first. /mob/proc/unEquip(obj/item/I, force = 0) //Force overrides NODROP for things like wizarditis and admin undress. - if(!I) //If there's nothing to drop, the drop is automatically successful. If(unEquip) should generally be used to check for NODROP. + if(!I) //If there's nothing to drop, the drop is automatically successful. return 1 - /*if((I.flags & NODROP) && !force) - return 0*/ - if(!I.canremove && !force) return 0 - if(I == r_hand) - r_hand = null - update_inv_r_hand() - else if(I == l_hand) - l_hand = null - update_inv_l_hand() - - if(I) - if(client) - client.screen -= I - I.loc = loc - I.dropped(src) - if(I) - I.layer = initial(I.layer) + remove_from_mob(I) return 1 //Attemps to remove an object on a mob. Will not move it to another area or such, just removes from the mob. -//It does call u_equip() though. So it can drop items to the floor but only if src is human. /mob/proc/remove_from_mob(var/obj/O) src.u_equip(O) if (src.client) @@ -306,99 +236,3 @@ var/list/slot_equipment_priority = list( \ //if(hasvar(src,"r_hand")) if(src:r_hand) items += src:r_hand return items - -/** BS12's proc to get the item in the active hand. Couldn't find the /tg/ equivalent. **/ -/mob/proc/equipped() - return get_active_hand() //TODO: get rid of this proc - -/mob/living/carbon/human/proc/equip_if_possible(obj/item/W, slot, del_on_fail = 1) // since byond doesn't seem to have pointers, this seems like the best way to do this :/ - //warning: icky code - var/equipped = 0 - switch(slot) - if(slot_back) - if(!src.back) - src.back = W - equipped = 1 - if(slot_wear_mask) - if(!src.wear_mask) - src.wear_mask = W - equipped = 1 - if(slot_handcuffed) - if(!src.handcuffed) - src.handcuffed = W - equipped = 1 - if(slot_l_hand) - if(!src.l_hand) - src.l_hand = W - equipped = 1 - if(slot_r_hand) - if(!src.r_hand) - src.r_hand = W - equipped = 1 - if(slot_belt) - if(!src.belt && src.w_uniform) - src.belt = W - equipped = 1 - if(slot_wear_id) - if(!src.wear_id && src.w_uniform) - src.wear_id = W - equipped = 1 - if(slot_l_ear) - if(!src.l_ear) - src.l_ear = W - equipped = 1 - if(slot_r_ear) - if(!src.r_ear) - src.r_ear = W - equipped = 1 - if(slot_glasses) - if(!src.glasses) - src.glasses = W - equipped = 1 - if(slot_gloves) - if(!src.gloves) - src.gloves = W - equipped = 1 - if(slot_head) - if(!src.head) - src.head = W - equipped = 1 - if(slot_shoes) - if(!src.shoes) - src.shoes = W - equipped = 1 - if(slot_wear_suit) - if(!src.wear_suit) - src.wear_suit = W - equipped = 1 - if(slot_w_uniform) - if(!src.w_uniform) - src.w_uniform = W - equipped = 1 - if(slot_l_store) - if(!src.l_store && src.w_uniform) - src.l_store = W - equipped = 1 - if(slot_r_store) - if(!src.r_store && src.w_uniform) - src.r_store = W - equipped = 1 - if(slot_s_store) - if(!src.s_store && src.wear_suit) - src.s_store = W - equipped = 1 - if(slot_in_backpack) - if (src.back && istype(src.back, /obj/item/weapon/storage/backpack)) - var/obj/item/weapon/storage/backpack/B = src.back - if(B.contents.len < B.storage_slots && W.w_class <= B.max_w_class) - W.loc = B - equipped = 1 - - if(equipped) - W.layer = 20 - if(src.back && W.loc != src.back) - W.loc = src - else - if (del_on_fail) - del(W) - return equipped diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 8aa3ad82008..4c265d520ee 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -235,7 +235,7 @@ src << "\red It becomes hard to see for some reason." eye_blurry = 10 if(getBrainLoss() >= 35) - if(7 <= rn && rn <= 9) if(hand && equipped()) + if(7 <= rn && rn <= 9) if(get_active_hand()) src << "\red Your hand won't respond properly, you drop what you're holding." drop_item() if(getBrainLoss() >= 50) diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 4ac03cdf5f2..e830657c83c 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -49,8 +49,8 @@ Stun(2) //Being hit while using a deadman switch - if(istype(equipped(),/obj/item/device/assembly/signaler)) - var/obj/item/device/assembly/signaler/signaler = equipped() + if(istype(get_active_hand(),/obj/item/device/assembly/signaler)) + var/obj/item/device/assembly/signaler/signaler = get_active_hand() if(signaler.deadman && prob(80)) src.visible_message("\red [src] triggers their deadman's switch!") signaler.signal() diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 84f74cacae0..6dd04d3ca5d 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -96,8 +96,8 @@ /client/verb/drop_item() set hidden = 1 - if(!isrobot(mob)) - mob.drop_item_v() + if(!isrobot(mob) && mob.stat == CONSCIOUS && isturf(mob.loc)) + return mob.drop_item() return diff --git a/code/modules/power/antimatter/computer.dm b/code/modules/power/antimatter/computer.dm index 3a47ec7abf2..d531ccfb540 100644 --- a/code/modules/power/antimatter/computer.dm +++ b/code/modules/power/antimatter/computer.dm @@ -45,7 +45,7 @@ src.state = STATE_DEFAULT if("login") var/mob/M = usr - var/obj/item/weapon/card/id/I = M.equipped() + var/obj/item/weapon/card/id/I = M.get_active_hand() if (I && istype(I)) if(src.check_access(I)) authenticated = 1 diff --git a/code/modules/projectiles/guns/projectile/pneumatic.dm b/code/modules/projectiles/guns/projectile/pneumatic.dm index 43a5bc8e9ad..a9cdea466c1 100644 --- a/code/modules/projectiles/guns/projectile/pneumatic.dm +++ b/code/modules/projectiles/guns/projectile/pneumatic.dm @@ -67,7 +67,7 @@ for(var/obj/item/O in src.contents) total_stored += O.w_class if(total_stored + W.w_class <= max_combined_w_class) - user.drop_item(W) + user.remove_from_mob(W) W.loc = src user << "You shove [W] into the hopper." else diff --git a/code/modules/projectiles/targeting.dm b/code/modules/projectiles/targeting.dm index 496455f24e4..59c5c028027 100644 --- a/code/modules/projectiles/targeting.dm +++ b/code/modules/projectiles/targeting.dm @@ -80,7 +80,7 @@ var/mob/living/M = loc if(M == T) return if(!istype(M)) return - if(src != M.equipped()) + if(src != M.get_active_hand()) stop_aim() return diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index 7f754e56b37..afe1eb3ef7c 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -925,7 +925,7 @@ user << "Cannot refine into a reagent." return 1 - user.before_take_item(O) + user.remove_from_mob(O) O.loc = src holdingitems += O src.updateUsrDialog() From cdfce64ad065330d2b930d1f5e24845472ab3892 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Mon, 30 Mar 2015 22:05:00 -0400 Subject: [PATCH 3/6] Replaces uses of u_equip() with remove_from_mob() or drop_from_inventory(), where appropriate. --- .../gamemodes/changeling/changeling_powers.dm | 8 +--- code/game/gamemodes/cult/runes.dm | 2 +- code/game/machinery/bots/farmbot.dm | 10 ++--- .../machinery/computer/HolodeckControl.dm | 2 +- .../computer3/computers/HolodeckControl.dm | 2 +- code/game/objects/items/ashtray.dm | 2 +- .../objects/items/weapons/cigs_lighters.dm | 2 +- .../objects/items/weapons/gift_wrappaper.dm | 2 +- .../items/weapons/implants/implanter.dm | 2 +- .../objects/items/weapons/storage/bags.dm | 2 +- .../objects/items/weapons/storage/storage.dm | 2 +- code/game/objects/items/weapons/tools.dm | 6 +-- .../structures/stool_bed_chair_nest/stools.dm | 4 +- code/modules/admin/topic.dm | 32 +++------------ code/modules/destilery/main.dm | 8 ++-- code/modules/mining/satchel_ore_boxdm.dm | 2 +- code/modules/mob/inventory.dm | 1 + code/modules/mob/living/carbon/carbon.dm | 13 ++---- .../mob/living/carbon/human/human_defense.dm | 2 +- .../mob/living/carbon/monkey/inventory.dm | 40 +++---------------- code/modules/organs/organ_external.dm | 4 +- code/modules/power/antimatter/control.dm | 4 +- .../reagent_containers/food/snacks.dm | 4 +- .../reagents/reagent_containers/syringes.dm | 2 +- 24 files changed, 45 insertions(+), 113 deletions(-) diff --git a/code/game/gamemodes/changeling/changeling_powers.dm b/code/game/gamemodes/changeling/changeling_powers.dm index 8d15141df1e..2d7ef7c020c 100644 --- a/code/game/gamemodes/changeling/changeling_powers.dm +++ b/code/game/gamemodes/changeling/changeling_powers.dm @@ -388,13 +388,7 @@ del(animation) for(var/obj/item/W in src) - C.u_equip(W) - if (C.client) - C.client.screen -= W - if (W) - W.loc = C.loc - W.dropped(C) - W.layer = initial(W.layer) + C.drop_from_inventory(W) var/mob/living/carbon/human/O = new /mob/living/carbon/human( src ) if (C.dna.GetUIState(DNA_UI_GENDER)) diff --git a/code/game/gamemodes/cult/runes.dm b/code/game/gamemodes/cult/runes.dm index 88e16dbe46b..2c2ca5b21b0 100644 --- a/code/game/gamemodes/cult/runes.dm +++ b/code/game/gamemodes/cult/runes.dm @@ -798,7 +798,7 @@ var/list/sacrificed = list() if (cultist.legcuffed) cultist.drop_from_inventory(cultist.legcuffed) if (istype(cultist.wear_mask, /obj/item/clothing/mask/muzzle)) - cultist.u_equip(cultist.wear_mask) + cultist.drop_from_inventory(cultist.wear_mask) if(istype(cultist.loc, /obj/structure/closet)&&cultist.loc:welded) cultist.loc:welded = 0 if(istype(cultist.loc, /obj/structure/closet/secure_closet)&&cultist.loc:locked) diff --git a/code/game/machinery/bots/farmbot.dm b/code/game/machinery/bots/farmbot.dm index 4db416e7a60..812d8bb3343 100644 --- a/code/game/machinery/bots/farmbot.dm +++ b/code/game/machinery/bots/farmbot.dm @@ -542,7 +542,7 @@ A.loc = src.loc user << "You add the robot arm to the [src]" src.loc = A //Place the water tank into the assembly, it will be needed for the finished bot - user.u_equip(S) + user.remove_from_mob(S) del(S) /obj/item/weapon/farmbot_arm_assembly/attackby(obj/item/weapon/W as obj, mob/user as mob) @@ -551,21 +551,21 @@ src.build_step++ user << "You add the plant analyzer to [src]!" src.name = "farmbot assembly" - user.u_equip(W) + user.remove_from_mob(W) del(W) else if(( istype(W, /obj/item/weapon/reagent_containers/glass/bucket)) && (src.build_step == 1)) src.build_step++ user << "You add a bucket to [src]!" src.name = "farmbot assembly with bucket" - user.u_equip(W) + user.remove_from_mob(W) del(W) else if(( istype(W, /obj/item/weapon/minihoe)) && (src.build_step == 2)) src.build_step++ user << "You add a minihoe to [src]!" src.name = "farmbot assembly with bucket and minihoe" - user.u_equip(W) + user.remove_from_mob(W) del(W) else if((isprox(W)) && (src.build_step == 3)) @@ -577,7 +577,7 @@ S.tank = wTank S.loc = get_turf(src) S.name = src.created_name - user.u_equip(W) + user.remove_from_mob(W) del(W) del(src) diff --git a/code/game/machinery/computer/HolodeckControl.dm b/code/game/machinery/computer/HolodeckControl.dm index e6075cb5a97..40a403a35f7 100644 --- a/code/game/machinery/computer/HolodeckControl.dm +++ b/code/game/machinery/computer/HolodeckControl.dm @@ -233,7 +233,7 @@ var/global/list/holodeck_programs = list( if(isobj(obj)) var/mob/M = obj.loc if(ismob(M)) - M.u_equip(obj) + M.remove_from_mob(obj) M.update_icons() //so their overlays update if(!silent) diff --git a/code/game/machinery/computer3/computers/HolodeckControl.dm b/code/game/machinery/computer3/computers/HolodeckControl.dm index e650185f855..80d60afd072 100644 --- a/code/game/machinery/computer3/computers/HolodeckControl.dm +++ b/code/game/machinery/computer3/computers/HolodeckControl.dm @@ -154,7 +154,7 @@ if(isobj(obj)) var/mob/M = obj.loc if(ismob(M)) - M.u_equip(obj) + M.remove_from_mob(obj) M.update_icons() //so their overlays update if(!silent) diff --git a/code/game/objects/items/ashtray.dm b/code/game/objects/items/ashtray.dm index 1e48c494999..b2417f8af3d 100644 --- a/code/game/objects/items/ashtray.dm +++ b/code/game/objects/items/ashtray.dm @@ -21,7 +21,7 @@ if (contents.len >= max_butts) user << "This ashtray is full." return - user.u_equip(W) + user.remove_from_mob(W) W.loc = src if (istype(W,/obj/item/clothing/mask/cigarette)) diff --git a/code/game/objects/items/weapons/cigs_lighters.dm b/code/game/objects/items/weapons/cigs_lighters.dm index 21c65905e47..da5ddfedbeb 100644 --- a/code/game/objects/items/weapons/cigs_lighters.dm +++ b/code/game/objects/items/weapons/cigs_lighters.dm @@ -198,7 +198,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM if(ismob(loc)) var/mob/living/M = loc M << "Your [name] goes out." - M.u_equip(src) //un-equip it so the overlays can update + M.remove_from_mob(src) //un-equip it so the overlays can update M.update_inv_wear_mask(0) processing_objects.Remove(src) del(src) diff --git a/code/game/objects/items/weapons/gift_wrappaper.dm b/code/game/objects/items/weapons/gift_wrappaper.dm index e96d0367217..b88832729e1 100644 --- a/code/game/objects/items/weapons/gift_wrappaper.dm +++ b/code/game/objects/items/weapons/gift_wrappaper.dm @@ -109,7 +109,7 @@ if(!ispath(gift_type,/obj/item)) return var/obj/item/I = new gift_type(M) - M.u_equip(src) + M.remove_from_mob(src) M.put_in_hands(I) I.add_fingerprint(M) del(src) diff --git a/code/game/objects/items/weapons/implants/implanter.dm b/code/game/objects/items/weapons/implants/implanter.dm index 19cb00b999d..e2f0382d013 100644 --- a/code/game/objects/items/weapons/implants/implanter.dm +++ b/code/game/objects/items/weapons/implants/implanter.dm @@ -123,7 +123,7 @@ c.scanned = A if(istype(A.loc,/mob/living/carbon/human)) var/mob/living/carbon/human/H = A.loc - H.u_equip(A) + H.remove_from_mob(A) else if(istype(A.loc,/obj/item/weapon/storage)) var/obj/item/weapon/storage/S = A.loc S.remove_from_storage(A) diff --git a/code/game/objects/items/weapons/storage/bags.dm b/code/game/objects/items/weapons/storage/bags.dm index 88db6abd3eb..f6c49b0fe62 100644 --- a/code/game/objects/items/weapons/storage/bags.dm +++ b/code/game/objects/items/weapons/storage/bags.dm @@ -156,7 +156,7 @@ break if(!inserted || !S.amount) - usr.u_equip(S) + usr.remove_from_mob(S) usr.update_icons() //update our overlays if (usr.client && usr.s_active != src) usr.client.screen -= S diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index 2e1d4d2a4cf..c32dedbefae 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -256,7 +256,7 @@ /obj/item/weapon/storage/proc/handle_item_insertion(obj/item/W as obj, prevent_warning = 0) if(!istype(W)) return 0 if(usr) - usr.u_equip(W) + usr.remove_from_mob(W) usr.update_icons() //update our overlays W.loc = src W.on_enter_storage(src) diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index 14f9ad482a5..f8618a89df0 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -188,12 +188,12 @@ if (user.client) user.client.screen -= src if (user.r_hand == src) - user.u_equip(src) + user.remove_from_mob(src) else - user.u_equip(src) + user.remove_from_mob(src) src.master = F src.layer = initial(src.layer) - user.u_equip(src) + user.remove_from_mob(src) if (user.client) user.client.screen -= src src.loc = F diff --git a/code/game/objects/structures/stool_bed_chair_nest/stools.dm b/code/game/objects/structures/stool_bed_chair_nest/stools.dm index 027d382795d..d898c82961f 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/stools.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/stools.dm @@ -61,7 +61,7 @@ origin.loc = get_turf(src) if(user) - user.u_equip(src) + user.remove_from_mob(src) user.visible_message("\blue [user] puts [src] down.", "\blue You put [src] down.") del src @@ -78,7 +78,7 @@ /obj/item/weapon/stool/attack(mob/M as mob, mob/user as mob) if (prob(5) && istype(M,/mob/living)) user.visible_message("\red [user] breaks [src] over [M]'s back!") - user.u_equip(src) + user.remove_from_mob(src) var/obj/item/stack/sheet/metal/m = new/obj/item/stack/sheet/metal m.loc = get_turf(src) del src diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 1d5e0f7b05b..a5c866b7eef 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1054,11 +1054,7 @@ //strip their stuff and stick it in the crate for(var/obj/item/I in M) - M.u_equip(I) - if(I) - I.loc = locker - I.layer = initial(I.layer) - I.dropped(M) + M.drop_from_inventory(I, locker) M.update_icons() //so they black out before warping @@ -1091,11 +1087,7 @@ return for(var/obj/item/I in M) - M.u_equip(I) - if(I) - I.loc = M.loc - I.layer = initial(I.layer) - I.dropped(M) + M.drop_from_inventory(I) M.Paralyse(5) sleep(5) @@ -1120,11 +1112,7 @@ return for(var/obj/item/I in M) - M.u_equip(I) - if(I) - I.loc = M.loc - I.layer = initial(I.layer) - I.dropped(M) + M.drop_from_inventory(I) M.Paralyse(5) sleep(5) @@ -1171,11 +1159,7 @@ return for(var/obj/item/I in M) - M.u_equip(I) - if(I) - I.loc = M.loc - I.layer = initial(I.layer) - I.dropped(M) + M.drop_from_inventory(I) if(istype(M, /mob/living/carbon/human)) var/mob/living/carbon/human/observer = M @@ -1961,13 +1945,7 @@ if(istype(W, /datum/organ/external)) continue //don't strip organs - H.u_equip(W) - if (H.client) - H.client.screen -= W - if (W) - W.loc = H.loc - W.dropped(H) - W.layer = initial(W.layer) + H.drop_from_inventory(W) //teleport person to cell H.loc = pick(prisonwarp) H.equip_to_slot_or_del(new /obj/item/clothing/under/color/orange(H), slot_w_uniform) diff --git a/code/modules/destilery/main.dm b/code/modules/destilery/main.dm index e6944724aaf..ccceda58332 100644 --- a/code/modules/destilery/main.dm +++ b/code/modules/destilery/main.dm @@ -58,7 +58,7 @@ /obj/machinery/mill/attackby(var/obj/item/weapon/W as obj, mob/user as mob) if(istype(W,/obj/item/weapon/reagent_containers/food)) - user.u_equip(W) + user.remove_from_mob(W) W.loc = src input += W else @@ -128,7 +128,7 @@ /obj/machinery/fermenter/attackby(var/obj/item/weapon/W as obj, mob/user as mob) if(istype(W,/obj/item/weapon/reagent_containers/food)) - user.u_equip(W) + user.remove_from_mob(W) W.loc = src input += W else @@ -189,7 +189,7 @@ /obj/machinery/still/attackby(var/obj/item/weapon/W as obj, mob/user as mob) if(istype(W,/obj/item/weapon/reagent_containers/food)) - user.u_equip(W) + user.remove_from_mob(W) W.loc = src input += W else @@ -274,7 +274,7 @@ /obj/machinery/centrifuge/attackby(var/obj/item/weapon/W as obj, mob/user as mob) if(istype(W,/obj/item/weapon/reagent_containers/food)) - user.u_equip(W) + user.remove_from_mob(W) W.loc = src input += W else diff --git a/code/modules/mining/satchel_ore_boxdm.dm b/code/modules/mining/satchel_ore_boxdm.dm index eb596309156..5428f3f6c0a 100644 --- a/code/modules/mining/satchel_ore_boxdm.dm +++ b/code/modules/mining/satchel_ore_boxdm.dm @@ -12,7 +12,7 @@ /obj/structure/ore_box/attackby(obj/item/weapon/W as obj, mob/user as mob) if (istype(W, /obj/item/weapon/ore)) - user.u_equip(W) + user.remove_from_mob(W) src.contents += W if (istype(W, /obj/item/weapon/storage)) var/obj/item/weapon/storage/S = W diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 34423228f44..55204634e80 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -173,6 +173,7 @@ var/list/slot_equipment_priority = list( \ //Removes the object from any slots the mob might have, calling the appropriate icon update proc. //Does nothing else. //DO NOT CALL THIS PROC DIRECTLY. It is meant to be called only by other inventory procs. +//The only exception to this is if you are transferring the item between slots on the same mob. //As far as I can tell the proc exists so that mobs with different inventory slots can override //the search through all the slots, without having to duplicate the rest of the item dropping. /mob/proc/u_equip(obj/W as obj) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index b1170468d87..7db6a2fe29b 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -301,16 +301,9 @@ if(!item) return //Grab processing has a chance of returning null - item.layer = initial(item.layer) - u_equip(item) - update_icons() - - if (istype(usr, /mob/living/carbon)) //Check if a carbon mob is throwing. Modify/remove this line as required. - item.loc = src.loc - if(src.client) - src.client.screen -= item - if(istype(item, /obj/item)) - item:dropped(src) // let it know it's been dropped + + src.remove_from_mob(item) + item.loc = src.loc //actually throw it! if (item) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index de42bb0bfcb..ebe84fa6d15 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -73,7 +73,7 @@ emp_act if(c_hand && (stun_amount || agony_amount > 10)) msg_admin_attack("[src.name] ([src.ckey]) was disarmed by a stun effect") - u_equip(c_hand) + drop_from_inventory(c_hand) if (affected.status & ORGAN_ROBOT) emote("me", 1, "drops what they were holding, their [affected.display_name] malfunctioning!") else diff --git a/code/modules/mob/living/carbon/monkey/inventory.dm b/code/modules/mob/living/carbon/monkey/inventory.dm index adeb4f903a8..623b9a9d776 100644 --- a/code/modules/mob/living/carbon/monkey/inventory.dm +++ b/code/modules/mob/living/carbon/monkey/inventory.dm @@ -81,13 +81,7 @@ if(istype(target.wear_mask, /obj/item/clothing)&& !target.wear_mask:canremove) return var/obj/item/W = target.wear_mask - target.u_equip(W) - if (target.client) - target.client.screen -= W - if (W) - W.loc = target.loc - W.dropped(target) - W.layer = initial(W.layer) + target.drop_from_inventory(W) W.add_fingerprint(source) else if (istype(item, /obj/item/clothing/mask)) @@ -99,13 +93,7 @@ if("l_hand") if (target.l_hand) var/obj/item/W = target.l_hand - target.u_equip(W) - if (target.client) - target.client.screen -= W - if (W) - W.loc = target.loc - W.layer = initial(W.layer) - W.dropped(target) + target.drop_from_inventory(W) W.add_fingerprint(source) else if (istype(item, /obj/item)) @@ -119,13 +107,7 @@ if("r_hand") if (target.r_hand) var/obj/item/W = target.r_hand - target.u_equip(W) - if (target.client) - target.client.screen -= W - if (W) - W.loc = target.loc - W.layer = initial(W.layer) - W.dropped(target) + target.drop_from_inventory(W) W.add_fingerprint(source) else if (istype(item, /obj/item)) @@ -139,13 +121,7 @@ if("back") if (target.back) var/obj/item/W = target.back - target.u_equip(W) - if (target.client) - target.client.screen -= W - if (W) - W.loc = target.loc - W.dropped(target) - W.layer = initial(W.layer) + target.target.drop_from_inventory(W) W.add_fingerprint(source) else if ((istype(item, /obj/item) && item.slot_flags & SLOT_BACK )) @@ -157,13 +133,7 @@ if("handcuff") if (target.handcuffed) var/obj/item/W = target.handcuffed - target.u_equip(W) - if (target.client) - target.client.screen -= W - if (W) - W.loc = target.loc - W.dropped(target) - W.layer = initial(W.layer) + target.target.drop_from_inventory(W) W.add_fingerprint(source) else if (istype(item, /obj/item/weapon/handcuffs)) diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index a49ff2c408c..e4506d8566b 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -828,11 +828,11 @@ Note that amputating the affected organ does in fact remove the infection from t return if(is_broken()) - owner.u_equip(c_hand) + owner.drop_from_inventory(c_hand) var/emote_scream = pick("screams in pain and ", "lets out a sharp cry and ", "cries out and ") owner.emote("me", 1, "[(owner.species && owner.species.flags & NO_PAIN) ? "" : emote_scream ]drops what they were holding in their [hand_name]!") if(is_malfunctioning()) - owner.u_equip(c_hand) + owner.drop_from_inventory(c_hand) owner.emote("me", 1, "drops what they were holding, their [hand_name] malfunctioning!") var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread() spark_system.set_up(5, 0, owner) diff --git a/code/modules/power/antimatter/control.dm b/code/modules/power/antimatter/control.dm index b6eb7915d24..1e99ad873a6 100644 --- a/code/modules/power/antimatter/control.dm +++ b/code/modules/power/antimatter/control.dm @@ -171,10 +171,8 @@ user << "\red There is already a [fueljar] inside!" return fueljar = W + user.remove_from_mob(W) W.loc = src - if(user.client) - user.client.screen -= W - user.u_equip(W) user.update_icons() user.visible_message("[user.name] loads an [W.name] into the [src.name].", \ "You load an [W.name].", \ diff --git a/code/modules/reagents/reagent_containers/food/snacks.dm b/code/modules/reagents/reagent_containers/food/snacks.dm index 7aaad7a6785..0ce1f1ee21b 100644 --- a/code/modules/reagents/reagent_containers/food/snacks.dm +++ b/code/modules/reagents/reagent_containers/food/snacks.dm @@ -165,9 +165,7 @@ return user << "\red You slip [W] inside [src]." - user.u_equip(W) - if ((user.client && user.s_active != src)) - user.client.screen -= W + user.remove_from_mob(W) W.dropped(user) add_fingerprint(user) contents += W diff --git a/code/modules/reagents/reagent_containers/syringes.dm b/code/modules/reagents/reagent_containers/syringes.dm index 744e212e78e..ccbbce738b6 100644 --- a/code/modules/reagents/reagent_containers/syringes.dm +++ b/code/modules/reagents/reagent_containers/syringes.dm @@ -250,7 +250,7 @@ if (target != user && target.getarmor(target_zone, "melee") > 5 && prob(50)) for(var/mob/O in viewers(world.view, user)) O.show_message(text("\red [user] tries to stab [target] in \the [hit_area] with [src.name], but the attack is deflected by armor!"), 1) - user.u_equip(src) + user.remove_from_mob(src) del(src) return From ab9886ce4789c25101f923f70c59583067e55c5f Mon Sep 17 00:00:00 2001 From: mwerezak Date: Mon, 30 Mar 2015 22:29:15 -0400 Subject: [PATCH 4/6] Updates comment --- code/modules/mob/inventory.dm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 55204634e80..97acaf86de9 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -170,12 +170,17 @@ var/list/slot_equipment_priority = list( \ if(hand) return drop_l_hand(Target) else return drop_r_hand(Target) -//Removes the object from any slots the mob might have, calling the appropriate icon update proc. -//Does nothing else. -//DO NOT CALL THIS PROC DIRECTLY. It is meant to be called only by other inventory procs. -//The only exception to this is if you are transferring the item between slots on the same mob. -//As far as I can tell the proc exists so that mobs with different inventory slots can override -//the search through all the slots, without having to duplicate the rest of the item dropping. +/* + Removes the object from any slots the mob might have, calling the appropriate icon update proc. + Does nothing else. + + DO NOT CALL THIS PROC DIRECTLY. It is meant to be called only by other inventory procs. + It's probably okay to use it if you are transferring the item between slots on the same mob, + but chances are you're safer calling remove_from_mob() or drop_from_inventory() anyways. + + As far as I can tell the proc exists so that mobs with different inventory slots can override + the search through all the slots, without having to duplicate the rest of the item dropping. +*/ /mob/proc/u_equip(obj/W as obj) if (W == r_hand) r_hand = null From 582ebcfc597d2bdfd41c03197e3dfe0a8bb852ad Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 31 Mar 2015 00:43:07 -0400 Subject: [PATCH 5/6] Typo fix --- code/modules/mob/living/carbon/monkey/inventory.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/carbon/monkey/inventory.dm b/code/modules/mob/living/carbon/monkey/inventory.dm index 623b9a9d776..81c2c699a79 100644 --- a/code/modules/mob/living/carbon/monkey/inventory.dm +++ b/code/modules/mob/living/carbon/monkey/inventory.dm @@ -121,7 +121,7 @@ if("back") if (target.back) var/obj/item/W = target.back - target.target.drop_from_inventory(W) + target.drop_from_inventory(W) W.add_fingerprint(source) else if ((istype(item, /obj/item) && item.slot_flags & SLOT_BACK )) @@ -133,7 +133,7 @@ if("handcuff") if (target.handcuffed) var/obj/item/W = target.handcuffed - target.target.drop_from_inventory(W) + target.drop_from_inventory(W) W.add_fingerprint(source) else if (istype(item, /obj/item/weapon/handcuffs)) From 5484a30a13c4c7e2d3e77288871558a1935d5b34 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 31 Mar 2015 01:40:15 -0400 Subject: [PATCH 6/6] Allows gloves/shoes to be worn even if one hand or foot is missing. Having a hand or foot removed still drops the worn items, so it still can be used to steal someones gloves/shoes. The difference is that you can now pick up the dropped item and wear it again if you still have the other hand/foot left. --- code/modules/mob/living/carbon/human/inventory.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index d35162c2fe5..6724a2ebe21 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -69,11 +69,11 @@ This saves us from having to call add_fingerprint() any time something is put in if(slot_glasses) return has_organ("head") if(slot_gloves) - return has_organ("l_hand") && has_organ("r_hand") + return has_organ("l_hand") || has_organ("r_hand") if(slot_head) return has_organ("head") if(slot_shoes) - return has_organ("r_foot") && has_organ("l_foot") + return has_organ("r_foot") || has_organ("l_foot") if(slot_wear_suit) return has_organ("chest") if(slot_w_uniform)