Merge pull request #8328 from PsiOmegaDelta/LessIsMore

Cleans up access handling.
This commit is contained in:
Chinsky
2015-03-03 10:21:16 +03:00
16 changed files with 927 additions and 953 deletions

View File

@@ -85,10 +85,8 @@
//MONEY
/var/const/access_crate_cash = 200
/obj/var/list/req_access = null
/obj/var/req_access_txt = "0"
/obj/var/list/req_one_access = null
/obj/var/req_one_access_txt = "0"
/obj/var/list/req_access = list()
/obj/var/list/req_one_access = list()
//returns 1 if this mob has sufficient access to use this object
/obj/proc/allowed(mob/M)
@@ -117,37 +115,14 @@
return null
/obj/proc/check_access(obj/item/I)
//These generations have been moved out of /obj/New() because they were slowing down the creation of objects that never even used the access system.
if(!src.req_access)
src.req_access = list()
if(src.req_access_txt)
var/list/req_access_str = text2list(req_access_txt,";")
for(var/x in req_access_str)
var/n = text2num(x)
if(n)
req_access += n
if(!src.req_one_access)
src.req_one_access = list()
if(src.req_one_access_txt)
var/list/req_one_access_str = text2list(req_one_access_txt,";")
for(var/x in req_one_access_str)
var/n = text2num(x)
if(n)
req_one_access += n
if(!istype(src.req_access, /list)) //something's very wrong
return 1
var/list/L = src.req_access
if(!L.len && (!src.req_one_access || !src.req_one_access.len)) //no requirements
if(!src.req_access.len && !src.req_one_access.len) //no requirements
return 1
if(!I)
return 0
for(var/req in src.req_access)
if(!(req in I.GetAccess())) //doesn't have this access
return 0
if(src.req_one_access && src.req_one_access.len)
if(src.req_one_access.len)
for(var/req in src.req_one_access)
if(req in I.GetAccess()) //has an access from the single access list
return 1
@@ -156,15 +131,13 @@
/obj/proc/check_access_list(var/list/L)
if(!src.req_access && !src.req_one_access) return 1
if(!istype(src.req_access, /list)) return 1
if(!src.req_access.len && (!src.req_one_access || !src.req_one_access.len)) return 1
if(!src.req_access.len && !src.req_one_access.len) return 1
if(!L) return 0
if(!istype(L, /list)) return 0
for(var/req in src.req_access)
if(!(req in L)) //doesn't have this access
return 0
if(src.req_one_access && src.req_one_access.len)
if(src.req_one_access.len)
for(var/req in src.req_one_access)
if(req in L) //has an access from the single access list
return 1

View File

@@ -182,7 +182,8 @@ for reference:
else if (istype(W, /obj/item/weapon/card/emag))
if (src.emagged == 0)
src.emagged = 1
src.req_access = null
src.req_access.Cut()
src.req_one_access.Cut()
user << "You break the ID authentication lock on \the [src]."
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(2, 1, src)

View File

@@ -1085,9 +1085,10 @@ About the new airlock wires panel:
//update the door's access to match the electronics'
secured_wires = electronics.secure
if(electronics.one_access)
req_access = null
req_access.Cut()
req_one_access = src.electronics.conf_access
else
req_one_access.Cut()
req_access = src.electronics.conf_access
//get the name from the assembly

View File

@@ -58,7 +58,7 @@
/obj/machinery/smartfridge/secure/extract
name = "\improper Slime Extract Storage"
desc = "A refrigerated storage unit for slime extracts"
req_access_txt = "47"
req_access = list(access_research)
/obj/machinery/smartfridge/secure/extract/accept_check(var/obj/item/O as obj)
if(istype(O,/obj/item/slime_extract))
@@ -70,7 +70,7 @@
desc = "A refrigerated storage unit for storing medicine and chemicals."
icon_state = "smartfridge" //To fix the icon in the map editor.
icon_on = "smartfridge_chem"
req_one_access_txt = "5;33"
req_one_access = list(access_medical,access_chemistry)
/obj/machinery/smartfridge/secure/medbay/accept_check(var/obj/item/O as obj)
if(istype(O,/obj/item/weapon/reagent_containers/glass/))
@@ -84,7 +84,7 @@
/obj/machinery/smartfridge/secure/virology
name = "\improper Refrigerated Virus Storage"
desc = "A refrigerated storage unit for storing viral material."
req_access_txt = "39"
req_access = list(access_virology)
icon_state = "smartfridge_virology"
icon_on = "smartfridge_virology"
icon_off = "smartfridge_virology-off"

View File

