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

View File

@@ -41,6 +41,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
power_environ = FALSE
valid_territory = FALSE
outdoors = TRUE
persistent_debris_allowed = FALSE
ambientsounds = SPACE
blob_allowed = FALSE //Eating up space doesn't count for victory as a blob.
considered_hull_exterior = TRUE

View File

@@ -24,6 +24,8 @@
var/clockwork_warp_allowed = TRUE
/// Message to display when the clockwork warp fails
var/clockwork_warp_fail = "The structure there is too dense for warping to pierce. (This is normal in high-security areas.)"
/// Persistent debris alowed
var/persistent_debris_allowed = TRUE
/// If mining tunnel generation is allowed in this area
var/tunnel_allowed = FALSE

View File

@@ -3,6 +3,8 @@
layer = ABOVE_NORMAL_TURF_LAYER
/// Is this kind of cleanable decal persistent
var/persistent = FALSE
/// Can we stack multiple in one tile?
var/persistence_allow_stacking = FALSE
var/list/random_icon_states = null
var/blood_state = "" //I'm sorry but cleanable/blood code is ass, and so is blood_DNA
@@ -36,20 +38,20 @@
addtimer(CALLBACK(src, /datum.proc/_AddElement, list(/datum/element/beauty, beauty)), 0)
/**
* Returns a list of data
* A data list is passed into this.
* This should return null to skip saving, or the type of data to save. Type must be /cleanable.
*/
/obj/effect/decal/cleanable/proc/PersistenceSave()
return null
/obj/effect/decal/cleanable/proc/PersistenceSave(list/data)
return type
/**
* Laods from a data list.
* Loads from a data list.
*/
/obj/effect/decal/cleanable/proc/PersistenceLoad(list/data)
return
/obj/effect/decal/cleanable/proc/replace_decal(obj/effect/decal/cleanable/C) // Returns true if we should give up in favor of the pre-existing decal
if(mergeable_decal)
qdel(C)
return mergeable_decal
/obj/effect/decal/cleanable/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/reagent_containers/glass) || istype(W, /obj/item/reagent_containers/food/drinks))

View File

@@ -12,6 +12,8 @@
icon_state = "ash"
mergeable_decal = FALSE
beauty = -50
persistent = TRUE
persistence_allow_stacking = TRUE
/obj/effect/decal/cleanable/ash/Initialize()
. = ..()
@@ -38,6 +40,8 @@
icon = 'icons/obj/shards.dmi'
icon_state = "tiny"
beauty = -100
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/glass/Initialize()
. = ..()
@@ -94,6 +98,8 @@
light_color = LIGHT_COLOR_GREEN
icon_state = "greenglow"
beauty = -300
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/greenglow/Initialize(mapload)
. = ..()
@@ -122,6 +128,8 @@
icon_state = "molten"
mergeable_decal = FALSE
beauty = -150
persistent = TRUE
persistence_allow_stacking = TRUE
/obj/effect/decal/cleanable/molten_object/large
name = "big gooey grey mass"
@@ -136,6 +144,7 @@
icon_state = "vomit_1"
random_icon_states = list("vomit_1", "vomit_2", "vomit_3", "vomit_4")
beauty = -150
persistent = TRUE
/obj/effect/decal/cleanable/vomit/on_attack_hand(mob/user, act_intent = user.a_intent, unarmed_attack_flags)
if(ishuman(user))
@@ -151,6 +160,10 @@
reagents.trans_to(H, reagents.total_volume)
qdel(src)
/obj/effect/decal/cleanable/vomit/PersistenceSave(list/data)
. = ..()
return /obj/effect/decal/cleanable/vomit/old
/obj/effect/decal/cleanable/vomit/old
name = "crusty dried vomit"
desc = "You try not to look at the chunks, and fail."
@@ -166,12 +179,16 @@
icon = 'icons/effects/tomatodecal.dmi'
random_icon_states = list("tomato_floor1", "tomato_floor2", "tomato_floor3")
beauty = -100
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/plant_smudge
name = "plant smudge"
gender = NEUTER
icon = 'icons/effects/tomatodecal.dmi'
random_icon_states = list("smashed_plant")
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/egg_smudge
name = "smashed egg"
@@ -179,6 +196,8 @@
gender = NEUTER
icon = 'icons/effects/tomatodecal.dmi'
random_icon_states = list("smashed_egg1", "smashed_egg2", "smashed_egg3")
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/pie_smudge //honk
name = "smashed pie"
@@ -186,6 +205,8 @@
gender = NEUTER
icon = 'icons/effects/tomatodecal.dmi'
random_icon_states = list("smashed_pie")
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/chem_pile
name = "chemical pile"
@@ -193,6 +214,8 @@
gender = NEUTER
icon = 'icons/obj/objects.dmi'
icon_state = "ash"
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/shreds
name = "shreds"
@@ -200,6 +223,8 @@
icon_state = "shreds"
gender = PLURAL
mergeable_decal = FALSE
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/shreds/ex_act(severity, target)
if(severity == 1) //so shreds created during an explosion aren't deleted by the explosion.
@@ -222,6 +247,8 @@
desc = "The herpes of arts and crafts."
icon = 'icons/effects/atmospherics.dmi'
gender = NEUTER
mergeable_decal = TRUE
persistent = TRUE
/obj/effect/decal/cleanable/glitter/pink
name = "pink glitter"
@@ -247,3 +274,5 @@
icon = 'icons/effects/blood.dmi'
icon_state = "xfloor1"
random_icon_states = list("xfloor1", "xfloor2", "xfloor3", "xfloor4", "xfloor5", "xfloor6", "xfloor7")
mergeable_decal = TRUE
persistent = TRUE

View File

@@ -5,6 +5,8 @@
icon_state = "rune1"
plane = ABOVE_WALL_PLANE //makes the graffiti visible over a wall.
gender = NEUTER
persistent = TRUE
persistence_allow_stacking = TRUE
mergeable_decal = FALSE
var/do_icon_rotate = TRUE
var/rotation = 0
@@ -29,3 +31,27 @@
if(main)
paint_colour = main
add_atom_colour(paint_colour, FIXED_COLOUR_PRIORITY)
/obj/effect/decal/cleanable/crayon/PersistenceSave(list/data)
. = ..()
if(icon != initial(icon)) // no support for alticons yet, awful system anyways
return null
data["icon_state"] = icon_stsate
data["paint_color"] = paint_colour
if(do_icon_rotate)
data["rotation"] = rotation
data["name"] = name
/obj/effect/decal/cleanable/crayon/PersistenceLoad(list/data)
. = ..()
if(data["name"])
name = data["name"]
if(do_icon_rotate && data["rotation"])
var/matrix/M = matrix()
M.turn(data["rotation"])
transform = M
if(data["paint_color"])
paint_colour = data["paint_color"])
add_atom_colour(paint_colour, FIXED_COLOUR_PRIORITY)
if(data["icon_state"])
icon_state = data["icon_state"]