From 4c7e9e4ff2e05b13145ba767efcfea79351426e6 Mon Sep 17 00:00:00 2001 From: Geeves Date: Sat, 9 Sep 2023 14:20:56 +0200 Subject: [PATCH] Nearsighted Camera Fix (#17124) * Nearsighted Camera Fix * fluffy changes --- code/game/atoms.dm | 4 ++++ code/game/machinery/camera/camera.dm | 3 +++ code/game/machinery/computer/camera.dm | 10 ++++++++++ .../modules/mob/living/carbon/human/human_helpers.dm | 4 ++-- code/modules/mob/living/carbon/human/life.dm | 4 +++- .../computers/modular_computer/core.dm | 9 +++++++-- .../modules/modular_computers/file_system/program.dm | 5 +++++ .../file_system/programs/security/camera.dm | 12 ++++++++++++ code/modules/nano/modules/nano_module.dm | 3 +++ .../geeves-nearsighted_officer_stuff_revengeance.yml | 6 ++++++ 10 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 html/changelogs/geeves-nearsighted_officer_stuff_revengeance.yml diff --git a/code/game/atoms.dm b/code/game/atoms.dm index cff5c0019c8..6eae14b690c 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -86,6 +86,10 @@ return 0 return -1 +/// Primarily used on machinery, when this returns TRUE, equipment that helps with vision, such as prescription glasses for nearsighted characters, have an effect despite the client eye not being on the mob +/atom/proc/grants_equipment_vision(var/mob/user) + return + /atom/proc/additional_sight_flags() return 0 diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 72ad58dea03..f68bc4d635c 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -285,6 +285,9 @@ if(isXRay()) return SEE_TURFS|SEE_MOBS|SEE_OBJS return 0 +/obj/machinery/camera/grants_equipment_vision(mob/user) + return can_use() + //This might be redundant, because of check_eye() /obj/machinery/camera/proc/kick_viewers() for(var/mob/O in player_list) diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index bbe681a1858..bfe0b66c434 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -35,6 +35,16 @@ reset_current() return viewflag +/obj/machinery/computer/security/grants_equipment_vision(var/mob/user as mob) + if(user.stat || user.blinded || inoperable()) + return FALSE + if(!current_camera) + return FALSE + var/viewflag = current_camera.check_eye(user) + if (viewflag < 0) //camera doesn't work + return FALSE + return TRUE + /obj/machinery/computer/security/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1) if(..()) return diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm index fd5a2d48a5f..80f5e7a8e0b 100644 --- a/code/modules/mob/living/carbon/human/human_helpers.dm +++ b/code/modules/mob/living/carbon/human/human_helpers.dm @@ -47,7 +47,7 @@ return ..() -/mob/living/carbon/human/proc/update_equipment_vision() +/mob/living/carbon/human/proc/update_equipment_vision(var/machine_grants_equipment_vision = FALSE) flash_protection = 0 equipment_tint_total = 0 equipment_see_invis = 0 @@ -62,7 +62,7 @@ else binoc_check = TRUE - if(((!client || client.eye == src || client.eye == loc || client.eye == z_eye) && binoc_check) || HAS_TRAIT(src, TRAIT_COMPUTER_VIEW)) // !client is so the unit tests function + if(((!client || client.eye == src || client.eye == loc || client.eye == z_eye) && binoc_check) || machine_grants_equipment_vision || HAS_TRAIT(src, TRAIT_COMPUTER_VIEW)) // !client is so the unit tests function if(istype(src.head, /obj/item/clothing/head)) add_clothing_protection(head) if(istype(src.glasses, /obj/item/clothing/glasses)) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 287cbdf20a0..9a616a821a9 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1398,12 +1398,14 @@ /mob/living/carbon/human/handle_vision() if(client) client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask, global_hud.nvg, global_hud.thermal, global_hud.meson, global_hud.science) + var/machine_has_equipment_vision = FALSE if(machine) var/viewflags = machine.check_eye(src) if(viewflags < 0) reset_view(null, 0) else if(viewflags) set_sight(sight, viewflags) + machine_has_equipment_vision = machine.grants_equipment_vision(src) else if(eyeobj) if(eyeobj.owner != src) reset_view(null) @@ -1418,7 +1420,7 @@ remoteview_target = null reset_view(null, 0) - update_equipment_vision() + update_equipment_vision(machine_has_equipment_vision) species.handle_vision(src) /mob/living/carbon/human/handle_hearing() diff --git a/code/modules/modular_computers/computers/modular_computer/core.dm b/code/modules/modular_computers/computers/modular_computer/core.dm index 6aa52e44c6d..63cefe651ea 100644 --- a/code/modules/modular_computers/computers/modular_computer/core.dm +++ b/code/modules/modular_computers/computers/modular_computer/core.dm @@ -355,8 +355,13 @@ /obj/item/modular_computer/check_eye(var/mob/user) if(active_program) return active_program.check_eye(user) - else - return ..() + return ..() + +// Used by camera monitor program +/obj/item/modular_computer/grants_equipment_vision(var/mob/user) + if(active_program) + return active_program.grants_equipment_vision(user) + return ..() /obj/item/modular_computer/get_cell() return battery_module ? battery_module.get_cell() : DEVICE_NO_CELL diff --git a/code/modules/modular_computers/file_system/program.dm b/code/modules/modular_computers/file_system/program.dm index 28508bbeffe..145686ed995 100644 --- a/code/modules/modular_computers/file_system/program.dm +++ b/code/modules/modular_computers/file_system/program.dm @@ -236,6 +236,11 @@ else return -1 +/// Relays the call to nano module, if we have one +/datum/computer_file/program/proc/grants_equipment_vision(var/mob/user) + if(NM) + return NM.grants_equipment_vision(user) + /datum/computer_file/program/proc/message_dead(var/message) for(var/mob/M in player_list) if(M.stat == DEAD && (M.client && M.client.prefs.toggles & CHAT_GHOSTEARS)) diff --git a/code/modules/modular_computers/file_system/programs/security/camera.dm b/code/modules/modular_computers/file_system/programs/security/camera.dm index 77dade74f70..aceba5da5de 100644 --- a/code/modules/modular_computers/file_system/programs/security/camera.dm +++ b/code/modules/modular_computers/file_system/programs/security/camera.dm @@ -191,6 +191,18 @@ reset_current() return viewflag +/datum/computer_file/program/camera_monitor/grants_equipment_vision(mob/user) + var/obj/item/modular_computer/MC = user.machine + if(istype(MC) && ui_host() == MC) + if(!MC.working || user.blinded || user.stat) + return FALSE + if(!current_camera) + return FALSE + var/viewflag = current_camera.check_eye(user) + if (viewflag < 0) //camera doesn't work + return FALSE + return TRUE + // ERT Variant of the program /datum/computer_file/program/camera_monitor/ert diff --git a/code/modules/nano/modules/nano_module.dm b/code/modules/nano/modules/nano_module.dm index 9ddc5f92a38..8488e24a6d0 100644 --- a/code/modules/nano/modules/nano_module.dm +++ b/code/modules/nano/modules/nano_module.dm @@ -18,6 +18,9 @@ /datum/nano_module/proc/check_eye(var/mob/user) return -1 +/datum/nano_module/proc/grants_equipment_vision(var/mob/user) + return FALSE + /datum/nano_module/proc/check_access(var/mob/user, var/access) if(!access) return 1 diff --git a/html/changelogs/geeves-nearsighted_officer_stuff_revengeance.yml b/html/changelogs/geeves-nearsighted_officer_stuff_revengeance.yml new file mode 100644 index 00000000000..60fdc963a1a --- /dev/null +++ b/html/changelogs/geeves-nearsighted_officer_stuff_revengeance.yml @@ -0,0 +1,6 @@ +author: Geeves + +delete-after: True + +changes: + - bugfix: "Using cameras while wearing glasses as a nearsighted character no longer reduces your vision radius." \ No newline at end of file