From 72dbce88cec9d9f3124a0c3778746501347176ab Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Thu, 17 Jul 2014 18:01:19 +0200 Subject: [PATCH 1/6] Fixes #5570 Also de-copypasted charger code, as i had the opportunity. --- code/game/machinery/recharger.dm | 52 +++++++++----------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/code/game/machinery/recharger.dm b/code/game/machinery/recharger.dm index a5d9a6ce1de..307db252400 100644 --- a/code/game/machinery/recharger.dm +++ b/code/game/machinery/recharger.dm @@ -9,6 +9,9 @@ obj/machinery/recharger idle_power_usage = 4 active_power_usage = 250 var/obj/item/charging = null + var/icon_state_charged = "recharger2" + var/icon_state_charging = "recharger1" + var/icon_state_idle = "recharger0" obj/machinery/recharger/attackby(obj/item/weapon/G as obj, mob/user as mob) if(istype(user,/mob/living/silicon)) @@ -71,28 +74,28 @@ obj/machinery/recharger/process() var/obj/item/weapon/gun/energy/E = charging if(E.power_supply.charge < E.power_supply.maxcharge) E.power_supply.give(100) - icon_state = "recharger1" + icon_state = icon_state_charging use_power(250) else - icon_state = "recharger2" + icon_state = icon_state_charged return if(istype(charging, /obj/item/weapon/melee/baton)) var/obj/item/weapon/melee/baton/B = charging if(B.charges < initial(B.charges)) B.charges++ - icon_state = "recharger1" + icon_state = icon_state_charging use_power(150) else - icon_state = "recharger2" + icon_state = icon_state_charged return if(istype(charging, /obj/item/device/laptop)) var/obj/item/device/laptop/L = charging if(L.stored_computer.battery.charge < L.stored_computer.battery.maxcharge) L.stored_computer.battery.give(100) - icon_state = "recharger1" + icon_state = icon_state_charging use_power(250) else - icon_state = "recharger2" + icon_state = icon_state_charged return obj/machinery/recharger/emp_act(severity) @@ -112,40 +115,15 @@ obj/machinery/recharger/emp_act(severity) obj/machinery/recharger/update_icon() //we have an update_icon() in addition to the stuff in process to make it feel a tiny bit snappier. if(charging) - icon_state = "recharger1" + icon_state = icon_state_charging else - icon_state = "recharger0" + icon_state = icon_state_idle +// Atlantis: No need for that copy-pasta code, just use var to store icon_states instead. obj/machinery/recharger/wallcharger name = "wall recharger" icon = 'icons/obj/stationobjs.dmi' icon_state = "wrecharger0" - -obj/machinery/recharger/wallcharger/process() - if(stat & (NOPOWER|BROKEN) || !anchored) - return - - if(charging) - if(istype(charging, /obj/item/weapon/gun/energy)) - var/obj/item/weapon/gun/energy/E = charging - if(E.power_supply.charge < E.power_supply.maxcharge) - E.power_supply.give(100) - icon_state = "wrecharger1" - use_power(250) - else - icon_state = "wrecharger2" - return - if(istype(charging, /obj/item/weapon/melee/baton)) - var/obj/item/weapon/melee/baton/B = charging - if(B.charges < initial(B.charges)) - B.charges++ - icon_state = "wrecharger1" - use_power(150) - else - icon_state = "wrecharger2" - -obj/machinery/recharger/wallcharger/update_icon() - if(charging) - icon_state = "wrecharger1" - else - icon_state = "wrecharger0" \ No newline at end of file + icon_state_idle = "wrecharger0" + icon_state_charging = "wrecharger1" + icon_state_charged = "wrecharger2" \ No newline at end of file From 4096b26c8d6f427385ff7394738595a0c01726cb Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Thu, 17 Jul 2014 19:03:31 +0200 Subject: [PATCH 2/6] Fixes #5553 Camera network key itself is useless without security camera program. Created hidden version of this program and added it to each laptop. In short: it works. --- code/WorkInProgress/computer3/NTOS.dm | 29 ++++++++++--------- .../computer3/computers/camera.dm | 4 +++ code/WorkInProgress/computer3/file.dm | 2 +- code/WorkInProgress/computer3/lapvend.dm | 2 ++ 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/code/WorkInProgress/computer3/NTOS.dm b/code/WorkInProgress/computer3/NTOS.dm index 0b921ad43b8..f6dc2697a85 100644 --- a/code/WorkInProgress/computer3/NTOS.dm +++ b/code/WorkInProgress/computer3/NTOS.dm @@ -22,20 +22,21 @@ var/dat = "" var/i = 0 for(var/datum/file/F in filelist) - i++ - if(i==1) - dat += "" - if(i>= 6) - i = 0 - dat += "" - continue - dat += {" - "} + if(!F.hidden_file) + i++ + if(i==1) + dat += "" + if(i>= 6) + i = 0 + dat += "" + continue + dat += {" + "} dat += "
-
-
- [F.name] -
-
+
+
+ [F.name] +
+
" return dat diff --git a/code/WorkInProgress/computer3/computers/camera.dm b/code/WorkInProgress/computer3/computers/camera.dm index 4da54340c1f..0883680f5c3 100644 --- a/code/WorkInProgress/computer3/computers/camera.dm +++ b/code/WorkInProgress/computer3/computers/camera.dm @@ -275,3 +275,7 @@ else usr << "The screen turns to static." return + + // Atlantis: Required for camnetkeys to work. +/datum/file/program/security/hidden + hidden_file = 1 \ No newline at end of file diff --git a/code/WorkInProgress/computer3/file.dm b/code/WorkInProgress/computer3/file.dm index 36935790673..849312ec50e 100644 --- a/code/WorkInProgress/computer3/file.dm +++ b/code/WorkInProgress/computer3/file.dm @@ -13,7 +13,7 @@ var/image = 'icons/ntos/file.png' // determines the icon to use, found in icons/ntos var/obj/machinery/computer3/computer // the parent computer, if fixed var/obj/item/part/computer/storage/device // the device that is containing this file - + var/hidden_file = 0 // Prevents file from showing up on NTOS program list. var/drm = 0 // Copy protection, called by copy() and move() var/readonly = 0 // Edit protection, called by edit(), which is just a failcheck proc diff --git a/code/WorkInProgress/computer3/lapvend.dm b/code/WorkInProgress/computer3/lapvend.dm index d36af863d11..747078edcd5 100644 --- a/code/WorkInProgress/computer3/lapvend.dm +++ b/code/WorkInProgress/computer3/lapvend.dm @@ -320,6 +320,8 @@ newlap.spawn_files += (/datum/file/camnet_key/creed) newlap.spawn_files += (/datum/file/program/arcade) newlap.spawn_files += (/datum/file/camnet_key/entertainment) + //Atlantis: Each laptop gets "invisible" program/security - REQUIRED for camnetkeys to work. + newlap.spawn_files += (/datum/file/program/security/hidden) newlap.update_spawn_files() /obj/machinery/lapvend/proc/calc_reimburse(var/obj/item/device/laptop/L) From 1e512fdde2e663adb2582a988fc00505e712ef6c Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Fri, 18 Jul 2014 00:47:39 +0200 Subject: [PATCH 3/6] Fixes #5569, Fixes #5571 - 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. --- code/WorkInProgress/computer3/component.dm | 144 +++++++++++++++--- .../computer3/computers/card.dm | 8 +- .../computer3/computers/medical.dm | 27 +++- .../computer3/computers/security.dm | 36 ++++- 4 files changed, 181 insertions(+), 34 deletions(-) diff --git a/code/WorkInProgress/computer3/component.dm b/code/WorkInProgress/computer3/component.dm index 8dc2ec835bf..501bbc973eb 100644 --- a/code/WorkInProgress/computer3/component.dm +++ b/code/WorkInProgress/computer3/component.dm @@ -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 +*/ diff --git a/code/WorkInProgress/computer3/computers/card.dm b/code/WorkInProgress/computer3/computers/card.dm index 6080b596431..5acb7c9de2f 100644 --- a/code/WorkInProgress/computer3/computers/card.dm +++ b/code/WorkInProgress/computer3/computers/card.dm @@ -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) diff --git a/code/WorkInProgress/computer3/computers/medical.dm b/code/WorkInProgress/computer3/computers/medical.dm index ee55a857b29..7fc5da12326 100644 --- a/code/WorkInProgress/computer3/computers/medical.dm +++ b/code/WorkInProgress/computer3/computers/medical.dm @@ -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("[src.temp]

