Skip to content

Commit

Permalink
Refactors area stuff (#52751)
Browse files Browse the repository at this point in the history
-bitfielded a bunch of bools on /area, I left some untouched cus they get called a lot
-Unused vars
-Fixed a var pretending to be a fake bool
-Probably more
  • Loading branch information
TiviPlus authored and MarkSuckerberg committed Dec 15, 2020
1 parent 2636e6e commit c1630c7
Show file tree
Hide file tree
Showing 44 changed files with 288 additions and 207 deletions.
25 changes: 25 additions & 0 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define ALL (~0) //For convenience.
#define NONE 0


GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768))

/* Directions */
Expand Down Expand Up @@ -60,6 +61,30 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
/// Blocks ruins spawning on the turf
#define NO_RUINS_1 (1<<10)

////////////////Area flags\\\\\\\\\\\\\\
/// If it's a valid territory for cult summoning or the CRAB-17 phone to spawn
#define VALID_TERRITORY (1<<0)
/// If blobs can spawn there and if it counts towards their score.
#define BLOBS_ALLOWED (1<<1)
/// If mining tunnel generation is allowed in this area
#define TUNNELS_ALLOWED (1<<2)
/// If flora are allowed to spawn in this area randomly through tunnel generation
#define FLORA_ALLOWED (1<<3)
/// If mobs can be spawned by natural random generation
#define MOB_SPAWN_ALLOWED (1<<4)
/// If megafauna can be spawned by natural random generation
#define MEGAFAUNA_SPAWN_ALLOWED (1<<5)
/// Are you forbidden from teleporting to the area? (centcom, mobs, wizard, hand teleporter)
#define NOTELEPORT (1<<6)
/// Hides area from player Teleport function.
#define HIDDEN_AREA (1<<7)
/// If false, loading multiple maps with this area type will create multiple instances.
#define UNIQUE_AREA (1<<8)
/// If people are allowed to suicide in it. Mostly for OOC stuff like minigames
#define BLOCK_SUICIDE (1<<9)
/// Can the Xenobio management console transverse this area by default?
#define XENOBIOLOGY_COMPATIBLE (1<<10)

