mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-26 09:32:21 +00:00
Fixes #86784
## About The Pull Request
Although some of the issues found were a direct result from #86692
(c698196766), there was still 40% of
length-related issues that wouldn't be covered anyways that are fixed in
this PR. I.E.:
* Name inputs without `MAX_NAME_LEN`
* Desc inputs without `MAX_DESC_LEN`
* Plaque inputs without `MAX_PLAQUE_LEN`
* Some people just screwed up the arguments so it would prefill
something like "40" in the `default` var because they didn't name their
vars.
To help me audit I added a lot of `max_length` named arguments to help
people understand it better. I think it might be kinder to have a
wrapper that handles adding `MAX_MESSAGE_LEN` in a lot of these cases
but I think there is some reason for a coder to be cognitive about input
texts? Let me know what you think. I didn't update anything
admin-related from what I can recall, let me know if anything needs to
be unlimited again.
## Why It's Good For The Game
The change to `INFINITY` notwithstanding, there were still an abundance
of issues that we needed to check up on. A lot of these are filtered on
down the line but it is clear that there needs to be something to catch
these issues. Maybe we could lint to make `max_length` a mandatory
argument? I don't know if that's necessary at all but I think that the
limit should be set by the invoker due to the wide arrangement of cases
that this proc could be used in.
This could all be a big nothingburger if the aforementioned PR is
reverted but a big chunk of cases fixed in this PR need to be fixed
regardless of that since people could put in 1024 character names for
stuff like guardians (or more now with the change). Consider this
"revert agnostic".
## Changelog
🆑
fix: A lot of instances where you could fill in 1024-character names
(normal limit is 42) have been patched out, along with too-long plaque
names, too-long descriptions, and more.
/🆑
216 lines
9.2 KiB
Plaintext
216 lines
9.2 KiB
Plaintext
/obj/structure/plaque //This is a plaque you can craft with gold, then permanently engrave a title and description on, with a fountain pen.
|
|
icon = 'icons/obj/signs.dmi'
|
|
icon_state = "blankplaque"
|
|
name = "blank plaque"
|
|
desc = "A blank plaque, use a fancy pen to engrave it. It can be detatched from the wall with a wrench."
|
|
anchored = TRUE
|
|
opacity = FALSE
|
|
density = FALSE
|
|
layer = SIGN_LAYER
|
|
custom_materials = list(/datum/material/gold =SHEET_MATERIAL_AMOUNT)
|
|
max_integrity = 200 //Twice as durable as regular signs.
|
|
armor_type = /datum/armor/structure_plaque
|
|
///Custom plaque structures and items both start "unengraved", once engraved with a fountain pen their text can't be altered again. Static plaques are already engraved.
|
|
var/engraved = FALSE
|
|
|
|
/datum/armor/structure_plaque
|
|
melee = 50
|
|
fire = 50
|
|
acid = 50
|
|
|
|
/obj/structure/plaque/Initialize(mapload)
|
|
. = ..()
|
|
register_context()
|
|
|
|
/obj/structure/plaque/add_context(atom/source, list/context, obj/item/held_item, mob/user)
|
|
. = ..()
|
|
switch (held_item?.tool_behaviour)
|
|
if (TOOL_WELDER)
|
|
context[SCREENTIP_CONTEXT_LMB] = "Repair"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
if (TOOL_WRENCH)
|
|
context[SCREENTIP_CONTEXT_LMB] = "Unfasten"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
if(istype(held_item, /obj/item/pen/fountain) && !engraved)
|
|
context[SCREENTIP_CONTEXT_LMB] = "Engrave"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
|
|
/obj/structure/plaque/attack_hand(mob/user, list/modifiers)
|
|
. = ..()
|
|
if(. || user.is_blind())
|
|
return
|
|
user.examinate(src)
|
|
|
|
/obj/structure/plaque/wrench_act(mob/living/user, obj/item/wrench/I)
|
|
. = ..()
|
|
user.visible_message(span_notice("[user] starts removing [src]..."), \
|
|
span_notice("You start unfastening [src]."))
|
|
I.play_tool_sound(src)
|
|
if(!I.use_tool(src, user, 4 SECONDS))
|
|
return TRUE
|
|
playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE)
|
|
user.visible_message(span_notice("[user] unfastens [src]."), \
|
|
span_notice("You unfasten [src]."))
|
|
var/obj/item/plaque/unwrenched_plaque = new (get_turf(user))
|
|
if(engraved) //If it's still just a basic unengraved plaque, we can (and should) skip some of the below variable transfers.
|
|
unwrenched_plaque.name = name //Copy over the plaque structure variables to the plaque item we're creating when we unwrench it.
|
|
unwrenched_plaque.desc = desc
|
|
unwrenched_plaque.engraved = engraved
|
|
unwrenched_plaque.icon_state = icon_state
|
|
unwrenched_plaque.update_integrity(get_integrity())
|
|
unwrenched_plaque.setDir(dir)
|
|
qdel(src) //The plaque structure on the wall goes poof and only the plaque item from unwrenching remains.
|
|
return TRUE
|
|
|
|
/obj/structure/plaque/welder_act(mob/living/user, obj/item/I)
|
|
. = ..()
|
|
if(user.combat_mode)
|
|
return FALSE
|
|
if(atom_integrity == max_integrity)
|
|
to_chat(user, span_warning("This plaque is already in perfect condition."))
|
|
return TRUE
|
|
if(!I.tool_start_check(user, amount=1))
|
|
return TRUE
|
|
user.visible_message(span_notice("[user] starts repairing [src]..."), \
|
|
span_notice("You start repairing [src]."))
|
|
if(!I.use_tool(src, user, 4 SECONDS, volume = 50))
|
|
return TRUE
|
|
user.visible_message(span_notice("[user] finishes repairing [src]."), \
|
|
span_notice("You finish repairing [src]."))
|
|
atom_integrity = max_integrity
|
|
return TRUE
|
|
|
|
/obj/structure/plaque/attackby(obj/item/I, mob/user, params)
|
|
if(istype(I, /obj/item/pen/fountain))
|
|
if(engraved)
|
|
to_chat(user, span_warning("This plaque has already been engraved."))
|
|
return
|
|
var/namechoice = tgui_input_text(user, "Title this plaque. (e.g. 'Best HoP Award', 'Great Ashwalker War Memorial')", "Plaque Customization", max_length = MAX_NAME_LEN)
|
|
if(!namechoice)
|
|
return
|
|
var/descriptionchoice = tgui_input_text(user, "Engrave this plaque's text", "Plaque Customization", max_length = MAX_PLAQUE_LEN)
|
|
if(!descriptionchoice)
|
|
return
|
|
if(!Adjacent(user)) //Make sure user is adjacent still
|
|
to_chat(user, span_warning("You need to stand next to the plaque to engrave it!"))
|
|
return
|
|
user.visible_message(span_notice("[user] begins engraving [src]."), \
|
|
span_notice("You begin engraving [src]."))
|
|
if(!do_after(user, 4 SECONDS, target = src)) //This spits out a visible message that somebody is engraving a plaque, then has a delay.
|
|
return
|
|
name = "\improper [namechoice]" //We want improper here so examine doesn't get weird if somebody capitalizes the plaque title.
|
|
desc = "The plaque reads: '[descriptionchoice]'"
|
|
engraved = TRUE //The plaque now has a name, description, and can't be altered again.
|
|
user.visible_message(span_notice("[user] engraves [src]."), \
|
|
span_notice("You engrave [src]."))
|
|
return
|
|
if(istype(I, /obj/item/pen))
|
|
if(engraved)
|
|
to_chat(user, span_warning("This plaque has already been engraved, and your pen isn't fancy enough to engrave it anyway! Find a fountain pen."))
|
|
return
|
|
to_chat(user, span_warning("Your pen isn't fancy enough to engrave this! Find a fountain pen.")) //Go steal the Curator's.
|
|
return
|
|
return ..()
|
|
|
|
/obj/item/plaque //The item version of the above.
|
|
icon = 'icons/obj/signs.dmi'
|
|
icon_state = "blankplaque"
|
|
inhand_icon_state = "blankplaque"
|
|
lefthand_file = 'icons/mob/inhands/items_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/items_righthand.dmi'
|
|
name = "blank plaque"
|
|
desc = "A blank plaque, use a fancy pen to engrave it. It can be placed on a wall."
|
|
w_class = WEIGHT_CLASS_NORMAL
|
|
custom_materials = list(/datum/material/gold =SHEET_MATERIAL_AMOUNT)
|
|
max_integrity = 200
|
|
armor_type = /datum/armor/item_plaque
|
|
///This points the item to make the proper structure when placed on a wall.
|
|
var/plaque_path = /obj/structure/plaque
|
|
///Custom plaque structures and items both start "unengraved", once engraved with a fountain pen their text can't be altered again.
|
|
var/engraved = FALSE
|
|
|
|
/datum/armor/item_plaque
|
|
melee = 50
|
|
fire = 50
|
|
acid = 50
|
|
|
|
/obj/item/plaque/welder_act(mob/living/user, obj/item/I)
|
|
. = ..()
|
|
if(user.combat_mode)
|
|
return FALSE
|
|
if(atom_integrity == max_integrity)
|
|
to_chat(user, span_warning("This plaque is already in perfect condition."))
|
|
return TRUE
|
|
if(!I.tool_start_check(user, amount=1))
|
|
return TRUE
|
|
user.visible_message(span_notice("[user] starts repairing [src]..."), \
|
|
span_notice("You start repairing [src]."))
|
|
if(!I.use_tool(src, user, 4 SECONDS, volume = 50))
|
|
return TRUE
|
|
user.visible_message(span_notice("[user] finishes repairing [src]."), \
|
|
span_notice("You finish repairing [src]."))
|
|
atom_integrity = max_integrity
|
|
return TRUE
|
|
|
|
|
|
/obj/item/plaque/attackby(obj/item/I, mob/user, params) //Same as part of the above, except for the item in hand instead of the structure.
|
|
if(istype(I, /obj/item/pen/fountain))
|
|
if(engraved)
|
|
to_chat(user, span_warning("This plaque has already been engraved."))
|
|
return
|
|
var/namechoice = tgui_input_text(user, "Title this plaque. (e.g. 'Best HoP Award', 'Great Ashwalker War Memorial')", "Plaque Customization", max_length = MAX_NAME_LEN)
|
|
if(!namechoice)
|
|
return
|
|
var/descriptionchoice = tgui_input_text(user, "Engrave this plaque's text", "Plaque Customization", max_length = MAX_PLAQUE_LEN)
|
|
if(!descriptionchoice)
|
|
return
|
|
if(!Adjacent(user)) //Make sure user is adjacent still
|
|
to_chat(user, span_warning("You need to stand next to the plaque to engrave it!"))
|
|
return
|
|
user.visible_message(span_notice("[user] begins engraving [src]."), \
|
|
span_notice("You begin engraving [src]."))
|
|
if(!do_after(user, 4 SECONDS, target = src)) //This spits out a visible message that somebody is engraving a plaque, then has a delay.
|
|
return
|
|
name = "\improper [namechoice]" //We want improper here so examine doesn't get weird if somebody capitalizes the plaque title.
|
|
desc = "The plaque reads: '[descriptionchoice]'"
|
|
engraved = TRUE //The plaque now has a name, description, and can't be altered again.
|
|
user.visible_message(span_notice("[user] engraves [src]."), \
|
|
span_notice("You engrave [src]."))
|
|
return
|
|
if(istype(I, /obj/item/pen))
|
|
if(engraved)
|
|
to_chat(user, span_warning("This plaque has already been engraved, and your pen isn't fancy enough to engrave it anyway! Find a fountain pen."))
|
|
return
|
|
to_chat(user, span_warning("Your pen isn't fancy enough to engrave this! Find a fountain pen.")) //Go steal the Curator's.
|
|
return
|
|
return ..()
|
|
|
|
/obj/item/plaque/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
|
|
if(!iswallturf(interacting_with))
|
|
return NONE
|
|
var/turf/target_turf = interacting_with
|
|
var/turf/user_turf = get_turf(user)
|
|
var/obj/structure/plaque/placed_plaque = new plaque_path(user_turf) //We place the plaque on the turf the user is standing, and pixel shift it to the target wall, as below.
|
|
//This is to mimic how signs and other wall objects are usually placed by mappers, and so they're only visible from one side of a wall.
|
|
var/dir = get_dir(user_turf, target_turf)
|
|
if(dir & NORTH)
|
|
placed_plaque.pixel_y = 32
|
|
else if(dir & SOUTH)
|
|
placed_plaque.pixel_y = -32
|
|
if(dir & EAST)
|
|
placed_plaque.pixel_x = 32
|
|
else if(dir & WEST)
|
|
placed_plaque.pixel_x = -32
|
|
user.visible_message(span_notice("[user] fastens [src] to [target_turf]."), \
|
|
span_notice("You attach [src] to [target_turf]."))
|
|
playsound(target_turf, 'sound/items/deconstruct.ogg', 50, TRUE)
|
|
if(engraved)
|
|
placed_plaque.name = name
|
|
placed_plaque.desc = desc
|
|
placed_plaque.engraved = engraved
|
|
placed_plaque.icon_state = icon_state
|
|
placed_plaque.update_integrity(get_integrity())
|
|
placed_plaque.setDir(dir)
|
|
qdel(src)
|
|
return ITEM_INTERACT_SUCCESS
|