Clear Screen") else - dat = text("Confirm Identity: []
", src, (src.scan ? text("[]", src.scan.name) : "----------")) + dat = text("Confirm Identity (R): []
", src, (scan ? text("[]", scan.name) : "----------")) + if (computer.cardslot.dualslot) + dat += text("Check Identity (W): []
", src, (scan2 ? text("[]", scan2.name) : "----------")) + if(scan2 && !scan) + dat += text("
Insert card into reader slot to log in.

") + 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 diff --git a/code/WorkInProgress/computer3/computers/security.dm b/code/WorkInProgress/computer3/computers/security.dm index f161b10cab9..f193b071396 100644 --- a/code/WorkInProgress/computer3/computers/security.dm +++ b/code/WorkInProgress/computer3/computers/security.dm @@ -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 Unable to establish a connection: \black You're too far away from the station!" return @@ -60,7 +65,11 @@ if (temp) dat = text("[]

Clear Screen", temp, src) else - dat = text("Confirm Identity: []
", src, (scan ? text("[]", scan.name) : "----------")) + dat = text("Confirm Identity (R): []
", src, (scan ? text("[]", scan.name) : "----------")) + if (computer.cardslot.dualslot) + dat += text("Check Identity (W): []
", src, (scan2 ? text("[]", scan2.name) : "----------")) + if(scan2 && !scan) + dat += text("
Insert card into reader slot to log in.

") 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("[]", background, src, R, R.fields["name"]) dat += text("[]", 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 From 95a45a646f7523d53bd54c013df04be58a750605 Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Fri, 18 Jul 2014 12:14:33 +0200 Subject: [PATCH 4/6] Fixes #5572 - Detective-vended laptops now have medical records program installed. --- code/WorkInProgress/computer3/lapvend.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/WorkInProgress/computer3/lapvend.dm b/code/WorkInProgress/computer3/lapvend.dm index 747078edcd5..5c4f56ad727 100644 --- a/code/WorkInProgress/computer3/lapvend.dm +++ b/code/WorkInProgress/computer3/lapvend.dm @@ -305,9 +305,10 @@ newlap.spawn_files += (/datum/file/program/card_comp) if(access_heads in C.access) newlap.spawn_files += (/datum/file/program/communications) - if(access_medical in C.access) - newlap.spawn_files += (/datum/file/program/crew) + if((access_medical in C.access) || (access_forensics_lockers in C.access)) //Gives detective the medical records program, but not the crew monitoring one. newlap.spawn_files += (/datum/file/program/med_data) + if (access_medical in C.access) + newlap.spawn_files += (/datum/file/program/crew) if(access_engine in C.access) newlap.spawn_files += (/datum/file/program/powermon) if(access_research in C.access) From 5cfe7d9dd870d3e3cdba775961880a44eaa76e23 Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Sun, 20 Jul 2014 01:55:11 +0200 Subject: [PATCH 5/6] Fixes #5670 - This also includes other vending machines than laptop vendor. They now actually take money from your account instead of pretending to do so and giving stuff for free. No moar spess communism. - Vending machines now ask for PIN code only if your account settings require it (ie: Security levels 1 or 2. Default is 0 - only ID card swipe) --- code/WorkInProgress/computer3/lapvend.dm | 196 ++++++++++++----------- code/game/machinery/vending.dm | 89 +++++----- 2 files changed, 152 insertions(+), 133 deletions(-) diff --git a/code/WorkInProgress/computer3/lapvend.dm b/code/WorkInProgress/computer3/lapvend.dm index 747078edcd5..36ca07118da 100644 --- a/code/WorkInProgress/computer3/lapvend.dm +++ b/code/WorkInProgress/computer3/lapvend.dm @@ -213,58 +213,66 @@ if (istype(I, /obj/item/weapon/card/id)) var/obj/item/weapon/card/id/C = I visible_message("[usr] swipes a card through [src].") - if(vendor_account) - var/attempt_pin = input("Enter pin code", "Vendor transaction") as num - var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2) - if(D) - var/transaction_amount = total() - if(transaction_amount <= D.money) - - //transfer the money - D.money -= transaction_amount - vendor_account.money += transaction_amount - - //Transaction logs - var/datum/transaction/T = new() - T.target_name = "[vendor_account.owner_name] (via [src.name])" - T.purpose = "Purchase of Laptop" - if(transaction_amount > 0) - T.amount = "([transaction_amount])" - else - T.amount = "[transaction_amount]" - T.source_terminal = src.name - T.date = current_date_string - T.time = worldtime2text() - D.transaction_log.Add(T) - // - T = new() - T.target_name = D.owner_name - T.purpose = "Purchase of Laptop" - T.amount = "[transaction_amount]" - T.source_terminal = src.name - T.date = current_date_string - T.time = worldtime2text() - vendor_account.transaction_log.Add(T) - - newlap = new /obj/machinery/computer3/laptop/vended(src.loc) - - choose_progs(C) - vend() - popup.close() - newlap.close_computer() - newlap = null - cardreader = 0 - floppy = 0 - radionet = 0 - camera = 0 - network = 0 - power = 0 + var/datum/money_account/CH = get_account(C.associated_account_number) + if(CH.security_level != 0) //If card requires pin authentication (ie seclevel 1 or 2) + if(vendor_account) + var/attempt_pin = input("Enter pin code", "Vendor transaction") as num + var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2) + if(D) + transfer_and_vend(D, C) else - usr << "\icon[src]You don't have that much money!" + usr << "\icon[src]Unable to access account. Check security settings and try again." else - usr << "\icon[src]Unable to access account. Check security settings and try again." + usr << "\icon[src]Unable to access vendor account. Please record the machine ID and call CentComm Support." else - usr << "\icon[src]Unable to access vendor account. Please record the machine ID and call CentComm Support." + transfer_and_vend(CH, C) + + +// Transfers money and vends the laptop. +/obj/machinery/lapvend/proc/transfer_and_vend(var/datum/money_account/D, var/obj/item/weapon/card/C) + var/transaction_amount = total() + if(transaction_amount <= D.money) + + //transfer the money + D.money -= transaction_amount + vendor_account.money += transaction_amount + //Transaction logs + var/datum/transaction/T = new() + T.target_name = "[vendor_account.owner_name] (via [src.name])" + T.purpose = "Purchase of Laptop" + if(transaction_amount > 0) + T.amount = "([transaction_amount])" + else + T.amount = "[transaction_amount]" + T.source_terminal = src.name + T.date = current_date_string + T.time = worldtime2text() + D.transaction_log.Add(T) + // + T = new() + T.target_name = D.owner_name + T.purpose = "Purchase of Laptop" + T.amount = "[transaction_amount]" + T.source_terminal = src.name + T.date = current_date_string + T.time = worldtime2text() + vendor_account.transaction_log.Add(T) + + newlap = new /obj/machinery/computer3/laptop/vended(src.loc) + + choose_progs(C) + vend() + popup.close() + newlap.close_computer() + newlap = null + cardreader = 0 + floppy = 0 + radionet = 0 + camera = 0 + network = 0 + power = 0 + else + usr << "\icon[src]You don't have that much money!" /obj/machinery/lapvend/proc/total() var/total = 0 @@ -352,49 +360,53 @@ if (istype(I, /obj/item/weapon/card/id)) var/obj/item/weapon/card/id/C = I visible_message("[usr] swipes a card through [src].") - if(vendor_account) - var/attempt_pin = input("Enter pin code", "Vendor transaction") as num - var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2) - if(D) - var/transaction_amount = total() - - //transfer the money - D.money += transaction_amount - vendor_account.money -= transaction_amount - - //Transaction logs - var/datum/transaction/T = new() - T.target_name = "[vendor_account.owner_name] (via [src.name])" - T.purpose = "Return purchase of Laptop" - if(transaction_amount > 0) - T.amount = "([transaction_amount])" + var/datum/money_account/CH = get_account(C.associated_account_number) + if(CH.security_level != 0) //If card requires pin authentication (ie seclevel 1 or 2) + if(vendor_account) + var/attempt_pin = input("Enter pin code", "Vendor transaction") as num + var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2) + if(D) + transfer_and_reimburse(D) else - T.amount = "[transaction_amount]" - T.source_terminal = src.name - T.date = current_date_string - T.time = worldtime2text() - D.transaction_log.Add(T) - // - T = new() - T.target_name = D.owner_name - T.purpose = "Return purchase of Laptop" - T.amount = "[transaction_amount]" - T.source_terminal = src.name - T.date = current_date_string - T.time = worldtime2text() - vendor_account.transaction_log.Add(T) - - del(relap) - - vendmode = 0 - cardreader = 0 - floppy = 0 - radionet = 0 - camera = 0 - network = 0 - power = 0 - + usr << "\icon[src]Unable to access account. Check security settings and try again." else - usr << "\icon[src]Unable to access account. Check security settings and try again." + usr << "\icon[src]Unable to access vendor account. Please record the machine ID and call CentComm Support." else - usr << "\icon[src]Unable to access vendor account. Please record the machine ID and call CentComm Support." \ No newline at end of file + transfer_and_reimburse(CH) + +/obj/machinery/lapvend/proc/transfer_and_reimburse(var/datum/money_account/D) + var/transaction_amount = total() + //transfer the money + D.money += transaction_amount + vendor_account.money -= transaction_amount + + //Transaction logs + var/datum/transaction/T = new() + T.target_name = "[vendor_account.owner_name] (via [src.name])" + T.purpose = "Return purchase of Laptop" + if(transaction_amount > 0) + T.amount = "([transaction_amount])" + else + T.amount = "[transaction_amount]" + T.source_terminal = src.name + T.date = current_date_string + T.time = worldtime2text() + D.transaction_log.Add(T) + // + T = new() + T.target_name = D.owner_name + T.purpose = "Return purchase of Laptop" + T.amount = "[transaction_amount]" + T.source_terminal = src.name + T.date = current_date_string + T.time = worldtime2text() + vendor_account.transaction_log.Add(T) + + del(relap) + vendmode = 0 + cardreader = 0 + floppy = 0 + radionet = 0 + camera = 0 + network = 0 + power = 0 \ No newline at end of file diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index 5dd31a036ea..009ab4c809c 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -187,53 +187,60 @@ if (istype(I, /obj/item/weapon/card/id)) var/obj/item/weapon/card/id/C = I visible_message("[usr] swipes a card through [src].") - if(check_accounts) - if(vendor_account) - var/attempt_pin = input("Enter pin code", "Vendor transaction") as num - var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2) - if(D) - var/transaction_amount = currently_vending.price - if(transaction_amount <= D.money) - - //transfer the money - D.money -= transaction_amount - vendor_account.money += transaction_amount - - //create entries in the two account transaction logs - var/datum/transaction/T = new() - T.target_name = "[vendor_account.owner_name] (via [src.name])" - T.purpose = "Purchase of [currently_vending.product_name]" - if(transaction_amount > 0) - T.amount = "([transaction_amount])" - else - T.amount = "[transaction_amount]" - T.source_terminal = src.name - T.date = current_date_string - T.time = worldtime2text() - D.transaction_log.Add(T) - // - T = new() - T.target_name = D.owner_name - T.purpose = "Purchase of [currently_vending.product_name]" - T.amount = "[transaction_amount]" - T.source_terminal = src.name - T.date = current_date_string - T.time = worldtime2text() - vendor_account.transaction_log.Add(T) - - // Vend the item - src.vend(src.currently_vending, usr) - currently_vending = null + var/datum/money_account/CH = get_account(C.associated_account_number) + if (CH) // Only proceed if card contains proper account number. + if(CH.security_level != 0) //If card requires pin authentication (ie seclevel 1 or 2) + if(vendor_account) + var/attempt_pin = input("Enter pin code", "Vendor transaction") as num + var/datum/money_account/D = attempt_account_access(C.associated_account_number, attempt_pin, 2) + transfer_and_vend(D) else - usr << "\icon[src]You don't have that much money!" + usr << "\icon[src]Unable to access account. Check security settings and try again." else - usr << "\icon[src]Unable to access account. Check security settings and try again." + //Just Vend it. + transfer_and_vend(CH) else - //Just Vend it. + usr << "\icon[src]Error: Unable to access your account. Please contact technical support if problem persists." + +/obj/machinery/vending/proc/transfer_and_vend(var/datum/money_account/acc) + if(acc) + var/transaction_amount = currently_vending.price + if(transaction_amount <= acc.money) + + //transfer the money + acc.money -= transaction_amount + vendor_account.money += transaction_amount + + //create entries in the two account transaction logs + var/datum/transaction/T = new() + T.target_name = "[vendor_account.owner_name] (via [src.name])" + T.purpose = "Purchase of [currently_vending.product_name]" + if(transaction_amount > 0) + T.amount = "([transaction_amount])" + else + T.amount = "[transaction_amount]" + T.source_terminal = src.name + T.date = current_date_string + T.time = worldtime2text() + acc.transaction_log.Add(T) + // + T = new() + T.target_name = acc.owner_name + T.purpose = "Purchase of [currently_vending.product_name]" + T.amount = "[transaction_amount]" + T.source_terminal = src.name + T.date = current_date_string + T.time = worldtime2text() + vendor_account.transaction_log.Add(T) + + // Vend the item src.vend(src.currently_vending, usr) currently_vending = null + else + usr << "\icon[src]You don't have that much money!" else - usr << "\icon[src]Unable to access vendor account. Please record the machine ID and call CentComm Support." + usr << "\icon[src]Error: Unable to access your account. Please contact technical support if problem persists." + /obj/machinery/vending/attack_paw(mob/user as mob) return attack_hand(user) From c127fee6b4448d79d98d48c9522e69b608a383d4 Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Sun, 20 Jul 2014 15:15:29 +0200 Subject: [PATCH 6/6] Adds battery status icon to NTOS - Laptops now have status icon which shows status of their internal battery. - Adds support for "status bar" - allows more status icons in future (such as, network connection? time? whatever), status bar icons should be 16x16px --- code/WorkInProgress/computer3/NTOS.dm | 28 ++++++++++++++++++++++ code/WorkInProgress/computer3/computer.dm | 10 ++++++++ icons/NTOS/battery_icons/batt_100.gif | Bin 0 -> 102 bytes icons/NTOS/battery_icons/batt_20.gif | Bin 0 -> 200 bytes icons/NTOS/battery_icons/batt_40.gif | Bin 0 -> 123 bytes icons/NTOS/battery_icons/batt_5.gif | Bin 0 -> 279 bytes icons/NTOS/battery_icons/batt_60.gif | Bin 0 -> 122 bytes icons/NTOS/battery_icons/batt_80.gif | Bin 0 -> 120 bytes icons/NTOS/battery_icons/batt_none.gif | Bin 0 -> 132 bytes 9 files changed, 38 insertions(+) create mode 100644 icons/NTOS/battery_icons/batt_100.gif create mode 100644 icons/NTOS/battery_icons/batt_20.gif create mode 100644 icons/NTOS/battery_icons/batt_40.gif create mode 100644 icons/NTOS/battery_icons/batt_5.gif create mode 100644 icons/NTOS/battery_icons/batt_60.gif create mode 100644 icons/NTOS/battery_icons/batt_80.gif create mode 100644 icons/NTOS/battery_icons/batt_none.gif diff --git a/code/WorkInProgress/computer3/NTOS.dm b/code/WorkInProgress/computer3/NTOS.dm index f6dc2697a85..86157dcc1c9 100644 --- a/code/WorkInProgress/computer3/NTOS.dm +++ b/code/WorkInProgress/computer3/NTOS.dm @@ -165,6 +165,8 @@
"} + + dat += generate_status_bar() var/list/files = list_files() if(current) dat +=window(current.name,buttonbar(),filegrid(files)) @@ -176,6 +178,32 @@ usr << browse(dat, "window=\ref[computer];size=670x510") onclose(usr, "\ref[computer]") + // STATUS BAR + // Small 16x16 icons representing status of components, etc. + // Currently only used by battery icon + // TODO: Add more icons! +/datum/file/program/ntos/proc/generate_status_bar() + var/dat = "" + + // Battery level icon + switch(computer.check_battery_status()) + if(-1) + dat += "" + if(0 to 5) + dat += "" + if(6 to 20) + dat += "" + if(21 to 40) + dat += "" + if(41 to 60) + dat += "" + if(61 to 80) + dat += "" + if(81 to 100) + dat += "" + dat += "
" + return dat + /datum/file/program/ntos/Topic(href, list/href_list) if(!interactable() || ..(href,href_list)) return diff --git a/code/WorkInProgress/computer3/computer.dm b/code/WorkInProgress/computer3/computer.dm index 093f7b5ed7d..456bdf3d71f 100644 --- a/code/WorkInProgress/computer3/computer.dm +++ b/code/WorkInProgress/computer3/computer.dm @@ -449,6 +449,16 @@ overlays += kb name = initial(name) + " (orange screen of death)" + //Returns percentage of battery charge remaining. Returns -1 if no battery is installed. + proc/check_battery_status() + if (battery) + var/obj/item/weapon/cell/B = battery + return round(B.charge / (B.maxcharge / 100)) + else + return -1 + + + /obj/machinery/computer3/wall_comp name = "terminal" icon = 'icons/obj/computer3.dmi' diff --git a/icons/NTOS/battery_icons/batt_100.gif b/icons/NTOS/battery_icons/batt_100.gif new file mode 100644 index 0000000000000000000000000000000000000000..72f04cff011a353076cd9852efe5c5df001ecd3e GIT binary patch literal 102 zcmZ?wbhEHb6krfwSjYeZ2M!!y_yJ-l{^#~{4GDI33~)8lGhk)}3H@Z@;V8o`~8mN8UgOeK45?30}8s6s?U^!%(;54gqN#`n&>~jVt=hOql7rmaovElU; Y?bfyvJpCum7}{O%PxVSwVPLQZ08WTN_y7O^ literal 0 HcmV?d00001 diff --git a/icons/NTOS/battery_icons/batt_40.gif b/icons/NTOS/battery_icons/batt_40.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d03a30c18ec5c9a219d559d492b584d01eb848b GIT binary patch literal 123 zcmZ?wbhEHb6krfw*u($=2M!!aNJ#kc1I&RDivPL&TtkAL9RpmA^bD98f#QlkSva{E zSQvCbYCzfwU>9}5^V=8D%%-BhY>C8T}5D?ewRX3RPLp1*rL L3p`}h7#OSpBbp+A literal 0 HcmV?d00001 diff --git a/icons/NTOS/battery_icons/batt_5.gif b/icons/NTOS/battery_icons/batt_5.gif new file mode 100644 index 0000000000000000000000000000000000000000..eddcc6ae824ddf8bb5414f485778c83c81404cfd GIT binary patch literal 279 zcmZ?wbhEHb6krfwIK%(~KNuJi5)yv=U^sB#09XJ-DE{a6a}5c0b_{Se(lcOY1PT3Q z;WT1kWzYf1gS0a+Yeek2^UuJGbJgCmMulDf8;;ecEX_%g6w7!u^UVvc0_*iU%N_^6 z|G$p~n`RrJ=5-HFYDi05X*_FqpIdBE=tmbq+n&S2>>z2g)7t5X28VNC2 F0|2HGVM+i1 literal 0 HcmV?d00001 diff --git a/icons/NTOS/battery_icons/batt_60.gif b/icons/NTOS/battery_icons/batt_60.gif new file mode 100644 index 0000000000000000000000000000000000000000..2a159b8e3c3c94aad428598ed1936c45cfa78b85 GIT binary patch literal 122 zcmZ?wbhEHb6krfw*u($=2M!!aNJ#kc1I&RDivPL&TtkAL9RpmA^bD98f#QlkSva{E zSQvCbYCzfwUq0t*;2;>5d@H%^U@(9Evfr**rj{yYBom@Zwyxw~X;%wLJ5JN|gvr>7T7i6IV6e+_$Rd(43WtHP(L* KBp5IIU8$qpxpmZTq=44OUKoeN)`nw7qaZSx1AvYVF- W=D$C3x}e9UHB~9oYJM*ZgEasEPbRJa literal 0 HcmV?d00001