Skip to content

Commit

Permalink
[MIRROR] Retools renamedByPlayer into TRAIT_WAS_RENAMED [MDB IGNORE…
Browse files Browse the repository at this point in the history
…] (#25355) (#935)

* Retools `renamedByPlayer` into TRAIT_WAS_RENAMED (#80013)

## About The Pull Request

On the tin, this lived on the `/obj` level and polluted a lot of stuff
even though only a very small fraction of stuff actually leveraged it.
Let's make it a trait for that boolean-like behavior so I can be happier
scrolling through view-variables with less non-necessary things.

I wish we could tie it to unique sources but that whole drinking glass
thing makes me suspicious of weirder things so I think the way we do it
(source being a `REF()` to the thing itself) is probably fine enough for
the time being.
## Why It's Good For The Game

Same behavior one can expect but just a bit cleaner on the backend.
## Changelog
Nothing that particularly concerns players.

* Retools `renamedByPlayer` into TRAIT_WAS_RENAMED

* Update Blueshift.dmm

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: san7890 <[email protected]>
Co-authored-by: Giz <[email protected]>
  • Loading branch information
4 people authored Dec 3, 2023
1 parent 38cae00 commit 6f0e0d2
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 52 deletions.
64 changes: 31 additions & 33 deletions _maps/RandomRuins/SpaceRuins/oldstation.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -2840,6 +2840,11 @@
/obj/structure/cable,
/turf/open/floor/iron,
/area/ruin/space/ancientstation/charlie/hall)
"mm" = (
/obj/machinery/power/supermatter_crystal/shard,
/obj/structure/closet/crate/radiation,
/turf/open/floor/iron/white/textured,
/area/ruin/space/ancientstation/delta/proto)
"mo" = (
/turf/open/floor/iron/white/corner{
dir = 1
Expand Down Expand Up @@ -3795,32 +3800,6 @@
/obj/effect/mapping_helpers/apc/away_general_access,
/turf/open/floor/engine/airless,
/area/ruin/space/ancientstation/beta/supermatter)
"rN" = (
/obj/effect/decal/cleanable/dirt,
/obj/effect/decal/cleanable/dirt,
/obj/structure/table/glass,
/obj/item/reagent_containers/cup/bottle{
pixel_x = 4;
list_reagents = list(/datum/reagent/growthserum=30);
name = "Experimental solution";
renamedByPlayer = 1;
pixel_y = 8
},
/obj/item/reagent_containers/cup/bottle{
pixel_x = -4;
list_reagents = list(/datum/reagent/consumable/nutriment/peptides=30);
name = "Solution for Molly";
renamedByPlayer = 1
},
/obj/item/reagent_containers/dropper{
pixel_x = -7;
pixel_y = 10
},
/obj/effect/turf_decal/tile/purple/half/contrasted{
dir = 1
},
/turf/open/floor/iron/white/textured_edge,
/area/ruin/space/ancientstation/delta/biolab)
"rP" = (
/obj/effect/spawner/structure/window/reinforced,
/turf/open/floor/plating,
Expand Down Expand Up @@ -5964,11 +5943,6 @@
/obj/machinery/duct,
/turf/template_noop,
/area/space/nearstation)
"HS" = (
/obj/machinery/power/supermatter_crystal/shard,
/obj/structure/closet/crate/radiation,
/turf/open/floor/iron/white/textured,
/area/ruin/space/ancientstation/delta/proto)
"HT" = (
/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden/layer4,
/obj/machinery/atmospherics/pipe/smart/manifold4w/scrubbers/hidden/layer2,
Expand Down Expand Up @@ -7737,6 +7711,30 @@
/obj/effect/mapping_helpers/airalarm/away_general_access,
/turf/open/floor/iron/white/textured,
/area/ruin/space/ancientstation/delta/proto)
"TH" = (
/obj/effect/decal/cleanable/dirt,
/obj/effect/decal/cleanable/dirt,
/obj/structure/table/glass,
/obj/item/reagent_containers/cup/bottle{
pixel_x = 4;
list_reagents = list(/datum/reagent/growthserum=30);
name = "Experimental solution";
pixel_y = 8
},
/obj/item/reagent_containers/cup/bottle{
pixel_x = -4;
list_reagents = list(/datum/reagent/consumable/nutriment/peptides=30);
name = "Solution for Molly"
},
/obj/item/reagent_containers/dropper{
pixel_x = -7;
pixel_y = 10
},
/obj/effect/turf_decal/tile/purple/half/contrasted{
dir = 1
},
/turf/open/floor/iron/white/textured_edge,
/area/ruin/space/ancientstation/delta/biolab)
"TI" = (
/obj/machinery/door/airlock/science,
/obj/effect/decal/cleanable/dirt,
Expand Down Expand Up @@ -14787,7 +14785,7 @@ bD
Yr
cD
uj
HS
mm
Oh
uj
Mx
Expand Down Expand Up @@ -15299,7 +15297,7 @@ aa
aa
aa
SU
rN
TH
Pg
zI
uI
Expand Down
2 changes: 0 additions & 2 deletions _maps/map_files/NSVBlueshift/Blueshift.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -32286,7 +32286,6 @@
/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden/layer4,
/obj/structure/disposalpipe/sorting/mail{
name = "Detective Junction";
renamedByPlayer = 30
},
/turf/open/floor/iron,
/area/station/hallway/primary/central/fore)
Expand Down Expand Up @@ -71348,7 +71347,6 @@
"nGH" = (
/obj/structure/disposalpipe/sorting/mail{
name = "Robotics Junction";
renamedByPlayer = 14
},
/turf/open/floor/iron,
/area/station/hallway/primary/upper)
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
/// Trait used by fugu glands to avoid double buffing
#define TRAIT_FUGU_GLANDED "fugu_glanded"

/// Trait that tracks if something has been renamed. Typically holds a REF() to the object itself (AKA src) for wide addition/removal.
#define TRAIT_WAS_RENAMED "was_renamed"

/// When someone with this trait fires a ranged weapon, their fire delays and click cooldowns are halved
#define TRAIT_DOUBLE_TAP "double_tap"

Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/traits/sources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,6 @@
#define CLOWNOP_TRAIT "clownop"

#define ANALYZER_TRAIT "analyzer_trait"

/// Trait when something was labelled by a pen.
#define PEN_LABEL_TRAIT "pen_label"
1 change: 1 addition & 0 deletions code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_UNDERFLOOR" = TRAIT_UNDERFLOOR,
"TRAIT_UNIQUE_IMMERSE" = TRAIT_UNIQUE_IMMERSE,
"TRAIT_VOIDSTORM_IMMUNE" = TRAIT_VOIDSTORM_IMMUNE,
"TRAIT_WAS_RENAMED" = TRAIT_WAS_RENAMED,
"TRAIT_WEATHER_IMMUNE" = TRAIT_WEATHER_IMMUNE,
),
/datum/controller/subsystem/economy = list(
Expand Down
6 changes: 2 additions & 4 deletions code/datums/components/food/ice_cream_holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@

/datum/component/ice_cream_holder/proc/on_update_name(atom/source, updates)
SIGNAL_HANDLER
var/obj/obj = source
if(istype(obj) && obj.renamedByPlayer) //Renamed by the player.
if(HAS_TRAIT(source, TRAIT_WAS_RENAMED))
return
var/scoops_len = length(scoops)
if(!scoops_len)
Expand All @@ -93,8 +92,7 @@

/datum/component/ice_cream_holder/proc/on_update_desc(atom/source, updates)
SIGNAL_HANDLER
var/obj/obj = source
if(istype(obj) && obj.renamedByPlayer) //Renamed by the player.
if(HAS_TRAIT(source, TRAIT_WAS_RENAMED))
return
var/scoops_len = length(scoops)
if(!scoops_len)
Expand Down
8 changes: 4 additions & 4 deletions code/datums/components/takes_reagent_appearance.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@
* * Returns [NONE] if the name was reset to initial state
*/
/datum/component/takes_reagent_appearance/proc/update_name(datum/glass_style/style)
var/obj/item/item_parent = parent
if(item_parent.renamedByPlayer)
if(HAS_TRAIT(parent, TRAIT_WAS_RENAMED))
return NONE

var/obj/item/item_parent = parent
if(isnull(style))
// no style (reset)
item_parent.name = initial(item_parent.name)
Expand All @@ -111,10 +111,10 @@
* * Returns [NONE] if the description was reset to initial state
*/
/datum/component/takes_reagent_appearance/proc/update_desc(datum/glass_style/style)
var/obj/item/item_parent = parent
if(item_parent.renamedByPlayer)
if(HAS_TRAIT(parent, TRAIT_WAS_RENAMED))
return NONE

var/obj/item/item_parent = parent
if(isnull(style))
// no style (reset)
item_parent.desc = initial(item_parent.desc)
Expand Down
2 changes: 0 additions & 2 deletions code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
/// Particles this obj uses when burning, if any
var/burning_particles

var/renamedByPlayer = FALSE //set when a player uses a pen on a renamable object

var/drag_slowdown // Amont of multiplicative slowdown applied if pulled. >1 makes you slower, <1 makes you faster.

/// Map tag for something. Tired of it being used on snowflake items. Moved here for some semblance of a standard.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/fermenting_barrel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

/obj/structure/fermenting_barrel/update_overlays()
. = ..()
if(src.renamedByPlayer || HAS_TRAIT(src, TRAIT_HAS_LABEL))
if(HAS_TRAIT(src, TRAIT_WAS_RENAMED) || HAS_TRAIT(src, TRAIT_HAS_LABEL))
. += mutable_appearance(icon, "[base_icon_state]_overlay_label")

/// Adds the fruit to the barrel to queue the fermentation
Expand Down
6 changes: 3 additions & 3 deletions code/modules/paperwork/pen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
label.remove_label()
label.apply_label()
to_chat(user, span_notice("You have successfully renamed \the [oldname] to [O]."))
O.renamedByPlayer = TRUE
ADD_TRAIT(O, TRAIT_WAS_RENAMED, PEN_LABEL_TRAIT)
O.update_appearance(UPDATE_ICON)

if(penchoice == "Description")
Expand All @@ -249,7 +249,7 @@
else
O.AddComponent(/datum/component/rename, O.name, input)
to_chat(user, span_notice("You have successfully changed [O]'s description."))
O.renamedByPlayer = TRUE
ADD_TRAIT(O, TRAIT_WAS_RENAMED, PEN_LABEL_TRAIT)
O.update_appearance(UPDATE_ICON)

if(penchoice == "Reset")
Expand All @@ -265,7 +265,7 @@
label.apply_label()

to_chat(user, span_notice("You have successfully reset [O]'s name and description."))
O.renamedByPlayer = FALSE
REMOVE_TRAIT(O, TRAIT_WAS_RENAMED, PEN_LABEL_TRAIT)
O.update_appearance(UPDATE_ICON)

/obj/item/pen/get_writing_implement_details()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/obj/item/reagent_containers/cup/glass/drinkingglass/on_reagent_change(datum/reagents/holder, ...)
. = ..()
if(!length(reagents.reagent_list))
renamedByPlayer = FALSE //so new drinks can rename the glass
REMOVE_TRAIT(src, TRAIT_WAS_RENAMED, PEN_LABEL_TRAIT) //so new drinks can rename the glass

// Having our icon state change removes fill thresholds
/obj/item/reagent_containers/cup/glass/drinkingglass/on_cup_change(datum/glass_style/style)
Expand Down Expand Up @@ -68,13 +68,13 @@
custom_price = PAYCHECK_CREW * 0.4

/obj/item/reagent_containers/cup/glass/drinkingglass/shotglass/update_name(updates)
if(renamedByPlayer)
if(HAS_TRAIT(src, TRAIT_WAS_RENAMED))
return
. = ..()
name = "[length(reagents.reagent_list) ? "filled " : ""]shot glass"

/obj/item/reagent_containers/cup/glass/drinkingglass/shotglass/update_desc(updates)
if(renamedByPlayer)
if(HAS_TRAIT(src, TRAIT_WAS_RENAMED))
return
. = ..()
if(length(reagents.reagent_list))
Expand Down

0 comments on commit 6f0e0d2

Please sign in to comment.