diff --git a/code/__HELPERS/logging.dm b/code/__HELPERS/logging.dm index 06506c9b8d91..b17d6b782c4f 100644 --- a/code/__HELPERS/logging.dm +++ b/code/__HELPERS/logging.dm @@ -9,6 +9,10 @@ /proc/error(msg) world.log << "## ERROR: [msg][log_end]" +//gives us the stack trace from CRASH() without ending the current proc. +/proc/stack_trace(msg) + CRASH(msg) + //print a warning message to world.log #define WARNING(MSG) warning("[MSG] in [__FILE__] at line [__LINE__] src: [UNLINT(src)] usr: [usr].") /proc/warning(msg) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 3b29d9f6fb6b..44857c464f78 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1520,10 +1520,6 @@ var/global/list/WALLITEMS = typecacheof(list( return L -//gives us the stack trace from CRASH() without ending the current proc. -/proc/stack_trace(msg) - CRASH(msg) - //Increases delay as the server gets more overloaded, //as sleeps aren't cheap and sleeping only to wake up and sleep again is wasteful #define DELTA_CALC max(((max(TICK_USAGE, world.cpu) / 100) * max(Master.sleep_delta - 1, 1)), 1) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 9a04c11b770e..a910fd21cb55 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -109,7 +109,7 @@ armor = list() atom_integrity = max_integrity - if(!isturf(loc)) + if(istype(loc, /obj/item/weapon/storage)) // todo: need to catch all spawns in /storage/ objects and make them use handle_item_insertion or forceMove, so we can remove this flags_2 |= IN_STORAGE if(item_state_world) @@ -368,12 +368,14 @@ // called when this item is removed from a storage item, which is passed on as S. The loc variable is already set to the new destination before this is called. /obj/item/proc/on_exit_storage(obj/item/weapon/storage/S) + SHOULD_CALL_PARENT(TRUE) flags_2 &= ~IN_STORAGE update_world_icon() return // called when this item is added into a storage item, which is passed on as S. The loc variable is already set to the storage item. /obj/item/proc/on_enter_storage(obj/item/weapon/storage/S) + SHOULD_CALL_PARENT(TRUE) flags_2 |= IN_STORAGE update_world_icon() return diff --git a/code/game/objects/items/weapons/shields.dm b/code/game/objects/items/weapons/shields.dm index 95eb57a95ff1..f2bdbcfec469 100644 --- a/code/game/objects/items/weapons/shields.dm +++ b/code/game/objects/items/weapons/shields.dm @@ -228,6 +228,7 @@ turn_off() /obj/item/weapon/shield/energy/on_enter_storage(obj/item/weapon/storage/S) + ..() if(active) attack_self(usr) diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index aa908370ab98..3177922c720d 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -46,17 +46,11 @@ if(startswith) for(var/item_path in startswith) - var/list/data = startswith[item_path] - if(islist(data)) - var/qty = data[1] - var/list/argsl = data.Copy() - argsl[1] = src - for(var/i in 1 to qty) - new item_path(arglist(argsl)) - else - for(var/i in 1 to (isnull(data)? 1 : data)) - new item_path(src) - update_icon() + var/quantity = startswith[item_path] || 1 + for(var/num in 1 to quantity) + new item_path(src) + + update_icon() // todo: some storages that use content as overlays can have problems with world_icons, need to fix it in the furure while adding new world_icons (donut_box and donuts, crayons and crayon box, etc.) /obj/item/weapon/storage/Destroy() QDEL_NULL(storage_ui) @@ -241,9 +235,17 @@ return TRUE -//This proc handles items being inserted. It does not perform any checks of whether an item can or can't be inserted. That's done by can_be_inserted() -//The stop_warning parameter will stop the insertion message from being displayed. It is intended for cases where you are inserting multiple items at once, -//such as when picking up all the items on a tile with one click. +// low level proc just to handle Move/ForceMove +/obj/item/weapon/storage/Entered(obj/item/mover) + . = ..() + + if(istype(mover)) + mover.on_enter_storage(src) + +// Handles item insertion with related events and user feedback. +// It does not perform any checks of whether an item can or can't be inserted. That's done by can_be_inserted() +// The stop_warning parameter will stop the insertion message from being displayed. It is intended for cases where you are inserting multiple items at once, +// such as when picking up all the items on a tile with one click. /obj/item/weapon/storage/proc/handle_item_insertion(obj/item/W, prevent_warning = FALSE, NoUpdate = FALSE) if(!istype(W)) return FALSE @@ -256,7 +258,6 @@ else W.forceMove(src) - W.on_enter_storage(src) if(usr) add_fingerprint(usr) diff --git a/code/game/objects/items/weapons/swords_axes_etc.dm b/code/game/objects/items/weapons/swords_axes_etc.dm index 75e5e2e5b59c..3a2c2c3ae55d 100644 --- a/code/game/objects/items/weapons/swords_axes_etc.dm +++ b/code/game/objects/items/weapons/swords_axes_etc.dm @@ -69,6 +69,7 @@ add_fingerprint(user) /obj/item/weapon/melee/energy/sword/on_enter_storage(obj/item/weapon/storage/S) + ..() if(active) attack_self(usr) diff --git a/code/modules/mining/coins.dm b/code/modules/mining/coins.dm index b335b13c51d0..6dd647e2e674 100644 --- a/code/modules/mining/coins.dm +++ b/code/modules/mining/coins.dm @@ -136,3 +136,12 @@ user.visible_message("[user] has flipped [src]. It lands on [coinflip].", "You flip [src]. It lands on [coinflip].", "You hear the clattering of loose change.") + +/obj/item/weapon/coin/update_world_icon() + update_icon() + +/obj/item/weapon/coin/update_icon() + if(item_state_world && (flags_2 & IN_INVENTORY || flags_2 & IN_STORAGE)) // big inventory icon, if we have it + icon_state = "coin_[cmineral]_[coinflip]" + else // default or small icon + icon_state = "coin_[cmineral]_[coinflip]_world" diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 92771349f816..bcff96dfba5a 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -291,7 +291,7 @@ if(SLOT_IN_BACKPACK) if(get_active_hand() == W) remove_from_mob(W) - W.loc = src.back + W.forceMove(src.back) if(SLOT_TIE) var/obj/item/clothing/under/uniform = w_uniform uniform.attach_accessory(W, src)