Merge pull request #6686 from Citadel-Station-13/upstream-merge-37719

[MIRROR] [s] Fix wallets acting as though they still contain removed IDs
This commit is contained in:
deathride58
2018-05-17 18:13:28 +00:00
committed by GitHub
+95 -91
View File
@@ -1,91 +1,95 @@
/obj/item/storage/wallet /obj/item/storage/wallet
name = "wallet" name = "wallet"
desc = "It can hold a few small and personal things." desc = "It can hold a few small and personal things."
icon_state = "wallet" icon_state = "wallet"
w_class = WEIGHT_CLASS_SMALL w_class = WEIGHT_CLASS_SMALL
resistance_flags = FLAMMABLE resistance_flags = FLAMMABLE
slot_flags = SLOT_ID slot_flags = SLOT_ID
var/obj/item/card/id/front_id = null var/obj/item/card/id/front_id = null
var/list/combined_access var/list/combined_access
/obj/item/storage/wallet/ComponentInitialize() /obj/item/storage/wallet/ComponentInitialize()
. = ..() . = ..()
GET_COMPONENT(STR, /datum/component/storage) GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 4 STR.max_items = 4
STR.can_hold = typecacheof(list( STR.can_hold = typecacheof(list(
/obj/item/stack/spacecash, /obj/item/stack/spacecash,
/obj/item/card, /obj/item/card,
/obj/item/clothing/mask/cigarette, /obj/item/clothing/mask/cigarette,
/obj/item/flashlight/pen, /obj/item/flashlight/pen,
/obj/item/seeds, /obj/item/seeds,
/obj/item/stack/medical, /obj/item/stack/medical,
/obj/item/toy/crayon, /obj/item/toy/crayon,
/obj/item/coin, /obj/item/coin,
/obj/item/dice, /obj/item/dice,
/obj/item/disk, /obj/item/disk,
/obj/item/implanter, /obj/item/implanter,
/obj/item/lighter, /obj/item/lighter,
/obj/item/lipstick, /obj/item/lipstick,
/obj/item/match, /obj/item/match,
/obj/item/paper, /obj/item/paper,
/obj/item/pen, /obj/item/pen,
/obj/item/photo, /obj/item/photo,
/obj/item/reagent_containers/dropper, /obj/item/reagent_containers/dropper,
/obj/item/reagent_containers/syringe, /obj/item/reagent_containers/syringe,
/obj/item/screwdriver, /obj/item/screwdriver,
/obj/item/stamp)) /obj/item/stamp))
/obj/item/storage/wallet/Exited(atom/movable/AM) /obj/item/storage/wallet/Exited(atom/movable/AM)
. = ..() . = ..()
refreshID() // The loc has not actually changed yet when this proc is called, so call
// refreshID and have it ignore the outgoing atom.
/obj/item/storage/wallet/proc/refreshID() refreshID(AM)
if(!(front_id in src))
front_id = null /obj/item/storage/wallet/proc/refreshID(atom/movable/removed)
for(var/obj/item/card/id/I in contents) LAZYCLEARLIST(combined_access)
LAZYINITLIST(combined_access) if(!(front_id in src) || front_id == removed)
LAZYCLEARLIST(combined_access) front_id = null
if(!front_id) for(var/obj/item/card/id/I in contents)
front_id = I if(I == removed)
combined_access |= I.access continue
update_icon() if(!front_id)
front_id = I
/obj/item/storage/wallet/Entered(atom/movable/AM) LAZYINITLIST(combined_access)
. = ..() combined_access |= I.access
refreshID() update_icon()
/obj/item/storage/wallet/update_icon() /obj/item/storage/wallet/Entered(atom/movable/AM)
var/new_state = "wallet" . = ..()
if(front_id) refreshID()
new_state = "wallet_[front_id.icon_state]"
if(new_state != icon_state) //avoid so many icon state changes. /obj/item/storage/wallet/update_icon()
icon_state = new_state var/new_state = "wallet"
if(front_id)
/obj/item/storage/wallet/GetID() new_state = "wallet_[front_id.icon_state]"
return front_id if(new_state != icon_state) //avoid so many icon state changes.
icon_state = new_state
/obj/item/storage/wallet/GetAccess()
if(LAZYLEN(combined_access)) /obj/item/storage/wallet/GetID()
return combined_access return front_id
else
return ..() /obj/item/storage/wallet/GetAccess()
if(LAZYLEN(combined_access))
/obj/item/storage/wallet/random return combined_access
icon_state = "random_wallet" else
return ..()
/obj/item/storage/wallet/random/PopulateContents()
var/item1_type = pick( /obj/item/stack/spacecash/c10, /obj/item/stack/spacecash/c100, /obj/item/stack/spacecash/c1000, /obj/item/stack/spacecash/c20, /obj/item/stack/spacecash/c200, /obj/item/stack/spacecash/c50, /obj/item/stack/spacecash/c500) /obj/item/storage/wallet/random
var/item2_type icon_state = "random_wallet"
if(prob(50))
item2_type = pick( /obj/item/stack/spacecash/c10, /obj/item/stack/spacecash/c100, /obj/item/stack/spacecash/c1000, /obj/item/stack/spacecash/c20, /obj/item/stack/spacecash/c200, /obj/item/stack/spacecash/c50, /obj/item/stack/spacecash/c500) /obj/item/storage/wallet/random/PopulateContents()
var/item3_type = pick( /obj/item/coin/silver, /obj/item/coin/silver, /obj/item/coin/gold, /obj/item/coin/iron, /obj/item/coin/iron, /obj/item/coin/iron ) var/item1_type = pick( /obj/item/stack/spacecash/c10, /obj/item/stack/spacecash/c100, /obj/item/stack/spacecash/c1000, /obj/item/stack/spacecash/c20, /obj/item/stack/spacecash/c200, /obj/item/stack/spacecash/c50, /obj/item/stack/spacecash/c500)
var/item2_type
spawn(2) if(prob(50))
if(item1_type) item2_type = pick( /obj/item/stack/spacecash/c10, /obj/item/stack/spacecash/c100, /obj/item/stack/spacecash/c1000, /obj/item/stack/spacecash/c20, /obj/item/stack/spacecash/c200, /obj/item/stack/spacecash/c50, /obj/item/stack/spacecash/c500)
new item1_type(src) var/item3_type = pick( /obj/item/coin/silver, /obj/item/coin/silver, /obj/item/coin/gold, /obj/item/coin/iron, /obj/item/coin/iron, /obj/item/coin/iron )
if(item2_type)
new item2_type(src) spawn(2)
if(item3_type) if(item1_type)
new item3_type(src) new item1_type(src)
update_icon() if(item2_type)
new item2_type(src)
if(item3_type)
new item3_type(src)
update_icon()