From 338869f6ad5913d6542c1818e6b07c22e1b00448 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Sat, 26 Dec 2020 11:48:28 -0800 Subject: [PATCH] changes --- .../subsystem/persistence/cleanable_debris.dm | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/code/controllers/subsystem/persistence/cleanable_debris.dm b/code/controllers/subsystem/persistence/cleanable_debris.dm index c4ef98121b..6f85436df8 100644 --- a/code/controllers/subsystem/persistence/cleanable_debris.dm +++ b/code/controllers/subsystem/persistence/cleanable_debris.dm @@ -21,12 +21,31 @@ if(loaded_debris) return loaded_debris = TRUE + var/list/allowed_turf_typecache = typecacheof(/turf/open) - typecacheof(/turf/open/space) + var/list/allowed_z_cache = list() var/list/data = json_decode(file2text("[get_map_persistence_path()]/debris.json")) var/list/z_lookup = list() /// reverse it for(var/z in SSmapping.z_to_station_z_index) var/sz = SSmapping.z_to_station_z_index[z] z_lookup[num2text(sz)] = z + for(var/z in data) + var/actual_z = z_lookup[z] + var/list/L1 = data[z] + for(var/x in L1) + var/list/L2 = data[z][x] + for(var/y in L2) + var/turf/tile = locate(x, y, z) + if(!tile) + continue + var/list/objects = data[z][x][y] + for(var/path in objects) + if(!IsValidDebrisLocation(tile, allowed_turf_typecache, allowed_z_cache, path, TRUE)) + continue + var/obj/effect/cleanable/instantiated = new path(tile) + var/list/data = objects[path] + if(data) + instantiated.PersistenceLoad(data) /datum/controller/subsystem/persistence/proc/SaveMapDebris() if(fexists("[get_map_persistence_path()]/debris.json")) @@ -38,16 +57,22 @@ var/list/data = list() var/list/z_lookup = SSmapping.z_to_station_z_index + WRITE_FILE("[get_map_persistence_path()]/debris.json", json_encode(data)) - -/datum/controller/subsystem/persistence/proc/IsValidDebrisLocation(turf/tile, list/allowed_typecache, list/allowed_zcache) +/datum/controller/subsystem/persistence/proc/IsValidDebrisLocation(turf/tile, list/allowed_typecache, list/allowed_zcache, type, loading = FALSE) if(!allowed_typecache[tile.type]) return FALSE if(!tile.loc.persistent_debris_allowed) return FALSE if(!allowed_zcache[num2text(tile.z)]) return FALSE + if(loading) + if(!initial(type.persistence_allow_stacking)) + var/obj/effect/cleanable/C = locate(type) in tile + if(!QDELETED(C)) + return FALSE + // Saving verifies allow stacking in the save proc. for(var/obj/structure/window/W in tile) if(W.fulltile) return FALSE