[MIRROR] Makes update_icon_updates_onmob more robust [MDB IGNORE] (#21076)

* Makes update_icon_updates_onmob more robust (#75324)

Safeguards against #74965 happening in the future.

Noticed a bunch of these were using ITEM_SLOT_HANDS. This is incorrect,
as the element already automatically updates held items. grep'd it to
catch future instances.

Likewise, a number of objects weren't passing slot_flags to the element,
meaning it wasn't actually updating those things properly when they were
being worn. I've simplified this so now the element will automatically
update all slot_flags, and passing an additional slot to the element
when being added is only needed for additional slots that might need to
be updated. This also means if slot_flags change, the element will now
update correctly as well.

🆑 ShizCalev
code: The update_icon_updates_onmob element will now automatically
update all slots in an item's slot_flags var. This does fix multiple
things that weren't updating properly. Passing a slot to the element is
now only necessary if you want to add additional slots to be updated.
/🆑

* Makes update_icon_updates_onmob more robust

---------

Co-authored-by: ShizCalev <ShizCalev@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-05-10 22:57:55 -07:00
committed by GitHub
co-authored by ShizCalev
parent e8343000c5
commit 077e2d4eee
27 changed files with 35 additions and 29 deletions
@@ -3,7 +3,7 @@
/datum/element/update_icon_updates_onmob
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
///The ITEM_SLOT_X flags to update on the parent mob. (Ex: ITEM_SLOT_HANDS|ITEM_SLOT_FEET)
///The ITEM_SLOT_X flags to update on the parent mob in additon to the item's slot_flags. (Ex: Passing ITEM_SLOT_HANDCUFFED for sneakers will update the handcuff overlays in addition to ITEM_SLOT_FEET's overlays when their icon changes.)
var/update_flags = NONE
///Should the element call [/mob/proc/update_body()] in addition to clothing updates?
var/update_body = FALSE
@@ -24,6 +24,6 @@
if(M.is_holding(target))
M.update_held_items()
else
M.update_clothing(update_flags)
M.update_clothing((target.slot_flags|update_flags))
if(update_body)
M.update_body()