diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm index 3d7d774bd1ed..84cad4cb7d1e 100644 --- a/code/modules/clothing/head/helmet.dm +++ b/code/modules/clothing/head/helmet.dm @@ -666,29 +666,39 @@ GLOBAL_LIST_INIT(allowed_helmet_items, list( return FALSE if(active_visor) + var/visor_to_deactivate = active_visor + var/skipped_hud = FALSE var/iterator = 1 - for(var/hud_type in total_visors) - if(hud_type == active_visor) + for(var/obj/item/device/helmet_visor/current_visor as anything in total_visors) + if(current_visor == active_visor || skipped_hud) if(length(total_visors) > iterator) - active_visor = total_visors[(iterator + 1)] - toggle_visor(user, total_visors[iterator], TRUE) + var/obj/item/device/helmet_visor/next_visor = total_visors[iterator + 1] + + if(!isnull(GLOB.huds[next_visor.hud_type].hudusers[user])) + iterator++ + skipped_hud = TRUE + continue + + active_visor = next_visor + toggle_visor(user, visor_to_deactivate, silent = TRUE) // disables the old visor toggle_visor(user) return active_visor else active_visor = null - toggle_visor(user, total_visors[iterator], FALSE) + toggle_visor(user, visor_to_deactivate, FALSE) return FALSE iterator++ - if(total_visors[1]) - active_visor = total_visors[1] + for(var/obj/item/device/helmet_visor/new_visor in total_visors) + + if(!isnull(GLOB.huds[new_visor.hud_type].hudusers[user])) + continue + + active_visor = new_visor toggle_visor(user) return active_visor - active_visor = null - recalculate_visors(user) return FALSE - /datum/action/item_action/cycle_helmet_huds/New(Target, obj/item/holder) . = ..() name = "Cycle helmet HUD"