mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
Speeds up lights on at roundstart (#36623)
* Speeds up lights on at roundstart * cleaner * for all of em * this was faster * speeds this up too * updates desc * updates the area if used * even more speed cutdown!!! * makes it do itself too * moar logging * adds moody light * unnecessary addition * correct name * kills this * makes brighter * back to pre conflict merge state
This commit is contained in:
@@ -76,6 +76,7 @@
|
|||||||
var/copy_logs = null
|
var/copy_logs = null
|
||||||
var/cargo_forwarding_on_roundstart = 0
|
var/cargo_forwarding_on_roundstart = 0
|
||||||
var/cargo_forwarding_amount_override = 0
|
var/cargo_forwarding_amount_override = 0
|
||||||
|
var/roundstart_lights_on = 0
|
||||||
|
|
||||||
// BSQL things
|
// BSQL things
|
||||||
var/bsql_debug = 0
|
var/bsql_debug = 0
|
||||||
@@ -282,6 +283,9 @@
|
|||||||
|
|
||||||
if ("cargo_forwarding_amount_override")
|
if ("cargo_forwarding_amount_override")
|
||||||
cargo_forwarding_amount_override = text2num(value)
|
cargo_forwarding_amount_override = text2num(value)
|
||||||
|
|
||||||
|
if("roundstart_lights_on")
|
||||||
|
roundstart_lights_on = 1
|
||||||
|
|
||||||
if ("use_recursive_explosions")
|
if ("use_recursive_explosions")
|
||||||
use_recursive_explosions = 1
|
use_recursive_explosions = 1
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ var/area/space_area
|
|||||||
var/uid
|
var/uid
|
||||||
var/obj/machinery/power/apc/areaapc = null
|
var/obj/machinery/power/apc/areaapc = null
|
||||||
var/list/obj/machinery/alarm/air_alarms = list()
|
var/list/obj/machinery/alarm/air_alarms = list()
|
||||||
|
var/list/obj/machinery/light_switch/lightswitches = list()
|
||||||
|
var/list/obj/machinery/light/lights = list()
|
||||||
var/list/area_turfs
|
var/list/area_turfs
|
||||||
plane = ABOVE_LIGHTING_PLANE
|
plane = ABOVE_LIGHTING_PLANE
|
||||||
layer = MAPPING_AREA_LAYER
|
layer = MAPPING_AREA_LAYER
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ var/datum/controller/gameticker/ticker
|
|||||||
theme.update_icon()
|
theme.update_icon()
|
||||||
|
|
||||||
/datum/controller/gameticker/proc/setup()
|
/datum/controller/gameticker/proc/setup()
|
||||||
|
var/total_tick = get_game_time()
|
||||||
//Create and announce mode
|
//Create and announce mode
|
||||||
if(master_mode=="secret")
|
if(master_mode=="secret")
|
||||||
hide_mode = 1
|
hide_mode = 1
|
||||||
@@ -215,27 +216,28 @@ var/datum/controller/gameticker/ticker
|
|||||||
CHECK_TICK
|
CHECK_TICK
|
||||||
|
|
||||||
//Now that we have all of the occupied areas, we handle the lights being on or off, before actually putting the players into their bodies.
|
//Now that we have all of the occupied areas, we handle the lights being on or off, before actually putting the players into their bodies.
|
||||||
if(roundstart_occupied_area_paths.len)
|
if(config.roundstart_lights_on || roundstart_occupied_area_paths.len)
|
||||||
var/tick = get_game_time()
|
var/light_tick = get_game_time()
|
||||||
var/obj/machinery/light_switch/LS
|
var/area/A
|
||||||
var/obj/machinery/light/lightykun
|
for(var/obj/item/device/flashlight/lamp/lampychan in lamps)
|
||||||
var/obj/item/device/flashlight/lamp/lampychan
|
A = get_area(lampychan)
|
||||||
for(var/area/A in areas)
|
if(config.roundstart_lights_on || (A.type in roundstart_occupied_area_paths))
|
||||||
if(A.type in roundstart_occupied_area_paths)
|
lampychan.toggle_onoff(1)
|
||||||
for(var/obj/O in A)
|
for(var/obj/machinery/light_switch/LS in lightswitches)
|
||||||
LS = O
|
A = get_area(LS)
|
||||||
lightykun = O
|
if(config.roundstart_lights_on || (A.type in roundstart_occupied_area_paths))
|
||||||
lampychan = O
|
LS.toggle_switch(1, FALSE, FALSE)
|
||||||
if(istype(LS))
|
roundstart_occupied_area_paths -= A.type // lights are covered by this so skip these areas
|
||||||
LS.toggle_switch(1, playsound = FALSE)
|
if(roundstart_occupied_area_paths.len)
|
||||||
else if(istype(lightykun))
|
for(var/obj/machinery/light/lightykun in alllights)
|
||||||
lightykun.on = 1
|
A = get_area(lightykun)
|
||||||
lightykun.update()
|
if(config.roundstart_lights_on || (A.type in roundstart_occupied_area_paths))
|
||||||
else if(istype(lampychan))
|
lightykun.on = 1
|
||||||
lampychan.toggle_onoff(1)
|
lightykun.update()
|
||||||
//Force the lighting subsystem to update.
|
//Force the lighting subsystem to update.
|
||||||
SSlighting.fire(FALSE, FALSE)
|
SSlighting.fire(FALSE, FALSE)
|
||||||
log_admin("Turned the lights on in [(get_game_time() - tick) / 10] seconds.")
|
log_admin("Turned the lights on in [(get_game_time() - light_tick) / 10] seconds.")
|
||||||
|
message_admins("Turned the lights on in [(get_game_time() - light_tick) / 10] seconds.")
|
||||||
|
|
||||||
var/list/clowns = list()
|
var/list/clowns = list()
|
||||||
var/already_an_ai = FALSE
|
var/already_an_ai = FALSE
|
||||||
@@ -313,6 +315,8 @@ var/datum/controller/gameticker/ticker
|
|||||||
Master.RoundStart()
|
Master.RoundStart()
|
||||||
wageSetup()
|
wageSetup()
|
||||||
post_roundstart()
|
post_roundstart()
|
||||||
|
log_admin("Roundstart complete in [(get_game_time() - total_tick) / 10] seconds.")
|
||||||
|
message_admins("Roundstart complete in [(get_game_time() - total_tick) / 10] seconds.")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
/mob/living/carbon/human/proc/make_fake_ai()
|
/mob/living/carbon/human/proc/make_fake_ai()
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
// the light switch
|
// the light switch
|
||||||
// can have multiple per area
|
// can have multiple per area
|
||||||
// can also operate on non-loc area through "otherarea" var
|
// can also operate on non-loc area through "otherarea" var
|
||||||
|
|
||||||
|
var/list/obj/machinery/light_switch/lightswitches = list()
|
||||||
|
|
||||||
/obj/machinery/light_switch
|
/obj/machinery/light_switch
|
||||||
name = "light switch"
|
name = "light switch"
|
||||||
desc = "It turns lights on and off. What are you, simple?"
|
desc = "It turns lights on and off. What are you, simple?"
|
||||||
@@ -10,41 +13,37 @@
|
|||||||
var/buildstage = 2
|
var/buildstage = 2
|
||||||
var/on = 0
|
var/on = 0
|
||||||
var/image/overlay
|
var/image/overlay
|
||||||
|
var/area/controlled_area
|
||||||
|
|
||||||
/obj/machinery/light_switch/supports_holomap()
|
/obj/machinery/light_switch/supports_holomap()
|
||||||
return TRUE
|
return TRUE
|
||||||
|
|
||||||
/obj/machinery/light_switch/New(var/loc, var/ndir, var/building = 2)
|
/obj/machinery/light_switch/New(var/loc, var/ndir, var/building = 2)
|
||||||
..()
|
..()
|
||||||
var/area/this_area = get_area(src)
|
controlled_area = get_area(src)
|
||||||
name = "[this_area.name] light switch"
|
name = "[controlled_area.name] light switch"
|
||||||
buildstage = building
|
buildstage = building
|
||||||
this_area.haslightswitch = TRUE
|
controlled_area.haslightswitch = TRUE
|
||||||
|
lightswitches += src
|
||||||
|
controlled_area.lightswitches += src
|
||||||
if(!buildstage)
|
if(!buildstage)
|
||||||
pixel_x = (ndir & 3)? 0 : (ndir == 4 ? 28 * PIXEL_MULTIPLIER: -28 * PIXEL_MULTIPLIER)
|
pixel_x = (ndir & 3)? 0 : (ndir == 4 ? 28 * PIXEL_MULTIPLIER: -28 * PIXEL_MULTIPLIER)
|
||||||
pixel_y = (ndir & 3)? (ndir ==1 ? 28 * PIXEL_MULTIPLIER: -28 * PIXEL_MULTIPLIER) : 0
|
pixel_y = (ndir & 3)? (ndir ==1 ? 28 * PIXEL_MULTIPLIER: -28 * PIXEL_MULTIPLIER) : 0
|
||||||
dir = ndir
|
dir = ndir
|
||||||
updateicon()
|
updateicon()
|
||||||
|
update_moody_light('icons/lighting/moody_lights.dmi', "overlay_lightswitch")
|
||||||
add_self_to_holomap()
|
add_self_to_holomap()
|
||||||
|
|
||||||
/obj/machinery/light_switch/proc/updateicon()
|
/obj/machinery/light_switch/Destroy()
|
||||||
if(!overlay)
|
lightswitches -= src
|
||||||
overlay = image(icon, "light1-overlay")
|
controlled_area.lightswitches -= src
|
||||||
overlay.plane = ABOVE_LIGHTING_PLANE
|
..()
|
||||||
overlay.layer = ABOVE_LIGHTING_LAYER
|
|
||||||
|
|
||||||
overlays.Cut()
|
/obj/machinery/light_switch/proc/updateicon()
|
||||||
if((stat & (FORCEDISABLE|NOPOWER)) || buildstage != 2)
|
if((stat & (FORCEDISABLE|NOPOWER)) || buildstage != 2)
|
||||||
icon_state = "light-p"
|
icon_state = "light-p"
|
||||||
set_light(0)
|
|
||||||
else
|
else
|
||||||
icon_state = on ? "light1" : "light0"
|
icon_state = on ? "light1" : "light0"
|
||||||
overlay.icon_state = "[icon_state]-overlay"
|
|
||||||
overlays += overlay
|
|
||||||
//If the lightswitch itself is in total darkness, even the overlay won't render, so we gotta light up the lightswitch just a tiny bit.
|
|
||||||
//...which, sadly, thanks to goonlights means "oops we have to softlight up the entire 3x3 around the lightswitch because we can't handle one-tile lights anymore"
|
|
||||||
//Maybe vis-contents will bring a more elegant solution when we support them?
|
|
||||||
set_light(1, 0.5, on ? "#82ff4c" : "#f86060")
|
|
||||||
|
|
||||||
/obj/machinery/light_switch/examine(mob/user)
|
/obj/machinery/light_switch/examine(mob/user)
|
||||||
..()
|
..()
|
||||||
@@ -114,28 +113,32 @@
|
|||||||
/obj/machinery/light_switch/attack_hand(mob/user)
|
/obj/machinery/light_switch/attack_hand(mob/user)
|
||||||
toggle_switch()
|
toggle_switch()
|
||||||
|
|
||||||
/obj/machinery/light_switch/proc/toggle_switch(var/newstate = null, var/playsound = TRUE)
|
/obj/machinery/light_switch/proc/toggle_switch(var/newstate = null, var/playsound = TRUE, var/non_instant = TRUE)
|
||||||
if(buildstage != 2)
|
if(on == newstate)
|
||||||
return
|
return
|
||||||
|
|
||||||
if(isnull(newstate))
|
if(isnull(newstate))
|
||||||
on = !on
|
on = !on
|
||||||
else if(on != newstate)
|
|
||||||
on = newstate
|
|
||||||
else
|
else
|
||||||
|
on = newstate
|
||||||
|
|
||||||
|
if(buildstage != 2)
|
||||||
return
|
return
|
||||||
|
|
||||||
if(playsound)
|
if(playsound)
|
||||||
playsound(src,'sound/misc/click.ogg',30,0,-1)
|
playsound(src,'sound/misc/click.ogg',30,0,-1)
|
||||||
|
|
||||||
var/area/this_area = get_area(src)
|
if(controlled_area)
|
||||||
this_area.updateicon()
|
controlled_area.lightswitches -= src
|
||||||
|
controlled_area = get_area(src)
|
||||||
|
controlled_area.lightswitches |= src
|
||||||
|
controlled_area.updateicon()
|
||||||
|
|
||||||
for(var/obj/machinery/light_switch/L in this_area)
|
for(var/obj/machinery/light_switch/L in controlled_area.lightswitches)
|
||||||
L.on = on
|
L.on = on
|
||||||
L.updateicon()
|
L.updateicon()
|
||||||
|
|
||||||
this_area.power_change()
|
for(var/obj/machinery/L2 in controlled_area.lights)
|
||||||
|
L2.power_change(non_instant)
|
||||||
|
|
||||||
/obj/machinery/light_switch/power_change()
|
/obj/machinery/light_switch/power_change()
|
||||||
if(powered(LIGHT))
|
if(powered(LIGHT))
|
||||||
|
|||||||
@@ -242,14 +242,20 @@
|
|||||||
on = onoff
|
on = onoff
|
||||||
update_brightness(playsound = FALSE)
|
update_brightness(playsound = FALSE)
|
||||||
|
|
||||||
|
var/list/obj/item/device/flashlight/lamp/lamps = list()
|
||||||
//Lamps draw power from the area they're in, unlike flashlights.
|
//Lamps draw power from the area they're in, unlike flashlights.
|
||||||
/obj/item/device/flashlight/lamp/New()
|
/obj/item/device/flashlight/lamp/New()
|
||||||
|
lamps += src
|
||||||
if(drawspower)
|
if(drawspower)
|
||||||
pwrconn = new(src)
|
pwrconn = new(src)
|
||||||
pwrconn.channel = LIGHT
|
pwrconn.channel = LIGHT
|
||||||
pwrconn.active_usage = 60 * brightness_on / 5 //power usage scales with brightness
|
pwrconn.active_usage = 60 * brightness_on / 5 //power usage scales with brightness
|
||||||
update_brightness(playsound = FALSE)
|
update_brightness(playsound = FALSE)
|
||||||
|
|
||||||
|
/obj/item/device/flashlight/lamp/Destroy()
|
||||||
|
lamps -= src
|
||||||
|
..()
|
||||||
|
|
||||||
/obj/item/device/flashlight/lamp/update_brightness(var/mob/user = null, var/playsound = TRUE)
|
/obj/item/device/flashlight/lamp/update_brightness(var/mob/user = null, var/playsound = TRUE)
|
||||||
if(drawspower)
|
if(drawspower)
|
||||||
if(on)
|
if(on)
|
||||||
|
|||||||
@@ -863,8 +863,8 @@ var/global/floorIsLava = 0
|
|||||||
<A href='?src=\ref[src];secretsfun=makelink'>Fix the station's link with Central Command</A><BR>
|
<A href='?src=\ref[src];secretsfun=makelink'>Fix the station's link with Central Command</A><BR>
|
||||||
<A href='?src=\ref[src];secretsfun=blackout'>Break all lights</A><BR>
|
<A href='?src=\ref[src];secretsfun=blackout'>Break all lights</A><BR>
|
||||||
<A href='?src=\ref[src];secretsfun=whiteout'>Fix all lights</A><BR>
|
<A href='?src=\ref[src];secretsfun=whiteout'>Fix all lights</A><BR>
|
||||||
<A href='?src=\ref[src];secretsfun=switchoff'>Flip all (ALL Z-LEVELS) light switches to off (Lags briefly)</A><BR>
|
<A href='?src=\ref[src];secretsfun=switchoff'>Flip all (ALL Z-LEVELS) light switches to off</A><BR>
|
||||||
<A href='?src=\ref[src];secretsfun=switchon'>Flip all (ALL Z-LEVELS) light switches to on (Lags briefly)</A><BR>
|
<A href='?src=\ref[src];secretsfun=switchon'>Flip all (ALL Z-LEVELS) light switches to on</A><BR>
|
||||||
<A href='?src=\ref[src];secretsfun=create_artifact'>Create custom artifact</A><BR>
|
<A href='?src=\ref[src];secretsfun=create_artifact'>Create custom artifact</A><BR>
|
||||||
<BR>
|
<BR>
|
||||||
<A href='?src=\ref[src];secretsfun=athfthrowing'>Toggle thrown items exploding on stop</A><BR>
|
<A href='?src=\ref[src];secretsfun=athfthrowing'>Toggle thrown items exploding on stop</A><BR>
|
||||||
|
|||||||
@@ -3572,13 +3572,13 @@
|
|||||||
if("switchoff")
|
if("switchoff")
|
||||||
feedback_inc("admin_secrets_fun_used",1)
|
feedback_inc("admin_secrets_fun_used",1)
|
||||||
feedback_add_details("admin_secrets_fun_used","WO")
|
feedback_add_details("admin_secrets_fun_used","WO")
|
||||||
for(var/obj/machinery/light_switch/LS in all_machines)
|
for(var/obj/machinery/light_switch/LS in lightswitches)
|
||||||
LS.toggle_switch(0)
|
LS.toggle_switch(0)
|
||||||
message_admins("[key_name_admin(usr)] switched off all lights", 1)
|
message_admins("[key_name_admin(usr)] switched off all lights", 1)
|
||||||
if("switchon")
|
if("switchon")
|
||||||
feedback_inc("admin_secrets_fun_used",1)
|
feedback_inc("admin_secrets_fun_used",1)
|
||||||
feedback_add_details("admin_secrets_fun_used","WO")
|
feedback_add_details("admin_secrets_fun_used","WO")
|
||||||
for(var/obj/machinery/light_switch/LS in all_machines)
|
for(var/obj/machinery/light_switch/LS in lightswitches)
|
||||||
LS.toggle_switch(1)
|
LS.toggle_switch(1)
|
||||||
message_admins("[key_name_admin(usr)] switched on all lights", 1)
|
message_admins("[key_name_admin(usr)] switched on all lights", 1)
|
||||||
if("floorlava")
|
if("floorlava")
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ var/global/list/obj/machinery/light/alllights = list()
|
|||||||
var/static_power_used = 0
|
var/static_power_used = 0
|
||||||
var/flickering = 0
|
var/flickering = 0
|
||||||
var/obj/item/weapon/light/current_bulb = null
|
var/obj/item/weapon/light/current_bulb = null
|
||||||
|
var/area/lights_area
|
||||||
var/spawn_with_bulb = /obj/item/weapon/light/tube
|
var/spawn_with_bulb = /obj/item/weapon/light/tube
|
||||||
var/fitting = "tube"
|
var/fitting = "tube"
|
||||||
var/rgb_upgrade = FALSE //add plastic to enable RGB mode
|
var/rgb_upgrade = FALSE //add plastic to enable RGB mode
|
||||||
@@ -154,6 +155,9 @@ var/global/list/obj/machinery/light/alllights = list()
|
|||||||
else
|
else
|
||||||
update(0)
|
update(0)
|
||||||
alllights += src
|
alllights += src
|
||||||
|
lights_area = get_area(src)
|
||||||
|
if(lights_area)
|
||||||
|
lights_area.lights += src
|
||||||
|
|
||||||
if(map.broken_lights)
|
if(map.broken_lights)
|
||||||
switch(fitting)
|
switch(fitting)
|
||||||
@@ -240,6 +244,8 @@ var/global/list/obj/machinery/light/alllights = list()
|
|||||||
seton(0)
|
seton(0)
|
||||||
..()
|
..()
|
||||||
alllights -= src
|
alllights -= src
|
||||||
|
if(lights_area)
|
||||||
|
lights_area.lights -= src
|
||||||
|
|
||||||
/obj/machinery/light/update_icon()
|
/obj/machinery/light/update_icon()
|
||||||
|
|
||||||
@@ -462,7 +468,7 @@ var/global/list/obj/machinery/light/alllights = list()
|
|||||||
return FALSE
|
return FALSE
|
||||||
if(!this_area.haslightswitch || !this_area.requires_power)
|
if(!this_area.haslightswitch || !this_area.requires_power)
|
||||||
return TRUE
|
return TRUE
|
||||||
for(var/obj/machinery/light_switch/L in this_area)
|
for(var/obj/machinery/light_switch/L in this_area.lightswitches)
|
||||||
if(L.on)
|
if(L.on)
|
||||||
success = TRUE
|
success = TRUE
|
||||||
break
|
break
|
||||||
@@ -628,8 +634,8 @@ var/global/list/obj/machinery/light/alllights = list()
|
|||||||
/*
|
/*
|
||||||
* Called when area power state changes.
|
* Called when area power state changes.
|
||||||
*/
|
*/
|
||||||
/obj/machinery/light/power_change()
|
/obj/machinery/light/power_change(var/non_instant = TRUE)
|
||||||
spawn(10)
|
spawn(10 * non_instant)
|
||||||
seton(has_power())
|
seton(has_power())
|
||||||
|
|
||||||
// called when on fire
|
// called when on fire
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ JOBS_HAVE_MINIMAL_ACCESS
|
|||||||
## Remove # here if you wish to have cargo forwards sent always be a set amount (for debugging)
|
## Remove # here if you wish to have cargo forwards sent always be a set amount (for debugging)
|
||||||
#CARGO_FORWARDING_AMOUNT_OVERRIDE 5
|
#CARGO_FORWARDING_AMOUNT_OVERRIDE 5
|
||||||
|
|
||||||
|
## Remove # here if you wish to have all lights on by default at roundstart
|
||||||
|
ROUNDSTART_LIGHTS_ON
|
||||||
|
|
||||||
## (SECURITY RISK ON PUBLIC SERVERS) Automatically give localhost clients +HOST access.
|
## (SECURITY RISK ON PUBLIC SERVERS) Automatically give localhost clients +HOST access.
|
||||||
LOCALHOST_AUTOADMIN
|
LOCALHOST_AUTOADMIN
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 34 KiB |
Reference in New Issue
Block a user