Files
CHOMPStation2/code/controllers/subsystems/persistence.dm
Rykka ad6870c78d Persistence Patch
- Fixes Paper and font tags stacking across rounds, as shown in: ![](https://cdn.discordapp.com/attachments/187013248309002240/741937939382141000/164fdd3a37fb22f18dfa9b5c431ffc04.png)

- Fixes Graffiti being persistent for over 50 rounds (10+ days)
- Sets Trash to be persistent for 4 rounds instead of 5
- Fixes Persistence being always-on because of if("persistence_enabled") config.persistence_enabled = 1. As explained: 
> it's on by default, which means config.txt will be read and if it's not there it stays at 1. If it is there,it gets set to 1. There is no way to disable it

- Adds config options to enable/disable **Persistence for Maploaded objects**, as well as a verb to toggle such.
- Adds Persistence to config.

Currently IGNORE_MAPLOAD for Persistance is **Disabled.**
Maploaded objects/dirt/etc will be saved by persistence, preserving current behavior.
2020-08-16 09:48:46 -04:00

59 lines
1.7 KiB
Plaintext

SUBSYSTEM_DEF(persistence)
name = "Persistence"
init_order = INIT_ORDER_PERSISTENCE
flags = SS_NO_FIRE
var/list/tracking_values = list()
var/list/persistence_datums = list()
/datum/controller/subsystem/persistence/Initialize()
. = ..()
for(var/thing in subtypesof(/datum/persistent))
var/datum/persistent/P = new thing
persistence_datums[thing] = P
P.Initialize()
/datum/controller/subsystem/persistence/Shutdown()
for(var/thing in persistence_datums)
var/datum/persistent/P = persistence_datums[thing]
P.Shutdown()
/datum/controller/subsystem/persistence/proc/track_value(var/atom/value, var/track_type)
if(config.persistence_disabled) //if the config is set to persistence disabled, nothing will save or load.
return
var/turf/T = get_turf(value)
if(!T)
return
var/area/A = get_area(T)
if(!A || (A.flags & AREA_FLAG_IS_NOT_PERSISTENT))
return
// if((!T.z in GLOB.using_map.station_levels) || !initialized)
if(!T.z in using_map.station_levels)
return
if(!tracking_values[track_type])
tracking_values[track_type] = list()
tracking_values[track_type] += value
/datum/controller/subsystem/persistence/proc/forget_value(var/atom/value, var/track_type)
if(tracking_values[track_type])
tracking_values[track_type] -= value
/datum/controller/subsystem/persistence/proc/show_info(var/mob/user)
if(!user.client.holder)
return
var/list/dat = list("<table width = '100%'>")
var/can_modify = check_rights(R_ADMIN, 0, user)
for(var/thing in persistence_datums)
var/datum/persistent/P = persistence_datums[thing]
if(P.has_admin_data)
dat += P.GetAdminSummary(user, can_modify)
dat += "</table>"
var/datum/browser/popup = new(user, "admin_persistence", "Persistence Data")
popup.set_content(jointext(dat, null))
popup.open()