Block atmos processing on ReservedTurfs\™️ (#84873)

## About The Pull Request

See title.

## Why It's Good For The Game

We get constant runtimes and issues from atmos processing on turfs we
are actively loading and/or reserving. I promised I would do something
about this months ago

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
Zephyr
2024-08-15 18:45:59 +02:00
committed by GitHub
co-authored by Ghom
parent e99d4b0d44
commit 52f7f44215
3 changed files with 27 additions and 13 deletions
+15 -11
View File
@@ -184,17 +184,20 @@ SUBSYSTEM_DEF(mapping)
if(index)
lists_to_reserve.Cut(1, index)
return
var/turf/T = packet[packetlen]
T.empty(RESERVED_TURF_TYPE, RESERVED_TURF_TYPE, null, TRUE)
LAZYINITLIST(unused_turfs["[T.z]"])
unused_turfs["[T.z]"] |= T
var/area/old_area = T.loc
LISTASSERTLEN(old_area.turfs_to_uncontain_by_zlevel, T.z, list())
old_area.turfs_to_uncontain_by_zlevel[T.z] += T
T.turf_flags = UNUSED_RESERVATION_TURF
world_contents += T
LISTASSERTLEN(world_turf_contents_by_z, T.z, list())
world_turf_contents_by_z[T.z] += T
var/turf/reserving_turf = packet[packetlen]
reserving_turf.empty(RESERVED_TURF_TYPE, RESERVED_TURF_TYPE, null, TRUE)
LAZYINITLIST(unused_turfs["[reserving_turf.z]"])
unused_turfs["[reserving_turf.z]"] |= reserving_turf
var/area/old_area = reserving_turf.loc
LISTASSERTLEN(old_area.turfs_to_uncontain_by_zlevel, reserving_turf.z, list())
old_area.turfs_to_uncontain_by_zlevel[reserving_turf.z] += reserving_turf
reserving_turf.turf_flags = UNUSED_RESERVATION_TURF
// reservation turfs are not allowed to interact with atmos at all
reserving_turf.blocks_air = TRUE
world_contents += reserving_turf
LISTASSERTLEN(world_turf_contents_by_z, reserving_turf.z, list())
world_turf_contents_by_z[reserving_turf.z] += reserving_turf
packet.len--
packetlen = length(packet)
@@ -731,6 +734,7 @@ ADMIN_VERB(load_away_mission, R_FUN, "Load Away Mission", "Load a specific away
for(var/turf/T as anything in block)
// No need to empty() these, because they just got created and are already /turf/open/space/basic.
T.turf_flags = UNUSED_RESERVATION_TURF
T.blocks_air = TRUE
CHECK_TICK
// Gotta create these suckers if we've not done so already
@@ -338,6 +338,12 @@
#endif
for(var/turf/open/enemy_tile as anything in adjacent_turfs)
#ifdef UNIT_TESTS
if(!istype(enemy_tile))
stack_trace("closed turf inside of adjacent turfs")
continue
#endif
// This var is only rarely set, exists so turfs can request to share at the end of our sharing
// We need this so we can assume share is communative, which we need to do to avoid a hellish amount of garbage_collect()s
if(enemy_tile.run_later)
@@ -55,6 +55,10 @@
for(var/turf/reserved_turf as anything in release_turfs)
SEND_SIGNAL(reserved_turf, COMSIG_TURF_RESERVATION_RELEASED, src)
// immediately disconnect from atmos
reserved_turf.blocks_air = TRUE
CALCULATE_ADJACENT_TURFS(reserved_turf, KILL_EXCITED)
// Makes the linter happy, even tho we don't await this
INVOKE_ASYNC(SSmapping, TYPE_PROC_REF(/datum/controller/subsystem/mapping, reserve_turfs), release_turfs)
@@ -93,7 +97,7 @@
// Its no longer unused, but its also not "used"
cordon_turf.turf_flags &= ~UNUSED_RESERVATION_TURF
cordon_turf.ChangeTurf(/turf/cordon, /turf/cordon)
cordon_turf.empty(/turf/cordon, /turf/cordon)
SSmapping.unused_turfs["[cordon_turf.z]"] -= cordon_turf
// still gets linked to us though
SSmapping.used_turfs[cordon_turf] = src
@@ -187,7 +191,7 @@
SSmapping.unused_turfs["[T.z]"] -= T
SSmapping.used_turfs[T] = src
T.turf_flags = (T.turf_flags | RESERVATION_TURF) & ~UNUSED_RESERVATION_TURF
T.ChangeTurf(turf_type, turf_type_is_baseturf ? turf_type : null)
T.empty(turf_type, turf_type_is_baseturf ? turf_type : null)
bottom_left_turfs += BL
top_right_turfs += TR