Some ITEM_SLOT bitflags fixes. (#92441)

## About The Pull Request

This PR fixes wrong usage of bitflags in a few places, where instead of
bitfields lists were used.

## Why It's Good For The Game

It will help prevent problems that can be a thing in the future,
improving consistency of the codebase.
This commit is contained in:
SSensum13
2025-08-11 21:20:50 +03:00
committed by GitHub
parent 63d9cdebe2
commit 4722bf017e
12 changed files with 22 additions and 20 deletions

View File

@@ -3,10 +3,10 @@
mobtype = /mob/living/carbon
proctype = PROC_REF(reducebang)
var/reduce_amount = 1
valid_slots = ITEM_SLOT_EARS | ITEM_SLOT_HEAD
/datum/component/wearertargeting/earprotection/Initialize(valid_slots, reduce_amount = 1)
/datum/component/wearertargeting/earprotection/Initialize(reduce_amount = 1)
. = ..()
src.valid_slots = valid_slots
if(reduce_amount)
src.reduce_amount = reduce_amount

View File

@@ -3,7 +3,7 @@
signals = list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_LIVING_HAND_ITEM_ATTACK)
mobtype = /mob/living/carbon
proctype = PROC_REF(reducecooldown)
valid_slots = list(ITEM_SLOT_GLOVES)
valid_slots = ITEM_SLOT_GLOVES
///The warcry this generates
var/warcry = "AT"

View File

@@ -1,5 +1,5 @@
/datum/component/wearertargeting/sitcomlaughter
valid_slots = list(ITEM_SLOT_HANDS, ITEM_SLOT_BELT, ITEM_SLOT_ID, ITEM_SLOT_LPOCKET, ITEM_SLOT_RPOCKET, ITEM_SLOT_SUITSTORE, ITEM_SLOT_DEX_STORAGE)
valid_slots = ITEM_SLOT_HANDS | ITEM_SLOT_BELT | ITEM_SLOT_ID | ITEM_SLOT_LPOCKET | ITEM_SLOT_RPOCKET | ITEM_SLOT_SUITSTORE | ITEM_SLOT_DEX_STORAGE
signals = list(COMSIG_MOB_HIT_BY_SPLAT, COMSIG_ON_CARBON_SLIP, COMSIG_POST_TILT_AND_CRUSH, COMSIG_MOB_CLUMSY_SHOOT_FOOT)
proctype = PROC_REF(EngageInComedy)
mobtype = /mob/living

View File

@@ -33,8 +33,8 @@
var/datum/callback/on_slip_callback
/// If parent is an item, this is the person currently holding/wearing the parent (or the parent if no one is holding it)
var/mob/living/holder
/// Whitelist of item slots the parent can be equipped in that make the holder slippery. If null or empty, it will always make the holder slippery.
var/list/slot_whitelist = list(ITEM_SLOT_OCLOTHING, ITEM_SLOT_ICLOTHING, ITEM_SLOT_GLOVES, ITEM_SLOT_FEET, ITEM_SLOT_HEAD, ITEM_SLOT_MASK, ITEM_SLOT_BELT, ITEM_SLOT_NECK)
/// Whitelist bitfields of item slots bitflags the parent can be equipped in that make the holder slippery. If null or empty, it will always make the holder slippery.
var/slot_whitelist = ITEM_SLOT_OCLOTHING | ITEM_SLOT_ICLOTHING | ITEM_SLOT_GLOVES | ITEM_SLOT_FEET | ITEM_SLOT_HEAD | ITEM_SLOT_MASK | ITEM_SLOT_BELT | ITEM_SLOT_NECK
///what we give to connect_loc by default, makes slippable mobs moving over us slip
var/static/list/default_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(Slip),
@@ -191,7 +191,7 @@
/datum/component/slippery/proc/on_equip(datum/source, mob/equipper, slot)
SIGNAL_HANDLER
if((!LAZYLEN(slot_whitelist) || (slot in slot_whitelist)) && isliving(equipper))
if((!slot || (slot & slot_whitelist)) && isliving(equipper))
holder = equipper
qdel(GetComponent(/datum/component/connect_loc_behalf))
AddComponent(/datum/component/connect_loc_behalf, holder, mob_connections)

View File

@@ -1,7 +1,9 @@
// A dummy parent type used for easily making components that target an item's wearer rather than the item itself.
/datum/component/wearertargeting
var/list/valid_slots = list()
/// Bitflag value of valid slots.
/// You can find all slot bitflags in code/__DEFINES/inventory.dm
var/valid_slots = NONE
var/list/signals = list()
var/proctype = GLOBAL_PROC_REF(pass)
var/mobtype = /mob/living
@@ -15,7 +17,7 @@
/datum/component/wearertargeting/proc/on_equip(datum/source, mob/equipper, slot)
SIGNAL_HANDLER
if((slot in valid_slots) && istype(equipper, mobtype))
if((valid_slots & slot) && istype(equipper, mobtype))
RegisterSignals(equipper, signals, proctype, TRUE)
else
UnregisterSignal(equipper, signals)

