From 94dfc81975e2aa46dde02b0f4b46d514d78ad943 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 4 Nov 2022 18:14:35 +0100 Subject: [PATCH] [MIRROR] Fixes issues with printing posters from the library management computer [MDB IGNORE] (#17344) * Fixes issues with printing posters from the library management computer (#70471) ## About The Pull Request Posters are kind of insane and they require that the poster item have either a poster_type defined in the type or that you pass the structure version of the poster to /new() otherwise they don't work. The weird thing is that the structure needs to be in the contents of the item too, or it again won't work (it won't remove the poster from your hands when placing it). I fixed it so all you need to do is pass the structure version of the poster to /new() on the item and it will move the structure to the contents of the item if needed. It's still a bit insane but it's better than it was and it fixed the bug. Also SSLibrary.printable_posters was grabbing the directional mapping helper of the random poster and so when you printed it and placed it, you'd get confusing results. I made a quick fix to stop that from happening. ## Why It's Good For The Game Bug fixes are generally good things. Fixes #70382 Fixes #66504 ## Changelog :cl: VexingRaven fix: Fixed posters printed from the library console staying in your hand when you place them fix: Fixed Random Official Poster printed from the library console always placing the west-facing variant no matter where you place it /:cl: * Fixes issues with printing posters from the library management computer Co-authored-by: VexingRaven --- code/controllers/subsystem/library.dm | 3 ++- code/game/objects/effects/contraband.dm | 22 ++++++++++++++++++++++ code/modules/library/lib_machines.dm | 4 +--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/code/controllers/subsystem/library.dm b/code/controllers/subsystem/library.dm index 3f6a04a3f02..e296d34eed6 100644 --- a/code/controllers/subsystem/library.dm +++ b/code/controllers/subsystem/library.dm @@ -49,7 +49,8 @@ SUBSYSTEM_DEF(library) /datum/controller/subsystem/library/proc/prepare_official_posters() printable_posters = list() for(var/obj/structure/sign/poster/official/poster_type as anything in subtypesof(/obj/structure/sign/poster/official)) - printable_posters[initial(poster_type.name)] = poster_type + if (initial(poster_type.printable) == TRUE) //Mostly this check exists to keep directionals from ending up in the printable list + printable_posters[initial(poster_type.name)] = poster_type /datum/controller/subsystem/library/proc/prepare_library_areas() library_areas = typesof(/area/station/service/library) - /area/station/service/library/abandoned diff --git a/code/game/objects/effects/contraband.dm b/code/game/objects/effects/contraband.dm index aa96d12a087..bee0bc68dfb 100644 --- a/code/game/objects/effects/contraband.dm +++ b/code/game/objects/effects/contraband.dm @@ -3,6 +3,14 @@ // The poster item +/** + * The rolled up item form of a poster + * + * In order to create one of these for a specific poster, you must pass the structure form of the poster as an argument to /new(). + * This structure then gets moved into the contents of the item where it will stay until the poster is placed by a player. + * The structure form is [obj/structure/sign/poster] and that's where all the specific posters are defined. + * If you just want a random poster, see [/obj/item/poster/random_official] or [/obj/item/poster/random_contraband] + */ /obj/item/poster name = "poorly coded poster" desc = "You probably shouldn't be holding this." @@ -22,6 +30,8 @@ ) AddElement(/datum/element/contextual_screentip_item_typechecks, hovering_item_typechecks) + if(new_poster_structure && (new_poster_structure.loc != src)) + new_poster_structure.forceMove(src) //The poster structure *must* be in the item's contents for the exited() proc to properly clean up when placing the poster poster_structure = new_poster_structure if(!new_poster_structure && poster_type) poster_structure = new poster_type(src) @@ -81,6 +91,12 @@ // The poster sign/structure +/** + * The structure form of a poster. + * + * These are what get placed on maps as posters. They are also what gets created when a player places a poster on a wall. + * For the item form that can be spawned for players, see [/obj/item/poster] + */ /obj/structure/sign/poster name = "poster" var/original_name @@ -91,6 +107,8 @@ var/ruined = FALSE var/random_basetype var/never_random = FALSE // used for the 'random' subclasses. + ///Whether the poster should be printable from library management computer. Mostly exists to keep directionals from being printed. + var/printable = FALSE var/poster_item_name = "hypothetical poster" var/poster_item_desc = "This hypothetical poster item should not exist, let's be honest here." @@ -726,6 +744,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sign/poster/contraband/random, 32) poster_item_name = "motivational poster" poster_item_desc = "An official Nanotrasen-issued poster to foster a compliant and obedient workforce. It comes with state-of-the-art adhesive backing, for easy pinning to any vertical surface." poster_item_icon_state = "rolled_legit" + printable = TRUE /obj/structure/sign/poster/official/random name = "Random Official Poster (ROP)" @@ -734,6 +753,9 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sign/poster/contraband/random, 32) never_random = TRUE MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sign/poster/official/random, 32) +//This is being hardcoded here to ensure we don't print directionals from the library management computer because they act wierd as a poster item +/obj/structure/sign/poster/official/random/directional + printable = FALSE /obj/structure/sign/poster/official/here_for_your_safety name = "Here For Your Safety" diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index 9ad2579b554..048e4507880 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -646,9 +646,7 @@ var/poster_type = SSlibrary.printable_posters[poster_name] if(!poster_type) return - - var/obj/item/poster/random_official/poster = new(loc, new poster_type) - poster.name = poster_name + new /obj/item/poster(loc, new poster_type) /obj/machinery/computer/libraryconsole/bookmanagement/proc/print_book(id) if (!SSdbcore.Connect())