diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index cbf0d6372e8..08a1a3aba41 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -40,6 +40,9 @@ ///from SSsun when the sun changes position : (azimuth) #define COMSIG_SUN_MOVED "sun_moved" +///from SSsecurity_level when the security level changes : (new_level) +#define COMSIG_SECURITY_LEVEL_CHANGED "security_level_changed" + ////////////////////////////////////////////////////////////////// // /datum signals diff --git a/code/controllers/subsystem/nightshift.dm b/code/controllers/subsystem/nightshift.dm index bc16085f68c..1e8daad6e61 100644 --- a/code/controllers/subsystem/nightshift.dm +++ b/code/controllers/subsystem/nightshift.dm @@ -27,7 +27,7 @@ SUBSYSTEM_DEF(nightshift) priority_announce(message, sound='sound/misc/notice2.ogg', sender_override="Automated Lighting System Announcement") /datum/controller/subsystem/nightshift/proc/check_nightshift() - var/emergency = GLOB.security_level >= SEC_LEVEL_RED + var/emergency = SSsecurity_level.current_level >= SEC_LEVEL_RED var/announcing = TRUE var/time = station_time() var/night_time = (time < nightshift_end_time) || (time > nightshift_start_time) diff --git a/code/controllers/subsystem/security_level.dm b/code/controllers/subsystem/security_level.dm new file mode 100644 index 00000000000..e3168dee0c3 --- /dev/null +++ b/code/controllers/subsystem/security_level.dm @@ -0,0 +1,17 @@ +SUBSYSTEM_DEF(security_level) + name = "Security Level" + flags = SS_NO_FIRE + /// Currently set security level + var/current_level = SEC_LEVEL_GREEN + +/** + * Sets a new security level as our current level + * + * Arguments: + * * new_level The new security level that will become our current level + */ +/datum/controller/subsystem/security_level/proc/set_level(new_level) + SSsecurity_level.current_level = new_level + SEND_SIGNAL(src, COMSIG_SECURITY_LEVEL_CHANGED, new_level) + SSnightshift.check_nightshift() + SSblackbox.record_feedback("tally", "security_level_changes", 1, get_security_level()) diff --git a/code/game/gamemodes/dynamic/dynamic.dm b/code/game/gamemodes/dynamic/dynamic.dm index e340217d258..55fe3a7c2aa 100644 --- a/code/game/gamemodes/dynamic/dynamic.dm +++ b/code/game/gamemodes/dynamic/dynamic.dm @@ -291,7 +291,7 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1) print_command_report(., "Central Command Status Summary", announce=FALSE) priority_announce("A summary has been copied and printed to all communications consoles.", "Security level elevated.", ANNOUNCER_INTERCEPT) - if(GLOB.security_level < SEC_LEVEL_BLUE) + if(SSsecurity_level.current_level < SEC_LEVEL_BLUE) set_security_level(SEC_LEVEL_BLUE) // Yes, this is copy pasted from game_mode diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index ff1cb07d30a..379acbd0e44 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -327,7 +327,7 @@ print_command_report(intercepttext, "Central Command Status Summary", announce=FALSE) priority_announce("A summary has been copied and printed to all communications consoles.", "Enemy communication intercepted. Security level elevated.", ANNOUNCER_INTERCEPT) - if(GLOB.security_level < SEC_LEVEL_BLUE) + if(SSsecurity_level.current_level < SEC_LEVEL_BLUE) set_security_level(SEC_LEVEL_BLUE) /* diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index 2be6e757a26..3433ea23941 100755 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -141,7 +141,7 @@ //if (new_sec_level != SEC_LEVEL_GREEN && new_sec_level != SEC_LEVEL_BLUE) - ORIGINAL if (new_sec_level < SEC_LEVEL_GREEN || new_sec_level > SEC_LEVEL_AMBER) //SKYRAT EDIT CHANGE - ALERTS return - if (GLOB.security_level == new_sec_level) + if (SSsecurity_level.current_level == new_sec_level) return set_security_level(new_sec_level) diff --git a/code/game/machinery/defibrillator_mount.dm b/code/game/machinery/defibrillator_mount.dm index 57022bf665f..a0790247679 100644 --- a/code/game/machinery/defibrillator_mount.dm +++ b/code/game/machinery/defibrillator_mount.dm @@ -37,7 +37,7 @@ . = ..() if(defib) . += "There is a defib unit hooked up. Alt-click to remove it." - if(GLOB.security_level >= SEC_LEVEL_RED) + if(SSsecurity_level.current_level >= SEC_LEVEL_RED) . += "Due to a security situation, its locking clamps can be toggled by swiping any ID." else . += "Its locking clamps can be [clamps_locked ? "dis" : ""]engaged by swiping an ID with access." @@ -102,7 +102,7 @@ return var/obj/item/card/id = I.GetID() if(id) - if(check_access(id) || GLOB.security_level >= SEC_LEVEL_RED) //anyone can toggle the clamps in red alert! + if(check_access(id) || SSsecurity_level.current_level >= SEC_LEVEL_RED) //anyone can toggle the clamps in red alert! if(!defib) to_chat(user, "You can't engage the clamps on a defibrillator that isn't there.") return diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 12dfe7d531e..dfd08f2b954 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -47,7 +47,7 @@ /obj/machinery/door/examine(mob/user) . = ..() if(red_alert_access) - if(GLOB.security_level >= SEC_LEVEL_RED) + if(SSsecurity_level.current_level >= SEC_LEVEL_RED) . += "Due to a security threat, its access requirements have been lifted!" else . += "In the event of a red alert, its access requirements will automatically lift." @@ -57,7 +57,7 @@ . += "It has labels indicating that it has an emergency mechanism to open it with just your hands if there's no power." /obj/machinery/door/check_access_list(list/access_list) - if(red_alert_access && GLOB.security_level >= SEC_LEVEL_RED) + if(red_alert_access && SSsecurity_level.current_level >= SEC_LEVEL_RED) return TRUE return ..() @@ -77,6 +77,7 @@ //doors only block while dense though so we have to use the proc real_explosion_block = explosion_block explosion_block = EXPLOSION_BLOCK_PROC + RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, .proc/check_security_level) /obj/machinery/door/proc/set_init_door_layer() if(density) @@ -93,6 +94,23 @@ air_update_turf(TRUE, FALSE) return ..() +/** + * Signal handler for checking if we notify our surrounding that access requirements are lifted accordingly to a newly set security level + * + * Arguments: + * * source The datum source of the signal + * * new_level The new security level that is in effect + */ +/obj/machinery/door/proc/check_security_level(datum/source, new_level) + SIGNAL_HANDLER + + if(new_level <= SEC_LEVEL_BLUE) + return + if(!red_alert_access) + return + audible_message("[src] whirr[p_s()] as [p_they()] automatically lift[p_s()] access requirements!") + playsound(src, 'sound/machines/boltsup.ogg', 50, TRUE) + /obj/machinery/door/proc/try_safety_unlock(mob/user) if(safety_mode && !hasPower() && density) to_chat(user, "You begin unlocking the airlock safety mechanism...") diff --git a/code/game/machinery/firealarm.dm b/code/game/machinery/firealarm.dm index 874c779bb8f..bbf32901c87 100644 --- a/code/game/machinery/firealarm.dm +++ b/code/game/machinery/firealarm.dm @@ -51,6 +51,7 @@ update_appearance() myarea = get_area(src) LAZYADD(myarea.firealarms, src) + RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, .proc/check_security_level) /obj/machinery/firealarm/ComponentInitialize() . = ..() @@ -78,9 +79,9 @@ . += "fire_overlay" if(is_station_level(z)) - . += "fire_[GLOB.security_level]" - . += mutable_appearance(icon, "fire_[GLOB.security_level]", layer, plane) - . += mutable_appearance(icon, "fire_[GLOB.security_level]", layer, EMISSIVE_PLANE) + . += "fire_[SSsecurity_level.current_level]" + . += mutable_appearance(icon, "fire_[SSsecurity_level.current_level]", layer, plane) + . += mutable_appearance(icon, "fire_[SSsecurity_level.current_level]", layer, EMISSIVE_PLANE) else . += "fire_[SEC_LEVEL_GREEN]" . += mutable_appearance(icon, "fire_[SEC_LEVEL_GREEN]", layer, plane) @@ -145,6 +146,19 @@ myarea.triggered_firealarms -= 1 update_appearance() +/** + * Signal handler for checking if we should update fire alarm appearance accordingly to a newly set security level + * + * Arguments: + * * source The datum source of the signal + * * new_level The new security level that is in effect + */ +/obj/machinery/firealarm/proc/check_security_level(datum/source, new_level) + SIGNAL_HANDLER + + if(is_station_level(z)) + update_appearance() + /obj/machinery/firealarm/proc/alarm(mob/user) if(!is_operational || !COOLDOWN_FINISHED(src, last_alarm)) return diff --git a/code/modules/security_levels/security_levels.dm b/code/modules/security_levels/security_levels.dm index 25292b54ce4..80ccff438b9 100644 --- a/code/modules/security_levels/security_levels.dm +++ b/code/modules/security_levels/security_levels.dm @@ -1,4 +1,3 @@ -GLOBAL_VAR_INIT(security_level, SEC_LEVEL_GREEN) //SEC_LEVEL_GREEN = code green //SEC_LEVEL_BLUE = code blue //SEC_LEVEL_RED = code red @@ -20,21 +19,17 @@ GLOBAL_VAR_INIT(security_level, SEC_LEVEL_GREEN) level = SEC_LEVEL_DELTA //Will not be announced if you try to set to the same level as it already is - if(level >= SEC_LEVEL_GREEN && level <= SEC_LEVEL_DELTA && level != GLOB.security_level) + if(level >= SEC_LEVEL_GREEN && level <= SEC_LEVEL_DELTA && level != SSsecurity_level.current_level) switch(level) if(SEC_LEVEL_GREEN) minor_announce(CONFIG_GET(string/alert_green), "Attention! Security level lowered to green:") if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL) - if(GLOB.security_level >= SEC_LEVEL_RED) + if(SSsecurity_level.current_level >= SEC_LEVEL_RED) SSshuttle.emergency.modTimer(4) else SSshuttle.emergency.modTimer(2) - GLOB.security_level = SEC_LEVEL_GREEN - for(var/obj/machinery/firealarm/FA in GLOB.machines) - if(is_station_level(FA.z)) - FA.update_appearance() if(SEC_LEVEL_BLUE) - if(GLOB.security_level < SEC_LEVEL_BLUE) + if(SSsecurity_level.current_level < SEC_LEVEL_BLUE) minor_announce(CONFIG_GET(string/alert_blue_upto), "Attention! Security level elevated to blue:",1) if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL) SSshuttle.emergency.modTimer(0.5) @@ -42,52 +37,28 @@ GLOBAL_VAR_INIT(security_level, SEC_LEVEL_GREEN) minor_announce(CONFIG_GET(string/alert_blue_downto), "Attention! Security level lowered to blue:") if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL) SSshuttle.emergency.modTimer(2) - GLOB.security_level = SEC_LEVEL_BLUE - for(var/obj/machinery/firealarm/FA in GLOB.machines) - if(is_station_level(FA.z)) - FA.update_appearance() if(SEC_LEVEL_RED) - if(GLOB.security_level < SEC_LEVEL_RED) + if(SSsecurity_level.current_level < SEC_LEVEL_RED) minor_announce(CONFIG_GET(string/alert_red_upto), "Attention! Code red!",1) if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL) - if(GLOB.security_level == SEC_LEVEL_GREEN) + if(SSsecurity_level.current_level == SEC_LEVEL_GREEN) SSshuttle.emergency.modTimer(0.25) else SSshuttle.emergency.modTimer(0.5) else minor_announce(CONFIG_GET(string/alert_red_downto), "Attention! Code red!") - GLOB.security_level = SEC_LEVEL_RED - - for(var/obj/machinery/firealarm/FA in GLOB.machines) - if(is_station_level(FA.z)) - FA.update_appearance() - for(var/obj/machinery/computer/shuttle/pod/pod in GLOB.machines) - pod.locked = FALSE if(SEC_LEVEL_DELTA) minor_announce(CONFIG_GET(string/alert_delta), "Attention! Delta security level reached!",1) if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL) - if(GLOB.security_level == SEC_LEVEL_GREEN) + if(SSsecurity_level.current_level == SEC_LEVEL_GREEN) SSshuttle.emergency.modTimer(0.25) - else if(GLOB.security_level == SEC_LEVEL_BLUE) + else if(SSsecurity_level.current_level == SEC_LEVEL_BLUE) SSshuttle.emergency.modTimer(0.5) - GLOB.security_level = SEC_LEVEL_DELTA - for(var/obj/machinery/firealarm/FA in GLOB.machines) - if(is_station_level(FA.z)) - FA.update_appearance() - for(var/obj/machinery/computer/shuttle/pod/pod in GLOB.machines) - pod.locked = FALSE - if(level >= SEC_LEVEL_RED) - for(var/obj/machinery/door/D in GLOB.machines) - if(D.red_alert_access) - D.visible_message("[D] whirrs as it automatically lifts access requirements!") - playsound(D, 'sound/machines/boltsup.ogg', 50, TRUE) - SSblackbox.record_feedback("tally", "security_level_changes", 1, get_security_level()) - SSnightshift.check_nightshift() - else - return + + SSsecurity_level.set_level(level) /proc/get_security_level() - switch(GLOB.security_level) + switch(SSsecurity_level.current_level) if(SEC_LEVEL_GREEN) return "green" if(SEC_LEVEL_BLUE) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 87dc7c509b4..fb1e37e4133 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -575,7 +575,7 @@ var/obj/machinery/computer/shuttle/C = getControlConsole() if(!istype(C, /obj/machinery/computer/shuttle/pod)) return ..() - if(GLOB.security_level >= SEC_LEVEL_RED || (C && (C.obj_flags & EMAGGED))) + if(SSsecurity_level.current_level >= SEC_LEVEL_RED || (C && (C.obj_flags & EMAGGED))) if(launch_status == UNLAUNCHED) launch_status = EARLY_LAUNCHED return ..() @@ -595,6 +595,10 @@ light_color = LIGHT_COLOR_BLUE density = FALSE +/obj/machinery/computer/shuttle/pod/Initialize(mapload) + . = ..() + RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, .proc/check_lock) + /obj/machinery/computer/shuttle/pod/ComponentInitialize() . = ..() AddElement(/datum/element/update_icon_blocker) @@ -610,6 +614,20 @@ . = ..() possible_destinations += ";[port.id]_lavaland" +/** + * Signal handler for checking if we should lock or unlock escape pods accordingly to a newly set security level + * + * Arguments: + * * source The datum source of the signal + * * new_level The new security level that is in effect + */ +/obj/machinery/computer/shuttle/pod/proc/check_lock(datum/source, new_level) + SIGNAL_HANDLER + + if(obj_flags & EMAGGED) + return + locked = new_level < SEC_LEVEL_RED + /obj/docking_port/stationary/random name = "escape pod" id = "pod" @@ -705,7 +723,7 @@ /obj/item/storage/pod/can_interact(mob/user) if(!..()) return FALSE - if(GLOB.security_level >= SEC_LEVEL_RED || unlocked) + if(SSsecurity_level.current_level >= SEC_LEVEL_RED || unlocked) return TRUE to_chat(user, "The storage unit will only unlock during a Red or Delta security alert.") diff --git a/modular_skyrat/master_files/code/modules/mob/living/dead/new_player/new_player.dm b/modular_skyrat/master_files/code/modules/mob/living/dead/new_player/new_player.dm index e073f7eddd5..4943f3da701 100644 --- a/modular_skyrat/master_files/code/modules/mob/living/dead/new_player/new_player.dm +++ b/modular_skyrat/master_files/code/modules/mob/living/dead/new_player/new_player.dm @@ -432,7 +432,7 @@ /mob/dead/new_player/proc/LateChoices() var/list/dat = list("