@@ -700,7 +700,7 @@
idle_power_usage = 211 //refrigerator - believe it or not, this is actually the average power consumption of a refrigerated vending machine according to NRCan.
product_slogans = "I hope nobody asks me for a bloody cup o' tea...;Alcohol is humanity's friend. Would you abandon a friend?;Quite delighted to serve you!;Is nobody thirsty on this station?"
product_ads = "Drink up!;Booze is good for you!;Alcohol is humanity's best friend.;Quite delighted to serve you!;Care for a nice, cold beer?;Nothing cures you like booze!;Have a sip!;Have a drink!;Have a beer!;Beer is good for you!;Only the finest alcohol!;Best quality booze since 2053!;Award-winning wine!;Maximum alcohol!;Man loves beer.;A toast for progress!"
req_access_txt = "25"
req_access = list(access_bar)
/obj/machinery/vending/assist
products = list( /obj/item/device/assembly/prox_sensor = 5,/obj/item/device/assembly/igniter = 3,/obj/item/device/assembly/signaler = 4,
@@ -788,7 +788,7 @@
icon_state = "med"
icon_deny = "med-deny"
product_ads = "Go save some lives!;The best stuff for your medbay.;Only the finest tools.;Natural chemicals!;This stuff saves lives.;Don't you want some?;Ping!"
req_access_txt = "5"
req_access = list(access_medical)
products = list(/obj/item/weapon/reagent_containers/glass/bottle/antitoxin = 4,/obj/item/weapon/reagent_containers/glass/bottle/inaprovaline = 4,
/obj/item/weapon/reagent_containers/glass/bottle/stoxin = 4,/obj/item/weapon/reagent_containers/glass/bottle/toxin = 4,
/obj/item/weapon/reagent_containers/syringe/antiviral = 4,/obj/item/weapon/reagent_containers/syringe = 12,
@@ -812,7 +812,7 @@
product_ads = "Go save some lives!;The best stuff for your medbay.;Only the finest tools.;Natural chemicals!;This stuff saves lives.;Don't you want some?"
icon_state = "wallmed"
icon_deny = "wallmed-deny"
req_access_txt = "5"
req_access = list(access_medical)
density = 0 //It is wall-mounted, and thus, not dense. --Superxpdude
products = list(/obj/item/stack/medical/bruise_pack = 2,/obj/item/stack/medical/ointment = 2,/obj/item/weapon/reagent_containers/hypospray/autoinjector = 4,/obj/item/device/healthanalyzer = 1)
contraband = list(/obj/item/weapon/reagent_containers/syringe/antitoxin = 4,/obj/item/weapon/reagent_containers/syringe/antiviral = 4,/obj/item/weapon/reagent_containers/pill/tox = 1)
@@ -822,7 +822,7 @@
desc = "Wall-mounted Medical Equipment dispenser."
icon_state = "wallmed"
icon_deny = "wallmed-deny"
req_access_txt = "5"
req_access = list(access_medical)
density = 0 //It is wall-mounted, and thus, not dense. --Superxpdude
products = list(/obj/item/weapon/reagent_containers/hypospray/autoinjector = 5,/obj/item/weapon/reagent_containers/syringe/antitoxin = 3,/obj/item/stack/medical/bruise_pack = 3,
/obj/item/stack/medical/ointment =3,/obj/item/device/healthanalyzer = 3)
@@ -834,7 +834,7 @@
product_ads = "Crack capitalist skulls!;Beat some heads in!;Don't forget - harm is good!;Your weapons are right here.;Handcuffs!;Freeze, scumbag!;Don't tase me bro!;Tase them, bro.;Why not have a donut?"
icon_state = "sec"
icon_deny = "sec-deny"
req_access_txt = "1"
req_access = list(access_security)
products = list(/obj/item/weapon/handcuffs = 8,/obj/item/weapon/grenade/flashbang = 4,/obj/item/device/flash = 5,
/obj/item/weapon/reagent_containers/food/snacks/donut/normal = 12,/obj/item/weapon/storage/box/evidence = 6)
contraband = list(/obj/item/clothing/glasses/sunglasses = 2,/obj/item/weapon/storage/donut_box = 2)
@@ -927,7 +927,7 @@
desc = "Tools for tools."
icon_state = "tool"
icon_deny = "tool-deny"
//req_access_txt = "12" //Maintenance access
//req_access = list(access_maint_tunnels) //Maintenance access
products = list(/obj/item/stack/cable_coil/random = 10,/obj/item/weapon/crowbar = 5,/obj/item/weapon/weldingtool = 3,/obj/item/weapon/wirecutters = 5,
/obj/item/weapon/wrench = 5,/obj/item/device/analyzer = 5,/obj/item/device/t_scanner = 5,/obj/item/weapon/screwdriver = 5)
contraband = list(/obj/item/weapon/weldingtool/hugetank = 2,/obj/item/clothing/gloves/fyellow = 2)
@@ -938,7 +938,7 @@
desc = "Spare tool vending. What? Did you expect some witty description?"
icon_state = "engivend"
icon_deny = "engivend-deny"
req_access_txt = "11" //Engineering Equipment access
req_access = list(access_engine_equip) //Engineering Equipment access
products = list(/obj/item/clothing/glasses/meson = 2,/obj/item/device/multitool = 4,/obj/item/weapon/airlock_electronics = 10,/obj/item/weapon/module/power_control = 10,/obj/item/weapon/airalarm_electronics = 10,/obj/item/weapon/cell/high = 10)
contraband = list(/obj/item/weapon/cell/potato = 3)
premium = list(/obj/item/weapon/storage/belt/utility = 3)
@@ -949,7 +949,7 @@
desc = "Everything you need for do-it-yourself station repair."
icon_state = "engi"
icon_deny = "engi-deny"
req_access_txt = "11"
req_access = list(access_engine_equip)
products = list(/obj/item/clothing/under/rank/chief_engineer = 4,/obj/item/clothing/under/rank/engineer = 4,/obj/item/clothing/shoes/orange = 4,/obj/item/clothing/head/hardhat = 4,
/obj/item/weapon/storage/belt/utility = 4,/obj/item/clothing/glasses/meson = 4,/obj/item/clothing/gloves/yellow = 4, /obj/item/weapon/screwdriver = 12,
/obj/item/weapon/crowbar = 12,/obj/item/weapon/wirecutters = 12,/obj/item/device/multitool = 12,/obj/item/weapon/wrench = 12,/obj/item/device/t_scanner = 12,
@@ -966,7 +966,7 @@
desc = "All the tools you need to create your own robot army."
icon_state = "robotics"
icon_deny = "robotics-deny"
req_access_txt = "29"
req_access = list(access_robotics)
products = list(/obj/item/clothing/suit/storage/toggle/labcoat = 4,/obj/item/clothing/under/rank/roboticist = 4,/obj/item/stack/cable_coil = 4,/obj/item/device/flash = 4,
/obj/item/weapon/cell/high = 12, /obj/item/device/assembly/prox_sensor = 3,/obj/item/device/assembly/signaler = 3,/obj/item/device/healthanalyzer = 3,
/obj/item/weapon/scalpel = 2,/obj/item/weapon/circular_saw = 2,/obj/item/weapon/tank/anesthetic = 2,/obj/item/clothing/mask/breath/medical = 5,

View File

@@ -12,8 +12,8 @@
icon = 'icons/obj/rig_modules.dmi'
desc = "A back-mounted hardsuit deployment and control mechanism."
slot_flags = SLOT_BACK
req_one_access = null
req_access = null
req_one_access = list()
req_access = list()
w_class = 4
// These values are passed on to all component pieces.

View File

@@ -21,8 +21,8 @@
return
else if(istype(W, /obj/item/weapon/card/emag))
locked_dna = null
req_access = null
req_one_access = null
req_access.Cut()
req_one_access.Cut()
locked = 0
subverted = 1
user << "<span class='danger'>You short out the access protocol for the suit.</span>"

View File

@@ -11,8 +11,8 @@
allowed = list(/obj/item/device/flashlight,/obj/item/weapon/tank,/obj/item/device/suit_cooling_unit,/obj/item/weapon/storage/bag/ore,/obj/item/device/t_scanner,/obj/item/weapon/pickaxe, /obj/item/weapon/rcd)
req_access = null
req_one_access = null
req_access = list()
req_one_access = list()
initial_modules = list(
/obj/item/rig_module/device/plasmacutter,
@@ -83,8 +83,8 @@
allowed = list(/obj/item/device/flashlight,/obj/item/weapon/tank,/obj/item/device/suit_cooling_unit,/obj/item/weapon/storage/firstaid,/obj/item/device/healthanalyzer,/obj/item/stack/medical,/obj/item/roller )
req_access = null
req_one_access = null
req_access = list()
req_one_access = list()
initial_modules = list(
/obj/item/rig_module/chem_dispenser/injector,
@@ -105,6 +105,6 @@
allowed = list(/obj/item/weapon/gun,/obj/item/device/flashlight,/obj/item/weapon/tank,/obj/item/device/suit_cooling_unit,/obj/item/weapon/melee/baton)
req_access = null
req_one_access = null
req_access = list()
req_one_access = list()

View File

@@ -954,8 +954,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
/obj/machinery/computer/rdconsole/robotics
name = "Robotics R&D Console"
id = 2
req_access = null
req_access_txt = "29"
req_access = list(access_robotics)
/obj/machinery/computer/rdconsole/core
name = "Core R&D Console"

View File

@@ -7,7 +7,7 @@
/obj/machinery/computer/shuttle_control/engineering
name = "engineering shuttle control console"
shuttle_tag = "Engineering"
//req_one_access_txt = "11;24"
//req_one_access = list(access_engine_equip,access_atmospherics)
circuit = /obj/item/weapon/circuitboard/engineering_shuttle
/obj/machinery/computer/shuttle_control/research