View File

@@ -177,7 +177,7 @@ GLOBAL_LIST_INIT(channel_tokens, list(
/obj/item/radio/headset/syndicate/alt/Initialize(mapload)
. = ..()
AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS))
AddComponent(/datum/component/wearertargeting/earprotection)
/obj/item/radio/headset/syndicate/alt/leader
name = "team leader headset"
@@ -201,7 +201,7 @@ GLOBAL_LIST_INIT(channel_tokens, list(
/obj/item/radio/headset/headset_sec/alt/Initialize(mapload)
. = ..()
AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS))
AddComponent(/datum/component/wearertargeting/earprotection)
/obj/item/radio/headset/headset_eng
name = "engineering radio headset"
@@ -284,7 +284,7 @@ GLOBAL_LIST_INIT(channel_tokens, list(
/obj/item/radio/headset/heads/captain/alt/Initialize(mapload)
. = ..()
AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS))
AddComponent(/datum/component/wearertargeting/earprotection)
/obj/item/radio/headset/heads/rd
name = "\proper the research director's headset"
@@ -316,7 +316,7 @@ GLOBAL_LIST_INIT(channel_tokens, list(
/obj/item/radio/headset/heads/hos/alt/Initialize(mapload)
. = ..()
AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS))
AddComponent(/datum/component/wearertargeting/earprotection)
/obj/item/radio/headset/heads/ce
name = "\proper the chief engineer's headset"
@@ -408,7 +408,7 @@ GLOBAL_LIST_INIT(channel_tokens, list(
/obj/item/radio/headset/headset_cent/alt/Initialize(mapload)
. = ..()
AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS))
AddComponent(/datum/component/wearertargeting/earprotection)
/obj/item/radio/headset/headset_cent/alt/leader
command = TRUE

View File

@@ -520,7 +520,7 @@ Return to step 11 of normal process."}
/obj/item/radio/headset/abductor/Initialize(mapload)
. = ..()
AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS))
AddComponent(/datum/component/wearertargeting/earprotection)
make_syndie()
// Stops humans from disassembling abductor headsets.

View File

@@ -218,7 +218,7 @@
/obj/item/radio/headset/psyker/Initialize(mapload)
. = ..()
AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS))
AddComponent(/datum/component/wearertargeting/earprotection)
/obj/item/radio/headset/psyker/equipped(mob/living/user, slot)
. = ..()

View File

@@ -25,7 +25,7 @@
/obj/item/clothing/ears/earmuffs/Initialize(mapload)
. = ..()
AddElement(/datum/element/earhealing)
AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_EARS))
AddComponent(/datum/component/wearertargeting/earprotection)
AddComponent(/datum/component/adjust_fishing_difficulty, -2)
/obj/item/clothing/ears/earmuffs/debug

View File

@@ -102,7 +102,7 @@
// When someone makes TRAIT_DEAF an element, or status effect, or whatever, give this item a way to bypass said deafness.
// just blocking future instances of deafness isn't what the item is meant to do but there's no proper way to do it otherwise at the moment.
active_components += AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_HEAD), reduce_amount = 2) // should be same as highest value
active_components += AddComponent(/datum/component/wearertargeting/earprotection, reduce_amount = 2) // should be same as highest value
active_components += AddComponent(
/datum/component/anti_magic, \
antimagic_flags = MAGIC_RESISTANCE_MIND, \

View File

@@ -1044,7 +1044,7 @@
/obj/item/mod/module/hearing_protection/on_part_activation()
var/obj/item/clothing/head_cover = mod.get_part_from_slot(ITEM_SLOT_HEAD) || mod.get_part_from_slot(ITEM_SLOT_MASK) || mod.get_part_from_slot(ITEM_SLOT_EYES)
if(istype(head_cover))
head_cover.AddComponent(/datum/component/wearertargeting/earprotection, list(ITEM_SLOT_HEAD))
head_cover.AddComponent(/datum/component/wearertargeting/earprotection)
var/datum/component/wearertargeting/earprotection/protection = head_cover.GetComponent(/datum/component/wearertargeting/earprotection)
protection.on_equip(src, mod.wearer, ITEM_SLOT_HEAD)

View File

@@ -337,7 +337,7 @@
lube_flags = NO_SLIP_WHEN_WALKING,\
on_slip_callback = CALLBACK(src, PROC_REF(AfterSlip)),\
can_slip_callback = CALLBACK(src, PROC_REF(try_slip)),\
slot_whitelist = list(ITEM_SLOT_ID, ITEM_SLOT_BELT),\
slot_whitelist = ITEM_SLOT_ID | ITEM_SLOT_BELT,\
)
AddComponent(/datum/component/wearertargeting/sitcomlaughter, CALLBACK(src, PROC_REF(after_sitcom_laugh)))