/*
These defines are used specifically with the atom/pass_flags bitmask
the atom/checkpass() proc uses them (tables will call movable atom checkpass(PASSTABLE) for example)
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ GLOBAL_LIST_INIT(typecache_powerfailure_safe_areas, typecacheof(/area/engine/eng
var/area/place = get_area(turfs[i])
if(blacklisted_areas[place.type])
continue
if(!place.requires_power || place.noteleport || place.hidden)
if(!place.requires_power || (place.area_flags & NOTELEPORT) || (place.area_flags & HIDDEN_AREA))
continue // No expanding powerless rooms etc
areas[place.name] = place
var/area_choice = input(creator, "Choose an area to expand or make a new area.", "Area Expansion") as null|anything in areas
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ B --><-- A
var/I = rand(1, L.len)
var/turf/T = L[I]
var/area/X = get_area(T)
if(!T.density && X.valid_territory)
if(!T.density && (X.area_flags & VALID_TERRITORY))
var/clear = TRUE
for(var/obj/O in T)
if(O.density)
Expand Down
13 changes: 13 additions & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ GLOBAL_LIST_INIT(bitfields, list(
"USES_TGUI" = USES_TGUI,
"FROZEN" = FROZEN,
),
"area_flags" = list(
"VALID_TERRITORY" = VALID_TERRITORY,
"BLOBS_ALLOWED" = BLOBS_ALLOWED,
"TUNNELS_ALLOWED" = TUNNELS_ALLOWED,
"FLORA_ALLOWED" = FLORA_ALLOWED,
"MOB_SPAWN_ALLOWED" = MOB_SPAWN_ALLOWED,
"MEGAFAUNA_SPAWN_ALLOWED" = MEGAFAUNA_SPAWN_ALLOWED,
"NOTELEPORT" = NOTELEPORT,
"HIDDEN_AREA" = HIDDEN_AREA,
"UNIQUE_AREA" = UNIQUE_AREA,
"BLOCK_SUICIDE" = BLOCK_SUICIDE,
"XENOBIOLOGY_COMPATIBLE" = XENOBIOLOGY_COMPATIBLE,
),
"datum_flags" = list(
"DF_USE_TAG" = DF_USE_TAG,
"DF_VAR_EDITED" = DF_VAR_EDITED,
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ GLOBAL_LIST_EMPTY(the_station_areas)
for(var/area/A in world)
if (is_type_in_typecache(A, station_areas_blacklist))
continue
if (!A.contents.len || !A.unique)
if (!A.contents.len || !(A.area_flags & UNIQUE_AREA))
continue
var/turf/picked = A.contents[1]
if (is_station_level(picked.z))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
/datum/action/item_action/vortex_recall/IsAvailable()
var/turf/current_location = get_turf(target)
var/area/current_area = current_location.loc
if(current_area.noteleport)
if(current_area.area_flags & NOTELEPORT)
to_chat(target, "[src] fizzles uselessly.")
return
if(istype(target, /obj/item/hierophant_club))
Expand Down
4 changes: 2 additions & 2 deletions code/datums/helper_datums/teleport.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

var/area/A = get_area(curturf)
var/area/B = get_area(destturf)
if(!forced && (HAS_TRAIT(teleatom, TRAIT_NO_TELEPORT) || A.noteleport || B.noteleport))
if(!forced && (HAS_TRAIT(teleatom, TRAIT_NO_TELEPORT) || (A.area_flags & NOTELEPORT) || (B.area_flags & NOTELEPORT)))
return FALSE

if(SEND_SIGNAL(destturf, COMSIG_ATOM_INTERCEPT_TELEPORT, channel, curturf, destturf))
Expand Down Expand Up @@ -157,7 +157,7 @@
if(T.is_transition_turf())
continue // Avoid picking these.
var/area/A = T.loc
if(!A.noteleport)
if(!(A.area_flags & NOTELEPORT))
posturfs.Add(T)
return posturfs

Expand Down
4 changes: 2 additions & 2 deletions code/datums/wires/airalarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
A.apply_mode(usr)
if(WIRE_ALARM) // Clear alarms.
var/area/AA = get_area(A)
if(AA.atmosalert(0, holder))
if(AA.atmosalert(FALSE, holder))
A.post_alert(0)
A.update_icon()

Expand All @@ -69,6 +69,6 @@
A.apply_mode(usr)
if(WIRE_ALARM) // Post alarm.
var/area/AA = get_area(A)
if(AA.atmosalert(2, holder))
if(AA.atmosalert(TRUE, holder))
A.post_alert(2)
A.update_icon()
27 changes: 12 additions & 15 deletions code/game/area/Space_Station_13_areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
power_light = FALSE
power_equip = FALSE
power_environ = FALSE
valid_territory = FALSE
area_flags = UNIQUE_AREA
outdoors = TRUE
ambientsounds = SPACE
blob_allowed = FALSE //Eating up space doesn't count for victory as a blob.
flags_1 = CAN_BE_DIRTY_1

/area/space/nearstation
Expand All @@ -58,8 +57,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
icon_state = "asteroid"
requires_power = FALSE
has_gravity = STANDARD_GRAVITY
blob_allowed = FALSE //Nope, no winning on the asteroid as a blob. Gotta eat the station.
valid_territory = FALSE
area_flags = UNIQUE_AREA
ambientsounds = MINING
flags_1 = CAN_BE_DIRTY_1

Expand All @@ -68,7 +66,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
ambientsounds = RUINS
always_unpowered = FALSE
requires_power = TRUE
blob_allowed = TRUE
area_flags = UNIQUE_AREA | BLOBS_ALLOWED

/area/asteroid/nearstation/bomb_site
name = "Bomb Testing Asteroid"
Expand All @@ -79,9 +77,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station

/area/maintenance
ambientsounds = MAINTENANCE
valid_territory = FALSE
lighting_colour_tube = "#ffe5cb"
lighting_colour_bulb = "#ffdbb4"
area_flags = BLOBS_ALLOWED | UNIQUE_AREA

//Departments

Expand Down Expand Up @@ -159,7 +157,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/maintenance/department/science/xenobiology
name = "Xenobiology Maintenance"
icon_state = "xenomaint"
xenobiology_compatible = TRUE
area_flags = VALID_TERRITORY | BLOBS_ALLOWED | UNIQUE_AREA | XENOBIOLOGY_COMPATIBLE


//Maintenance - Generic
Expand Down Expand Up @@ -373,7 +371,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/crew_quarters/dorms
name = "Dormitories"
icon_state = "Sleep"
safe = TRUE
area_flags = VALID_TERRITORY | BLOBS_ALLOWED | UNIQUE_AREA

/area/crew_quarters/dorms/barracks
name = "Sleep Barracks"
Expand Down Expand Up @@ -563,7 +561,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/engine/atmospherics_engine
name = "Atmospherics Engine"
icon_state = "atmos_engine"
valid_territory = FALSE
area_flags = BLOBS_ALLOWED | UNIQUE_AREA

/area/engine/engine_room //donut station specific
name = "Engine Room"
Expand All @@ -580,7 +578,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/engine/supermatter
name = "Supermatter Engine"
icon_state = "engine_sm"
valid_territory = FALSE
area_flags = BLOBS_ALLOWED | UNIQUE_AREA

/area/engine/break_room
name = "Engineering Foyer"
Expand Down Expand Up @@ -608,8 +606,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/solar
requires_power = FALSE
dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT
valid_territory = FALSE
blob_allowed = FALSE
area_flags = UNIQUE_AREA
flags_1 = NONE
ambientsounds = ENGINEERING

Expand Down Expand Up @@ -1058,9 +1055,9 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
icon_state = "toxstorage"

/area/science/test_area
valid_territory = FALSE
name = "Toxins Test Area"
icon_state = "toxtest"
area_flags = BLOBS_ALLOWED | UNIQUE_AREA

/area/science/mixing
name = "Toxins Mixing Lab"
Expand All @@ -1069,7 +1066,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/science/mixing/chamber
name = "Toxins Mixing Chamber"
icon_state = "toxmix"
valid_territory = FALSE
area_flags = BLOBS_ALLOWED | UNIQUE_AREA

/area/science/misc_lab
name = "Testing Lab"
Expand Down Expand Up @@ -1128,7 +1125,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/storage/tcom
name = "Telecomms Storage"
icon_state = "green"
valid_territory = FALSE
area_flags = BLOBS_ALLOWED | UNIQUE_AREA

/area/storage/eva
name = "EVA Storage"
Expand Down
57 changes: 22 additions & 35 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
invisibility = INVISIBILITY_LIGHTING

var/map_name // Set in New(); preserves the name set by the map maker, even if renamed by the Blueprints.

var/valid_territory = TRUE // If it's a valid territory for cult summoning or the CRAB-17 phone to spawn
var/blob_allowed = TRUE // If blobs can spawn there and if it counts towards their score.
var/area_flags = VALID_TERRITORY | BLOBS_ALLOWED | UNIQUE_AREA

var/fire = null
var/atmos = TRUE
///Whether there is an atmos alarm in this area
var/atmosalm = FALSE
var/poweralm = TRUE
var/lightswitch = TRUE
Expand All @@ -29,10 +26,8 @@
var/beauty = 0 // Beauty average per open turf in the area
var/beauty_threshold = 150 //If a room is too big it doesn't have beauty.

var/requires_power = TRUE
var/always_unpowered = FALSE // This gets overridden to 1 for space in area/Initialize().

var/outdoors = FALSE //For space, the asteroid, lavaland, etc. Used with blueprints to determine if we are adding a new area (vs editing a station room)
/// For space, the asteroid, lavaland, etc. Used with blueprints or with weather to determine if we are adding a new area (vs editing a station room)
var/outdoors = FALSE

var/areasize = 0 //Size of the area in open turfs, only calculated for indoors areas.

Expand All @@ -41,21 +36,16 @@
/// Mood message for being here, only shows up if mood_bonus != 0
var/mood_message = "<span class='nicegreen'>This area is pretty nice!\n</span>"

///Will objects this area be needing power?
var/requires_power = TRUE
/// This gets overridden to 1 for space in area/Initialize().
var/always_unpowered = FALSE

var/power_equip = TRUE
var/power_light = TRUE
var/power_environ = TRUE

var/has_gravity = 0
///Are you forbidden from teleporting to the area? (centcom, mobs, wizard, hand teleporter)
var/noteleport = FALSE
///Hides area from player Teleport function.
var/hidden = FALSE
///Is the area teleport-safe: no space / radiation / aggresive mobs / other dangers
var/safe = FALSE
/// If false, loading multiple maps with this area type will create multiple instances.
var/unique = TRUE

var/no_air = null
var/has_gravity = FALSE

var/parallax_movedir = 0

Expand All @@ -66,8 +56,7 @@
var/list/cameras
var/list/firealarms
var/firedoors_last_closed_on = 0
/// Can the Xenobio management console transverse this area by default?
var/xenobiology_compatible = FALSE

///Boolean to limit the areas (subtypes included) that atoms in this area can smooth with. Used for shuttles.
var/area_limited_icon_smoothing = FALSE

Expand Down Expand Up @@ -107,7 +96,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
/proc/process_teleport_locs()
for(var/V in GLOB.sortedAreas)
var/area/AR = V
if(istype(AR, /area/shuttle) || AR.noteleport)
if(istype(AR, /area/shuttle) || AR.area_flags & NOTELEPORT)
continue
if(GLOB.teleportlocs[AR.name])
continue
Expand All @@ -134,7 +123,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
else // no icon state? use random.
minimap_color = rgb(rand(50,70),rand(50,70),rand(50,70)) // This interacts with the map loader, so it needs to be set immediately
// rather than waiting for atoms to initialize.
if (unique)
if (area_flags & UNIQUE_AREA)
GLOB.areas_by_type[type] = src
power_usage = new /list(AREA_USAGE_LEN) // Some atoms would like to use power in Initialize()
return ..()
Expand All @@ -149,8 +138,6 @@ GLOBAL_LIST_EMPTY(teleportlocs)
*/
/area/Initialize()
icon_state = ""
layer = AREA_LAYER
map_name = name // Save the initial (the name set in the map) name of the area.

