From 075f89fcb00ef8ec217c252f8bd7173113aa09c7 Mon Sep 17 00:00:00 2001 From: Krausus Date: Mon, 8 Jun 2015 06:37:52 -0400 Subject: [PATCH] Fixes stacks acting strange for cyborgs Robot modules weren't handling qdel'd stacks properly, so now they simply don't get qdel'd. They shouldn't get deleted often enough for this to hurt performance. Also, the module slot of a stack will now be deselected when it's used up, and it will show up immediately when respawned while recharging. --- code/game/objects/items/stacks/stack.dm | 9 +++++---- code/modules/mob/living/silicon/robot/inventory.dm | 5 +++++ code/modules/mob/living/silicon/robot/robot_modules.dm | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index f7e53bde3ab..3db6ae018f8 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -142,11 +142,11 @@ new_item.amount = R.res_amount*multiplier //new_item.add_to_stacks(usr) src.amount-=R.req_amount*multiplier - if (src.amount<=0) + if (src.amount < 1) // Just in case a stack's amount ends up fractional somehow var/oldsrc = src src = null //dont kill proc after del() usr.unEquip(oldsrc, 1) - del(oldsrc) + del(oldsrc) // Not qdel, because qdel'd stacks act strange for cyborgs if (istype(O,/obj/item)) usr.put_in_hands(O) O.add_fingerprint(usr) @@ -165,10 +165,11 @@ if (amount < used) return 0 amount -= used - if (amount <= 0) + if (amount < 1) // Just in case a stack's amount ends up fractional somehow if(usr) usr.unEquip(src, 1) - qdel(src) + spawn() + del(src) // Not qdel, because qdel'd stacks act strange for cyborgs update_icon() return 1 diff --git a/code/modules/mob/living/silicon/robot/inventory.dm b/code/modules/mob/living/silicon/robot/inventory.dm index eadef1b98c1..47f515401dc 100644 --- a/code/modules/mob/living/silicon/robot/inventory.dm +++ b/code/modules/mob/living/silicon/robot/inventory.dm @@ -220,3 +220,8 @@ while(slot_start != slot_num) //If we wrap around without finding any free slots, just give up. return + +/mob/living/silicon/robot/unEquip(obj/item/I) + if(I == module_active) + deselect_module(get_selected_module()) + return ..() diff --git a/code/modules/mob/living/silicon/robot/robot_modules.dm b/code/modules/mob/living/silicon/robot/robot_modules.dm index 774e90e55d9..4dd8b65610e 100644 --- a/code/modules/mob/living/silicon/robot/robot_modules.dm +++ b/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -37,6 +37,7 @@ if(!stacktypes || !stacktypes.len) return + var/stack_respawned = 0 for(var/T in stacktypes) var/O = locate(T) in src.modules var/obj/item/stack/S = O @@ -46,9 +47,12 @@ S = new T(src) src.modules += S S.amount = 1 + stack_respawned = 1 if(S && S.amount < stacktypes[T]) S.amount++ + if(stack_respawned && istype(R) && R.hud_used) + R.hud_used.update_robot_modules_display() /obj/item/weapon/robot_module/proc/rebuild()//Rebuilds the list so it's possible to add/remove items from the module var/list/temp_list = modules