From 8af0051fd6beb6f3a8f8482bd7a2f12ce28f53ea Mon Sep 17 00:00:00 2001 From: Lohikar Date: Thu, 6 Jul 2017 15:37:58 -0500 Subject: [PATCH] More macros (#2955) changes: Holomaps now use an area flag instead of a proc to determine which areas do not draw on the holomap. The supply shuttle once more has a roof. The supply shuttle's landing zone is now dynamically lit. Turfs only generate visibility updates on Initialize() after mapload - visualnet is not initialized by then anyways. Merged /datum/gas_mixture/(init) into /datum/gas_mixture/New(). Converted a ZAS proc into a macro. Made ZAS attempt to remove a turf from a zone instead of always rebuilding it in a certain case. Macroized two misc procs. Fixes #2947. --- code/ZAS/Connection.dm | 4 ++-- code/ZAS/Turf.dm | 20 +++++++++---------- code/ZAS/Zone.dm | 2 +- code/__defines/ZAS.dm | 2 ++ code/__defines/misc.dm | 4 ++++ code/_helpers/game.dm | 6 ------ code/controllers/subsystems/air.dm | 8 +------- .../subsystems/initialization/minimap.dm | 6 +++++- code/game/area/Space Station 13 areas.dm | 13 +++--------- code/game/area/areas.dm | 8 -------- code/game/area/asteroid_areas.dm | 4 +--- code/game/supplyshuttle.dm | 6 +++--- code/game/turfs/simulated.dm | 2 ++ code/modules/mob/freelook/update_triggers.dm | 9 ++------- code/modules/xgm/xgm_gas_mixture.dm | 3 ++- 15 files changed, 38 insertions(+), 59 deletions(-) diff --git a/code/ZAS/Connection.dm b/code/ZAS/Connection.dm index 2a66aa29e8e..d6274b823a2 100644 --- a/code/ZAS/Connection.dm +++ b/code/ZAS/Connection.dm @@ -60,8 +60,8 @@ Class Procs: /connection/New(turf/simulated/A, turf/simulated/B) #ifdef ZASDBG - ASSERT(SSair.has_valid_zone(A)) - //ASSERT(SSair.has_valid_zone(B)) + ASSERT(TURF_HAS_VALID_ZONE(A)) + //ASSERT(TURF_HAS_VALID_ZONE(B)) #endif src.A = A src.B = B diff --git a/code/ZAS/Turf.dm b/code/ZAS/Turf.dm index ffc42e580c2..ee2b30564e5 100644 --- a/code/ZAS/Turf.dm +++ b/code/ZAS/Turf.dm @@ -43,7 +43,7 @@ if(istype(unsim, /turf/simulated)) var/turf/simulated/sim = unsim - if(SSair.has_valid_zone(sim)) + if(TURF_HAS_VALID_ZONE(sim)) SSair.connect(sim, src) @@ -150,11 +150,15 @@ #endif //Check that our zone hasn't been cut off recently. - //This happens when windows move or are constructed. We need to rebuild. + //This happens when windows move or are constructed. Try to remove first, otherwise we need to rebuild. if((previously_open & d) && istype(unsim, /turf/simulated)) var/turf/simulated/sim = unsim if(zone && sim.zone == zone) - zone.rebuild() + if (can_safely_remove_from_zone()) + c_copy_air() + zone.remove(src) + else + zone.rebuild() return continue @@ -166,8 +170,7 @@ var/turf/simulated/sim = unsim sim.open_directions |= reverse_dir[d] - if(SSair.has_valid_zone(sim)) - + if(TURF_HAS_VALID_ZONE(sim)) //Might have assigned a zone, since this happens for each direction. if(!zone) @@ -182,11 +185,8 @@ #endif //Postpone this tile rather than exit, since a connection can still be made. - if(!postponed) postponed = list() - postponed.Add(sim) - + LAZYADD(postponed, sim) else - sim.zone.add(src) #ifdef ZASDBG @@ -215,7 +215,7 @@ if(!postponed) postponed = list() postponed.Add(unsim) - if(!SSair.has_valid_zone(src)) //Still no zone, make a new one. + if(!TURF_HAS_VALID_ZONE(src)) //Still no zone, make a new one. var/zone/newzone = new/zone() newzone.add(src) diff --git a/code/ZAS/Zone.dm b/code/ZAS/Zone.dm index bf7e8ad8b61..9b5f5853417 100644 --- a/code/ZAS/Zone.dm +++ b/code/ZAS/Zone.dm @@ -66,7 +66,7 @@ Class Procs: #ifdef ZASDBG ASSERT(!invalid) ASSERT(istype(T)) - ASSERT(!SSair.has_valid_zone(T)) + ASSERT(!TURF_HAS_VALID_ZONE(T)) #endif var/datum/gas_mixture/turf_air = T.return_air() add_tile_air(turf_air) diff --git a/code/__defines/ZAS.dm b/code/__defines/ZAS.dm index 0aaa7284362..04fc3c16c98 100644 --- a/code/__defines/ZAS.dm +++ b/code/__defines/ZAS.dm @@ -13,6 +13,8 @@ #define CANPASS_PROC 3 #define CANPASS_NEVER 4 +#define TURF_HAS_VALID_ZONE(T) (istype(T, /turf/simulated) && T:zone && !T:zone:invalid) + #ifdef MULTIZAS #define ATMOS_CANPASS_TURF(ret,A,B) \ if (A.blocks_air & AIR_BLOCKED || B.blocks_air & AIR_BLOCKED) { \ diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm index 448dfe6c5ee..a91da6cd147 100644 --- a/code/__defines/misc.dm +++ b/code/__defines/misc.dm @@ -164,6 +164,7 @@ Will print: "/mob/living/carbon/human/death" (you can optionally embed it in a s //Area flags, possibly more to come #define RAD_SHIELDED 1 //shielded from radiation, clearly #define SPAWN_ROOF 2 // if we should attempt to spawn a roof above us. +#define HIDE_FROM_HOLOMAP 4 // if we shouldn't be drawn on station holomaps // Custom layer definitions, supplementing the default TURF_LAYER, MOB_LAYER, etc. #define DOOR_OPEN_LAYER 2.7 //Under all objects if opened. 2.7 due to tables being at 2.6 @@ -369,3 +370,6 @@ Will print: "/mob/living/carbon/human/death" (you can optionally embed it in a s #endif #define DEFAULT_SIGHT (SEE_SELF|SEE_BLACKNESS) + +#define isStationLevel(Z) ((Z) in config.station_levels) +#define isNotStationLevel(Z) !isStationLevel(Z) diff --git a/code/_helpers/game.dm b/code/_helpers/game.dm index c6402eac5fc..2315565e875 100644 --- a/code/_helpers/game.dm +++ b/code/_helpers/game.dm @@ -60,12 +60,6 @@ return heard -/proc/isStationLevel(var/level) - return level in config.station_levels - -/proc/isNotStationLevel(var/level) - return !isStationLevel(level) - /proc/isPlayerLevel(var/level) return level in config.player_levels diff --git a/code/controllers/subsystems/air.dm b/code/controllers/subsystems/air.dm index 4f1e0419ada..6d23ef41363 100644 --- a/code/controllers/subsystems/air.dm +++ b/code/controllers/subsystems/air.dm @@ -180,7 +180,7 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun var/turf/T = curr_tiles[curr_tiles.len] curr_tiles.len-- - if (QDELETED(T)) + if (!T) if (no_mc_tick) CHECK_TICK else if (MC_TICK_CHECK) @@ -304,12 +304,6 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun ATMOS_CANPASS_TURF(., B, A) return ablock | . -/datum/controller/subsystem/air/proc/has_valid_zone(turf/simulated/T) - #ifdef ZASDBG - ASSERT(istype(T)) - #endif - return istype(T) && T.zone && !T.zone.invalid - /datum/controller/subsystem/air/proc/merge(zone/A, zone/B) #ifdef ZASDBG ASSERT(istype(A)) diff --git a/code/controllers/subsystems/initialization/minimap.dm b/code/controllers/subsystems/initialization/minimap.dm index fe9436e66a5..f673bb3912a 100644 --- a/code/controllers/subsystems/initialization/minimap.dm +++ b/code/controllers/subsystems/initialization/minimap.dm @@ -59,7 +59,11 @@ for(var/x = 1 to world.maxx) for(var/y = 1 to world.maxy) var/turf/tile = locate(x, y, zlevel) - if(tile && tile.loc:holomapAlwaysDraw()) + var/area/A + if(tile) + A = tile.loc + if (A.flags & HIDE_FROM_HOLOMAP) + continue if(IS_ROCK(tile)) continue if(IS_OBSTACLE(tile)) diff --git a/code/game/area/Space Station 13 areas.dm b/code/game/area/Space Station 13 areas.dm index b0e6ce0f87d..443d149107b 100755 --- a/code/game/area/Space Station 13 areas.dm +++ b/code/game/area/Space Station 13 areas.dm @@ -570,7 +570,7 @@ area/space/atmosalert() /area/maintenance - flags = RAD_SHIELDED + flags = RAD_SHIELDED | HIDE_FROM_HOLOMAP sound_env = TUNNEL_ENCLOSED turf_initializer = new /datum/turf_initializer/maintenance() ambience = list( @@ -582,9 +582,6 @@ area/space/atmosalert() ) station_area = 1 -/area/maintenance/holomapAlwaysDraw() - return FALSE - /area/maintenance/civ name = "\improper Civilian Maintenance" icon_state = "maintcentral" @@ -1548,9 +1545,7 @@ area/space/atmosalert() name = "\improper Vault" icon_state = "nuke_storage" holomap_color = null - -/area/security/nuke_storage/holomapAlwaysDraw() - return FALSE + flags = HIDE_FROM_HOLOMAP /area/security/checkpoint name = "\improper Security Checkpoint" @@ -1977,9 +1972,7 @@ area/space/atmosalert() /area/turret_protected station_area = 1 - -/area/turret_protected/holomapAlwaysDraw() - return FALSE + flags = HIDE_FROM_HOLOMAP /area/turret_protected/ai_upload name = "\improper AI Upload Chamber" diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index c621d614a3f..7e8a2311e78 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -385,11 +385,3 @@ var/list/mob/living/forced_ambiance_list = new if (turfs.len) return pick(turfs) else return null - - -// Whether the turfs in the area should be drawn onto the "base" holomap. -/area/proc/holomapAlwaysDraw() - return TRUE - -/area/shuttle/holomapAlwaysDraw() - return FALSE diff --git a/code/game/area/asteroid_areas.dm b/code/game/area/asteroid_areas.dm index 3a67437c47e..077642b2b9e 100644 --- a/code/game/area/asteroid_areas.dm +++ b/code/game/area/asteroid_areas.dm @@ -12,9 +12,7 @@ /area/mine/unexplored name = "Mine" icon_state = "unexplored" - -/area/mine/unexplored/holomapAlwaysDraw() - return FALSE + flags = HIDE_FROM_HOLOMAP //S diff --git a/code/game/supplyshuttle.dm b/code/game/supplyshuttle.dm index 7a6eabffed9..2c6d3482a0d 100644 --- a/code/game/supplyshuttle.dm +++ b/code/game/supplyshuttle.dm @@ -1,8 +1,8 @@ //Config stuff #define SUPPLY_DOCKZ 3 //Z-level of the Dock. #define SUPPLY_STATIONZ 1 //Z-level of the Station. -#define SUPPLY_STATION_AREATYPE "/area/supply/station" //Type of the supply shuttle area for station -#define SUPPLY_DOCK_AREATYPE "/area/supply/dock" //Type of the supply shuttle area for dock +#define SUPPLY_STATION_AREATYPE /area/supply/station //Type of the supply shuttle area for station +#define SUPPLY_DOCK_AREATYPE /area/supply/dock //Type of the supply shuttle area for dock //Supply packs are in /code/defines/obj/supplypacks.dm //Computers are in /code/game/machinery/computer/supply.dm @@ -16,7 +16,7 @@ icon_state = "shuttle3" requires_power = 0 station_area = 1 - dynamic_lighting = 0 + flags = SPAWN_ROOF | HIDE_FROM_HOLOMAP /area/supply/dock name = "Supply Shuttle" diff --git a/code/game/turfs/simulated.dm b/code/game/turfs/simulated.dm index b4888e54285..966a0e3c7a9 100644 --- a/code/game/turfs/simulated.dm +++ b/code/game/turfs/simulated.dm @@ -51,6 +51,8 @@ . = ..() levelupdate(mapload) + if (!mapload) + updateVisibility(src) /turf/simulated/proc/AddTracks(var/typepath,var/bloodDNA,var/comingdir,var/goingdir,var/bloodcolor="#A10808") var/obj/effect/decal/cleanable/blood/tracks/tracks = locate(typepath) in src diff --git a/code/modules/mob/freelook/update_triggers.dm b/code/modules/mob/freelook/update_triggers.dm index faa33e93f9b..eefcd547ecf 100644 --- a/code/modules/mob/freelook/update_triggers.dm +++ b/code/modules/mob/freelook/update_triggers.dm @@ -16,11 +16,6 @@ updateVisibility(src) return ..() -/turf/simulated/Initialize() - . = ..() - updateVisibility(src) - - // STRUCTURES /obj/structure/Destroy() @@ -33,8 +28,8 @@ updateVisibility(src) return ..() -/obj/effect/New() - ..() +/obj/effect/Initialize() + . = ..() updateVisibility(src) // DOORS diff --git a/code/modules/xgm/xgm_gas_mixture.dm b/code/modules/xgm/xgm_gas_mixture.dm index 99de3cb50c6..68f7f272bfc 100644 --- a/code/modules/xgm/xgm_gas_mixture.dm +++ b/code/modules/xgm/xgm_gas_mixture.dm @@ -1,7 +1,7 @@ /datum/gas_mixture //Associative list of gas moles. //Gases with 0 moles are not tracked and are pruned by update_values() - var/list/gas = list() + var/list/gas //Temperature in Kelvin of this gas mix. var/temperature = 0 @@ -19,6 +19,7 @@ volume = _volume temperature = _temperature group_multiplier = _group_multiplier + gas = list() /datum/gas_mixture/proc/get_gas(gasid) if(!gas.len)