diff --git a/citadel.dme b/citadel.dme index ecbcfbf7797..61a19ccbc11 100644 --- a/citadel.dme +++ b/citadel.dme @@ -238,6 +238,7 @@ #include "code\__DEFINES\mining\legacy.dm" #include "code\__DEFINES\misc\attack_animations.dm" #include "code\__DEFINES\misc\message_ranges.dm" +#include "code\__DEFINES\misc\nightshift.dm" #include "code\__DEFINES\mobs\actions.dm" #include "code\__DEFINES\mobs\characteristics.dm" #include "code\__DEFINES\mobs\grab.dm" diff --git a/code/__DEFINES/color/lights.dm b/code/__DEFINES/color/lights.dm index 66f715b6b35..781628408b0 100644 --- a/code/__DEFINES/color/lights.dm +++ b/code/__DEFINES/color/lights.dm @@ -1,4 +1,6 @@ -//Some defines to generalise colours used in lighting. +//* Some defines to generalise colours used in lighting. +//* This file also contains powers/ranges, because power really does matter for lighting. + //! ## GENERAL COLORS //? Important note on colors. Colors can end up significantly different from the basic html picture, especially when saturated! #define LIGHT_COLOR_WHITE "#FFFFFF" // rgb(255, 255, 255) Pure white. @@ -34,4 +36,13 @@ #define LIGHT_COLOR_INCANDESCENT_TUBE "#E0EFF0" // rgb(224, 239, 240) Slightly blueish white. #define LIGHT_COLOR_INCANDESCENT_BULB "#FFFEB8" // rgb(255, 254, 184) Slightly yellowish white. #define LIGHT_COLOR_INCANDESCENT_FLASHLIGHT "#FFCC66" // rgb(255, 204, 102) Slightly yellowish white. -#define LIGHT_COLOR_NIGHTSHIFT "#616191" // rgb(97, 97, 145) Dark blue. + +/// Nightshift Light Color +/// Used on full-strength light tubes. +#define LIGHT_COLOR_NIGHTSHIFT "#c7c7ff" +/// Nightshift Light Power +/// Used on full-strength light tubes. +#define LIGHT_POWER_NIGHTSHIFT 0.435 +/// Nightshift Light Range +/// Used on full-strength light tubes. +#define LIGHT_RANGE_NIGHTSHIFT 7 diff --git a/code/__DEFINES/misc/nightshift.dm b/code/__DEFINES/misc/nightshift.dm new file mode 100644 index 00000000000..339b7008edd --- /dev/null +++ b/code/__DEFINES/misc/nightshift.dm @@ -0,0 +1,32 @@ +//* This file is explicitly licensed under the MIT license. *// +//* Copyright (c) 2023 Citadel Station developers. *// + +//* nightshift flags + +#define NIGHTSHIFT_LEVEL_UNSET (1<<0) + +#define NIGHTSHIFT_LEVEL_PUBLIC_HALLWAYS (1<<1) +#define NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES (1<<2) + +#define NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS (1<<3) +#define NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES (1<<4) +#define NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE (1<<5) +#define NIGHTSHIFT_LEVEL_DEPARTMENT_LEISURE (1<<6) + +#define NIGHTSHIFT_LEVEL_COMMAND_HALLWAYS (1<<7) +#define NIGHTSHIFT_LEVEL_COMMAND_FACILITIES (1<<8) +#define NIGHTSHIFT_LEVEL_COMMAND_SENSITIVE (1<<9) + +//* Do not randomly change this, it is used for configuration. *// +DEFINE_BITFIELD(nightshift_level, list( + BITFIELD_NAMED("Unset", NIGHTSHIFT_LEVEL_UNSET), + BITFIELD_NAMED("PublicHalls", NIGHTSHIFT_LEVEL_PUBLIC_HALLWAYS), + BITFIELD_NAMED("PublicAreas", NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES), + BITFIELD_NAMED("DepartmentHalls", NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS), + BITFIELD_NAMED("DepartmentAreas", NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES), + BITFIELD_NAMED("DepartmentSecure", NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE), + BITFIELD_NAMED("DepartmentLeisure", NIGHTSHIFT_LEVEL_DEPARTMENT_LEISURE), + BITFIELD_NAMED("CommandHalls", NIGHTSHIFT_LEVEL_COMMAND_HALLWAYS), + BITFIELD_NAMED("CommandAreas", NIGHTSHIFT_LEVEL_COMMAND_FACILITIES), + BITFIELD_NAMED("CommandSecure", NIGHTSHIFT_LEVEL_COMMAND_SENSITIVE), +)) diff --git a/code/__HELPERS/datastructs/priority_queue.dm b/code/__HELPERS/datastructs/priority_queue.dm index 7c43fe02cbb..a77f218a04a 100644 --- a/code/__HELPERS/datastructs/priority_queue.dm +++ b/code/__HELPERS/datastructs/priority_queue.dm @@ -1,66 +1,89 @@ +//* This file is explicitly licensed under the MIT license. *// +//* Copyright (c) 2023 Citadel Station developers. *// + /** - * array-backed priority heap + * An array-backed priority queue. * - * not written in house, cloned from oldish polaris/bay (?) + * The "front" of the queue is popped first; check comparators.dm for what this means. */ /datum/priority_queue - var/list/queue - var/comparison_function + /// comparaison function + var/procpath/comparison + /// internal array + var/list/array = list() -/datum/priority_queue/New(compare) - queue = list() - comparison_function = compare +/datum/priority_queue/New(cmp) + src.comparison = cmp + array = list() /datum/priority_queue/proc/is_empty() - return !queue.len - -/datum/priority_queue/proc/enqueue(data) - queue.Add(data) - var/index = queue.len + return length(array) == 0 - //From what I can tell, this automagically sorts the added data into the correct location. - while(index > 2 && call(comparison_function)(queue[index / 2], queue[index]) > 0) - queue.Swap(index, index / 2) - index /= 2 +/datum/priority_queue/proc/enqueue(entry) + array += entry + bubble_up(length(array)) /datum/priority_queue/proc/dequeue() - if(!queue.len) - return 0 - return remove(1) + if(length(array) == 0) + return null + . = array[1] + array.Swap(1, length(array)) + --array.len + bubble_down(1) -/datum/priority_queue/proc/remove(index) - if(index > queue.len) - return 0 +/datum/priority_queue/proc/peek() + return length(array)? array[1] : null - var/thing = queue[index] - queue.Swap(index, queue.len) - --queue.len - if(index < queue.len) - fix_queue(index) - return thing - -/datum/priority_queue/proc/fix_queue(index) - var/child = 2 * index - var/item = queue[index] +// todo: define this +/datum/priority_queue/proc/bubble_up(index) + while(index >= 2 && call(comparison)(array[index], array[index / 2]) < 0) + array.Swap(index, index / 2) + index /= 2 - while(child <= queue.len) - if(child < queue.len && call(comparison_function)(queue[child], queue[child + 1]) > 0) - child++ - if(call(comparison_function)(item, queue[child]) > 0) - queue[index] = queue[child] - index = child +// todo: define this +/datum/priority_queue/proc/bubble_down(index) + var/length = length(array) + var/next = index * 2 + while(next <= length) + // left always exists, right doesn't necessarily exist + if(call(comparison)(array[next], array[index]) < 0) + if(next < length && call(comparison)(array[next], array[next + 1]) > 0) + array.Swap(index, next + 1) + index = next + 1 + else + array.Swap(index, next) + index = next + else if(next < length && call(comparison)(array[next + 1], array[index]) < 0) + array.Swap(index, next + 1) + index = next + 1 else break - child = 2 * index - queue[index] = item + next = index * 2 -/datum/priority_queue/proc/clone_list() - return queue.Copy() +/** + * returns copy of list of entries in no particular order + */ +/datum/priority_queue/proc/flattened() + return array.Copy() -/datum/priority_queue/proc/size() - return queue.len +/datum/priority_queue/proc/remove_index(index) + var/length = length(array) + if(!index || index > length) + return + if(index == length) + . = array[index] + --array.len + return + . = array[index] + array.Swap(index, length) + --array.len + bubble_down(index) + +/datum/priority_queue/proc/find(entry) + return array.Find(entry) -/datum/priority_queue/proc/remove_item(data) - var/index = queue.Find(data) - if(index) - return remove(index) +/datum/priority_queue/proc/remove_entry(entry) + return remove_index(array.Find(entry)) + +/datum/priority_queue/proc/size() + return length(array) diff --git a/code/__HELPERS/graphs/astar.dm b/code/__HELPERS/graphs/astar.dm index d851edea14f..1a0079c465e 100644 --- a/code/__HELPERS/graphs/astar.dm +++ b/code/__HELPERS/graphs/astar.dm @@ -114,7 +114,7 @@ var/datum/graph_astar_node/target = path_node_by_position[datum] if(target.best_estimated_cost) if(best_estimated_cost + call(datum, dist)(end) < target.best_estimated_cost) - open.remove_item(target) + open.remove_entry(target) else continue @@ -122,7 +122,7 @@ path_node_by_position[datum] = next_node open.enqueue(next_node) - if(max_nodes && length(open.queue) > max_nodes) - open.remove(length(open.queue)) + if(max_nodes && length(open.array) > max_nodes) + open.remove_index(length(open.array)) return path diff --git a/code/__HELPERS/pathfinding/astar.dm b/code/__HELPERS/pathfinding/astar.dm index 8de65a3f5ca..901fb35ae76 100644 --- a/code/__HELPERS/pathfinding/astar.dm +++ b/code/__HELPERS/pathfinding/astar.dm @@ -176,7 +176,7 @@ GLOBAL_VAR_INIT(astar_visualization_persist, 3 SECONDS) start.color = ASTAR_VISUAL_COLOR_OPEN #endif - while(length(open.queue)) + while(length(open.array)) // get best node var/datum/astar_node/top = open.dequeue() current = top.pos @@ -231,7 +231,7 @@ GLOBAL_VAR_INIT(astar_visualization_persist, 3 SECONDS) turfs_got_colored[top.pos] = TRUE #endif - if(length(open.queue) > ASTAR_SANE_NODE_LIMIT) + if(length(open.array) > ASTAR_SANE_NODE_LIMIT) #ifdef ASTAR_DEBUGGING astar_wipe_colors_after(turfs_got_colored, GLOB.astar_visualization_persist) #endif diff --git a/code/__HELPERS/pathfinding/jps.dm b/code/__HELPERS/pathfinding/jps.dm index 75f7bbdb584..9e1cdb51474 100644 --- a/code/__HELPERS/pathfinding/jps.dm +++ b/code/__HELPERS/pathfinding/jps.dm @@ -406,7 +406,7 @@ GLOBAL_VAR_INIT(jps_visualization_resolve, TRUE) while(TRUE); #endif //* loop - while(length(open.queue)) + while(length(open.array)) node_top = open.dequeue() node_top_pos = node_top.pos #ifdef JPS_DEBUGGING diff --git a/code/__HELPERS/sorts/comparators.dm b/code/__HELPERS/sorts/comparators.dm index 6e3134a538e..0214226acb5 100644 --- a/code/__HELPERS/sorts/comparators.dm +++ b/code/__HELPERS/sorts/comparators.dm @@ -1,6 +1,10 @@ /** * Comparators for use with /datum/sort_instance (or wherever you want) - * They should return negative, zero, or positive numbers for a < b, a == b, and a > b respectively. + * + * They should return negative, zero, or positive numbers for a < b, a == b, and a > b respectively, where + * * neg : a < b = "a should be in front of b", + * * zero: a == b = "a and b are equivalent" + * * pos : a > b = "a should be behind b" */ //! Standard Sort diff --git a/code/controllers/configuration/config_entry.dm b/code/controllers/configuration/config_entry.dm index c8b2cdd3f9f..8c571111df7 100644 --- a/code/controllers/configuration/config_entry.dm +++ b/code/controllers/configuration/config_entry.dm @@ -224,7 +224,7 @@ continue_check_key = ispath(new_key) switch(value_mode) if(VALUE_MODE_FLAG) - new_value = TRUE + new_value = text2num(key_value) != 0 && lowertext(key_value) != "false" continue_check_value = TRUE if(VALUE_MODE_NUM) new_value = text2num(key_value) diff --git a/code/controllers/configuration/entries/game.dm b/code/controllers/configuration/entries/game.dm index 549ab14ca68..3da3132bf9c 100644 --- a/code/controllers/configuration/entries/game.dm +++ b/code/controllers/configuration/entries/game.dm @@ -37,9 +37,6 @@ /datum/config_entry/flag/allow_holidays default = TRUE -/datum/config_entry/flag/nightshifts_enabled - default = TRUE - /datum/config_entry/string/alert_desc_green default = "All threats to the station have passed. Security may not have weapons visible, privacy laws are once again fully enforced." @@ -81,3 +78,34 @@ /datum/config_entry/flag/almost_everyone_has_maintenance_access default = TRUE + +//* Nightshifts *// + +/datum/config_entry/flag/nightshifts_enabled + default = TRUE + +/datum/config_entry/keyed_list/nightshift_levels + default = list( + "Unset", + "PublicHalls", + "PublicAreas", + "DepartmentHalls", + "DepartmentLeisure", + "CommandHalls", + ) + lowercase = FALSE + key_mode = KEY_MODE_TEXT + value_mode = VALUE_MODE_FLAG + +/datum/config_entry/keyed_list/nightshift_levels/ValidateAndSet(str_val) + . = ..() + if(!.) + return + var/datum/bitfield/single/target_bitfield = /datum/bitfield/single/nightshift_level + var/target_bitname = initial(target_bitfield.variable) + var/list/actual_bitfield = GLOB.bitfields[target_bitname] + var/new_flags = NONE + for(var/key in config_entry_value) + if(config_entry_value[key]) + new_flags |= actual_bitfield[key] + SSnightshift.nightshift_level = new_flags diff --git a/code/controllers/subsystem/nightshift.dm b/code/controllers/subsystem/nightshift.dm index 8696aa14806..7321979537b 100644 --- a/code/controllers/subsystem/nightshift.dm +++ b/code/controllers/subsystem/nightshift.dm @@ -5,6 +5,11 @@ SUBSYSTEM_DEF(nightshift) wait = 60 SECONDS subsystem_flags = SS_NO_TICK_CHECK + /// Set from configuration - enabled nightshift flags. + var/nightshift_level = NONE + + //! legacy below + var/nightshift_active = FALSE var/nightshift_start_time = 19 HOURS + 30 MINUTES //7:30 PM, station time var/nightshift_end_time = 7 HOURS + 30 MINUTES //7:30 AM, station time @@ -64,7 +69,7 @@ SUBSYSTEM_DEF(nightshift) for(var/obj/machinery/power/apc/apc in GLOB.apcs) if(apc.z in (LEGACY_MAP_DATUM).station_levels) - apc.set_nightshift(active, TRUE) + apc.set_nightshift(active && (apc.area.nightshift_level & nightshift_level), TRUE) CHECK_TICK SSlighting.resume_instant() diff --git a/code/game/area/Space Station 13 areas.dm b/code/game/area/Space Station 13 areas.dm index 3498b98848f..7b83d56f66d 100644 --- a/code/game/area/Space Station 13 areas.dm +++ b/code/game/area/Space Station 13 areas.dm @@ -33,6 +33,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station ambience = AMBIENCE_SPACE area_flags = AREA_FLAG_EXTERNAL is_outside = OUTSIDE_YES + nightshift_level = NONE /area/space/atmosalert() return @@ -1113,6 +1114,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/hallway/primary/ sound_env = LARGE_ENCLOSED ambience = AMBIENCE_GENERIC + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_HALLWAYS /area/hallway/primary/fore name = "\improper Fore Primary Hallway" @@ -1146,6 +1148,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station name = "\improper Central Primary Hallway - Port" icon_state = "hallC4" +/area/hallway/secondary + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_HALLWAYS + /area/hallway/secondary/exit name = "\improper Escape Shuttle Hallway" icon_state = "escape" @@ -1291,63 +1296,77 @@ NOTE: there are two lists of areas in the end of this file: centcom and station name = "Bridge" icon_state = "bridge" music = "signal" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/bridge/bridge_hallway name = "Bridge Hallway" icon_state = "bridge" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_HALLWAYS /area/bridge/meeting_room name = "Heads of Staff Meeting Room" icon_state = "bridge" music = null sound_env = MEDIUM_SOFTFLOOR + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/bridge/office name = "Official On-Site Office" icon_state = "bridge" music = null sound_env = MEDIUM_SOFTFLOOR + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/bridge/hop_office name = "Head Of Personal Office" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/triumph/station/public_meeting_room name = "Public Meeting Room" icon_state = "blue" sound_env = SMALL_SOFTFLOOR + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/crew_quarters/captain name = "Command - Facility Director's Office" icon_state = "captain" sound_env = MEDIUM_SOFTFLOOR + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/crew_quarters/heads/hop name = "Command - HoP's Office" icon_state = "head_quarters" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/crew_quarters/heads/blueshield name = "Command - Blueshield's Office" icon_state = "head_quarters" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/crew_quarters/heads/hor name = "Research - RD's Office" icon_state = "head_quarters" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/crew_quarters/heads/chief name = "Engineering - CE's Office" icon_state = "head_quarters" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/crew_quarters/heads/hos name = "Security - HoS' Office" icon_state = "head_quarters" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/crew_quarters/heads/cmo name = "Medbay - CMO's Office" icon_state = "head_quarters" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_FACILITIES /area/crew_quarters/courtroom name = "Courtroom" icon_state = "courtroom" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/mint name = "Mint" @@ -1368,6 +1387,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station icon_state = "crew_quarters" area_flags = AREA_RAD_SHIELDED ambience = AMBIENCE_GENERIC + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/crew_quarters/toilet name = "Dormitory Toilets" @@ -1652,6 +1672,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/crew_quarters/recreation_area_hallway name = "\improper Recreation Area Hallway" icon_state = "recreation_area_hallway" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_HALLWAYS /area/crew_quarters/recreation_area_restroom name = "\improper Recreation Area Restroom" @@ -1895,6 +1916,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station name = "\improper Engineering" icon_state = "engineering" ambience = AMBIENCE_ENGINEERING + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/engineering/shield_gen name = "\improper Shield Generation" @@ -1905,6 +1927,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station icon_state = "atmos" sound_env = LARGE_ENCLOSED ambience = AMBIENCE_ATMOS + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/engineering/atmos/backup name = "\improper Backup Atmospherics" @@ -1918,48 +1941,59 @@ NOTE: there are two lists of areas in the end of this file: centcom and station name = "\improper Atmospherics Storage" icon_state = "atmos_storage" sound_env = SMALL_ENCLOSED + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/engineering/atmos/processing name = "Atmospherics Processing" icon_state = "atmos" sound_env = LARGE_ENCLOSED + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/engineering/atmos/intake name = "\improper Atmospherics Intake" icon_state = "atmos" sound_env = MOUNTAINS + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/engineering/atmos/hallway name = "\improper Atmospherics Main Hallway" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/engineering/atmos/locker_room name = "\improper Engineering Atmos Locker Room" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/engineering/atmos/eva name = "\improper Engineering Atmos EVA" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/engineering/drone_fabrication name = "\improper Engineering Drone Fabrication" icon_state = "drone_fab" sound_env = SMALL_ENCLOSED + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/engineering/engine_smes name = "\improper Engineering SMES" icon_state = "engine_smes" sound_env = SMALL_ENCLOSED + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/engineering/engine_room name = "\improper Engine Room" icon_state = "engine" sound_env = LARGE_ENCLOSED + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/engineering/engine_airlock name = "\improper Engine Room Airlock" icon_state = "engine" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/engineering/engine_monitoring name = "\improper Engine Monitoring Room" icon_state = "engine_monitoring" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/engineering/engine_waste name = "\improper Engine Waste Handling" @@ -1972,6 +2006,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/engineering/foyer name = "\improper Engineering Foyer" icon_state = "engineering_foyer" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/engineering/foyer/lower name = "\improper Lower Enginering Foyer" @@ -2054,6 +2089,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station requires_power = 1 always_unpowered = 1 ambience = AMBIENCE_SPACE + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/solar/auxport name = "\improper Fore Port Solar Array" @@ -2157,10 +2193,12 @@ NOTE: there are two lists of areas in the end of this file: centcom and station name = "\improper Medical" icon_state = "medbay" music = 'sound/ambience/signal.ogg' + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/medical/medbay name = "\improper Medbay Hallway - Port" icon_state = "medbay" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/medical/resleeving name = "Resleeving Lab" @@ -2170,14 +2208,17 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/medical/medbay2 name = "\improper Medbay Hallway - Starboard" icon_state = "medbay2" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/medical/medbay3 name = "\improper Medbay Hallway - Fore" icon_state = "medbay3" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/medical/medbay4 name = "\improper Medbay Hallway - Aft" icon_state = "medbay4" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/medical/biostorage name = "\improper Secondary Storage" @@ -2186,6 +2227,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/medical/reception name = "\improper Medbay Reception" icon_state = "medbay" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/medical/medbay_emt_bay name = "\improper Medical EMT Bay" @@ -2351,10 +2393,12 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/medical/first_aid_station_starboard name = "\improper Starboard First-Aid Station" icon_state = "medbay2" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/medical/first_aid_station name = "\improper Port First-Aid Station" icon_state = "medbay2" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/medical/psych_ward name = "\improper Psych Ward" @@ -2362,13 +2406,18 @@ NOTE: there are two lists of areas in the end of this file: centcom and station //Security +/area/security + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES + /area/security/main name = "\improper Security Office" icon_state = "security" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/security/lobby name = "\improper Security Lobby" icon_state = "security" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/security/brig name = "\improper Security - Brig" @@ -2403,6 +2452,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station icon_state = "armory" ambience = AMBIENCE_HIGHSEC area_flags = AREA_FLAG_BLUE_SHIELDED + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/security/briefing_room name = "\improper Security - Briefing Room" @@ -2423,6 +2473,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/security/riot_control name = "\improper Security - Riot Control" icon_state = "riot_control" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/security/detectives_office name = "\improper Security - Forensic Office" @@ -2479,6 +2530,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/security/breakroom name = "\improper Security Breakroom" icon_state = "security" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_LEISURE /area/security/brig/visitation name = "\improper Visitation" @@ -2519,7 +2571,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/security/visitor name = "\improper Security Visitor Room" icon_state = "security" - + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /* New() @@ -2602,14 +2654,17 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/quartermaster name = "\improper Quartermasters" icon_state = "quart" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/quartermaster/hallway name = "\improper Cargo Hallway" icon_state = "quart" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/quartermaster/office name = "\improper Cargo Office" icon_state = "quartoffice" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/quartermaster/storage name = "\improper Cargo Bay" @@ -2619,6 +2674,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/quartermaster/foyer name = "\improper Cargo Bay Foyer" icon_state = "quartstorage" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/quartermaster/warehouse name = "\improper Cargo Warehouse" @@ -2648,6 +2704,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station // SCIENCE +/area/rnd + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES + /area/rnd/research name = "\improper Research and Development" icon_state = "research" @@ -2655,15 +2714,18 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/rnd/research_foyer name = "\improper Research Foyer" icon_state = "research_foyer" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/rnd/research_foyer_auxiliary name = "\improper Research Foyer Auxiliary" icon_state = "research_foyer_aux" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/rnd/research_restroom name = "\improper Research Restroom" icon_state = "research_restroom" sound_env = SMALL_ENCLOSED + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_LEISURE /area/rnd/research_storage name = "\improper Research Storage" @@ -2731,10 +2793,12 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/rnd/outpost name = "\improper Research Outpost Hallway" icon_state = "research" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/rnd/breakroom name = "\improper Research Break Room" icon_state = "research" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_LEISURE /area/rnd/reception_desk name = "\improper Research Reception Desk" @@ -2751,6 +2815,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/rnd/hallway name = "\improper Research Lower Hallway" icon_state = "research" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/rnd/anomaly_lab name = "\improper Anomaly Lab" @@ -2951,33 +3016,41 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/storage/tools name = "Auxiliary Tool Storage" icon_state = "storage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/primary name = "Primary Tool Storage" icon_state = "primarystorage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/autolathe name = "Autolathe Storage" icon_state = "storage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/art name = "Art Supply Storage" icon_state = "storage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/auxillary name = "Auxillary Storage" icon_state = "auxstorage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/eva name = "EVA Storage" icon_state = "eva" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/surface_eva icon_state = "storage" name = "\improper Surface EVA" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/surface_eva/external name = "\improper Surface EVA Access" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/secure name = "Secure Storage" @@ -2986,30 +3059,37 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/storage/emergency_storage/emergency name = "Starboard Emergency Storage" icon_state = "emergencystorage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/emergency_storage/emergency2 name = "Port Emergency Storage" icon_state = "emergencystorage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/emergency_storage/emergency3 name = "Central Emergency Storage" icon_state = "emergencystorage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/emergency_storage/emergency4 name = "Civilian Emergency Storage" icon_state = "emergencystorage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/emergency_storage/emergency5 name = "Dock Emergency Storage" icon_state = "emergencystorage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/emergency_storage/emergency6 name = "Cargo Emergency Storage" icon_state = "emergencystorage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/storage/tech name = "Technical Storage" icon_state = "auxstorage" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/storage/testroom requires_power = 0 @@ -3132,6 +3212,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/constructionsite name = "\improper Construction Site" icon_state = "storage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/constructionsite/storage name = "\improper Construction Site Storage Area" @@ -3231,50 +3312,60 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/ai_monitored/storage/eva name = "EVA Storage" icon_state = "eva" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/ai_monitored/storage/secure name = "Secure Storage" icon_state = "storage" ambience = AMBIENCE_HIGHSEC + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/ai_monitored/storage/emergency name = "Emergency Storage" icon_state = "storage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/ai_monitored/storage/emergency/eva name = "Emergency EVA" icon_state = "storage" + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES /area/ai_upload name = "\improper AI Upload Chamber" icon_state = "ai_upload" ambience = AMBIENCE_AI + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_SENSITIVE /area/ai_upload_foyer name = "AI Upload Access" icon_state = "ai_foyer" sound_env = SMALL_ENCLOSED ambience = AMBIENCE_AI + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_SENSITIVE /area/ai_server_room name = "Messaging Server Room" icon_state = "ai_server" sound_env = SMALL_ENCLOSED ambience = AMBIENCE_AI + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_SENSITIVE /area/ai name = "\improper AI Chamber" icon_state = "ai_chamber" ambience = AMBIENCE_AI + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_SENSITIVE /area/ai/foyer name = "\improper AI Core Access" + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_SENSITIVE /area/ai_cyborg_station name = "\improper Cyborg Station" icon_state = "ai_cyborg" sound_env = SMALL_ENCLOSED ambience = AMBIENCE_AI + nightshift_level = NIGHTSHIFT_LEVEL_COMMAND_SENSITIVE /area/aisat name = "\improper AI Satellite" @@ -3462,43 +3553,51 @@ NOTE: there are two lists of areas in the end of this file: centcom and station /area/exploration name = "\improper Exploration Foyer" icon_state = "purple" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_HALLWAYS /area/exploration/excursion_dock name = "\improper Excursion Shuttle Dock" icon_state = "hangar" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/exploration/courser_dock name = "\improper Courser Shuttle Dock" icon_state = "hangar" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/exploration/explorer_prep name = "\improper Explorer Prep Room" icon_state = "locker" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/exploration/pilot_prep name = "\improper Pilot Prep Room" icon_state = "locker" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/exploration/meeting name = "\improper Explorer Meeting Room" icon_state = "northeast" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_LEISURE /area/exploration/showers name = "\improper Explorer Showers" icon_state = "restrooms" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_LEISURE /area/exploration/medical name = "\improper Exploration Med Station" icon_state = "medbay" + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/exploration/pathfinder_office name = "\improper Pathfinder's Office" - + nightshift_level = NIGHTSHIFT_LEVEL_DEPARTMENT_FACILITIES /area/station/protean_nanite_room name = "\improper Nanite Chamber" icon_state = "blue" - + nightshift_level = NIGHTSHIFT_LEVEL_PUBLIC_FACILITIES //Elevator areas // Used for creating the exchange areas. diff --git a/code/game/area/area.dm b/code/game/area/area.dm index d0329eb5e68..541ee23cca3 100644 --- a/code/game/area/area.dm +++ b/code/game/area/area.dm @@ -30,6 +30,11 @@ /// default initial gas mix var/initial_gas_mix = GAS_STRING_STP + //? nightshift + /// nightshift level + /// in general, nightshift must be at or above this level for it to proc on areas. + var/nightshift_level = NIGHTSHIFT_LEVEL_UNSET + //? tracking lists for machinery /// holopads - lazyinit'd var/list/obj/machinery/holopad/holopads diff --git a/code/modules/power/lighting/lighting.dm b/code/modules/power/lighting/lighting.dm index aa97f40d756..29b7667b2b0 100644 --- a/code/modules/power/lighting/lighting.dm +++ b/code/modules/power/lighting/lighting.dm @@ -560,9 +560,9 @@ var/global/list/light_type_cache = list() needsound = FALSE // Don't play sound again until we've been turned off if(on) - var/correct_range = nightshift_enabled ? brightness_range_ns : brightness_range - var/correct_power = nightshift_enabled ? brightness_power_ns : brightness_power - var/correct_color = nightshift_enabled ? brightness_color_ns : brightness_color + var/correct_range = nightshift_enabled ? (brightness_range_ns || brightness_range) : brightness_range + var/correct_power = nightshift_enabled ? (brightness_power_ns || brightness_power) : brightness_power + var/correct_color = nightshift_enabled ? (brightness_color_ns || brightness_color) : brightness_color if(light_range != correct_range || light_power != correct_power || light_color != correct_color) if(!auto_flicker) switchcount++ diff --git a/code/modules/power/lighting/lights.dm b/code/modules/power/lighting/lights.dm index 310aa167305..9b8c12f5bcc 100644 --- a/code/modules/power/lighting/lights.dm +++ b/code/modules/power/lighting/lights.dm @@ -20,13 +20,18 @@ var/rigged = 0 var/broken_chance = 0 - ///how much light it gives off + /// range of light var/brightness_range = 8 + /// power of light var/brightness_power = 0.8 + /// color of light var/brightness_color = LIGHT_COLOR_HALOGEN - var/nightshift_range = 6 - var/nightshift_power = 0.5 + /// range of light under nightshift; null for no change + var/nightshift_range = LIGHT_RANGE_NIGHTSHIFT + /// power of light under nightshift; null for no change + var/nightshift_power = LIGHT_POWER_NIGHTSHIFT + /// color of light under nightshift; null for no change var/nightshift_color = LIGHT_COLOR_NIGHTSHIFT /obj/item/light/tube @@ -104,12 +109,17 @@ base_icon_state = "lbulb" item_state = "contvapour" materials_base = list(MAT_GLASS = 100) - brightness_color = LIGHT_COLOR_TUNGSTEN + brightness_color = LIGHT_COLOR_TUNGSTEN brightness_range = 4 + brightness_power = 0.8 - nightshift_range = 4 - nightshift_power = 0.5 + // todo: bulb nightshift stuff needs to be defines + // we basically disable it because bulbs are already pretty weak + + nightshift_color = null + nightshift_range = null + nightshift_power = null /obj/item/light/bulb/strong name = "light bulb" @@ -118,14 +128,9 @@ base_icon_state = "lbulb" item_state = "contvapour" materials_base = list(MAT_GLASS = 100) - brightness_color = LIGHT_COLOR_TUNGSTEN brightness_range = 8 - nightshift_range = 8 //Basically just a no-nightshift light. - nightshift_power = 0.8 - nightshift_color = LIGHT_COLOR_TUNGSTEN - /obj/item/light/throw_impact(atom/hit_atom) ..() shatter() diff --git a/code/modules/unit_tests/core/priority_queue.dm b/code/modules/unit_tests/core/priority_queue.dm index 28e0339f0c1..83d4a3eca60 100644 --- a/code/modules/unit_tests/core/priority_queue.dm +++ b/code/modules/unit_tests/core/priority_queue.dm @@ -3,9 +3,9 @@ for(var/i in 1 to 1000) queue.enqueue(rand(1, 100000)) var/last = queue.dequeue() - while(length(queue.queue)) + while(length(queue.array)) var/next = queue.dequeue() if(next < last) - TEST_FAIL("Priority queue out of order. next [next] last [last] queue [json_encode(queue.queue)]") + TEST_FAIL("Priority queue out of order. next [next] last [last] queue [json_encode(queue.array)]") return last = next diff --git a/config/entries/game.txt b/config/entries/game.txt index 0dbc702386a..8f155dab9f7 100644 --- a/config/entries/game.txt +++ b/config/entries/game.txt @@ -11,9 +11,6 @@ STARLIGHT ## Set to 0 to disable holidays (you monster) ALLOW_HOLIDAYS -## Set to 0 to disable nightshifts (you monster!!) -NIGHTSHIFTS_ENABLED - ## Engine submap probabilities ## Supermatter ENGINE_SUBMAP EngineSubmap_SM 40 @@ -43,3 +40,25 @@ EMOJIS ## Set to 0 to disable everyone on station having maint. ALMOST_EVERYONE_HAS_MAINTENANCE_ACCESS + +### Nightshift ### + +## Set to 0 to disable nightshifts (you monster!!) +NIGHTSHIFTS_ENABLED + +## Nightshift Levels +## Set to 1 or 0 as needed. + +NIGHTSHIFT_LEVELS Unset 0 + +NIGHTSHIFT_LEVELS PublicHalls 1 +NIGHTSHIFT_LEVELS PublicAreas 1 + +NIGHTSHIFT_LEVELS DepartmentHalls 1 +NIGHTSHIFT_LEVELS DepartmentAreas 0 +NIGHTSHIFT_LEVELS DepartmentSecure 0 +NIGHTSHIFT_LEVELS DepartmentLeisure 1 + +NIGHTSHIFT_LEVELS CommandHalls 1 +NIGHTSHIFT_LEVELS CommandAreas 0 +NIGHTSHIFT_LEVELS CommandSecure 0