This commit is contained in:
silicons
2020-12-26 11:35:47 -08:00
parent 5cf717e75d
commit 45af2360ad
7 changed files with 116 additions and 16 deletions

View File

@@ -23,7 +23,7 @@ SUBSYSTEM_DEF(persistence)
LoadGamePersistence()
var/map_persistence_path = get_map_persistence_path()
if(map_persistence_path)
LoadMapPersistence(map_persistence_path)
LoadMapPersistence()
return ..()
/**
@@ -40,7 +40,7 @@ SUBSYSTEM_DEF(persistence)
SaveGamePersistence()
var/map_persistence_path = get_map_persistence_path()
if(map_persistence_path)
SaveMapPersistence(map_persistence_path)
SaveMapPersistence()
/**
* Loads persistent data relevant to the server: Configurations, past gamemodes, votes, etc
@@ -83,20 +83,14 @@ SUBSYSTEM_DEF(persistence)
/**
* Loads persistent data relevant to the current map: Objects, etc.
*
* @params
* data_directory - The data directory to use. Each map with a persistence key has its own, and this is based on the persistence key.
*/
/datum/controller/subsystem/persistence/proc/LoadMapPersistence(data_directory)
/datum/controller/subsystem/persistence/proc/LoadMapPersistence()
return
/**
* Saves persistent data relevant to the current map: Objects, etc.
*
* @params
* data_directory - The data directory to use. Each map with a persistence key has its own, and this is based on the persistence key.
*/
/datum/controller/subsystem/persistence/proc/SaveMapPersistence(data_directory)
/datum/controller/subsystem/persistence/proc/SaveMapPersistence()
return
/datum/controller/subsystem/persistence/proc/LoadChiselMessages()

View File

@@ -1,3 +1,49 @@
/**
* Persistence for cleanable debris.
*/
/datum/controller/subsystem/persistence
/// tracks if we already loaded debris. Unlike everything else, this can actually be a major problem if some badmin procs it twice.
var/loaded_debris = FALSE
/datum/controller/subsystem/persistence/LoadMapPersistence()
. = ..()
if(CONFIG_GET(flag/persistent_debris))
LoadMapDebris()
/datum/controller/subsystem/persistence/SaveMapPersistence()
. = ..()
if(CONFIG_GET(flag/persistent_debris))
SaveMapDebris()
/datum/controller/subsystem/persistence/proc/LoadMapDebris()
if(!fexists("[get_map_persistence_path()]/debris.json"))
return
if(loaded_debris)
return
loaded_debris = TRUE
var/list/data = json_decode(file2text("[get_map_persistence_path()]/debris.json"))
/datum/controller/subsystem/persistence/proc/SaveMapDebris()
if(fexists("[get_map_persistence_path()]/debris.json"))
fdel("[get_map_persistence_path()]/debris.json")
var/list/allowed_turf_typecache = typecacheof(/turf/open) - typecacheof(/turf/open/space)
var/list/allowed_z_cache = list()
for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION))
allowed_z_cache[num2text(z)] = TRUE
var/list/data = list()
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)
if(!allowed_typecache[tile.type])
return FALSE
if(!tile.loc.persistent_debris_allowed)
return FALSE
if(!allowed_zcache[num2text(tile.z)])
return FALSE
for(var/obj/structure/window/W in tile)
if(W.fulltile)
return FALSE
return TRUE