if(requires_power)
luminosity = 0
Expand Down Expand Up @@ -260,9 +247,9 @@ GLOBAL_LIST_EMPTY(teleportlocs)
*
* Sends to all ai players, alert consoles, drones and alarm monitor programs in the world
*/
/area/proc/atmosalert(danger_level, obj/source)
if(danger_level != atmosalm)
if (danger_level==2)
/area/proc/atmosalert(isdangerous, obj/source)
if(isdangerous != atmosalm)
if(isdangerous==TRUE)

for (var/item in GLOB.silicon_mobs)
var/mob/living/silicon/aiPlayer = item
Expand All @@ -277,7 +264,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
var/datum/computer_file/program/alarm_monitor/p = item
p.triggerAlarm("Atmosphere", src, cameras, source)

else if (src.atmosalm == 2)
else
for (var/item in GLOB.silicon_mobs)
var/mob/living/silicon/aiPlayer = item
aiPlayer.cancelAlarm("Atmosphere", src, source)
Expand All @@ -291,9 +278,9 @@ GLOBAL_LIST_EMPTY(teleportlocs)
var/datum/computer_file/program/alarm_monitor/p = item
p.cancelAlarm("Atmosphere", src, source)

src.atmosalm = danger_level
return 1
return 0
atmosalm = isdangerous
return TRUE
return FALSE

/**
* Try to close all the firedoors in the area
Expand Down Expand Up @@ -626,8 +613,8 @@ GLOBAL_LIST_EMPTY(teleportlocs)
power_light = FALSE
power_environ = FALSE
always_unpowered = FALSE
valid_territory = FALSE
blob_allowed = FALSE
area_flags &= ~VALID_TERRITORY
area_flags &= ~BLOBS_ALLOWED
addSorted()
/**
* Set the area size of the area
Expand Down
Loading

0 comments on commit c1630c7

Please sign in to comment.