Skip to content

Commit

Permalink
Fix lots of problems with wallets as ID (#6411)
Browse files Browse the repository at this point in the history
# About the pull request

This PR refactors all wear_id usages in favor of get_idcard() so that
wallets can be suitable ID cards.

I have not exhaustively tested all the areas of code that had to altered
for this though.

# Explain why it's good for the game

Fixes #6409 

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/366594a0-29e7-40e5-a2f0-ee29aa9ed627)

</details>


# Changelog
:cl: Drathek
fix: Fixed wallets as IDs breaking many things
/:cl:
  • Loading branch information
Drulikar authored Jun 15, 2024
1 parent d9c2f8e commit 46cc54b
Show file tree
Hide file tree
Showing 33 changed files with 190 additions and 177 deletions.
8 changes: 4 additions & 4 deletions code/datums/medal_awards.dm
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ GLOBAL_LIST_INIT(human_medals, list(MARINE_CONDUCT_MEDAL, MARINE_BRONZE_HEART_ME
return TRUE

/proc/open_medal_panel(mob/living/carbon/human/user, obj/printer)
var/obj/item/card/id/card = user.wear_id
var/obj/item/card/id/card = user?.get_idcard()
if(!card)
to_chat(user, SPAN_WARNING("You must have an authenticated ID Card to award medals."))
return
Expand Down Expand Up @@ -580,9 +580,9 @@ GLOBAL_DATUM_INIT(ic_medals_panel, /datum/ic_medal_panel, new)
. = ..()
if(.)
return
var/mob/living/carbon/human/user = usr
var/obj/item/card/id/card = user.wear_id
if(!card)
var/mob/living/carbon/human/user = ui.user
var/obj/item/card/id/card = user?.get_idcard()
if(card)
to_chat(user, SPAN_WARNING("You must have an authenticated ID Card to award medals."))
return

Expand Down
3 changes: 2 additions & 1 deletion code/defines/procs/announcement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
continue

// If they have iff AND a marine headset they will recieve announcements
if ((FACTION_MARINE in H.wear_id?.faction_group) && (istype(H.wear_l_ear, /obj/item/device/radio/headset/almayer) || istype(H.wear_r_ear, /obj/item/device/radio/headset/almayer)))
var/obj/item/card/id/card = H.get_idcard()
if ((FACTION_MARINE in card?.faction_group) && (istype(H.wear_l_ear, /obj/item/device/radio/headset/almayer) || istype(H.wear_r_ear, /obj/item/device/radio/headset/almayer)))
continue

if((H.faction != faction_to_display && !add_PMCs) || (H.faction != faction_to_display && add_PMCs && !(H.faction in FACTION_LIST_WY)) && !(faction_to_display in H.faction_group)) //faction checks
Expand Down
2 changes: 1 addition & 1 deletion code/game/jobs/job/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
var/datum/money_account/generated_account
//Give them an account in the database.
if(!(flags_startup_parameters & ROLE_NO_ACCOUNT))
var/obj/item/card/id/card = account_user.wear_id
var/obj/item/card/id/card = account_user.get_idcard()
var/user_has_preexisting_account = account_user.mind?.initial_account
if(card && !user_has_preexisting_account)
var/datum/paygrade/account_paygrade = GLOB.paygrades[card.paygrade]
Expand Down
10 changes: 5 additions & 5 deletions code/game/jobs/job/marine/squads.dm
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@

var/obj/item/card/id/C = ID
if(!C)
C = M.wear_id
C = M.get_idcard()
if(!C)
C = M.get_active_hand()
if(!istype(C))
Expand Down Expand Up @@ -554,7 +554,7 @@
return //not assigned to the correct squad
var/obj/item/card/id/C = ID
if(!istype(C))
C = M.wear_id
C = M.get_idcard()
if(!istype(C))
return FALSE //Abort, no ID found

Expand Down Expand Up @@ -637,9 +637,9 @@
R.keys -= key
qdel(key)
R.recalculateChannels()
if(istype(old_lead.wear_id, /obj/item/card/id))
var/obj/item/card/id/ID = old_lead.wear_id
ID.access -= ACCESS_MARINE_LEADER
var/obj/item/card/id/card = old_lead.get_idcard()
if(card)
card.access -= ACCESS_MARINE_LEADER
REMOVE_TRAITS_IN(old_lead, TRAIT_SOURCE_SQUAD_LEADER)
old_lead.hud_set_squad()
old_lead.update_inv_head() //updating marine helmet leader overlays
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/ARES/ARES_interface.dm
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@
authentication = get_ares_access(idcard)
last_login = idcard.registered_name
else if(operator.wear_id)
idcard = operator.wear_id
if(istype(idcard))
idcard = operator.get_idcard()
if(idcard)
authentication = get_ares_access(idcard)
last_login = idcard.registered_name
else
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/ARES/ARES_interface_apollo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@
authentication = get_ares_access(idcard)
last_login = idcard.registered_name
else if(user.wear_id)
idcard = user.wear_id
if(istype(idcard))
idcard = user.get_idcard()
if(idcard)
authentication = get_ares_access(idcard)
last_login = idcard.registered_name
else
Expand Down Expand Up @@ -317,8 +317,8 @@
if(istype(idcard))
has_id = TRUE
else if(user.wear_id)
idcard = user.wear_id
if(istype(idcard))
idcard = user.get_idcard()
if(idcard)
has_id = TRUE
if(!has_id)
to_chat(user, SPAN_WARNING("You require an ID card to request an access ticket!"))
Expand Down
11 changes: 5 additions & 6 deletions code/game/machinery/ARES/ARES_step_triggers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
return FALSE
if(ishuman(passer))
var/mob/living/carbon/human/trespasser = passer
if(pass_accesses && (trespasser.wear_id))
var/obj/item/card/id/card = trespasser.get_idcard()
if(pass_accesses && card)
for(var/tag in pass_accesses)
if(tag in trespasser.wear_id.access)
if(tag in card.access)
return FALSE
Trigger(passer)
return TRUE
Expand Down Expand Up @@ -123,11 +124,9 @@
var/check_contents = TRUE
if(ishuman(passer))
var/mob/living/carbon/human/human_passer = passer
idcard = human_passer.wear_id
if(istype(idcard))
idcard = human_passer.get_idcard()
if(idcard)
check_contents = FALSE
else
idcard = null

if(istype(passer, /obj/item/card/id))
idcard = passer
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/ARES/apollo_pda.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@
authentication = get_ares_access(idcard)
last_login = idcard.registered_name
else if(user.wear_id)
idcard = user.wear_id
if(istype(idcard))
idcard = user.get_idcard()
if(idcard)
authentication = get_ares_access(idcard)
last_login = idcard.registered_name
else
Expand Down Expand Up @@ -343,8 +343,8 @@
if(istype(idcard))
has_id = TRUE
else if(user.wear_id)
idcard = user.wear_id
if(istype(idcard))
idcard = user.get_idcard()
if(idcard)
has_id = TRUE
if(!has_id)
to_chat(user, SPAN_WARNING("You require an ID card to request an access ticket!"))
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/computer/almayer_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
var/obj/item/card/id/idcard = human_user.get_active_hand()
var/bio_fail = FALSE
if(!istype(idcard))
idcard = human_user.wear_id
idcard = human_user.get_idcard()
if(!istype(idcard))
bio_fail = TRUE
else if(!idcard.check_biometrics(human_user))
Expand Down Expand Up @@ -198,8 +198,8 @@
var/obj/item/card/id/idcard = human_user.get_active_hand()
var/bio_fail = FALSE
if(!istype(idcard))
idcard = human_user.wear_id
if(!istype(idcard))
idcard = human_user.get_idcard()
if(!idcard)
bio_fail = TRUE
else if(!idcard.check_biometrics(human_user))
bio_fail = TRUE
Expand Down
12 changes: 6 additions & 6 deletions code/game/machinery/computer/communications.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
if(ACCESS_MARINE_SENIOR in I.access)
authenticated = 2
else
I = C.wear_id
if(istype(I))
I = C.get_idcard()
if(I)
if(check_access(I)) authenticated = 1
if(ACCESS_MARINE_SENIOR in I.access)
authenticated = 2
Expand Down Expand Up @@ -117,8 +117,8 @@
var/obj/item/card/id/idcard = human_user.get_active_hand()
var/bio_fail = FALSE
if(!istype(idcard))
idcard = human_user.wear_id
if(!istype(idcard))
idcard = human_user.get_idcard()
if(idcard)
bio_fail = TRUE
else if(!idcard.check_biometrics(human_user))
bio_fail = TRUE
Expand Down Expand Up @@ -171,8 +171,8 @@
var/obj/item/card/id/idcard = human_user.get_active_hand()
var/bio_fail = FALSE
if(!istype(idcard))
idcard = human_user.wear_id
if(!istype(idcard))
idcard = human_user.get_idcard()
if(!idcard)
bio_fail = TRUE
else if(!idcard.check_biometrics(human_user))
bio_fail = TRUE
Expand Down
19 changes: 9 additions & 10 deletions code/game/machinery/computer/groundside_operations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,11 @@
if(A)
area_name = sanitize_area(A.name)

var/obj/item/card/id/card = H.get_idcard()
if(H.job)
role = H.job
else if(istype(H.wear_id, /obj/item/card/id)) //decapitated marine is mindless,
var/obj/item/card/id/ID = H.wear_id //we use their ID to get their role.
if(ID.rank)
role = ID.rank
else if(card?.rank) //decapitated marine is mindless,
role = card.rank

switch(H.stat)
if(CONSCIOUS)
Expand Down Expand Up @@ -216,8 +215,8 @@
var/obj/item/card/id/idcard = human_user.get_active_hand()
var/bio_fail = FALSE
if(!istype(idcard))
idcard = human_user.wear_id
if(!istype(idcard))
idcard = human_user.get_idcard()
if(!idcard)
bio_fail = TRUE
else if(!idcard.check_biometrics(human_user))
bio_fail = TRUE
Expand All @@ -244,8 +243,8 @@
var/signed = null
if(ishuman(usr))
var/mob/living/carbon/human/H = usr
var/obj/item/card/id/id = H.wear_id
if(istype(id))
var/obj/item/card/id/id = H.get_idcard()
if(id)
var/paygrade = get_paygrades(id.paygrade, FALSE, H.gender)
signed = "[paygrade] [id.registered_name]"

Expand Down Expand Up @@ -322,8 +321,8 @@
var/obj/item/card/id/idcard = human_user.get_active_hand()
var/bio_fail = FALSE
if(!istype(idcard))
idcard = human_user.wear_id
if(!istype(idcard))
idcard = human_user.get_idcard()
if(!idcard)
bio_fail = TRUE
else if(!idcard.check_biometrics(human_user))
bio_fail = TRUE
Expand Down
17 changes: 9 additions & 8 deletions code/game/machinery/vending/cm_vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ GLOBAL_LIST_EMPTY(vending_products)
to_chat(user, SPAN_WARNING("That set is already taken."))
vend_fail()
return FALSE
var/obj/item/card/id/ID = human_user.wear_id
if(!istype(ID) || !ID.check_biometrics(user))
var/obj/item/card/id/card = human_user.get_idcard()
if(!card?.check_biometrics(user))
to_chat(user, SPAN_WARNING("You must be wearing your [SPAN_INFO("dog tags")] to select a specialization!"))
return FALSE
var/specialist_assignment
Expand Down Expand Up @@ -604,8 +604,8 @@ GLOBAL_LIST_EMPTY(vending_products)
to_chat(user, SPAN_WARNING("<b>Something bad occurred with [src], tell a Dev.</b>"))
vend_fail()
return FALSE
ID.set_assignment((human_user.assigned_squad ? (human_user.assigned_squad.name + " ") : "") + JOB_SQUAD_SPECIALIST + " ([specialist_assignment])")
GLOB.data_core.manifest_modify(user.real_name, WEAKREF(user), ID.assignment)
card.set_assignment((human_user.assigned_squad ? (human_user.assigned_squad.name + " ") : "") + JOB_SQUAD_SPECIALIST + " ([specialist_assignment])")
GLOB.data_core.manifest_modify(user.real_name, WEAKREF(user), card.assignment)
GLOB.available_specialist_sets -= p_name
else if(vendor_role.Find(JOB_SYNTH))
if(user.job != JOB_SYNTH)
Expand Down Expand Up @@ -807,8 +807,8 @@ GLOBAL_LIST_EMPTY(vending_products)
return FALSE

var/mob/living/carbon/human/human_user = user
var/obj/item/card/id/idcard = human_user.wear_id
if(!istype(idcard))
var/obj/item/card/id/idcard = human_user.get_idcard()
if(!idcard)
if(display)
to_chat(user, SPAN_WARNING("Access denied. No ID card detected"))
vend_fail()
Expand Down Expand Up @@ -1406,10 +1406,11 @@ GLOBAL_LIST_INIT(cm_vending_gear_corresponding_types_list, list(
if(vend_flags & VEND_UNIFORM_RANKS)
if(insignas_override)
var/obj/item/clothing/under/underclothes = new_item
var/obj/item/card/id/card = user.get_idcard()

//Gives ranks to the ranked
if(istype(underclothes) && user.wear_id && user.wear_id.paygrade)
var/rankpath = get_rank_pins(user.wear_id.paygrade)
if(istype(underclothes) && card?.paygrade)
var/rankpath = get_rank_pins(card.paygrade)
if(rankpath)
var/obj/item/clothing/accessory/ranks/rank_insignia = new rankpath()
var/obj/item/clothing/accessory/patch/uscmpatch = new()
Expand Down
12 changes: 6 additions & 6 deletions code/game/machinery/vending/vendor_types/dress.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
return

var/mob/living/carbon/human/H = user
var/obj/item/card/id/id_card = H.wear_id
var/obj/item/card/id/id_card = H.get_idcard()
var/list/role_specific_uniforms
var/list/vended_items
var/list/display_list = list()
if(istype(id_card))
if(id_card)
role_specific_uniforms = id_card.uniform_sets
vended_items = id_card.vended_items
for(var/category_type in GLOB.uniform_categories)
Expand Down Expand Up @@ -83,9 +83,9 @@
/obj/structure/machinery/cm_vending/clothing/dress/ui_data(mob/user)

var/mob/living/carbon/human/H = user
var/obj/item/card/id/id_card = H.wear_id
var/obj/item/card/id/id_card = H.get_idcard()
var/list/vended_items
if(istype(id_card))
if(id_card)
vended_items = id_card.vended_items

var/list/data = list()
Expand Down Expand Up @@ -120,9 +120,9 @@

var/item_path = L[3]

var/obj/item/card/id/id_card = H.wear_id
var/obj/item/card/id/id_card = H.get_idcard()

if(!istype(id_card)) //not wearing an ID
if(!id_card) //not wearing an ID
to_chat(H, SPAN_WARNING("Access denied. No ID card detected"))
return

Expand Down
7 changes: 4 additions & 3 deletions code/game/objects/items/devices/cictablet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
/obj/item/device/cotablet/attack_self(mob/living/carbon/human/user as mob)
..()

if(src.allowed(user) && user.wear_id?.check_biometrics(user))
var/obj/item/card/id/card = user.get_idcard()
if(allowed(user) && card?.check_biometrics(user))
tgui_interact(user)
else
to_chat(user, SPAN_DANGER("Access denied."))
Expand Down Expand Up @@ -109,8 +110,8 @@
var/signed = null
if(ishuman(user))
var/mob/living/carbon/human/human_user = user
var/obj/item/card/id/id = human_user.wear_id
if(istype(id))
var/obj/item/card/id/id = human_user.get_idcard()
if(id)
var/paygrade = get_paygrades(id.paygrade, FALSE, human_user.gender)
signed = "[paygrade] [id.registered_name]"

Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/devices/portable_vendor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
to_chat(user, SPAN_WARNING("Access denied."))
return

var/obj/item/card/id/idcard = human_user.wear_id
if(!istype(idcard)) //not wearing an ID
var/obj/item/card/id/idcard = human_user.get_idcard()
if(!idcard) //not wearing an ID
to_chat(human_user, SPAN_WARNING("Access denied. No ID card detected"))
return

Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/devices/radio/headset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@
var/mob/living/carbon/human/wearer = usr
if(!istype(wearer))
return
var/obj/item/card/id/id_card = wearer.wear_id?.GetID()
if(!istype(id_card))
var/obj/item/card/id/id_card = wearer.get_idcard()
if(!id_card)
return

var/datum/paygrade/paygrade_actual = GLOB.paygrades[id_card.paygrade]
if(!paygrade_actual)
return
Expand Down
Loading

0 comments on commit 46cc54b

Please sign in to comment.