Adds CI to forbid some istype(src) checks. (#26980)

* first set of changes

* the last checks

* actually builds

* Update code/modules/surgery/organs/subtypes/standard_organs.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* Update tools/ci/check_grep2.py

Signed-off-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* 1 fix (cigarettes) and better encapsulation in files

* yeeep

---------

Signed-off-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
This commit is contained in:
Contrabang
2024-11-06 12:56:36 +00:00
committed by GitHub
co-authored by Luc
parent 5ac9a04796
commit 0f717d660a
33 changed files with 178 additions and 149 deletions
@@ -55,7 +55,7 @@
var/turf/T = get_turf(src)
check_gravity(T)
if(!istype(src, /obj/effect/decal/cleanable/blood/footprints) && ((T && (T.density)) || !gravity_check || locate(/obj/structure/window/full) in T || locate(/obj/structure/grille/) in T))
if(should_be_off_floor())
off_floor = TRUE
layer = ABOVE_MOB_LAYER
plane = GAME_PLANE
@@ -85,6 +85,10 @@
overlays.Cut()
..()
/obj/effect/decal/cleanable/blood/proc/should_be_off_floor()
var/turf/T = get_turf(src)
return ((T && T.density) || !gravity_check || (locate(/obj/structure/window/full) in T) || (locate(/obj/structure/grille) in T))
/obj/effect/decal/cleanable/blood/proc/dry()
name = dryname
desc = drydesc
@@ -123,6 +123,9 @@ GLOBAL_LIST_EMPTY(fluidtrack_cache)
alpha = base_alpha + bloodiness
/obj/effect/decal/cleanable/blood/footprints/should_be_off_floor()
return FALSE
/proc/createFootprintsFrom(atom/movable/A, dir, turf/T)
var/obj/effect/decal/cleanable/blood/footprints/FP = new /obj/effect/decal/cleanable/blood/footprints(T)
if(ishuman(A))
+5
View File
@@ -98,6 +98,11 @@
create_reagents(100)
reagents.add_reagent_list(scoop_reagents)
/obj/effect/decal/build_base_description(infix, suffix) // overriding this is a sin but it fixes a worse sin
. = list("[bicon(src)] That's \a [src][infix]. [suffix]")
if(desc)
. += desc
/obj/effect/decal/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/reagent_containers/glass) || istype(I, /obj/item/reagent_containers/drinks))
scoop(I, user)
+2 -2
View File
@@ -389,7 +389,7 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
attack_hand(A)
/obj/item/attack_ai(mob/user as mob)
if(istype(src.loc, /obj/item/robot_module))
if(istype(loc, /obj/item/robot_module))
// If the item is part of a cyborg module, equip it
if(!isrobot(user))
return
@@ -1022,7 +1022,7 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
return FALSE
// Only matches and cigars can light fancy smokables.
if(cig.fancy && !istype(src, /obj/item/match) && !istype(src, /obj/item/lighter/zippo))
if(length(cig.fancy_lighters) && !is_type_in_list(src, cig.fancy_lighters))
to_chat(user, "<span class='danger'>[cig] straight out REFUSES to be lit by such uncivilized means!</span>")
return FALSE
+16 -16
View File
@@ -194,6 +194,21 @@
return access
return access | guest_pass.GetAccess()
/obj/item/card/id/proc/attach_guest_pass(obj/item/card/id/guest/G, mob/user)
if(world.time > G.expiration_time)
to_chat(user, "There's no point, the guest pass has expired.")
return
if(guest_pass)
to_chat(user, "There's already a guest pass attached to this ID.")
return
if(G.registered_name != registered_name && G.registered_name != "NOT SPECIFIED")
to_chat(user, "The guest pass cannot be attached to this ID.")
return
if(!user.unEquip(G))
return
G.loc = src
guest_pass = G
/obj/item/card/id/GetID()
return src
@@ -266,22 +281,7 @@
to_chat(user, "This ID has already been stamped!")
else if(istype(W, /obj/item/card/id/guest))
if(istype(src, /obj/item/card/id/guest))
return
var/obj/item/card/id/guest/G = W
if(world.time > G.expiration_time)
to_chat(user, "There's no point, the guest pass has expired.")
return
if(guest_pass)
to_chat(user, "There's already a guest pass attached to this ID.")
return
if(G.registered_name != registered_name && G.registered_name != "NOT SPECIFIED")
to_chat(user, "The guest pass cannot be attached to this ID")
return
if(!user.unEquip(G))
return
G.loc = src
guest_pass = G
attach_guest_pass(W, user)
/obj/item/card/id/AltClick(mob/user)
if(user.stat || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || !Adjacent(user))
+6 -6
View File
@@ -33,8 +33,8 @@ LIGHTERS ARE IN LIGHTERS.DM
var/icon_on = "cigon" //Note - these are in masks.dmi not in cigarette.dmi
/// Unlit cigarette sprite.
var/icon_off = "cigoff"
/// Are we an extra-classy smokable?
var/fancy = FALSE
/// Do we require special items to be lit?
var/list/fancy_lighters = list()
/// What trash item the cigarette makes when it burns out.
var/type_butt = /obj/item/cigbutt
/// How long does the cigarette last before going out? Decrements by 1 every cycle.
@@ -108,7 +108,7 @@ LIGHTERS ARE IN LIGHTERS.DM
else
to_chat(user, "<span class='notice'>You put [src] into your mouth.</span>")
return TRUE
// If they DO have a cig, try to light it with your own cig.
if(!cigarette_lighter_act(user, M))
return ..()
@@ -417,7 +417,7 @@ LIGHTERS ARE IN LIGHTERS.DM
icon_on = "cigaron"
icon_off = "cigaroff"
throw_speed = 0.5
fancy = TRUE
fancy_lighters = list(/obj/item/match, /obj/item/lighter/zippo)
type_butt = /obj/item/cigbutt/cigarbutt
smoketime = 300
chem_volume = 120
@@ -523,7 +523,7 @@ LIGHTERS ARE IN LIGHTERS.DM
item_state = "pipeoff"
icon_on = "pipeon" //Note - these are in masks.dmi
icon_off = "pipeoff"
fancy = TRUE
fancy_lighters = list(/obj/item/match, /obj/item/lighter/zippo)
smoketime = 500
chem_volume = 200
list_reagents = list("nicotine" = 200)
@@ -583,7 +583,7 @@ LIGHTERS ARE IN LIGHTERS.DM
else
to_chat(user, "<span class='warning'>You need to dry this first!</span>")
return
return ..()
/obj/item/clothing/mask/cigarette/pipe/cobpipe
+12 -6
View File
@@ -214,9 +214,7 @@
materials = list()
trashtype = /obj/item/restraints/handcuffs/cable/zipties/used
/obj/item/restraints/handcuffs/cable/zipties/cyborg/attack(mob/living/carbon/C, mob/user)
if(isrobot(user))
cuff(C, user, FALSE)
/obj/item/restraints/handcuffs/cable/zipties/used
desc = "A pair of broken zipties."
@@ -268,10 +266,10 @@
//////////////////////////////
/obj/item/restraints/handcuffs/cable/attackby(obj/item/I, mob/user, params)
..()
// Don't allow borgs to send their their ziptie module to the shadow realm.
if(istype(src, /obj/item/restraints/handcuffs/cable/zipties/cyborg))
return
handle_attack_construction(I, user)
/obj/item/restraints/handcuffs/cable/proc/handle_attack_construction(obj/item/I, mob/user)
if(istype(I, /obj/item/stack/rods))
var/obj/item/stack/rods/R = I
if(!R.use(1))
@@ -306,3 +304,11 @@
if(istype(I, /obj/item/toy/crayon))
var/obj/item/toy/crayon/C = I
cable_color(C.dye_color)
/obj/item/restraints/handcuffs/cable/zipties/cyborg/attack(mob/living/carbon/C, mob/user)
if(isrobot(user))
cuff(C, user, FALSE)
/obj/item/restraints/handcuffs/cable/zipties/cyborg/handle_attack_construction(obj/item/I, mob/user)
// Don't allow borgs to send their their ziptie module to the shadow realm.
return
+1 -1
View File
@@ -383,7 +383,7 @@
lit = TRUE
w_class = WEIGHT_CLASS_BULKY //to prevent it going to pockets
is_unathi_fire = TRUE
/obj/item/match/unathi/cigarette_lighter_act(mob/living/target, mob/living/user, obj/item/direct_attackby_item)
var/obj/item/clothing/mask/cigarette/cig = ..()
if(!cig)
@@ -36,6 +36,13 @@
else
. += "There are [length(contents)] [icon_type]s in the box."
/obj/item/storage/fancy/remove_from_storage(obj/item/I, atom/new_location)
if(!istype(I))
return FALSE
update_icon()
return ..()
/*
* Donut Box
*/
@@ -503,10 +503,6 @@
if(!istype(I))
return FALSE
if(istype(src, /obj/item/storage/fancy))
var/obj/item/storage/fancy/F = src
F.update_icon()
for(var/_M in mobs_viewing)
var/mob/M = _M
if((M.s_active == src) && M.client)
+5 -1
View File
@@ -9,6 +9,7 @@
flags_2 = RAD_PROTECT_CONTENTS_2 | RAD_NO_CONTAMINATE_2
blocks_emissive = EMISSIVE_BLOCK_GENERIC
var/does_emissive = FALSE
var/removable = TRUE
/obj/structure/sign/Initialize(mapload)
. = ..()
@@ -36,7 +37,7 @@
playsound(loc, 'sound/items/welder.ogg', 80, TRUE)
/obj/structure/sign/screwdriver_act(mob/user, obj/item/I)
if(istype(src, /obj/structure/sign/double))
if(!removable)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
@@ -85,6 +86,9 @@
to_chat(user, "<span class='notice'>You fasten [S] with your [I].</span>")
qdel(src)
/obj/structure/sign/double
removable = FALSE
/obj/structure/sign/double/map
name = "station map"
desc = "A framed picture of the station."
+8 -14
View File
@@ -43,6 +43,7 @@
var/minimum_env_smash = ENVIRONMENT_SMASH_WALLS
/// Can this table be flipped?
var/can_be_flipped = TRUE
var/flipped_table_icon_base = "table"
/obj/structure/table/Initialize(mapload)
. = ..()
@@ -78,19 +79,7 @@
type++
if(type == 1)
subtype = direction == turn(dir,90) ? "-" : "+"
var/base = "table"
if(istype(src, /obj/structure/table/wood))
base = "wood"
if(istype(src, /obj/structure/table/reinforced))
base = "rtable"
if(istype(src, /obj/structure/table/wood/poker))
base = "poker"
if(istype(src, /obj/structure/table/wood/fancy))
base = "fancy"
if(istype(src, /obj/structure/table/wood/fancy/black))
base = "fancyblack"
icon_state = "[base]flip[type][type == 1 ? subtype : ""]"
icon_state = "[flipped_table_icon_base]flip[type][type == 1 ? subtype : ""]"
/obj/structure/table/proc/update_smoothing()
if((smoothing_flags & (SMOOTH_CORNERS|SMOOTH_BITMASK)) && !flipped)
@@ -101,7 +90,7 @@
clear_smooth_overlays()
// Need to override this to allow flipped tables to be mapped in without the smoothing subsystem resetting the icon_state
/obj/structure/table/set_smoothed_icon_state(new_junction)
/obj/structure/table/set_smoothed_icon_state(new_junction)
if(flipped)
return
..()
@@ -650,6 +639,7 @@
icon = 'icons/obj/smooth_structures/tables/wood_table.dmi'
icon_state = "wood_table-0"
base_icon_state = "wood_table"
flipped_table_icon_base = "wood"
frame = /obj/structure/table_frame/wood
framestack = /obj/item/stack/sheet/wood
buildstack = /obj/item/stack/sheet/wood
@@ -669,6 +659,7 @@
icon = 'icons/obj/smooth_structures/tables/poker_table.dmi'
icon_state = "poker_table-0"
base_icon_state = "poker_table"
flipped_table_icon_base = "poker"
buildstack = /obj/item/stack/tile/carpet
/obj/structure/table/wood/poker/narsie_act()
@@ -684,6 +675,7 @@
icon = 'icons/obj/smooth_structures/tables/fancy/fancy_table.dmi'
icon_state = "fancy_table-0"
base_icon_state = "fancy_table"
flipped_table_icon_base = "fancy"
frame = /obj/structure/table_frame
framestack = /obj/item/stack/rods
buildstack = /obj/item/stack/tile/carpet
@@ -700,6 +692,7 @@
/obj/structure/table/wood/fancy/black
icon_state = "fancy_table_black-0"
base_icon_state = "fancy_table_black"
flipped_table_icon_base = "fancyblack"
buildstack = /obj/item/stack/tile/carpet/black
icon = 'icons/obj/smooth_structures/tables/fancy/fancy_table_black.dmi'
@@ -762,6 +755,7 @@
icon = 'icons/obj/smooth_structures/tables/reinforced_table.dmi'
icon_state = "reinforced_table-0"
base_icon_state = "reinforced_table"
flipped_table_icon_base = "rtables"
deconstruction_ready = FALSE
buildstack = /obj/item/stack/sheet/plasteel
smoothing_groups = list(SMOOTH_GROUP_REINFORCED_TABLES)