mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Switches around turf/datum garbage handling (my fault..). Adds null check for zone rebuilds.
This commit is contained in:
510
code/ZAS/Turf.dm
510
code/ZAS/Turf.dm
@@ -1,255 +1,255 @@
|
|||||||
/turf/simulated/var/zone/zone
|
/turf/simulated/var/zone/zone
|
||||||
/turf/simulated/var/open_directions
|
/turf/simulated/var/open_directions
|
||||||
|
|
||||||
/turf/var/needs_air_update = 0
|
/turf/var/needs_air_update = 0
|
||||||
/turf/var/datum/gas_mixture/air
|
/turf/var/datum/gas_mixture/air
|
||||||
|
|
||||||
/turf/simulated/proc/update_graphic(list/graphic_add = null, list/graphic_remove = null)
|
/turf/simulated/proc/update_graphic(list/graphic_add = null, list/graphic_remove = null)
|
||||||
if(graphic_add && graphic_add.len)
|
if(graphic_add && graphic_add.len)
|
||||||
overlays += graphic_add
|
overlays += graphic_add
|
||||||
if(graphic_remove && graphic_remove.len)
|
if(graphic_remove && graphic_remove.len)
|
||||||
overlays -= graphic_remove
|
overlays -= graphic_remove
|
||||||
|
|
||||||
/turf/proc/update_air_properties()
|
/turf/proc/update_air_properties()
|
||||||
var/block = c_airblock(src)
|
var/block = c_airblock(src)
|
||||||
if(block & AIR_BLOCKED)
|
if(block & AIR_BLOCKED)
|
||||||
//dbg(blocked)
|
//dbg(blocked)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#ifdef ZLEVELS
|
#ifdef ZLEVELS
|
||||||
for(var/d = 1, d < 64, d *= 2)
|
for(var/d = 1, d < 64, d *= 2)
|
||||||
#else
|
#else
|
||||||
for(var/d = 1, d < 16, d *= 2)
|
for(var/d = 1, d < 16, d *= 2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var/turf/unsim = get_step(src, d)
|
var/turf/unsim = get_step(src, d)
|
||||||
|
|
||||||
if(!unsim)
|
if(!unsim)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
block = unsim.c_airblock(src)
|
block = unsim.c_airblock(src)
|
||||||
|
|
||||||
if(block & AIR_BLOCKED)
|
if(block & AIR_BLOCKED)
|
||||||
//unsim.dbg(air_blocked, turn(180,d))
|
//unsim.dbg(air_blocked, turn(180,d))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var/r_block = c_airblock(unsim)
|
var/r_block = c_airblock(unsim)
|
||||||
|
|
||||||
if(r_block & AIR_BLOCKED)
|
if(r_block & AIR_BLOCKED)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if(istype(unsim, /turf/simulated))
|
if(istype(unsim, /turf/simulated))
|
||||||
|
|
||||||
var/turf/simulated/sim = unsim
|
var/turf/simulated/sim = unsim
|
||||||
if(air_master.has_valid_zone(sim))
|
if(air_master.has_valid_zone(sim))
|
||||||
|
|
||||||
air_master.connect(sim, src)
|
air_master.connect(sim, src)
|
||||||
|
|
||||||
/turf/simulated/update_air_properties()
|
/turf/simulated/update_air_properties()
|
||||||
if(zone && zone.invalid)
|
if(zone && zone.invalid)
|
||||||
c_copy_air()
|
c_copy_air()
|
||||||
zone = null //Easier than iterating through the list at the zone.
|
zone = null //Easier than iterating through the list at the zone.
|
||||||
|
|
||||||
var/s_block = c_airblock(src)
|
var/s_block = c_airblock(src)
|
||||||
if(s_block & AIR_BLOCKED)
|
if(s_block & AIR_BLOCKED)
|
||||||
#ifdef ZASDBG
|
#ifdef ZASDBG
|
||||||
if(verbose) world << "Self-blocked."
|
if(verbose) world << "Self-blocked."
|
||||||
//dbg(blocked)
|
//dbg(blocked)
|
||||||
#endif
|
#endif
|
||||||
if(zone)
|
if(zone)
|
||||||
var/zone/z = zone
|
var/zone/z = zone
|
||||||
if(locate(/obj/machinery/door/airlock) in src) //Hacky, but prevents normal airlocks from rebuilding zones all the time
|
if(locate(/obj/machinery/door/airlock) in src) //Hacky, but prevents normal airlocks from rebuilding zones all the time
|
||||||
z.remove(src)
|
z.remove(src)
|
||||||
else
|
else
|
||||||
z.rebuild()
|
z.rebuild()
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
var/previously_open = open_directions
|
var/previously_open = open_directions
|
||||||
open_directions = 0
|
open_directions = 0
|
||||||
|
|
||||||
var/list/postponed
|
var/list/postponed
|
||||||
#ifdef ZLEVELS
|
#ifdef ZLEVELS
|
||||||
for(var/d = 1, d < 64, d *= 2)
|
for(var/d = 1, d < 64, d *= 2)
|
||||||
#else
|
#else
|
||||||
for(var/d = 1, d < 16, d *= 2)
|
for(var/d = 1, d < 16, d *= 2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var/turf/unsim = get_step(src, d)
|
var/turf/unsim = get_step(src, d)
|
||||||
|
|
||||||
if(!unsim) //edge of map
|
if(!unsim) //edge of map
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var/block = unsim.c_airblock(src)
|
var/block = unsim.c_airblock(src)
|
||||||
if(block & AIR_BLOCKED)
|
if(block & AIR_BLOCKED)
|
||||||
|
|
||||||
#ifdef ZASDBG
|
#ifdef ZASDBG
|
||||||
if(verbose) world << "[d] is blocked."
|
if(verbose) world << "[d] is blocked."
|
||||||
//unsim.dbg(air_blocked, turn(180,d))
|
//unsim.dbg(air_blocked, turn(180,d))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var/r_block = c_airblock(unsim)
|
var/r_block = c_airblock(unsim)
|
||||||
if(r_block & AIR_BLOCKED)
|
if(r_block & AIR_BLOCKED)
|
||||||
|
|
||||||
#ifdef ZASDBG
|
#ifdef ZASDBG
|
||||||
if(verbose) world << "[d] is blocked."
|
if(verbose) world << "[d] is blocked."
|
||||||
//dbg(air_blocked, d)
|
//dbg(air_blocked, d)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Check that our zone hasn't been cut off recently.
|
//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. We need to rebuild.
|
||||||
if((previously_open & d) && istype(unsim, /turf/simulated))
|
if((previously_open & d) && istype(unsim, /turf/simulated))
|
||||||
var/turf/simulated/sim = unsim
|
var/turf/simulated/sim = unsim
|
||||||
if(sim.zone == zone)
|
if(zone && sim.zone == zone)
|
||||||
zone.rebuild()
|
zone.rebuild()
|
||||||
return
|
return
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
open_directions |= d
|
open_directions |= d
|
||||||
|
|
||||||
if(istype(unsim, /turf/simulated))
|
if(istype(unsim, /turf/simulated))
|
||||||
|
|
||||||
var/turf/simulated/sim = unsim
|
var/turf/simulated/sim = unsim
|
||||||
sim.open_directions |= reverse_dir[d]
|
sim.open_directions |= reverse_dir[d]
|
||||||
|
|
||||||
if(air_master.has_valid_zone(sim))
|
if(air_master.has_valid_zone(sim))
|
||||||
|
|
||||||
//Might have assigned a zone, since this happens for each direction.
|
//Might have assigned a zone, since this happens for each direction.
|
||||||
if(!zone)
|
if(!zone)
|
||||||
|
|
||||||
//if((block & ZONE_BLOCKED) || (r_block & ZONE_BLOCKED && !(s_block & ZONE_BLOCKED)))
|
//if((block & ZONE_BLOCKED) || (r_block & ZONE_BLOCKED && !(s_block & ZONE_BLOCKED)))
|
||||||
if(((block & ZONE_BLOCKED) && !(r_block & ZONE_BLOCKED)) || (r_block & ZONE_BLOCKED && !(s_block & ZONE_BLOCKED)))
|
if(((block & ZONE_BLOCKED) && !(r_block & ZONE_BLOCKED)) || (r_block & ZONE_BLOCKED && !(s_block & ZONE_BLOCKED)))
|
||||||
#ifdef ZASDBG
|
#ifdef ZASDBG
|
||||||
if(verbose) world << "[d] is zone blocked."
|
if(verbose) world << "[d] is zone blocked."
|
||||||
//dbg(zone_blocked, d)
|
//dbg(zone_blocked, d)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Postpone this tile rather than exit, since a connection can still be made.
|
//Postpone this tile rather than exit, since a connection can still be made.
|
||||||
if(!postponed) postponed = list()
|
if(!postponed) postponed = list()
|
||||||
postponed.Add(sim)
|
postponed.Add(sim)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
sim.zone.add(src)
|
sim.zone.add(src)
|
||||||
|
|
||||||
#ifdef ZASDBG
|
#ifdef ZASDBG
|
||||||
dbg(assigned)
|
dbg(assigned)
|
||||||
if(verbose) world << "Added to [zone]"
|
if(verbose) world << "Added to [zone]"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else if(sim.zone != zone)
|
else if(sim.zone != zone)
|
||||||
|
|
||||||
#ifdef ZASDBG
|
#ifdef ZASDBG
|
||||||
if(verbose) world << "Connecting to [sim.zone]"
|
if(verbose) world << "Connecting to [sim.zone]"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
air_master.connect(src, sim)
|
air_master.connect(src, sim)
|
||||||
|
|
||||||
|
|
||||||
#ifdef ZASDBG
|
#ifdef ZASDBG
|
||||||
else if(verbose) world << "[d] has same zone."
|
else if(verbose) world << "[d] has same zone."
|
||||||
|
|
||||||
else if(verbose) world << "[d] has invalid zone."
|
else if(verbose) world << "[d] has invalid zone."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
//Postponing connections to tiles until a zone is assured.
|
//Postponing connections to tiles until a zone is assured.
|
||||||
if(!postponed) postponed = list()
|
if(!postponed) postponed = list()
|
||||||
postponed.Add(unsim)
|
postponed.Add(unsim)
|
||||||
|
|
||||||
if(!air_master.has_valid_zone(src)) //Still no zone, make a new one.
|
if(!air_master.has_valid_zone(src)) //Still no zone, make a new one.
|
||||||
var/zone/newzone = new/zone()
|
var/zone/newzone = new/zone()
|
||||||
newzone.add(src)
|
newzone.add(src)
|
||||||
|
|
||||||
#ifdef ZASDBG
|
#ifdef ZASDBG
|
||||||
dbg(created)
|
dbg(created)
|
||||||
|
|
||||||
ASSERT(zone)
|
ASSERT(zone)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//At this point, a zone should have happened. If it hasn't, don't add more checks, fix the bug.
|
//At this point, a zone should have happened. If it hasn't, don't add more checks, fix the bug.
|
||||||
|
|
||||||
for(var/turf/T in postponed)
|
for(var/turf/T in postponed)
|
||||||
air_master.connect(src, T)
|
air_master.connect(src, T)
|
||||||
|
|
||||||
/turf/proc/post_update_air_properties()
|
/turf/proc/post_update_air_properties()
|
||||||
if(connections) connections.update_all()
|
if(connections) connections.update_all()
|
||||||
|
|
||||||
/turf/assume_air(datum/gas_mixture/giver) //use this for machines to adjust air
|
/turf/assume_air(datum/gas_mixture/giver) //use this for machines to adjust air
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
/turf/proc/assume_gas(gasid, moles, temp = 0)
|
/turf/proc/assume_gas(gasid, moles, temp = 0)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
/turf/return_air()
|
/turf/return_air()
|
||||||
//Create gas mixture to hold data for passing
|
//Create gas mixture to hold data for passing
|
||||||
var/datum/gas_mixture/GM = new
|
var/datum/gas_mixture/GM = new
|
||||||
|
|
||||||
GM.adjust_multi("oxygen", oxygen, "carbon_dioxide", carbon_dioxide, "nitrogen", nitrogen, "phoron", phoron)
|
GM.adjust_multi("oxygen", oxygen, "carbon_dioxide", carbon_dioxide, "nitrogen", nitrogen, "phoron", phoron)
|
||||||
GM.temperature = temperature
|
GM.temperature = temperature
|
||||||
|
|
||||||
return GM
|
return GM
|
||||||
|
|
||||||
/turf/remove_air(amount as num)
|
/turf/remove_air(amount as num)
|
||||||
var/datum/gas_mixture/GM = new
|
var/datum/gas_mixture/GM = new
|
||||||
|
|
||||||
var/sum = oxygen + carbon_dioxide + nitrogen + phoron
|
var/sum = oxygen + carbon_dioxide + nitrogen + phoron
|
||||||
if(sum>0)
|
if(sum>0)
|
||||||
GM.gas["oxygen"] = (oxygen/sum)*amount
|
GM.gas["oxygen"] = (oxygen/sum)*amount
|
||||||
GM.gas["carbon_dioxide"] = (carbon_dioxide/sum)*amount
|
GM.gas["carbon_dioxide"] = (carbon_dioxide/sum)*amount
|
||||||
GM.gas["nitrogen"] = (nitrogen/sum)*amount
|
GM.gas["nitrogen"] = (nitrogen/sum)*amount
|
||||||
GM.gas["phoron"] = (phoron/sum)*amount
|
GM.gas["phoron"] = (phoron/sum)*amount
|
||||||
|
|
||||||
GM.temperature = temperature
|
GM.temperature = temperature
|
||||||
GM.update_values()
|
GM.update_values()
|
||||||
|
|
||||||
return GM
|
return GM
|
||||||
|
|
||||||
/turf/simulated/assume_air(datum/gas_mixture/giver)
|
/turf/simulated/assume_air(datum/gas_mixture/giver)
|
||||||
var/datum/gas_mixture/my_air = return_air()
|
var/datum/gas_mixture/my_air = return_air()
|
||||||
my_air.merge(giver)
|
my_air.merge(giver)
|
||||||
|
|
||||||
/turf/simulated/assume_gas(gasid, moles, temp = null)
|
/turf/simulated/assume_gas(gasid, moles, temp = null)
|
||||||
var/datum/gas_mixture/my_air = return_air()
|
var/datum/gas_mixture/my_air = return_air()
|
||||||
|
|
||||||
if(isnull(temp))
|
if(isnull(temp))
|
||||||
my_air.adjust_gas(gasid, moles)
|
my_air.adjust_gas(gasid, moles)
|
||||||
else
|
else
|
||||||
my_air.adjust_gas_temp(gasid, moles, temp)
|
my_air.adjust_gas_temp(gasid, moles, temp)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
/turf/simulated/remove_air(amount as num)
|
/turf/simulated/remove_air(amount as num)
|
||||||
var/datum/gas_mixture/my_air = return_air()
|
var/datum/gas_mixture/my_air = return_air()
|
||||||
return my_air.remove(amount)
|
return my_air.remove(amount)
|
||||||
|
|
||||||
/turf/simulated/return_air()
|
/turf/simulated/return_air()
|
||||||
if(zone)
|
if(zone)
|
||||||
if(!zone.invalid)
|
if(!zone.invalid)
|
||||||
air_master.mark_zone_update(zone)
|
air_master.mark_zone_update(zone)
|
||||||
return zone.air
|
return zone.air
|
||||||
else
|
else
|
||||||
if(!air)
|
if(!air)
|
||||||
make_air()
|
make_air()
|
||||||
c_copy_air()
|
c_copy_air()
|
||||||
return air
|
return air
|
||||||
else
|
else
|
||||||
if(!air)
|
if(!air)
|
||||||
make_air()
|
make_air()
|
||||||
return air
|
return air
|
||||||
|
|
||||||
/turf/proc/make_air()
|
/turf/proc/make_air()
|
||||||
air = new/datum/gas_mixture
|
air = new/datum/gas_mixture
|
||||||
air.temperature = temperature
|
air.temperature = temperature
|
||||||
air.adjust_multi("oxygen", oxygen, "carbon_dioxide", carbon_dioxide, "nitrogen", nitrogen, "phoron", phoron)
|
air.adjust_multi("oxygen", oxygen, "carbon_dioxide", carbon_dioxide, "nitrogen", nitrogen, "phoron", phoron)
|
||||||
air.group_multiplier = 1
|
air.group_multiplier = 1
|
||||||
air.volume = CELL_VOLUME
|
air.volume = CELL_VOLUME
|
||||||
|
|
||||||
/turf/simulated/proc/c_copy_air()
|
/turf/simulated/proc/c_copy_air()
|
||||||
if(!air) air = new/datum/gas_mixture
|
if(!air) air = new/datum/gas_mixture
|
||||||
air.copy_from(zone.air)
|
air.copy_from(zone.air)
|
||||||
air.group_multiplier = 1
|
air.group_multiplier = 1
|
||||||
|
|||||||
@@ -85,10 +85,10 @@ var/datum/controller/process/garbage_collector/garbage_collector
|
|||||||
A.finalize_qdel()
|
A.finalize_qdel()
|
||||||
|
|
||||||
/datum/proc/finalize_qdel()
|
/datum/proc/finalize_qdel()
|
||||||
del(src)
|
garbage_collector.AddTrash(src)
|
||||||
|
|
||||||
/turf/finalize_qdel()
|
/turf/finalize_qdel()
|
||||||
garbage_collector.AddTrash(src)
|
del(src)
|
||||||
|
|
||||||
// Default implementation of clean-up code.
|
// Default implementation of clean-up code.
|
||||||
// This should be overridden to remove all references pointing to the object being destroyed.
|
// This should be overridden to remove all references pointing to the object being destroyed.
|
||||||
|
|||||||
@@ -84,3 +84,12 @@
|
|||||||
"<span class='notice'>You hear metal clanking.</span>")
|
"<span class='notice'>You hear metal clanking.</span>")
|
||||||
add_fingerprint(user)
|
add_fingerprint(user)
|
||||||
return M
|
return M
|
||||||
|
|
||||||
|
//Cleanup
|
||||||
|
/obj/Destroy()
|
||||||
|
. = ..()
|
||||||
|
unbuckle_mob()
|
||||||
|
|
||||||
|
/obj/Del()
|
||||||
|
. = ..()
|
||||||
|
unbuckle_mob()
|
||||||
|
|||||||
@@ -40,8 +40,7 @@
|
|||||||
/obj/singularity_act()
|
/obj/singularity_act()
|
||||||
ex_act(1)
|
ex_act(1)
|
||||||
if(src)
|
if(src)
|
||||||
spawn(0)
|
qdel(src)
|
||||||
qdel(src)
|
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
/obj/singularity_pull(S, current_size)
|
/obj/singularity_pull(S, current_size)
|
||||||
@@ -72,6 +71,7 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
/obj/machinery/power/supermatter/shard/singularity_act()
|
/obj/machinery/power/supermatter/shard/singularity_act()
|
||||||
|
src.loc = null
|
||||||
qdel(src)
|
qdel(src)
|
||||||
return 5000
|
return 5000
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@
|
|||||||
SetUniversalState(/datum/universal_state/supermatter_cascade)
|
SetUniversalState(/datum/universal_state/supermatter_cascade)
|
||||||
log_admin("New super singularity made by eating a SM crystal [prints]. Last touched by [src.fingerprintslast].")
|
log_admin("New super singularity made by eating a SM crystal [prints]. Last touched by [src.fingerprintslast].")
|
||||||
message_admins("New super singularity made by eating a SM crystal [prints]. Last touched by [src.fingerprintslast].")
|
message_admins("New super singularity made by eating a SM crystal [prints]. Last touched by [src.fingerprintslast].")
|
||||||
spawn(0)
|
src.loc = null
|
||||||
qdel(src)
|
qdel(src)
|
||||||
return 50000
|
return 50000
|
||||||
|
|
||||||
/obj/item/projectile/beam/emitter/singularity_pull()
|
/obj/item/projectile/beam/emitter/singularity_pull()
|
||||||
|
|||||||
Reference in New Issue
Block a user