From 8e1affa1f5c477f9753166ca4f5dc15c84699060 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Thu, 2 Jan 2020 23:56:40 -0800 Subject: [PATCH] nightshift changes --- code/__DEFINES/misc.dm | 6 + .../configuration/entries/game_options.dm | 9 ++ code/controllers/subsystem/nightshift.dm | 8 +- code/game/area/Space_Station_13_areas.dm | 17 +++ code/game/area/areas.dm | 2 + code/modules/power/apc.dm | 140 ++++++++++-------- config/game_options.txt | 11 +- 7 files changed, 128 insertions(+), 65 deletions(-) diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index d89743d2d2..502e1b5edf 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -530,3 +530,9 @@ GLOBAL_LIST_INIT(pda_reskins, list(PDA_SKIN_CLASSIC = 'icons/obj/pda.dmi', PDA_S #define CRYOMOBS 'icons/obj/cryo_mobs.dmi' #define CANT_REENTER_ROUND -1 + +//Nightshift levels. +#define NIGHTSHIFT_AREA_NONE 0 //default +#define NIGHTSHIFT_AREA_PUBLIC 1 //hallways +#define NIGHTSHIFT_AREA_RECREATION 2 //dorms common areas, etc +#define NIGHTSHIFT_AREA_DEPARTMENT_HALLS 3 //interior hallways, etc diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index 61b5788ef8..7ddc9095ee 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -362,6 +362,15 @@ /datum/config_entry/flag/enable_night_shifts +/datum/config_entry/number/night_shift_public_areas_only + config_entry_value = NIGHTSHIFT_AREA_PUBLIC + +/datum/config_entry/flag/nightshift_toggle_requires_auth + config_entry_value = FALSE + +/datum/config_entry/flag/nightshift_toggle_public_requires_auth + config_entry_value = TRUE + /datum/config_entry/flag/randomize_shift_time /datum/config_entry/flag/shift_time_realtime diff --git a/code/controllers/subsystem/nightshift.dm b/code/controllers/subsystem/nightshift.dm index df406eed3c..6ce8704655 100644 --- a/code/controllers/subsystem/nightshift.dm +++ b/code/controllers/subsystem/nightshift.dm @@ -35,21 +35,21 @@ SUBSYSTEM_DEF(nightshift) if(!emergency) announce("Restoring night lighting configuration to normal operation.") else - announce("Disabling night lighting: Station is in a state of emergency.") + announce("Disabling night lighting: Station is in a state of emergency.") if(emergency) night_time = FALSE if(nightshift_active != night_time) update_nightshift(night_time, announcing) -/datum/controller/subsystem/nightshift/proc/update_nightshift(active, announce = TRUE) +/datum/controller/subsystem/nightshift/proc/update_nightshift(active, announce = TRUE, max_level = (!active? INFINITY : CONFIG_GET(number/night_shift_public_area_only))) nightshift_active = active if(announce) if (active) announce("Good evening, crew. To reduce power consumption and stimulate the circadian rhythms of some species, all of the lights aboard the station have been dimmed for the night.") else - announce("Good morning, crew. As it is now day time, all of the lights aboard the station have been restored to their former brightness.") + var/public_only = CONFIG_GET(number/night_shift_public_area_only) for(var/A in GLOB.apcs_list) var/obj/machinery/power/apc/APC = A - if (APC.area && (APC.area.type in GLOB.the_station_areas)) + if(APC.area && (!max_level || !APC.area.nightshift_public_area || (APC.area.nightshift_public_area <= max_level)) && (APC.area.type in GLOB.the_station_areas)) APC.set_nightshift(active) CHECK_TICK diff --git a/code/game/area/Space_Station_13_areas.dm b/code/game/area/Space_Station_13_areas.dm index fa66306302..4cfbc7366f 100644 --- a/code/game/area/Space_Station_13_areas.dm +++ b/code/game/area/Space_Station_13_areas.dm @@ -259,6 +259,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station //Hallway +/area/hallway + nightshift_public_area = NIGHTSHIFT_AREA_PUBLIC + /area/hallway/primary/aft name = "Aft Primary Hallway" icon_state = "hallA" @@ -404,14 +407,17 @@ NOTE: there are two lists of areas in the end of this file: centcom and station name = "Dormitories" icon_state = "Sleep" safe = TRUE + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/crew_quarters/dorms/male name = "Male Dorm" icon_state = "Sleep" + nightshift_public_area = NIGHTSHIFT_AREA_NONE /area/crew_quarters/dorms/female name = "Female Dorm" icon_state = "Sleep" + nightshift_public_area = NIGHTSHIFT_AREA_NONE /area/crew_quarters/rehab_dome name = "Rehabilitation Dome" @@ -448,26 +454,32 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/crew_quarters/locker name = "Locker Room" icon_state = "locker" + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/crew_quarters/lounge name = "Lounge" icon_state = "yellow" + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/crew_quarters/fitness name = "Fitness Room" icon_state = "fitness" + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/crew_quarters/fitness/recreation name = "Recreation Area" icon_state = "fitness" + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/crew_quarters/cafeteria name = "Cafeteria" icon_state = "cafeteria" + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/crew_quarters/cafeteria/lunchroom name = "Lunchroom" icon_state = "cafeteria" + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/crew_quarters/kitchen name = "Kitchen" @@ -480,6 +492,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/crew_quarters/bar name = "Bar" icon_state = "bar" + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/crew_quarters/bar/atrium name = "Atrium" @@ -518,6 +531,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station name = "Library" icon_state = "library" flags_1 = NONE + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/library/lounge name = "Library Lounge" @@ -527,6 +541,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station name = "Abandoned Library" icon_state = "library" flags_1 = NONE + nightshift_public_area = NIGHTSHIFT_AREA_NONE /area/chapel icon_state = "chapel" @@ -534,12 +549,14 @@ NOTE: there are two lists of areas in the end of this file: centcom and station flags_1 = NONE clockwork_warp_allowed = FALSE clockwork_warp_fail = "The consecration here prevents you from warping in." + nightshift_public_area = NIGHTSHIFT_AREA_RECREATION /area/chapel/main name = "Chapel" /area/chapel/main/monastery name = "Monastery" + nightshift_public_area = NIGHTSHIFT_AREA_NONE /area/chapel/office name = "Chapel Office" diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index f65ea98cab..2d256aad27 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -63,6 +63,8 @@ var/xenobiology_compatible = FALSE //Can the Xenobio management console transverse this area by default? var/list/canSmoothWithAreas //typecache to limit the areas that atoms in this area can smooth with + var/nightshift_public_area = NIGHTSHIFT_AREA_NONE //considered a public area for nightshift + /*Adding a wizard area teleport list because motherfucking lag -- Urist*/ /*I am far too lazy to make it a proper list of areas so I'll just make it run the usual telepot routine at the start of the game*/ GLOBAL_LIST_EMPTY(teleportlocs) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 2652026a11..5f51a87f80 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -98,6 +98,7 @@ var/force_update = 0 var/emergency_lights = FALSE var/nightshift_lights = FALSE + var/nightshift_requires_auth = FALSE var/last_nightshift_switch = 0 var/update_state = -1 var/update_overlay = -1 @@ -239,6 +240,7 @@ update_icon() make_terminal() + update_nightshift_auth_requirement() addtimer(CALLBACK(src, .proc/update), 5) @@ -806,6 +808,7 @@ /obj/machinery/power/apc/ui_data(mob/user) var/list/data = list( "locked" = locked && !(integration_cog && is_servant_of_ratvar(user)), + "lock_nightshift" = nightshift_requires_auth, "failTime" = failure_timer, "isOperating" = operating, "externalPower" = main_status, @@ -913,70 +916,73 @@ . = UI_INTERACTIVE /obj/machinery/power/apc/ui_act(action, params) - if(..() || !can_use(usr, 1) || (locked && !usr.has_unlimited_silicon_privilege && !failure_timer && !(integration_cog && (is_servant_of_ratvar(usr))))) + if(..() || !can_use(usr, 1)) return - switch(action) - if("lock") - if(usr.has_unlimited_silicon_privilege) - if((obj_flags & EMAGGED) || (stat & (BROKEN|MAINT))) - to_chat(usr, "The APC does not respond to the command.") - else - locked = !locked - update_icon() - . = TRUE - if("cover") - coverlocked = !coverlocked - . = TRUE - if("breaker") - toggle_breaker() - . = TRUE - if("toggle_nightshift") - toggle_nightshift_lights() - . = TRUE - if("charge") - chargemode = !chargemode - if(!chargemode) - charging = APC_NOT_CHARGING - update_icon() - . = TRUE - if("channel") - if(params["eqp"]) - equipment = setsubsystem(text2num(params["eqp"])) - update_icon() - update() - else if(params["lgt"]) - lighting = setsubsystem(text2num(params["lgt"])) - update_icon() - update() - else if(params["env"]) - environ = setsubsystem(text2num(params["env"])) - update_icon() - update() - . = TRUE - if("overload") - if(usr.has_unlimited_silicon_privilege) - overload_lighting() - . = TRUE - if("hack") - if(get_malf_status(usr)) - malfhack(usr) - if("occupy") - if(get_malf_status(usr)) - malfoccupy(usr) - if("deoccupy") - if(get_malf_status(usr)) - malfvacate() - if("reboot") + if(failure_timer) + if(action == "reboot") failure_timer = 0 update_icon() update() - if("emergency_lighting") - emergency_lights = !emergency_lights - for(var/obj/machinery/light/L in area) - if(!initial(L.no_emergency)) //If there was an override set on creation, keep that override - L.no_emergency = emergency_lights - INVOKE_ASYNC(L, /obj/machinery/light/.proc/update, FALSE) - CHECK_TICK + var/authorized = (!locked || !usr.has_unlimited_silicon_privilege || failure_timer || (integration_cog && (is_servant_of_ratvar(usr)))) + if((action == "toggle_nightshift") && (!nightshift_requires_auth || authorized)) + toggle_nightshift_lights() + . = TRUE + if(authorized) + switch(action) + if("lock") + if(usr.has_unlimited_silicon_privilege) + if((obj_flags & EMAGGED) || (stat & (BROKEN|MAINT))) + to_chat(usr, "The APC does not respond to the command.") + else + locked = !locked + update_icon() + . = TRUE + if("cover") + coverlocked = !coverlocked + . = TRUE + if("breaker") + toggle_breaker() + . = TRUE + if("charge") + chargemode = !chargemode + if(!chargemode) + charging = APC_NOT_CHARGING + update_icon() + . = TRUE + if("channel") + if(params["eqp"]) + equipment = setsubsystem(text2num(params["eqp"])) + update_icon() + update() + else if(params["lgt"]) + lighting = setsubsystem(text2num(params["lgt"])) + update_icon() + update() + else if(params["env"]) + environ = setsubsystem(text2num(params["env"])) + update_icon() + update() + . = TRUE + if("overload") + if(usr.has_unlimited_silicon_privilege) + overload_lighting() + . = TRUE + if("hack") + if(get_malf_status(usr)) + malfhack(usr) + if("occupy") + if(get_malf_status(usr)) + malfoccupy(usr) + if("deoccupy") + if(get_malf_status(usr)) + malfvacate() + if("emergency_lighting") + emergency_lights = !emergency_lights + for(var/obj/machinery/light/L in area) + if(!initial(L.no_emergency)) //If there was an override set on creation, keep that override + L.no_emergency = emergency_lights + INVOKE_ASYNC(L, /obj/machinery/light/.proc/update, FALSE) + CHECK_TICK return 1 /obj/machinery/power/apc/proc/toggle_breaker() @@ -1383,6 +1389,8 @@ /obj/machinery/power/apc/proc/set_nightshift(on) set waitfor = FALSE + if(nightshift_lights == on) + return nightshift_lights = on for(var/obj/machinery/light/L in area) if(L.nightshift_allowed) @@ -1390,6 +1398,18 @@ L.update(FALSE) CHECK_TICK +/obj/machinery/power/apc/proc/update_nightshift_auth_requirement() + nightshift_requires_auth = nightshift_toggle_requires_auth() + +/obj/machinery/power/apc/proc/nightshift_toggle_requires_auth() + if(!area) + return FALSE + var/configured_level = CONFIG_GET(number/nightshift_public_areas_only) + var/our_level = area.nightshift_public_area + var/public_requires_auth = CONFIG_GET(flag/nightshift_toggle_public_requires_auth) + var/normal_requires_auth = CONFIG_GET(flag/nightshift_toggle_requires_auth) + return (configured_level && our_level && (our_level <= configured_level))? public_requires_auth : normal_requires_auth) + #undef UPSTATE_CELL_IN #undef UPSTATE_OPENED1 #undef UPSTATE_OPENED2 diff --git a/config/game_options.txt b/config/game_options.txt index 34c8ca48fd..24d3baadd5 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -560,6 +560,15 @@ ROUNDSTART_TRAITS ## Enable night shifts ## #ENABLE_NIGHT_SHIFTS +## Makes night shifts only affect in-code public-flagged areas. Nightshifts hit the level as defined in __DEFINES/misc.dm that this is set to and anything below. ## +NIGHT_SHIFT_PUBLIC_AREAS_ONLY 1 + +## Nightshift toggles REQUIRE APC authorization ## +#NIGHTSHIFT_TOGGLE_REQUIRES_AUTH + +## Nightshift toggles in public areas REQUIRE APC authorization ## +NIGHTSHIFT_TOGGLE_PUBLIC_REQUIRES_AUTH + ## Enable randomized shift start times## #RANDOMIZE_SHIFT_TIME @@ -578,4 +587,4 @@ DYNAMIC_VOTING ## Choose which Engine to start the round with, comment to remove an Engine from the rotation BOX_RANDOM_ENGINE Engine SM BOX_RANDOM_ENGINE Engine Tesla -BOX_RANDOM_ENGINE Engine Singulo \ No newline at end of file +BOX_RANDOM_ENGINE Engine Singulo