Minor Turf Refactor (#13690)

* Turf GC

* might as well do this

* additions

* Bay being bay
This commit is contained in:
Fox McCloud
2020-06-30 17:47:09 -06:00
committed by GitHub
parent 641654b75f
commit 0dea896023
21 changed files with 144 additions and 146 deletions
+1 -1
View File
@@ -176,7 +176,7 @@
if(istype(loc, /turf/simulated))
var/turf/simulated/T = loc
if(T.to_be_destroyed)
if(T.to_be_destroyed && !T.changing_turf)
var/chance_of_deletion
if(T.heat_capacity) //beware of division by zero
chance_of_deletion = T.max_fire_temperature_sustained / T.heat_capacity * 8 //there is no problem with prob(23456), min() was redundant --rastaf0
+1 -1
View File
@@ -74,8 +74,8 @@
air.temperature = temperature
/turf/simulated/Destroy()
visibilityChanged()
QDEL_NULL(active_hotspot)
QDEL_NULL(wet_overlay)
return ..()
/turf/simulated/assume_air(datum/gas_mixture/giver)
+9 -9
View File
@@ -322,16 +322,18 @@
apply_mode()
/obj/machinery/alarm/proc/handle_heating_cooling(var/datum/gas_mixture/environment, var/datum/tlv/cur_tlv, var/turf/simulated/location)
/obj/machinery/alarm/proc/handle_heating_cooling(datum/gas_mixture/environment, datum/tlv/cur_tlv, turf/simulated/location)
cur_tlv = TLV["temperature"]
//Handle temperature adjustment here.
if(environment.temperature < target_temperature - 2 || environment.temperature > target_temperature + 2 || regulating_temperature)
//If it goes too far, we should adjust ourselves back before stopping.
if(!cur_tlv.get_danger_level(target_temperature))
var/datum/gas_mixture/gas = location.remove_air(0.25 * environment.total_moles())
if(!gas)
return
if(!regulating_temperature)
regulating_temperature = 1
visible_message("\The [src] clicks as it starts [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
"You hear a click and a faint electronic hum.")
visible_message("\The [src] clicks as it starts [environment.temperature > target_temperature ? "cooling" : "heating"] the room.", "You hear a click and a faint electronic hum.")
if(target_temperature > MAX_TEMPERATURE)
target_temperature = MAX_TEMPERATURE
@@ -339,9 +341,8 @@
if(target_temperature < MIN_TEMPERATURE)
target_temperature = MIN_TEMPERATURE
var/datum/gas_mixture/gas = location.remove_air(0.25*environment.total_moles())
var/heat_capacity = gas.heat_capacity()
var/energy_used = max( abs( heat_capacity*(gas.temperature - target_temperature) ), MAX_ENERGY_CHANGE)
var/energy_used = max(abs(heat_capacity * (gas.temperature - target_temperature) ), MAX_ENERGY_CHANGE)
//Use power. Assuming that each power unit represents 1000 watts....
use_power(energy_used/1000, ENVIRON)
@@ -349,16 +350,15 @@
//We need to cool ourselves.
if(heat_capacity)
if(environment.temperature > target_temperature)
gas.temperature -= energy_used/heat_capacity
gas.temperature -= energy_used / heat_capacity
else
gas.temperature += energy_used/heat_capacity
gas.temperature += energy_used / heat_capacity
environment.merge(gas)
if(abs(environment.temperature - target_temperature) <= 0.5)
regulating_temperature = 0
visible_message("\The [src] clicks quietly as it stops [environment.temperature > target_temperature ? "cooling" : "heating"] the room.",\
"You hear a click as a faint electronic humming stops.")
visible_message("\The [src] clicks quietly as it stops [environment.temperature > target_temperature ? "cooling" : "heating"] the room.", "You hear a click as a faint electronic humming stops.")
/obj/machinery/alarm/update_icon()
if(wiresexposed)
+2 -2
View File
@@ -5,8 +5,8 @@
/turf/simulated/floor/mech_bay_recharge_floor/airless
icon_state = "recharge_floor_asteroid"
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
/obj/machinery/mech_bay_recharge_port
@@ -21,6 +21,7 @@
if(i == lowBoundX || i == hiBoundX || j == lowBoundY || j == hiBoundY)
new /turf/simulated/wall/vault(locate(i,j,z),type)
else
new /turf/simulated/floor/vault(locate(i,j,z),type)
var/turf/T = new /turf/simulated/floor/vault(locate(i, j, z))
T.icon_state = "[type]vault"
qdel(src)
-6
View File
@@ -8,12 +8,6 @@
nitrogen = MOLES_N2STANDARD
var/to_be_destroyed = 0 //Used for fire, if a melting temperature was reached, it will be destroyed
var/max_fire_temperature_sustained = 0 //The max temperature of the fire which it was subjected to
var/dirtoverlay = null
/turf/simulated/New()
..()
levelupdate()
visibilityChanged()
/turf/simulated/proc/break_tile()
return
+2 -2
View File
@@ -31,8 +31,8 @@ GLOBAL_LIST_INIT(icons_to_ignore_at_floor_init, list("damaged1","damaged2","dama
var/list/burnt_states = list("floorscorched1", "floorscorched2")
var/list/prying_tool_list = list(TOOL_CROWBAR) //What tool/s can we use to pry up the tile?
/turf/simulated/floor/New()
..()
/turf/simulated/floor/Initialize(mapload)
. = ..()
if(icon_state in GLOB.icons_to_ignore_at_floor_init) //so damaged/burned tiles or plating icons aren't saved as the default
icon_regular_floor = "floor"
else
+14 -15
View File
@@ -49,9 +49,9 @@
floor_tile = /obj/item/stack/tile/grass
broken_states = list("sand")
/turf/simulated/floor/grass/Initialize()
/turf/simulated/floor/grass/Initialize(mapload)
. = ..()
update_icon()
..()
/turf/simulated/floor/grass/update_icon()
icon_state = "grass[pick("1","2","3","4")]"
@@ -80,10 +80,9 @@
)
/turf/simulated/floor/carpet/New()
..()
if(broken || burnt)
make_plating()
/turf/simulated/floor/carpet/Initialize(mapload)
. = ..()
update_icon()
/turf/simulated/floor/carpet/update_icon()
if(!..())
@@ -119,18 +118,18 @@
broken_states = list("damaged")
plane = PLANE_SPACE
/turf/simulated/floor/fakespace/New()
..()
icon_state = "[rand(0,25)]"
/turf/simulated/floor/carpet/arcade
icon = 'icons/goonstation/turf/floor.dmi'
icon_state = "arcade"
floor_tile = /obj/item/stack/tile/arcade_carpet
smooth = SMOOTH_FALSE
/turf/simulated/floor/fakespace/Initialize(mapload)
. = ..()
icon_state = SPACE_ICON_STATE
/turf/simulated/floor/fakespace/get_smooth_underlay_icon(mutable_appearance/underlay_appearance, turf/asking_turf, adjacency_dir)
underlay_appearance.icon = 'icons/turf/space.dmi'
underlay_appearance.icon_state = SPACE_ICON_STATE
underlay_appearance.plane = PLANE_SPACE
return TRUE
/turf/simulated/floor/carpet/arcade
icon = 'icons/goonstation/turf/floor.dmi'
icon_state = "arcade"
floor_tile = /obj/item/stack/tile/arcade_carpet
smooth = SMOOTH_FALSE
-3
View File
@@ -8,9 +8,6 @@
light_power = 0.75
light_color = LIGHT_COLOR_LAVA
/turf/simulated/floor/plating/lava/New()
..()
/turf/simulated/floor/plating/lava/ex_act()
return
@@ -20,8 +20,8 @@
var/state = LIGHTFLOOR_ON
var/can_modify_colour = TRUE
/turf/simulated/floor/light/New()
..()
/turf/simulated/floor/light/Initialize(mapload)
. = ..()
update_icon()
/turf/simulated/floor/light/update_icon()
+16 -16
View File
@@ -14,8 +14,8 @@
icon_state = ""
var/list/icons = list()
/turf/simulated/floor/mineral/New()
..()
/turf/simulated/floor/mineral/Initialize(mapload)
. = ..()
broken_states = list("[initial(icon_state)]_dam")
/turf/simulated/floor/mineral/update_icon()
@@ -97,24 +97,24 @@
broken_states = list("titanium_dam1","titanium_dam2","titanium_dam3","titanium_dam4","titanium_dam5")
/turf/simulated/floor/mineral/titanium/airless
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
/turf/simulated/floor/mineral/titanium/blue
icon_state = "titanium_blue"
/turf/simulated/floor/mineral/titanium/blue/airless
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
/turf/simulated/floor/mineral/titanium/yellow
icon_state = "titanium_yellow"
/turf/simulated/floor/mineral/titanium/yellow/airless
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
/turf/simulated/floor/mineral/titanium/purple
@@ -122,8 +122,8 @@
floor_tile = /obj/item/stack/tile/mineral/titanium/purple
/turf/simulated/floor/mineral/titanium/purple/airless
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
//PLASTITANIUM (syndieshuttle)
@@ -137,8 +137,8 @@
icon_state = "plastitanium_red"
/turf/simulated/floor/mineral/plastitanium/red/airless
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
/turf/simulated/floor/mineral/plastitanium/red/brig
@@ -179,8 +179,8 @@
spam_flag = world.time + 10
/turf/simulated/floor/mineral/bananium/airless
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
@@ -254,8 +254,8 @@
floor_tile = /obj/item/stack/tile/mineral/abductor
icons = list("alienpod1", "alienpod2", "alienpod3", "alienpod4", "alienpod5", "alienpod6", "alienpod7", "alienpod8", "alienpod9")
/turf/simulated/floor/mineral/abductor/New()
..()
/turf/simulated/floor/mineral/abductor/Initialize(mapload)
. = ..()
icon_state = "alienpod[rand(1,9)]"
/turf/simulated/floor/mineral/abductor/break_tile()
+6 -14
View File
@@ -3,19 +3,11 @@
icon_state = "rockvault"
smooth = SMOOTH_FALSE
/turf/simulated/floor/vault/New(location, vtype)
..()
icon_state = "[vtype]vault"
/turf/simulated/wall/vault
icon = 'icons/turf/walls.dmi'
icon_state = "rockvault"
smooth = SMOOTH_FALSE
/turf/simulated/wall/vault/New(location, vtype)
..()
icon_state = "[vtype]vault"
/turf/simulated/floor/bluegrid
icon = 'icons/turf/floors.dmi'
icon_state = "bcircuit"
@@ -35,12 +27,12 @@
/turf/simulated/floor/greengrid/airless
icon_state = "gcircuit"
name = "airless floor"
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
/turf/simulated/floor/greengrid/airless/New()
..()
/turf/simulated/floor/greengrid/airless/Initialize(mapload)
. = ..()
name = "floor"
/turf/simulated/floor/redgrid
@@ -78,8 +70,8 @@
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
var/obj/machinery/poolcontroller/linkedcontroller = null
/turf/simulated/floor/beach/water/New()
..()
/turf/simulated/floor/beach/water/Initialize(mapload)
. = ..()
var/image/overlay_image = image('icons/misc/beach.dmi', icon_state = "water5", layer = ABOVE_MOB_LAYER)
overlay_image.plane = GAME_PLANE
overlays += overlay_image
@@ -12,12 +12,12 @@
/turf/simulated/floor/plasteel/airless
name = "airless floor"
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
/turf/simulated/floor/plasteel/airless/New()
..()
/turf/simulated/floor/plasteel/airless/Initialize(mapload)
. = ..()
name = "floor"
/turf/simulated/floor/plasteel/airless/indestructible // For bomb testing range
+16 -16
View File
@@ -14,17 +14,17 @@
"xeno" = list('sound/effects/footstep/plating_xeno.ogg')
)
/turf/simulated/floor/plating/New()
..()
/turf/simulated/floor/plating/Initialize(mapload)
. = ..()
icon_plating = icon_state
update_icon()
/turf/simulated/floor/plating/damaged/New()
..()
/turf/simulated/floor/plating/damaged/Initialize(mapload)
. = ..()
break_tile()
/turf/simulated/floor/plating/burnt/New()
..()
/turf/simulated/floor/plating/burnt/Initialize(mapload)
. = ..()
burn_tile()
/turf/simulated/floor/plating/update_icon()
@@ -113,12 +113,12 @@
/turf/simulated/floor/plating/airless
icon_state = "plating"
name = "airless plating"
oxygen = 0.01
nitrogen = 0.01
oxygen = 0
nitrogen = 0
temperature = TCMB
/turf/simulated/floor/plating/airless/New()
..()
/turf/simulated/floor/plating/airless/Initialize(mapload)
. = ..()
name = "plating"
/turf/simulated/floor/engine
@@ -190,8 +190,8 @@
name = "engraved floor"
icon_state = "cult"
/turf/simulated/floor/engine/cult/New()
..()
/turf/simulated/floor/engine/cult/Initialize(mapload)
. = ..()
if(SSticker.mode)//only do this if the round is going..otherwise..fucking asteroid..
icon_state = SSticker.cultdat.cult_floor_icon_state
@@ -275,8 +275,8 @@
icon = 'icons/turf/floors/ironsand.dmi'
icon_state = "ironsand1"
/turf/simulated/floor/plating/ironsand/New()
..()
/turf/simulated/floor/plating/ironsand/Initialize(mapload)
. = ..()
icon_state = "ironsand[rand(1,15)]"
/turf/simulated/floor/plating/ironsand/remove_plating()
@@ -359,8 +359,8 @@
name = "alien floor"
icon_state = "alienpod1"
/turf/simulated/floor/plating/abductor/New()
..()
/turf/simulated/floor/plating/abductor/Initialize(mapload)
. = ..()
icon_state = "alienpod[rand(1,9)]"
/turf/simulated/floor/plating/ice
+3 -6
View File
@@ -9,8 +9,8 @@
sheet_amount = 1
girder_type = /obj/structure/girder/cult
/turf/simulated/wall/cult/New()
..()
/turf/simulated/wall/cult/Initialize(mapload)
. = ..()
if(SSticker.mode)//game hasn't started offically don't do shit..
new /obj/effect/temp_visual/cult/turf(src)
icon_state = SSticker.cultdat.cult_wall_icon_state
@@ -72,10 +72,7 @@
realappearance.linked = src
/turf/simulated/wall/clockwork/Destroy()
if(realappearance)
qdel(realappearance)
realappearance = null
QDEL_NULL(realappearance)
return ..()
/turf/simulated/wall/clockwork/ReplaceWithLattice()
+5 -6
View File
@@ -21,6 +21,11 @@
/turf/space/Initialize(mapload)
if(!istype(src, /turf/space/transit))
icon_state = SPACE_ICON_STATE
vis_contents.Cut() //removes inherited overlays
if(initialized)
stack_trace("Warning: [src]([type]) initialized multiple times!")
initialized = TRUE
var/area/A = loc
if(!IS_DYNAMIC_LIGHTING(src) && IS_DYNAMIC_LIGHTING(A))
@@ -34,12 +39,6 @@
return INITIALIZE_HINT_NORMAL
/turf/space/Destroy(force)
if(force)
. = ..()
else
return QDEL_HINT_LETMELIVE
/turf/space/BeforeChange()
..()
var/datum/space_level/S = GLOB.space_manager.get_zlev(z)
+2 -2
View File
@@ -125,9 +125,9 @@
/turf/space/transit/attackby()
return
/turf/space/transit/New()
/turf/space/transit/Initialize(mapload)
. = ..()
update_icon()
..()
/turf/space/transit/proc/update_icon()
var/p = 9
+44 -25
View File
@@ -31,21 +31,29 @@
var/image/obscured //camerachunks
var/changing_turf = FALSE
var/list/blueprint_data //for the station blueprints, images of objects eg: pipes
var/list/footstep_sounds
var/shoe_running_volume = 50
var/shoe_walking_volume = 20
/turf/New()
..()
/turf/Initialize(mapload)
if(initialized)
stack_trace("Warning: [src]([type]) initialized multiple times!")
initialized = TRUE
// by default, vis_contents is inherited from the turf that was here before
vis_contents.Cut()
levelupdate()
if(smooth)
queue_smooth(src)
visibilityChanged()
for(var/atom/movable/AM in src)
Entered(AM)
if(smooth && SSticker && SSticker.current_state == GAME_STATE_PLAYING)
queue_smooth(src)
/turf/Initialize(mapload)
. = ..()
var/area/A = loc
if(!IS_DYNAMIC_LIGHTING(src) && IS_DYNAMIC_LIGHTING(A))
@@ -54,9 +62,11 @@
if(light_power && light_range)
update_light()
if (opacity)
if(opacity)
has_opaque_atom = TRUE
return INITIALIZE_HINT_NORMAL
/hook/startup/proc/smooth_world()
var/watch = start_watch()
log_startup_progress("Smoothing atoms...")
@@ -70,16 +80,29 @@
log_startup_progress(" Smoothed atoms in [stop_watch(watch)]s.")
return TRUE
/turf/Destroy()
// Adds the adjacent turfs to the current atmos processing
if(SSair)
for(var/direction in GLOB.cardinal)
if(atmos_adjacent_turfs & direction)
var/turf/simulated/T = get_step(src, direction)
if(istype(T))
SSair.add_to_active(T)
/turf/Destroy(force)
. = QDEL_HINT_IWILLGC
if(!changing_turf)
stack_trace("Incorrect turf deletion")
changing_turf = FALSE
if(force)
..()
//this will completely wipe turf state
var/turf/B = new world.turf(src)
for(var/A in B.contents)
qdel(A)
return
// Adds the adjacent turfs to the current atmos processing
for(var/direction in GLOB.cardinal)
if(atmos_adjacent_turfs & direction)
var/turf/simulated/T = get_step(src, direction)
if(istype(T))
SSair.add_to_active(T)
SSair.remove_from_active(src)
visibilityChanged()
QDEL_LIST(blueprint_data)
initialized = FALSE
..()
return QDEL_HINT_HARDDEL_NOW
/turf/attack_hand(mob/user as mob)
user.Move_Pulled(src)
@@ -209,10 +232,10 @@
var/old_corners = corners
BeforeChange()
if(SSair)
SSair.remove_from_active(src)
var/old_baseturf = baseturf
changing_turf = TRUE
qdel(src) //Just get the side effects and call Destroy
var/turf/W = new path(src)
W.baseturf = old_baseturf
@@ -225,7 +248,6 @@
if(SSlighting.initialized)
recalc_atom_opacity()
lighting_object = old_lighting_object
affecting_lights = old_affecting_lights
corners = old_corners
if(old_opacity != opacity || dynamic_lighting != old_dynamic_lighting)
@@ -524,12 +546,9 @@
I.appearance = AM.appearance
I.appearance_flags = RESET_COLOR|RESET_ALPHA|RESET_TRANSFORM
I.loc = src
I.dir = AM.dir
I.setDir(AM.dir)
I.alpha = 128
if(!blueprint_data)
blueprint_data = list()
blueprint_data += I
LAZYADD(blueprint_data, I)
/turf/proc/add_blueprints_preround(atom/movable/AM)
if(!SSticker || SSticker.current_state != GAME_STATE_PLAYING)
+2 -2
View File
@@ -40,6 +40,6 @@
nitrogen = 0
temperature = TCMB
/turf/unsimulated/floor/plating/airless/New()
..()
/turf/unsimulated/floor/plating/airless/Initialize(mapload)
. = ..()
name = "plating"
+9 -9
View File
@@ -3,9 +3,9 @@
icon = 'icons/misc/beach.dmi'
var/water_overlay_image = null
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/turf/unsimulated/beach/New()
..()
/turf/unsimulated/beach/Initialize(mapload)
. = ..()
if(water_overlay_image)
var/image/overlay_image = image('icons/misc/beach.dmi', icon_state = water_overlay_image, layer = ABOVE_MOB_LAYER)
overlay_image.plane = GAME_PLANE
@@ -15,10 +15,10 @@
name = "Sand"
icon_state = "desert"
mouse_opacity = MOUSE_OPACITY_ICON
/turf/unsimulated/beach/sand/New() //adds some aesthetic randomness to the beach sand
/turf/unsimulated/beach/sand/Initialize(mapload)
. = ..() //adds some aesthetic randomness to the beach sand
icon_state = pick("desert", "desert0", "desert1", "desert2", "desert3", "desert4")
..()
/turf/unsimulated/beach/sand/dense //for boundary "walls"
density = 1
@@ -42,7 +42,7 @@
/turf/unsimulated/beach/water/Entered(atom/movable/AM, atom/OldLoc)
. = ..()
if(!linkedcontroller)
return
return
if(ismob(AM))
linkedcontroller.mobinpool += AM
@@ -79,8 +79,8 @@
/turf/unsimulated/beach/water/edge_drop)
var/obj/effect/beach_drop_overlay/water_overlay
/turf/unsimulated/beach/water/drop/New()
..()
/turf/unsimulated/beach/water/drop/Initialize(mapload)
. = ..()
water_overlay = new(src)
/turf/unsimulated/beach/water/drop/Destroy()
+4 -4
View File
@@ -7,8 +7,8 @@
name = "grass patch"
icon_state = "grass1"
/turf/unsimulated/floor/grass/New()
..()
/turf/unsimulated/floor/grass/Initialize(mapload)
. = ..()
icon_state = "grass[rand(1,4)]"
/turf/unsimulated/floor/snow
@@ -20,8 +20,8 @@
name = "alien floor"
icon_state = "alienpod1"
/turf/unsimulated/floor/abductor/New()
..()
/turf/unsimulated/floor/abductor/Initialize(mapload)
. = ..()
icon_state = "alienpod[rand(1,9)]"
/turf/unsimulated/floor/vox