diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index b987983362fa..1181d91963dd 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -128,15 +128,16 @@ #define DEFAULT_JOB_TYPE /datum/job/assistant //Area flags, possibly more to come -#define AREA_FLAG_RAD_SHIELDED BITFLAG(1) //shielded from radiation, clearly -#define AREA_FLAG_SPAWN_ROOF BITFLAG(2) // if we should attempt to spawn a roof above us. -#define AREA_FLAG_HIDE_FROM_HOLOMAP BITFLAG(3) // if we shouldn't be drawn on station holomaps -#define AREA_FLAG_FIRING_RANGE BITFLAG(4) -#define AREA_FLAG_NO_CREW_EXPECTED BITFLAG(5) // Areas where crew is not expected to ever be. Used to tell antag bases and such from crew-accessible areas on centcom level. -#define AREA_FLAG_PRISON BITFLAG(6) // Marks prison area for purposes of checking if brigged/imprisoned -#define AREA_FLAG_NO_GHOST_TELEPORT_ACCESS BITFLAG(7) // Marks whether ghosts should not have teleport access to this area -#define AREA_FLAG_INDESTRUCTIBLE_TURFS BITFLAG(8) //Marks whether or not turfs in this area can be destroyed by explosions -#define AREA_FLAG_IS_BACKGROUND BITFLAG(9) //Marks whether or not blueprints can create areas on top of this area +#define AREA_FLAG_RAD_SHIELDED BITFLAG(1) // shielded from radiation, clearly +#define AREA_FLAG_SPAWN_ROOF BITFLAG(2) // if we should attempt to spawn a roof above us. +#define AREA_FLAG_HIDE_FROM_HOLOMAP BITFLAG(3) // if we shouldn't be drawn on station holomaps +#define AREA_FLAG_FIRING_RANGE BITFLAG(4) // Area dedicated for firing pin logic +#define AREA_FLAG_NO_CREW_EXPECTED BITFLAG(5) // Areas where crew is not expected to ever be. Used to tell antag bases and such from crew-accessible areas on centcom level. +#define AREA_FLAG_PRISON BITFLAG(6) // Marks prison area for purposes of checking if brigged/imprisoned +#define AREA_FLAG_NO_GHOST_TELEPORT_ACCESS BITFLAG(7) // Marks whether ghosts should not have teleport access to this area +#define AREA_FLAG_INDESTRUCTIBLE_TURFS BITFLAG(8) // Marks whether or not turfs in this area can be destroyed by explosions +#define AREA_FLAG_IS_BACKGROUND BITFLAG(9) // Marks whether or not blueprints can create areas on top of this area +#define AREA_FLAG_PREVENT_PERSISTENT_TRASH BITFLAG(10) // Marks whether or not the area allows trash to become persistent in it // Convoluted setup so defines can be supplied by Bay12 main server compile script. // Should still work fine for people jamming the icons into their repo. diff --git a/code/controllers/subsystems/persistence.dm b/code/controllers/subsystems/persistence.dm index 35c869317425..d52cfb59f64c 100644 --- a/code/controllers/subsystems/persistence.dm +++ b/code/controllers/subsystems/persistence.dm @@ -120,9 +120,11 @@ SUBSYSTEM_DEF(persistence) * RETURN: JSON formatted content of track or null if an exception occured. */ /datum/controller/subsystem/persistence/proc/track_get_content(var/obj/track) - var/result = null + var/result = json_encode(list()) try - result = json_encode(track.persistence_get_content()) + var/list/content = track.persistence_get_content() + if(content && content.len) + result = json_encode(content) catch(var/exception/e) log_subsystem_persistence("Track: Failed to get/encode track content: [e]") return result @@ -202,10 +204,6 @@ SUBSYSTEM_DEF(persistence) if(!SSdbcore.Connect()) log_subsystem_persistence("SQL ERROR during persistence database_add_entry. Failed to connect.") else - var/content = track_get_content(track) - if (!content) - return - var/turf/T = get_turf(track) if(!T || !is_station_level(T.z)) // The persistence system only supports objects from the main map levels for multiple reasons, e.g. Z level value, mapping support return @@ -217,7 +215,7 @@ SUBSYSTEM_DEF(persistence) "author_ckey" = track.persistence_author_ckey, "type" = "[track.type]", "expire_in_days" = track.persistance_expiration_time_days, - "content" = content, + "content" = track_get_content(track), "x" = T.x, "y" = T.y, "z" = T.z @@ -236,10 +234,6 @@ SUBSYSTEM_DEF(persistence) if(!SSdbcore.Connect()) log_subsystem_persistence("SQL ERROR during persistence database_update_entry. Failed to connect.") else - var/content = track_get_content(track) - if (!content) - return - var/turf/T = get_turf(track) if(!T || !is_station_level(T.z)) // The persistence system only supports objects from the main map levels for multiple reasons, e.g. Z level value, mapping support return @@ -249,7 +243,7 @@ SUBSYSTEM_DEF(persistence) list( "author_ckey" = track.persistence_author_ckey, "expire_in_days" = track.persistance_expiration_time_days, - "content" = content, + "content" = track_get_content(track), "x" = T.x, "y" = T.y, "z" = T.z, diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index fef0c9d805ec..ba6edaf170d6 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -234,6 +234,11 @@ /// Holder var for the item outline filter, null when no outline filter on the item. var/outline_filter + // Persistency + // Set this to true if you want the item to become persistent trash + // Requires the usual implementation requirements for new persistent types but provides a single implementation for trash logic + var/persistency_considered_trash = FALSE + /obj/item/Initialize(mapload, ...) . = ..() if(islist(armor)) @@ -480,18 +485,38 @@ if(item_flags & ITEM_FLAG_HELD_MAP_TEXT) check_maptext() - if(zoom) zoom(user) //binoculars, scope, etc SEND_SIGNAL(src, COMSIG_ITEM_DROPPED, user) - in_inventory = FALSE if(user && (z_flags & ZMM_MANGLE_PLANES)) addtimer(CALLBACK(user, /mob/proc/check_emissive_equipment), 0, TIMER_UNIQUE) user?.update_equipment_speed_mods() + try_make_persistent_trash() + +/obj/item/pipe_eject(var/direction) + SHOULD_CALL_PARENT(TRUE) + ..() + try_make_persistent_trash() // Trash that gets thrown into disposal bins and ends up in the disposal areas shouldn't be persistent after all + +/obj/item/proc/try_make_persistent_trash() + SHOULD_NOT_OVERRIDE(TRUE) + PROTECTED_PROC(TRUE) + if(persistency_considered_trash) // Persistent trash - Applicable if considered_persistent_trash is true + // Trash-like items should become only persistent when they are not dropped in a maint or disposals, otherwise they get deregistered + var/turf/T = get_turf(src) + if(T) + var/area/A = get_area(T) + if(A && !(A.area_flags & AREA_FLAG_PREVENT_PERSISTENT_TRASH)) + persistance_expiration_time_days = 3 // Ensure expiration date is set to prevent long term trash + SSpersistence.register_track(src, usr == null ? null : ckey(usr.key)) + else + SSpersistence.deregister_track(src) + else + SSpersistence.deregister_track(src) /obj/item/proc/remove_item_verbs(mob/user) if(ismech(user)) //very snowflake, but necessary due to how mechs work @@ -603,6 +628,9 @@ user.update_equipment_speed_mods() + if(persistency_considered_trash || persistence_track_active) // The moment trash like items get picked up they are no longer persistent + SSpersistence.deregister_track(src) + /obj/item/proc/check_equipped(var/mob/user, var/slot, var/assisted_equip = FALSE) return TRUE diff --git a/code/game/objects/items/trash.dm b/code/game/objects/items/trash.dm index e7dd99220ff8..03372a8ac9c4 100644 --- a/code/game/objects/items/trash.dm +++ b/code/game/objects/items/trash.dm @@ -10,10 +10,34 @@ desc = "General waste material, refuse or litter. Dispose responsibly." drop_sound = 'sound/items/drop/wrapper.ogg' pickup_sound = 'sound/items/pickup/wrapper.ogg' + persistency_considered_trash = TRUE /obj/item/trash/attack(mob/living/target_mob, mob/living/user, target_zone) return +/obj/item/trash/persistence_get_content() + var/list/content = list() + content["name"] = name + content["desc"] = desc + content["icon"] = icon + content["icon_state"] = icon_state + content["item_state"] = item_state + content["drop_sound"] = drop_sound + content["pickup_sound"] = pickup_sound + return content + +/obj/item/trash/persistence_apply_content(content, x, y, z) + name = content["name"] + desc = content["desc"] + icon = file(content["icon"]) + icon_state = content["icon_state"] + item_state = content["item_state"] + drop_sound = file(content["drop_sound"]) + pickup_sound = file(content["pickup_sound"]) + src.x = x + src.y = y + src.z = z + /obj/item/trash/koisbar name = "\improper k'ois bar wrapper" icon_state = "koisbar" diff --git a/code/game/objects/structures/inflatable.dm b/code/game/objects/structures/inflatable.dm index f278a056413c..a75056b82b09 100644 --- a/code/game/objects/structures/inflatable.dm +++ b/code/game/objects/structures/inflatable.dm @@ -289,6 +289,12 @@ name = "torn inflatable wall" desc = "A folded membrane which rapidly expands into a large cubical shape on activation. It is too torn to be usable." icon_state = "folded_wall-torn" + persistency_considered_trash = TRUE + +/obj/item/inflatable/torn/persistence_apply_content(content, x, y, z) + src.x = x + src.y = y + src.z = z /obj/item/inflatable/torn/attack_self(mob/user) to_chat(user, SPAN_NOTICE("The inflatable wall is too torn to be inflated!")) @@ -298,6 +304,12 @@ name = "torn inflatable door" desc = "A folded membrane which rapidly expands into a simple door on activation. It is too torn to be usable." icon_state = "folded_door-torn" + persistency_considered_trash = TRUE + +/obj/item/inflatable/door/torn/persistence_apply_content(content, x, y, z) + src.x = x + src.y = y + src.z = z /obj/item/inflatable/door/torn/attack_self(mob/user) to_chat(user, SPAN_NOTICE("The inflatable door is too torn to be inflated!")) diff --git a/code/modules/mapping/reader.dm b/code/modules/mapping/reader.dm index b31e125312a5..a83b502eb0c7 100644 --- a/code/modules/mapping/reader.dm +++ b/code/modules/mapping/reader.dm @@ -543,6 +543,7 @@ GLOBAL_LIST_INIT(_preloader_path, null) /area/template_noop name = "Area Passthrough" icon_state = "noop" + area_flags = AREA_FLAG_PREVENT_PERSISTENT_TRASH /turf/template_noop name = "Turf Passthrough" diff --git a/code/modules/reagents/reagent_containers/food/drinks/bottle.dm b/code/modules/reagents/reagent_containers/food/drinks/bottle.dm index 77ca5f87f51c..3eb054a40678 100644 --- a/code/modules/reagents/reagent_containers/food/drinks/bottle.dm +++ b/code/modules/reagents/reagent_containers/food/drinks/bottle.dm @@ -247,6 +247,12 @@ ///The mask image for mimicking a broken-off neck of the bottle var/static/icon/flipped_broken_outline = icon('icons/obj/item/reagent_containers/food/drinks/drink_effects.dmi', "broken-flipped") w_class = WEIGHT_CLASS_SMALL + persistency_considered_trash = TRUE + +/obj/item/broken_bottle/persistence_apply_content(content, x, y, z) + src.x = x + src.y = y + src.z = z #define DRINK_FLUFF_GETMORE "This drink is made by Getmore Corporation, a subsidiary of NanoTrasen. It mostly specializes in fast food and consumer food products, \ but also makes average quality alcohol. Many can find Getmore products in grocery stores, vending machines, \ diff --git a/html/changelogs/fabiank3-persistent-trash.yml b/html/changelogs/fabiank3-persistent-trash.yml new file mode 100644 index 000000000000..610cf0c0d637 --- /dev/null +++ b/html/changelogs/fabiank3-persistent-trash.yml @@ -0,0 +1,6 @@ +author: FabianK3 + +delete-after: True + +changes: + - rscadd: "Added multiple types of trash to the persistence system. Trash will become persistent when it's dropped unless it's in a maint, in the custodial areas (including disposal/compactor) or gets picked up again. Persistent trash can be found up to three days later." diff --git a/maps/sccv_horizon/areas/_horizon_areas.dm b/maps/sccv_horizon/areas/_horizon_areas.dm index 24c5ead9448d..e7cddbe6a526 100644 --- a/maps/sccv_horizon/areas/_horizon_areas.dm +++ b/maps/sccv_horizon/areas/_horizon_areas.dm @@ -43,5 +43,5 @@ no_light_control = TRUE allow_nightmode = FALSE ambience = AMBIENCE_SPACE - area_flags = AREA_FLAG_HIDE_FROM_HOLOMAP + area_flags = AREA_FLAG_HIDE_FROM_HOLOMAP | AREA_FLAG_PREVENT_PERSISTENT_TRASH area_blurb = "The sheer scale of the SCCV Horizon is never more apparent when crawling across its hull like an ant." diff --git a/maps/sccv_horizon/areas/horizon_areas_maintenance.dm b/maps/sccv_horizon/areas/horizon_areas_maintenance.dm index 70743c8e5003..f54e8d553065 100644 --- a/maps/sccv_horizon/areas/horizon_areas_maintenance.dm +++ b/maps/sccv_horizon/areas/horizon_areas_maintenance.dm @@ -2,7 +2,7 @@ /area/horizon/maintenance name = "Horizon - Maintenance (PARENT AREA - DON'T USE)" icon_state = "maintenance" - area_flags = AREA_FLAG_RAD_SHIELDED | AREA_FLAG_HIDE_FROM_HOLOMAP + area_flags = AREA_FLAG_RAD_SHIELDED | AREA_FLAG_HIDE_FROM_HOLOMAP | AREA_FLAG_PREVENT_PERSISTENT_TRASH sound_environment = SOUND_AREA_TUNNEL_ENCLOSED turf_initializer = new /datum/turf_initializer/maintenance() area_blurb = "Scarcely lit, cramped, and filled with stale, dusty air. Around you hisses compressed air through the pipes, a buzz of electrical charge through the wires, and muffled rumbles of the hull settling. This place may feel alien compared to the interior of the ship and is a place where one could get lost or badly hurt, but some may find the isolation comforting." diff --git a/maps/sccv_horizon/areas/horizon_areas_service.dm b/maps/sccv_horizon/areas/horizon_areas_service.dm index ef5a66e3b14c..903e2d12ad0c 100644 --- a/maps/sccv_horizon/areas/horizon_areas_service.dm +++ b/maps/sccv_horizon/areas/horizon_areas_service.dm @@ -84,6 +84,7 @@ area_blurb = "A strong, concentrated smell of many cleaning supplies linger within this room." area_blurb_category = "janitor" horizon_deck = 1 + area_flags = AREA_FLAG_PREVENT_PERSISTENT_TRASH /area/horizon/service/custodial/disposals name = "Disposals and Recycling (PARENT AREA - DON'T USE)"