diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index f1732ade47fc..301f1a683d9d 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -330,7 +330,8 @@ SUBSYSTEM_DEF(ticker) PostSetup() - // Toggle lightswitches on in occupied departments + + // Toggle lightswitches off in unoccupied departments var/list/lightup_area_typecache = list() var/minimal_access = CONFIG_GET(flag/jobs_have_minimal_access) for(var/mob/living/carbon/human/player in GLOB.player_list) @@ -341,11 +342,17 @@ SUBSYSTEM_DEF(ticker) if(!job) continue lightup_area_typecache |= job.areas_to_light_up(minimal_access) - for(var/area in lightup_area_typecache) - var/area/place = locate(area) in GLOB.areas - if(!place || place.lights_always_start_on) + + for(var/area/place as anything in GLOB.areas) + if(!istype(place)) continue - place.lightswitch = TRUE + if(place.lights_always_start_on) + continue + if(!is_station_level(place.z)) + continue + if(is_type_in_typecache(place, lightup_area_typecache)) + continue + place.lightswitch = FALSE place.update_appearance() for(var/obj/machinery/light_switch/lswitch in place) diff --git a/code/game/area/Space_Station_13_areas.dm b/code/game/area/Space_Station_13_areas.dm index b2d0e33cd69b..3a09e69d92c5 100644 --- a/code/game/area/Space_Station_13_areas.dm +++ b/code/game/area/Space_Station_13_areas.dm @@ -515,7 +515,6 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/crew_quarters/theatre/abandoned name = "Abandoned Theatre" icon_state = "Theatre" - lights_always_start_on = FALSE /area/library name = "Library" diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 6f7c4e58b6ad..92cb1053db07 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -135,6 +135,7 @@ /// Whether the lights in this area aren't turned off when it's empty at roundstart var/lights_always_start_on = FALSE + /** * A list of teleport locations diff --git a/code/game/machinery/lightswitch.dm b/code/game/machinery/lightswitch.dm index 9e61e8634e17..4d94c08c4a52 100644 --- a/code/game/machinery/lightswitch.dm +++ b/code/game/machinery/lightswitch.dm @@ -91,14 +91,6 @@ return INITIALIZE_HINT_LATELOAD return INITIALIZE_HINT_NORMAL -/obj/machinery/light_switch/LateInitialize() - if(!is_station_level(z)) - return - var/area/source_area = get_area(get_turf(src)) - if(source_area.lights_always_start_on) - return - turn_off() - /obj/machinery/light_switch/update_appearance(updates=ALL) . = ..() luminosity = (stat & NOPOWER) ? 0 : 1 diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index 63a2fb57bcf2..74489d3df45e 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -287,6 +287,9 @@ ///More stress stuff. var/turning_on = FALSE + ///Flicker cooldown + COOLDOWN_DECLARE(flicker_cooldown) + /obj/machinery/light/broken status = LIGHT_BROKEN icon_state = "tube-broken" @@ -353,9 +356,6 @@ // Light projects out backwards from the dir of the light set_light(l_dir = REVERSE_DIR(dir)) - if(mapload && our_area.lights_always_start_on) - turn_on(trigger = FALSE, quiet = TRUE) - return INITIALIZE_HINT_LATELOAD /obj/machinery/light/LateInitialize() @@ -729,8 +729,9 @@ /obj/machinery/light/proc/flicker(amount = rand(10, 20)) set waitfor = 0 - if(flickering) + if(flickering || !COOLDOWN_FINISHED(src, flicker_cooldown)) return + COOLDOWN_START(src, flicker_cooldown, 10 SECONDS) flickering = 1 if(on && status == LIGHT_OK) for(var/i = 0; i < amount; i++) @@ -1075,9 +1076,9 @@ transfer_fingerprints_to(M) qdel(src) -/proc/flicker_all_lights() +/proc/flicker_all_lights() //not QUITE all lights, but it reduces lag for(var/obj/machinery/light/L in GLOB.machines) - if(is_station_level(L.z)) + if(is_station_level(L.z) && prob(50)) addtimer(CALLBACK(L, TYPE_PROC_REF(/obj/machinery/light, flicker), rand(3, 6)), rand(0, 15)) #undef LIGHT_ON_DELAY_UPPER