Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes modified MA overlays potentially causing duplicate overlays #173

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 48 additions & 14 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@

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

. = NONE
Expand All @@ -782,19 +781,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
Loading