Skip to content

Commit

Permalink
[MIRROR] Fixes modified MA overlays potentially causing duplicate ove…
Browse files Browse the repository at this point in the history
…rlays [MDB IGNORE] (#173)

* Fixes modified MA overlays potentially causing duplicate overlays (#78719)
---------

Co-authored-by: Emmett Gaines <[email protected]>
  • Loading branch information
Steals-The-PRs and ninjanomnom authored Oct 20, 2023
1 parent f64cf6c commit 0952de8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
62 changes: 48 additions & 14 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,6 @@

/// Updates the icon of the atom
/atom/proc/update_icon(updates=ALL)
SIGNAL_HANDLER
SHOULD_CALL_PARENT(TRUE)

. = NONE
Expand All @@ -796,19 +795,54 @@
SSvis_overlays.remove_vis_overlay(src, managed_vis_overlays)

var/list/new_overlays = update_overlays(updates)
if (managed_overlays)
if (length(overlays) == (islist(managed_overlays) ? length(managed_overlays) : 1))
overlays = null
POST_OVERLAY_CHANGE(src)
else
cut_overlay(managed_overlays)
managed_overlays = null
if(length(new_overlays))
if (length(new_overlays) == 1)
managed_overlays = new_overlays[1]
else
managed_overlays = new_overlays
add_overlay(new_overlays)
var/nulls = 0
for(var/i in 1 to length(new_overlays))
var/atom/maybe_not_an_atom = new_overlays[i]
if(isnull(maybe_not_an_atom))
nulls++
continue
if(istext(maybe_not_an_atom) || isicon(maybe_not_an_atom))
continue
new_overlays[i] = maybe_not_an_atom.appearance
if(nulls)
for(var/i in 1 to nulls)
new_overlays -= null

var/identical = FALSE
var/new_length = length(new_overlays)
if(!managed_overlays && !new_length)
identical = TRUE
else if(!islist(managed_overlays))
if(new_length == 1 && managed_overlays == new_overlays[1])
identical = TRUE
else if(length(managed_overlays) == new_length)
identical = TRUE
for(var/i in 1 to length(managed_overlays))
if(managed_overlays[i] != new_overlays[i])
identical = FALSE
break

if(!identical)
var/full_control = FALSE
if(managed_overlays)
full_control = length(overlays) == (islist(managed_overlays) ? length(managed_overlays) : 1)
if(full_control)
overlays = null
else
cut_overlay(managed_overlays)

switch(length(new_overlays))
if(0)
if(full_control)
POST_OVERLAY_CHANGE(src)
managed_overlays = null
if(1)
add_overlay(new_overlays)
managed_overlays = new_overlays[1]
else
add_overlay(new_overlays)
managed_overlays = new_overlays

. |= UPDATE_OVERLAYS

. |= SEND_SIGNAL(src, COMSIG_ATOM_UPDATED_ICON, updates, .)
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/devices/radio/radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@
. = ..()
if(unscrewed)
return
if(broadcasting)
if(broadcasting && overlay_mic_idle)
. += overlay_mic_idle
if(listening)
if(listening && overlay_speaker_idle)
. += overlay_speaker_idle

/obj/item/radio/screwdriver_act(mob/living/user, obj/item/tool)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reagent_containers/cups/drinks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@
custom_price = PAYCHECK_LOWER * 0.8

/obj/item/reagent_containers/cup/glass/waterbottle/Initialize(mapload)
. = ..()
cap_overlay = mutable_appearance(cap_icon, cap_icon_state)
. = ..()
if(cap_on)
spillable = FALSE
update_appearance()
Expand Down
4 changes: 3 additions & 1 deletion code/modules/reagents/reagent_containers/syringes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@

/obj/item/reagent_containers/syringe/update_overlays()
. = ..()
. += update_reagent_overlay()
var/list/reagent_overlays = update_reagent_overlay()
if(reagent_overlays)
. += reagent_overlays

/// Returns a list of overlays to add that relate to the reagents inside the syringe
/obj/item/reagent_containers/syringe/proc/update_reagent_overlay()
Expand Down

0 comments on commit 0952de8

Please sign in to comment.