Removes the bitflag helpers (#49106)

This commit is contained in:
Emmett Gaines
2020-02-03 16:26:00 -05:00
committed by GitHub
parent 094e911d52
commit 2cf7728494
19 changed files with 56 additions and 65 deletions
-10
View File
@@ -4,16 +4,6 @@
#define ALL (~0) //For convenience.
#define NONE 0
//for convenience
#define ENABLE_BITFIELD(variable, flag) (variable |= (flag))
#define DISABLE_BITFIELD(variable, flag) (variable &= ~(flag))
#define CHECK_BITFIELD(variable, flag) (variable & (flag))
#define TOGGLE_BITFIELD(variable, flag) (variable ^= (flag))
//check if all bitflags specified are present
#define CHECK_MULTIPLE_BITFIELDS(flagvar, flags) (((flagvar) & (flags)) == (flags))
GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768))
// for /datum/var/datum_flags
+1 -1
View File
@@ -341,7 +341,7 @@ GLOBAL_LIST_EMPTY(species_list)
drifting = 0
user_loc = user.loc
if(L && !CHECK_MULTIPLE_BITFIELDS(L.mobility_flags, required_mobility_flags))
if(L && !((L.mobility_flags & required_mobility_flags) == required_mobility_flags))
. = 0
break
+1 -1
View File
@@ -42,7 +42,7 @@
return
var/mob/living/LM = parent
if(!T.footstep || LM.buckled || LM.lying || !CHECK_MULTIPLE_BITFIELDS(LM.mobility_flags, MOBILITY_STAND | MOBILITY_MOVE) || LM.throwing || LM.movement_type & (VENTCRAWLING | FLYING))
if(!T.footstep || LM.buckled || LM.lying || !((LM.mobility_flags & (MOBILITY_STAND | MOBILITY_MOVE)) == (MOBILITY_STAND | MOBILITY_MOVE)) || LM.throwing || LM.movement_type & (VENTCRAWLING | FLYING))
if (LM.lying && !LM.buckled && !(!T.footstep || LM.movement_type & (VENTCRAWLING | FLYING))) //play crawling sound if we're lying
playsound(T, 'sound/effects/footstep/crawl1.ogg', 15 * volume)
return
+6 -6
View File
@@ -201,7 +201,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
qdel(src)
return
// allowing reagents to react after being lit
DISABLE_BITFIELD(reagents.flags, NO_REACT)
reagents.flags &= ~(NO_REACT)
reagents.handle_reactions()
icon_state = icon_on
item_state = icon_on
@@ -227,7 +227,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
icon_state = icon_off
item_state = icon_off
STOP_PROCESSING(SSobj, src)
ENABLE_BITFIELD(reagents.flags, NO_REACT)
reagents.flags |= NO_REACT
lit = FALSE
if(ismob(loc))
var/mob/living/M = loc
@@ -817,7 +817,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
if(!screw)
screw = TRUE
to_chat(user, "<span class='notice'>You open the cap on [src].</span>")
ENABLE_BITFIELD(reagents.flags, OPENCONTAINER)
reagents.flags |= OPENCONTAINER
if(obj_flags & EMAGGED)
add_overlay("vapeopen_high")
else if(super)
@@ -827,7 +827,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
else
screw = FALSE
to_chat(user, "<span class='notice'>You close the cap on [src].</span>")
DISABLE_BITFIELD(reagents.flags, OPENCONTAINER)
reagents.flags &= ~(OPENCONTAINER)
cut_overlays()
if(O.tool_behaviour == TOOL_MULTITOOL)
@@ -875,7 +875,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
if(slot == ITEM_SLOT_MASK)
if(!screw)
to_chat(user, "<span class='notice'>You start puffing on the vape.</span>")
DISABLE_BITFIELD(reagents.flags, NO_REACT)
reagents.flags &= ~(NO_REACT)
START_PROCESSING(SSobj, src)
else //it will not start if the vape is opened.
to_chat(user, "<span class='warning'>You need to close the cap first!</span>")
@@ -883,7 +883,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
/obj/item/clothing/mask/vape/dropped(mob/user)
. = ..()
if(user.get_item_by_slot(ITEM_SLOT_MASK) == src)
ENABLE_BITFIELD(reagents.flags, NO_REACT)
reagents.flags |= NO_REACT
STOP_PROCESSING(SSobj, src)
/obj/item/clothing/mask/vape/proc/hand_reagents()//had to rename to avoid duplicate error
+6 -6
View File
@@ -126,10 +126,10 @@
. = ..()
if(!proximity)
return
if(isOn())
handle_fuel_and_temps(1, user)
if(!QDELETED(O) && isliving(O)) // can't ignite something that doesn't exist
var/mob/living/L = O
if(L.IgniteMob())
@@ -145,10 +145,10 @@
. = ..()
if(!proximity)
return
if(isOn())
handle_fuel_and_temps(1, user)
if(!QDELETED(O) && isliving(O)) // can't ignite something that doesn't exist
var/mob/living/L = O
if(L.IgniteMob())
@@ -281,10 +281,10 @@
status = !status
if(status)
to_chat(user, "<span class='notice'>You resecure [src] and close the fuel tank.</span>")
DISABLE_BITFIELD(reagents.flags, OPENCONTAINER)
reagents.flags &= ~(OPENCONTAINER)
else
to_chat(user, "<span class='notice'>[src] can now be attached, modified, and refuelled.</span>")
ENABLE_BITFIELD(reagents.flags, OPENCONTAINER)
reagents.flags |= OPENCONTAINER
add_fingerprint(user)
/obj/item/weldingtool/proc/flamethrower_rods(obj/item/I, mob/user)
+4 -4
View File
@@ -214,7 +214,7 @@
// Here's hoping it doesn't stay like this for years before we finish conversion to step_
var/atom/firstbump
var/canPassSelf = CanPass(mover, src)
if(canPassSelf || CHECK_BITFIELD(mover.movement_type, UNSTOPPABLE))
if(canPassSelf || (mover.movement_type & UNSTOPPABLE))
for(var/i in contents)
if(QDELETED(mover))
return FALSE //We were deleted, do not attempt to proceed with movement.
@@ -224,7 +224,7 @@
if(!thing.Cross(mover))
if(QDELETED(mover)) //Mover deleted from Cross/CanPass, do not proceed.
return FALSE
if(CHECK_BITFIELD(mover.movement_type, UNSTOPPABLE))
if((mover.movement_type & UNSTOPPABLE))
mover.Bump(thing)
continue
else
@@ -236,7 +236,7 @@
firstbump = src
if(firstbump)
mover.Bump(firstbump)
return CHECK_BITFIELD(mover.movement_type, UNSTOPPABLE)
return (mover.movement_type & UNSTOPPABLE)
return TRUE
/turf/Exit(atom/movable/mover, atom/newloc)
@@ -250,7 +250,7 @@
if(!thing.Uncross(mover, newloc))
if(thing.flags_1 & ON_BORDER_1)
mover.Bump(thing)
if(!CHECK_BITFIELD(mover.movement_type, UNSTOPPABLE))
if(!(mover.movement_type & UNSTOPPABLE))
return FALSE
if(QDELETED(mover))
return FALSE //We were deleted.
+6 -6
View File
@@ -286,7 +286,7 @@
selectors_used |= query.where_switched
combined_refs |= query.select_refs
running -= query
if(!CHECK_BITFIELD(query.options, SDQL2_OPTION_DO_NOT_AUTOGC))
if(!(query.options & SDQL2_OPTION_DO_NOT_AUTOGC))
QDEL_IN(query, 50)
if(sequential && waiting_queue.len)
finished = FALSE
@@ -473,23 +473,23 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/SDQL2_VV_all, new(null
if("select")
switch(value)
if("force_nulls")
DISABLE_BITFIELD(options, SDQL2_OPTION_SELECT_OUTPUT_SKIP_NULLS)
options &= ~(SDQL2_OPTION_SELECT_OUTPUT_SKIP_NULLS)
if("proccall")
switch(value)
if("blocking")
ENABLE_BITFIELD(options, SDQL2_OPTION_BLOCKING_CALLS)
options |= SDQL2_OPTION_BLOCKING_CALLS
if("priority")
switch(value)
if("high")
ENABLE_BITFIELD(options, SDQL2_OPTION_HIGH_PRIORITY)
options |= SDQL2_OPTION_HIGH_PRIORITY
if("autogc")
switch(value)
if("keep_alive")
ENABLE_BITFIELD(options, SDQL2_OPTION_DO_NOT_AUTOGC)
options |= SDQL2_OPTION_DO_NOT_AUTOGC
if("sequential")
switch(value)
if("true")
ENABLE_BITFIELD(options,SDQL2_OPTION_SEQUENTIAL)
options |= SDQL2_OPTION_SEQUENTIAL
/datum/SDQL2_query/proc/ARun()
INVOKE_ASYNC(src, .proc/Run)
+1 -1
View File
@@ -40,7 +40,7 @@
/obj/item/clothing/Initialize()
if(CHECK_BITFIELD(clothing_flags, VOICEBOX_TOGGLABLE))
if((clothing_flags & VOICEBOX_TOGGLABLE))
actions_types += /datum/action/item_action/toggle_voice_box
. = ..()
if(ispath(pocket_storage_component_path))
+3 -3
View File
@@ -10,9 +10,9 @@
var/adjusted_flags = null
/obj/item/clothing/mask/attack_self(mob/user)
if(CHECK_BITFIELD(clothing_flags, VOICEBOX_TOGGLABLE))
TOGGLE_BITFIELD(clothing_flags, VOICEBOX_DISABLED)
var/status = !CHECK_BITFIELD(clothing_flags, VOICEBOX_DISABLED)
if((clothing_flags & VOICEBOX_TOGGLABLE))
clothing_flags ^= (VOICEBOX_DISABLED)
var/status = !(clothing_flags & VOICEBOX_DISABLED)
to_chat(user, "<span class='notice'>You turn the voice box in [src] [status ? "on" : "off"].</span>")
/obj/item/clothing/mask/equipped(mob/M, slot)
+4 -4
View File
@@ -80,7 +80,7 @@
modifies_speech = TRUE
/obj/item/clothing/mask/pig/handle_speech(datum/source, list/speech_args)
if(!CHECK_BITFIELD(clothing_flags, VOICEBOX_DISABLED))
if(!(clothing_flags & VOICEBOX_DISABLED))
speech_args[SPEECH_MESSAGE] = pick("Oink!","Squeeeeeeee!","Oink Oink!")
/obj/item/clothing/mask/pig/cursed
@@ -106,7 +106,7 @@
modifies_speech = TRUE
/obj/item/clothing/mask/frog/handle_speech(datum/source, list/speech_args) //whenever you speak
if(!CHECK_BITFIELD(clothing_flags, VOICEBOX_DISABLED))
if(!(clothing_flags & VOICEBOX_DISABLED))
if(prob(5)) //sometimes, the angry spirit finds others words to speak.
speech_args[SPEECH_MESSAGE] = pick("HUUUUU!!","SMOOOOOKIN'!!","Hello my baby, hello my honey, hello my rag-time gal.", "Feels bad, man.", "GIT DIS GUY OFF ME!!" ,"SOMEBODY STOP ME!!", "NORMIES, GET OUT!!")
else
@@ -135,7 +135,7 @@
modifies_speech = TRUE
/obj/item/clothing/mask/cowmask/handle_speech(datum/source, list/speech_args)
if(!CHECK_BITFIELD(clothing_flags, VOICEBOX_DISABLED))
if(!(clothing_flags & VOICEBOX_DISABLED))
speech_args[SPEECH_MESSAGE] = pick("Moooooooo!","Moo!","Moooo!")
/obj/item/clothing/mask/cowmask/cursed
@@ -159,7 +159,7 @@
clothing_flags = VOICEBOX_TOGGLABLE
/obj/item/clothing/mask/horsehead/handle_speech(datum/source, list/speech_args)
if(!CHECK_BITFIELD(clothing_flags, VOICEBOX_DISABLED))
if(!(clothing_flags & VOICEBOX_DISABLED))
speech_args[SPEECH_MESSAGE] = pick("NEEIIGGGHHHH!", "NEEEIIIIGHH!", "NEIIIGGHH!", "HAAWWWWW!", "HAAAWWW!")
/obj/item/clothing/mask/horsehead/cursed
@@ -615,7 +615,7 @@
/obj/item/reagent_containers/food/drinks/soda_cans/proc/open_soda(mob/user)
to_chat(user, "You pull back the tab of \the [src] with a satisfying pop.") //Ahhhhhhhh
ENABLE_BITFIELD(reagents.flags, OPENCONTAINER)
reagents.flags |= OPENCONTAINER
playsound(src, "can_open", 50, TRUE)
spillable = TRUE
@@ -620,7 +620,7 @@
/obj/item/reagent_containers/food/snacks/canned/proc/open_can(mob/user)
to_chat(user, "<span class='notice'>You pull back the tab of \the [src].</span>")
playsound(user.loc, 'sound/items/foodcanopen.ogg', 50)
ENABLE_BITFIELD(reagents.flags, OPENCONTAINER)
reagents.flags |= OPENCONTAINER
spillable = TRUE
/obj/item/reagent_containers/food/snacks/canned/attack_self(mob/user)
@@ -56,12 +56,12 @@
/obj/structure/fermenting_barrel/attack_hand(mob/user)
open = !open
if(open)
DISABLE_BITFIELD(reagents.flags, DRAINABLE)
ENABLE_BITFIELD(reagents.flags, REFILLABLE)
reagents.flags &= ~(DRAINABLE)
reagents.flags |= REFILLABLE
to_chat(user, "<span class='notice'>You open [src], letting you fill it.</span>")
else
ENABLE_BITFIELD(reagents.flags, DRAINABLE)
DISABLE_BITFIELD(reagents.flags, REFILLABLE)
reagents.flags |= DRAINABLE
reagents.flags &= ~(REFILLABLE)
to_chat(user, "<span class='notice'>You close [src], letting you draw from its tap.</span>")
update_icon()
+1 -1
View File
@@ -137,7 +137,7 @@
if(start_T && end_T)
log_combat(src, throwable_mob, "thrown", addition="grab from tile in [AREACOORD(start_T)] towards tile at [AREACOORD(end_T)]")
else if(!CHECK_BITFIELD(I.item_flags, ABSTRACT) && !HAS_TRAIT(I, TRAIT_NODROP))
else if(!(I.item_flags & ABSTRACT) && !HAS_TRAIT(I, TRAIT_NODROP))
thrown_thing = I
dropItemToGround(I, silent = TRUE)
@@ -136,7 +136,7 @@
/obj/item/ammo_casing/shotgun/dart/noreact/Initialize()
. = ..()
ENABLE_BITFIELD(reagents.flags, NO_REACT)
reagents.flags |= NO_REACT
/obj/item/ammo_casing/shotgun/dart/bioterror
desc = "A shotgun dart filled with deadly toxins."
+7 -6
View File
@@ -253,7 +253,7 @@
/obj/projectile/proc/process_hit(turf/T, atom/target, qdel_self, hit_something = FALSE) //probably needs to be reworked entirely when pixel movement is done.
if(QDELETED(src) || !T || !target) //We're done, nothing's left.
if((qdel_self == FORCE_QDEL) || ((qdel_self == QDEL_SELF) && !temporary_unstoppable_movement && !CHECK_BITFIELD(movement_type, UNSTOPPABLE)))
if((qdel_self == FORCE_QDEL) || ((qdel_self == QDEL_SELF) && !temporary_unstoppable_movement && !(movement_type & UNSTOPPABLE)))
qdel(src)
return hit_something
permutated |= target //Make sure we're never hitting it again. If we ever run into weirdness with piercing projectiles needing to hit something multiple times.. well.. that's a to-do.
@@ -262,16 +262,16 @@
SEND_SIGNAL(target, COMSIG_PROJECTILE_PREHIT, args)
var/result = target.bullet_act(src, def_zone)
if(result == BULLET_ACT_FORCE_PIERCE)
if(!CHECK_BITFIELD(movement_type, UNSTOPPABLE))
if(!(movement_type & UNSTOPPABLE))
temporary_unstoppable_movement = TRUE
ENABLE_BITFIELD(movement_type, UNSTOPPABLE)
movement_type |= UNSTOPPABLE
return process_hit(T, select_target(T), qdel_self, TRUE) //Hit whatever else we can since we're piercing through but we're still on the same tile.
else if(result == BULLET_ACT_TURF) //We hit the turf but instead we're going to also hit something else on it.
return process_hit(T, select_target(T), QDEL_SELF, TRUE)
else //Whether it hit or blocked, we're done!
qdel_self = QDEL_SELF
hit_something = TRUE
if((qdel_self == FORCE_QDEL) || ((qdel_self == QDEL_SELF) && !temporary_unstoppable_movement && !CHECK_BITFIELD(movement_type, UNSTOPPABLE)))
if((qdel_self == FORCE_QDEL) || ((qdel_self == QDEL_SELF) && !temporary_unstoppable_movement && !(movement_type & UNSTOPPABLE)))
qdel(src)
return hit_something
@@ -547,7 +547,8 @@
else
var/mob/living/L = target
if(!direct_target)
if(!CHECK_BITFIELD(L.mobility_flags, MOBILITY_USE | MOBILITY_STAND | MOBILITY_MOVE) || !(L.stat == CONSCIOUS)) //If they're able to 1. stand or 2. use items or 3. move, AND they are not softcrit, they are not stunned enough to dodge projectiles passing over.
var/checking = MOBILITY_USE | MOBILITY_STAND | MOBILITY_MOVE
if(!((L.mobility_flags & checking) == checking) || !(L.stat == CONSCIOUS)) //If they're able to 1. stand or 2. use items or 3. move, AND they are not softcrit, they are not stunned enough to dodge projectiles passing over.
return FALSE
return TRUE
@@ -622,7 +623,7 @@
if(.)
if(temporary_unstoppable_movement)
temporary_unstoppable_movement = FALSE
DISABLE_BITFIELD(movement_type, UNSTOPPABLE)
movement_type &= ~(UNSTOPPABLE)
if(fired && can_hit_target(original, permutated, TRUE))
Bump(original)
@@ -23,7 +23,7 @@
"<span class='userdanger'>You were protected against \the [src]!</span>")
..(target, blocked)
DISABLE_BITFIELD(reagents.flags, NO_REACT)
reagents.flags &= ~(NO_REACT)
reagents.handle_reactions()
return BULLET_ACT_HIT
@@ -17,7 +17,7 @@
/obj/projectile/curse_hand/Initialize(mapload)
. = ..()
ENABLE_BITFIELD(movement_type, UNSTOPPABLE)
movement_type |= UNSTOPPABLE
handedness = prob(50)
icon_state = "cursehand[handedness]"
@@ -31,7 +31,7 @@
/obj/projectile/curse_hand/prehit(atom/target)
if(target == original)
DISABLE_BITFIELD(movement_type, UNSTOPPABLE)
movement_type &= ~(UNSTOPPABLE)
else if(!isturf(target))
return FALSE
return ..()
@@ -40,7 +40,7 @@
if(arm)
arm.End()
arm = null
if(CHECK_BITFIELD(movement_type, UNSTOPPABLE))
if((movement_type & UNSTOPPABLE))
playsound(src, 'sound/effects/curse3.ogg', 25, TRUE, -1)
var/turf/T = get_step(src, dir)
var/obj/effect/temp_visual/dir_setting/curse/hand/leftover = new(T, dir)
+5 -5
View File
@@ -121,7 +121,7 @@
if(SSshuttle.emergency.mode == SHUTTLE_STRANDED)
authorized.Cut()
DISABLE_BITFIELD(obj_flags, EMAGGED)
obj_flags &= ~(EMAGGED)
if(ENGINES_STARTED || (!IS_DOCKED))
return .
@@ -140,7 +140,7 @@
if(!IS_DOCKED)
return
if(CHECK_BITFIELD(obj_flags, EMAGGED) || ENGINES_STARTED) //SYSTEM ERROR: THE SHUTTLE WILL LA-SYSTEM ERROR: THE SHUTTLE WILL LA-SYSTEM ERROR: THE SHUTTLE WILL LAUNCH IN 10 SECONDS
if((obj_flags & EMAGGED) || ENGINES_STARTED) //SYSTEM ERROR: THE SHUTTLE WILL LA-SYSTEM ERROR: THE SHUTTLE WILL LA-SYSTEM ERROR: THE SHUTTLE WILL LAUNCH IN 10 SECONDS
to_chat(user, "<span class='warning'>The shuttle is already about to launch!</span>")
return
@@ -148,7 +148,7 @@
message_admins("[ADMIN_LOOKUPFLW(user)] has emagged the emergency shuttle [time] seconds before launch.")
log_shuttle("[key_name(user)] has emagged the emergency shuttle in [COORD(src)] [time] seconds before launch.")
ENABLE_BITFIELD(obj_flags, EMAGGED)
obj_flags |= EMAGGED
SSshuttle.emergency.movement_force = list("KNOCKDOWN" = 60, "THROW" = 20)//YOUR PUNY SEATBELTS can SAVE YOU NOW, MORTAL
var/datum/species/S = new
for(var/i in 1 to 10)
@@ -458,11 +458,11 @@
/obj/machinery/computer/shuttle/pod/ComponentInitialize()
. = ..()
AddElement(/datum/element/update_icon_blocker)
/obj/machinery/computer/shuttle/pod/emag_act(mob/user)
if(obj_flags & EMAGGED)
return
ENABLE_BITFIELD(obj_flags, EMAGGED)
obj_flags |= EMAGGED
to_chat(user, "<span class='warning'>You fry the pod's alert level checking system.</span>")
/obj/machinery/computer/shuttle/pod/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock, idnum, override=FALSE)