mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
- Reworked card reader code, it's cleaner and less copypaste now - Updated medical records, security records and HoP card computer to work with the update. It's however possible i missed something, can't go through all computers in game. Tell me if you find something that's broken due to this, i will fix it ASAP. - Security records color for "none" security status changed a bit so it doesn't burn eyes of anyone trying to read it (issue #5571 - white on light green? Bad choice imo) - Multi-card readers now actually WORK for laptops. This includes security records (issue #5569) and medical records (same case, just not reported). You still have to insert your card into read slot, if you insert it into wrong slot notification will be shown that you should use read slot instead of write one.
This commit is contained in:
@@ -91,29 +91,127 @@
|
||||
return
|
||||
..(I,user)
|
||||
|
||||
proc/insert(var/obj/item/weapon/card/card)
|
||||
// cardslot.insert(card, slot)
|
||||
// card: The card obj you want to insert (usually your ID)
|
||||
// slot: Which slot to insert into (1: reader, 2: writer, 3: auto), 3 default
|
||||
proc/insert(var/obj/item/weapon/card/card, var/slot = 3)
|
||||
if(!computer)
|
||||
return 0
|
||||
if(reader != null)
|
||||
usr << "There is already something in the slot!"
|
||||
// This shouldn't happen, just in case..
|
||||
if(slot == 2 && !dualslot)
|
||||
usr << "This device has only one card slot"
|
||||
return 0
|
||||
if(istype(card,/obj/item/weapon/card/emag)) // emag reader slot
|
||||
usr << "You insert \the [card], and the computer grinds, sparks, and beeps. After a moment, the card ejects itself."
|
||||
computer.emagged = 1
|
||||
return 1
|
||||
var/mob/living/L = usr
|
||||
L.drop_item()
|
||||
card.loc = src
|
||||
reader = card
|
||||
|
||||
proc/remove()
|
||||
reader.loc = loc
|
||||
var/mob/living/carbon/human/user = usr
|
||||
if(istype(user) && !user.get_active_hand())
|
||||
user.put_in_hands(reader)
|
||||
else
|
||||
reader.loc = computer.loc
|
||||
reader = null
|
||||
if(istype(card,/obj/item/weapon/card/emag)) // emag reader slot
|
||||
if(!writer)
|
||||
usr << "You insert \the [card], and the computer grinds, sparks, and beeps. After a moment, the card ejects itself."
|
||||
computer.emagged = 1
|
||||
return 1
|
||||
else
|
||||
usr << "You are unable to insert \the [card], as the reader slot is occupied"
|
||||
|
||||
var/mob/living/L = usr
|
||||
switch(slot)
|
||||
if(1)
|
||||
if(equip_to_reader(card, L))
|
||||
usr << "You insert the card into reader slot"
|
||||
else
|
||||
usr << "There is already something in the reader slot."
|
||||
if(2)
|
||||
if(equip_to_writer(card, L))
|
||||
usr << "You insert the card into writer slot"
|
||||
else
|
||||
usr << "There is already something in the reader slot."
|
||||
if(3)
|
||||
if(equip_to_reader(card, L))
|
||||
usr << "You insert the card into reader slot"
|
||||
else if (equip_to_writer(card, L) && dualslot)
|
||||
usr << "You insert the card into writer slot"
|
||||
else if (dualslot)
|
||||
usr << "There is already something in both slots."
|
||||
else
|
||||
usr << "There is already something in the reader slot."
|
||||
|
||||
|
||||
// Usage of insert() preferred, as it also tells result to the user.
|
||||
proc/equip_to_reader(var/obj/item/weapon/card/card, var/mob/living/L)
|
||||
if(!reader)
|
||||
L.drop_item()
|
||||
card.loc = src
|
||||
reader = card
|
||||
return 1
|
||||
return 0
|
||||
|
||||
proc/equip_to_writer(var/obj/item/weapon/card/card, var/mob/living/L)
|
||||
if(!writer && dualslot)
|
||||
L.drop_item()
|
||||
card.loc = src
|
||||
writer = card
|
||||
return 1
|
||||
return 0
|
||||
|
||||
// cardslot.remove(slot)
|
||||
// slot: Which slot to remove card(s) from (1: reader only, 2: writer only, 3: both [works even with one card], 4: reader and if empty then writer ), 3 default
|
||||
proc/remove(var/slot = 3)
|
||||
var/mob/living/L = usr
|
||||
switch(slot)
|
||||
if(1)
|
||||
if (remove_reader(L))
|
||||
L << "You remove the card from reader slot"
|
||||
else
|
||||
L << "There is no card in the reader slot"
|
||||
if(2)
|
||||
if (remove_writer(L))
|
||||
L << "You remove the card from writer slot"
|
||||
else
|
||||
L << "There is no card in the writer slot"
|
||||
if(3)
|
||||
if (remove_reader(L))
|
||||
if (remove_writer(L))
|
||||
L << "You remove cards from both slots"
|
||||
else
|
||||
L << "You remove the card from reader slot"
|
||||
else
|
||||
if(remove_writer(L))
|
||||
L << "You remove the card from writer slot"
|
||||
else
|
||||
L << "There are no cards in both slots"
|
||||
if(4)
|
||||
if (!remove_reader(L))
|
||||
if (remove_writer(L))
|
||||
L << "You remove the card from writer slot"
|
||||
else if (!dualslot)
|
||||
L << "There is no card in the reader slot"
|
||||
else
|
||||
L << "There are no cards in both slots"
|
||||
else
|
||||
L << "You remove the card from reader slot"
|
||||
|
||||
|
||||
proc/remove_reader(var/mob/living/L)
|
||||
if(reader)
|
||||
reader.loc = loc
|
||||
if(istype(L) && !L.get_active_hand())
|
||||
L.put_in_hands(reader)
|
||||
else
|
||||
reader.loc = computer.loc
|
||||
reader = null
|
||||
return 1
|
||||
return 0
|
||||
|
||||
proc/remove_writer(var/mob/living/L)
|
||||
if(writer && dualslot)
|
||||
writer.loc = loc
|
||||
if(istype(L) && !L.get_active_hand())
|
||||
L.put_in_hands(writer)
|
||||
else
|
||||
writer.loc = computer.loc
|
||||
writer = null
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
|
||||
// Authorizes the user based on the computer's requirements
|
||||
proc/authenticate()
|
||||
@@ -133,6 +231,13 @@
|
||||
desc = "Contains slots for inserting magnetic swipe cards for reading and writing."
|
||||
dualslot = 1
|
||||
|
||||
|
||||
/*
|
||||
// Atlantis: Reworked card manipulation a bit.
|
||||
// No need for separated code for dual and single readers.
|
||||
// Both is handled in single-slot reader code now, thanks to the "dualslot" var.
|
||||
// Leaving this code here if someone wants to somehow use it, just uncomment.
|
||||
|
||||
insert(var/obj/item/weapon/card/card,var/slot = 0)
|
||||
if(!computer)
|
||||
return 0
|
||||
@@ -194,5 +299,6 @@
|
||||
user.put_in_hands(card)
|
||||
else
|
||||
card.loc = computer.loc
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -253,9 +253,9 @@
|
||||
if("remove" in href_list)
|
||||
var/which = href_list["remove"]
|
||||
if(which == "writer")
|
||||
computer.cardslot.remove(computer.cardslot.writer)
|
||||
computer.cardslot.remove(2)
|
||||
else
|
||||
computer.cardslot.remove(computer.cardslot.reader)
|
||||
computer.cardslot.remove(1)
|
||||
auth = 0
|
||||
|
||||
if("insert" in href_list)
|
||||
@@ -264,9 +264,9 @@
|
||||
|
||||
var/which = href_list["insert"]
|
||||
if(which == "writer")
|
||||
computer.cardslot.insert(card,1)
|
||||
else
|
||||
computer.cardslot.insert(card,2)
|
||||
else
|
||||
computer.cardslot.insert(card,1)
|
||||
|
||||
if("print" in href_list)
|
||||
if (printing)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
req_one_access = list(access_medical, access_forensics_lockers)
|
||||
|
||||
var/obj/item/weapon/card/id/scan = null
|
||||
var/obj/item/weapon/card/id/scan2 = null
|
||||
var/authenticated = null
|
||||
var/rank = null
|
||||
var/screen = null
|
||||
@@ -56,7 +57,12 @@
|
||||
if (temp)
|
||||
dat = text("<TT>[src.temp]</TT><BR><BR><A href='?src=\ref[src];temp=1'>Clear Screen</A>")
|
||||
else
|
||||
dat = text("Confirm Identity: <A href='?src=\ref[];scan=1'>[]</A><HR>", src, (src.scan ? text("[]", src.scan.name) : "----------"))
|
||||
dat = text("Confirm Identity (R): <A href='?src=\ref[];cardr=1'>[]</A><HR>", src, (scan ? text("[]", scan.name) : "----------"))
|
||||
if (computer.cardslot.dualslot)
|
||||
dat += text("Check Identity (W): <A href='?src=\ref[];cardw=1'>[]</A><BR>", src, (scan2 ? text("[]", scan2.name) : "----------"))
|
||||
if(scan2 && !scan)
|
||||
dat += text("<div class='notice'>Insert card into reader slot to log in.</div><br>")
|
||||
|
||||
if (src.authenticated)
|
||||
switch(src.screen)
|
||||
if(1.0)
|
||||
@@ -165,19 +171,32 @@
|
||||
if (href_list["temp"])
|
||||
src.temp = null
|
||||
|
||||
if (href_list["scan"])
|
||||
if (href_list["cardr"])
|
||||
if (scan)
|
||||
if(istype(usr,/mob/living/carbon/human) && !usr.get_active_hand())
|
||||
computer.cardslot.remove(scan)
|
||||
computer.cardslot.remove(1)
|
||||
else
|
||||
scan.loc = get_turf(src)
|
||||
scan = null
|
||||
else
|
||||
var/obj/item/I = usr.get_active_hand()
|
||||
if (istype(I, /obj/item/weapon/card/id))
|
||||
computer.cardslot.insert(I)
|
||||
computer.cardslot.insert(I, 1)
|
||||
scan = I
|
||||
|
||||
if (href_list["cardw"])
|
||||
if (scan2)
|
||||
if(istype(usr,/mob/living/carbon/human) && !usr.get_active_hand())
|
||||
computer.cardslot.remove(2)
|
||||
else
|
||||
scan2.loc = get_turf(src)
|
||||
scan2 = null
|
||||
else
|
||||
var/obj/item/I = usr.get_active_hand()
|
||||
if (istype(I, /obj/item/weapon/card/id))
|
||||
computer.cardslot.insert(I, 2)
|
||||
scan2 = I
|
||||
|
||||
else if (href_list["logout"])
|
||||
src.authenticated = null
|
||||
src.screen = null
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
req_one_access = list(access_security, access_forensics_lockers)
|
||||
|
||||
var/obj/item/weapon/card/id/scan = null
|
||||
var/obj/item/weapon/card/id/scan2 = null
|
||||
var/authenticated = null
|
||||
var/rank = null
|
||||
var/screen = null
|
||||
@@ -49,9 +50,13 @@
|
||||
return
|
||||
usr.set_machine(src)
|
||||
scan = computer.cardslot.reader
|
||||
|
||||
if (computer.cardslot.dualslot)
|
||||
scan2 = computer.cardslot.writer
|
||||
|
||||
if(!interactable())
|
||||
return
|
||||
return
|
||||
|
||||
if (computer.z > 6)
|
||||
usr << "\red <b>Unable to establish a connection</b>: \black You're too far away from the station!"
|
||||
return
|
||||
@@ -60,7 +65,11 @@
|
||||
if (temp)
|
||||
dat = text("<TT>[]</TT><BR><BR><A href='?src=\ref[];choice=Clear Screen'>Clear Screen</A>", temp, src)
|
||||
else
|
||||
dat = text("Confirm Identity: <A href='?src=\ref[];choice=Confirm Identity'>[]</A><HR>", src, (scan ? text("[]", scan.name) : "----------"))
|
||||
dat = text("Confirm Identity (R): <A href='?src=\ref[];choice=Confirm Identity R'>[]</A><HR>", src, (scan ? text("[]", scan.name) : "----------"))
|
||||
if (computer.cardslot.dualslot)
|
||||
dat += text("Check Identity (W): <A href='?src=\ref[];choice=Confirm Identity W'>[]</A><BR>", src, (scan2 ? text("[]", scan2.name) : "----------"))
|
||||
if(scan2 && !scan)
|
||||
dat += text("<div class='notice'>Insert card into reader slot to log in.</div><br>")
|
||||
if (authenticated)
|
||||
switch(screen)
|
||||
if(1.0)
|
||||
@@ -100,9 +109,9 @@
|
||||
if("Released")
|
||||
background = "'background-color:#3BB9FF;'"
|
||||
if("None")
|
||||
background = "'background-color:#00FF7F;'"
|
||||
if("")
|
||||
background = "'background-color:#00FF00;'"
|
||||
if("")
|
||||
background = "'background-color:#00FF7F;'"
|
||||
crimstat = "No Record."
|
||||
dat += text("<tr style=[]><td><A href='?src=\ref[];choice=Browse Record;d_rec=\ref[]'>[]</a></td>", background, src, R, R.fields["name"])
|
||||
dat += text("<td>[]</td>", R.fields["id"])
|
||||
@@ -236,19 +245,32 @@ What a mess.*/
|
||||
active1 = null
|
||||
active2 = null
|
||||
|
||||
if("Confirm Identity")
|
||||
if("Confirm Identity R")
|
||||
if (scan)
|
||||
if(istype(usr,/mob/living/carbon/human) && !usr.get_active_hand())
|
||||
computer.cardslot.remove(scan)
|
||||
computer.cardslot.remove(1)
|
||||
else
|
||||
scan.loc = get_turf(src)
|
||||
scan = null
|
||||
else
|
||||
var/obj/item/I = usr.get_active_hand()
|
||||
if (istype(I, /obj/item/weapon/card/id))
|
||||
computer.cardslot.insert(I)
|
||||
computer.cardslot.insert(I, 1)
|
||||
scan = I
|
||||
|
||||
if("Confirm Identity W")
|
||||
if (scan2)
|
||||
if(istype(usr,/mob/living/carbon/human) && !usr.get_active_hand())
|
||||
computer.cardslot.remove(2)
|
||||
else
|
||||
scan2.loc = get_turf(src)
|
||||
scan2 = null
|
||||
else
|
||||
var/obj/item/I = usr.get_active_hand()
|
||||
if (istype(I, /obj/item/weapon/card/id))
|
||||
computer.cardslot.insert(I, 2)
|
||||
scan2 = I
|
||||
|
||||
if("Log Out")
|
||||
authenticated = null
|
||||
screen = null
|
||||
|
||||
Reference in New Issue
Block a user