From 4421bede170d3e98c00b33f57283f5371423ba39 Mon Sep 17 00:00:00 2001 From: Cael_Aislinn Date: Fri, 12 Jul 2013 03:40:06 +1000 Subject: [PATCH 1/2] moved money accounts into a global list + removed db syncing (some procs could be global but left where they are for convenience), fixed an issue with latejoiners having no account, fixed a runtime Signed-off-by: Cael_Aislinn --- .../Cael_Aislinn/Economy/Accounts.dm | 164 ++++++++---------- code/WorkInProgress/Mini/ATM.dm | 21 ++- code/game/jobs/job_controller.dm | 2 +- code/modules/events/money_hacker.dm | 11 +- code/modules/events/money_lotto.dm | 4 +- 5 files changed, 96 insertions(+), 106 deletions(-) diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm b/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm index 6fef666acad..7fcd57eefd3 100644 --- a/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm +++ b/code/WorkInProgress/Cael_Aislinn/Economy/Accounts.dm @@ -5,6 +5,7 @@ var/global/list/datum/money_account/department_accounts = list() var/global/next_account_number = 0 var/global/obj/machinery/account_database/centcomm_account_db var/global/datum/money_account/vendor_account +var/global/list/all_money_accounts = list() /proc/create_station_account() if(!station_account) @@ -27,8 +28,7 @@ var/global/datum/money_account/vendor_account //add the account station_account.transaction_log.Add(T) - for(var/obj/machinery/account_database/A in machines) - A.accounts.Add(station_account) + all_money_accounts.Add(station_account) /proc/create_department_account(department) next_account_number = rand(111111, 999999) @@ -50,14 +50,71 @@ var/global/datum/money_account/vendor_account //add the account department_account.transaction_log.Add(T) - for(var/obj/machinery/account_database/A in machines) - A.accounts.Add(department_account) + all_money_accounts.Add(department_account) department_accounts[department] = department_account //the current ingame time (hh:mm) can be obtained by calling: //worldtime2text() +/proc/create_account(var/new_owner_name = "Default user", var/starting_funds = 0, var/obj/machinery/account_database/source_db) + + //create a new account + var/datum/money_account/M = new() + M.owner_name = new_owner_name + M.remote_access_pin = rand(1111, 111111) + M.money = starting_funds + + //create an entry in the account transaction log for when it was created + var/datum/transaction/T = new() + T.target_name = new_owner_name + T.purpose = "Account creation" + T.amount = starting_funds + if(!source_db) + //set a random date, time and location some time over the past few decades + T.date = "[num2text(rand(1,31))] [pick("January","February","March","April","May","June","July","August","September","October","November","December")], 25[rand(10,56)]" + T.time = "[rand(0,24)]:[rand(11,59)]" + T.source_terminal = "NTGalaxyNet Terminal #[rand(111,1111)]" + + M.account_number = rand(111111, 999999) + else + T.date = current_date_string + T.time = worldtime2text() + T.source_terminal = source_db.machine_id + + M.account_number = next_account_number + next_account_number += rand(1,25) + + //create a sealed package containing the account details + var/obj/item/smallDelivery/P = new /obj/item/smallDelivery(source_db.loc) + + var/obj/item/weapon/paper/R = new /obj/item/weapon/paper(P) + P.wrapped = R + R.name = "Account information: [M.owner_name]" + R.info = "Account details (confidential)


" + R.info += "Account holder: [M.owner_name]
" + R.info += "Account number: [M.account_number]
" + R.info += "Account pin: [M.remote_access_pin]
" + R.info += "Starting balance: $[M.money]
" + R.info += "Date and time: [worldtime2text()], [current_date_string]

" + R.info += "Creation terminal ID: [source_db.machine_id]
" + R.info += "Authorised NT officer overseeing creation: [source_db.held_card.registered_name]
" + + //stamp the paper + var/image/stampoverlay = image('icons/obj/bureaucracy.dmi') + stampoverlay.icon_state = "paper_stamp-cent" + if(!R.stamped) + R.stamped = new + R.stamped += /obj/item/weapon/stamp + R.overlays += stampoverlay + R.stamps += "
This paper has been stamped by the Accounts Database." + + //add the account + M.transaction_log.Add(T) + all_money_accounts.Add(M) + + return M + /datum/money_account var/owner_name = "" var/account_number = 0 @@ -82,7 +139,6 @@ var/global/datum/money_account/vendor_account icon = 'virology.dmi' icon_state = "analyser" density = 1 - var/list/accounts = list() req_one_access = list(access_hop, access_captain) var/receipt_num var/machine_id = "" @@ -156,10 +212,10 @@ var/global/datum/money_account/vendor_account dat += "" dat += "" else - dat += "Create new account Sync accounts across databases

" + dat += "Create new account

" dat += "" - for(var/i=1, i<=accounts.len, i++) - var/datum/money_account/D = accounts[i] + for(var/i=1, i<=all_money_accounts.len, i++) + var/datum/money_account/D = all_money_accounts[i] dat += "" dat += "" dat += "" @@ -193,22 +249,12 @@ var/global/datum/money_account/vendor_account if(href_list["choice"]) switch(href_list["choice"]) - if("sync_accounts") - for(var/obj/machinery/account_database/A in machines) - for(var/datum/money_account/M in src.accounts) - if(!A.accounts.Find(M)) - A.accounts.Add(M) - for(var/datum/money_account/M in A.accounts) - if(!src.accounts.Find(M)) - src.accounts.Add(M) - usr << "\icon[src] Accounts synched across all NanoTrasen financial databases." - if("create_account") creating_new_account = 1 if("finalise_create_account") var/account_name = href_list["holder_name"] var/starting_funds = max(text2num(href_list["starting_funds"]), 0) - add_account(account_name, starting_funds) + create_account(account_name, starting_funds, src) if(starting_funds > 0) //subtract the money station_account.money -= starting_funds @@ -247,85 +293,18 @@ var/global/datum/money_account/vendor_account access_level = 1 if("view_account_detail") var/index = text2num(href_list["account_index"]) - if(index && index <= accounts.len) - detailed_account_view = accounts[index] + if(index && index <= all_money_accounts.len) + detailed_account_view = all_money_accounts[index] if("view_accounts_list") detailed_account_view = null creating_new_account = 0 src.attack_hand(usr) -/obj/machinery/account_database/proc/add_account_across_all(var/new_owner_name = "Default user", var/starting_funds = 0, var/pre_existing = 0) - var/datum/money_account/M = add_account(new_owner_name, starting_funds, pre_existing) - for(var/obj/machinery/account_database/D in machines) - if(D == src) - continue - D.accounts.Add(M) - - return M - -/obj/machinery/account_database/proc/add_account(var/new_owner_name = "Default user", var/starting_funds = 0, var/pre_existing = 0) - - //create a new account - var/datum/money_account/M = new() - M.owner_name = new_owner_name - M.remote_access_pin = rand(1111, 111111) - M.money = starting_funds - - //create an entry in the account transaction log for when it was created - var/datum/transaction/T = new() - T.target_name = new_owner_name - T.purpose = "Account creation" - T.amount = starting_funds - if(pre_existing) - //set a random date, time and location some time over the past few decades - T.date = "[num2text(rand(1,31))] [pick("January","February","March","April","May","June","July","August","September","October","November","December")], 25[rand(10,56)]" - T.time = "[rand(0,24)]:[rand(11,59)]" - T.source_terminal = "NTGalaxyNet Terminal #[rand(111,1111)]" - - M.account_number = rand(111111, 999999) - else - T.date = current_date_string - T.time = worldtime2text() - T.source_terminal = machine_id - - M.account_number = next_account_number - next_account_number += rand(1,25) - - //create a sealed package containing the account details - var/obj/item/smallDelivery/P = new(src.loc) - - var/obj/item/weapon/paper/R = new(P) - P.wrapped = R - R.name = "Account information: [M.owner_name]" - R.info = "Account details (confidential)


" - R.info += "Account holder: [M.owner_name]
" - R.info += "Account number: [M.account_number]
" - R.info += "Account pin: [M.remote_access_pin]
" - R.info += "Starting balance: $[M.money]
" - R.info += "Date and time: [worldtime2text()], [current_date_string]

" - R.info += "Creation terminal ID: [machine_id]
" - R.info += "Authorised NT officer overseeing creation: [held_card.registered_name]
" - - //stamp the paper - var/image/stampoverlay = image('icons/obj/bureaucracy.dmi') - stampoverlay.icon_state = "paper_stamp-cent" - if(!R.stamped) - R.stamped = new - R.stamped += /obj/item/weapon/stamp - R.overlays += stampoverlay - R.stamps += "
This paper has been stamped by the Accounts Database." - - //add the account - M.transaction_log.Add(T) - accounts.Add(M) - - return M - /obj/machinery/account_database/proc/charge_to_account(var/attempt_account_number, var/source_name, var/purpose, var/terminal_id, var/amount) if(!activated) return 0 - for(var/datum/money_account/D in accounts) + for(var/datum/money_account/D in all_money_accounts) if(D.account_number == attempt_account_number) D.money += amount @@ -350,7 +329,12 @@ var/global/datum/money_account/vendor_account /obj/machinery/account_database/proc/attempt_account_access(var/attempt_account_number, var/attempt_pin_number, var/security_level_passed = 0) if(!activated) return 0 - for(var/datum/money_account/D in accounts) + for(var/datum/money_account/D in all_money_accounts) if(D.account_number == attempt_account_number) if( D.security_level <= security_level_passed && (!D.security_level || D.remote_access_pin == attempt_pin_number) ) return D + +/obj/machinery/account_database/proc/get_account(var/account_number) + for(var/datum/money_account/D in all_money_accounts) + if(D.account_number == account_number) + return D diff --git a/code/WorkInProgress/Mini/ATM.dm b/code/WorkInProgress/Mini/ATM.dm index 544c439033a..a7c0544591b 100644 --- a/code/WorkInProgress/Mini/ATM.dm +++ b/code/WorkInProgress/Mini/ATM.dm @@ -36,9 +36,12 @@ log transactions /obj/machinery/atm/New() ..() - reconnect_database() machine_id = "[station_name()] RT #[num_financial_terminals++]" +/obj/machinery/atm/initialize() + ..() + reconnect_database() + /obj/machinery/atm/process() if(stat & NOPOWER) return @@ -253,13 +256,15 @@ log transactions playsound(src, 'buzz-two.ogg', 50, 1) //create an entry in the account transaction log - var/datum/transaction/T = new() - T.target_name = authenticated_account.owner_name - T.purpose = "Unauthorised login attempt" - T.source_terminal = machine_id - T.date = current_date_string - T.time = worldtime2text() - authenticated_account.transaction_log.Add(T) + var/datum/money_account/failed_account = linked_db.get_account(tried_account_num) + if(failed_account) + var/datum/transaction/T = new() + T.target_name = failed_account.owner_name + T.purpose = "Unauthorised login attempt" + T.source_terminal = machine_id + T.date = current_date_string + T.time = worldtime2text() + failed_account.transaction_log.Add(T) else usr << "\red \icon[src] Incorrect pin/account combination entered, [max_pin_attempts - number_incorrect_tries] attempts remaining." previous_account_number = tried_account_num diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 5456b8e598b..84e96be0f3e 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -369,7 +369,7 @@ var/global/datum/controller/occupations/job_master //give them an account in the station database if(centcomm_account_db) - var/datum/money_account/M = centcomm_account_db.add_account_across_all(H.real_name, starting_funds = rand(50,500)*10, pre_existing = 1) + var/datum/money_account/M = create_account(H.real_name, rand(50,500)*10, null) if(H.mind) var/remembered_info = "" remembered_info += "Your account number is: #[M.account_number]
" diff --git a/code/modules/events/money_hacker.dm b/code/modules/events/money_hacker.dm index 28541cda071..d3473ce0807 100644 --- a/code/modules/events/money_hacker.dm +++ b/code/modules/events/money_hacker.dm @@ -8,12 +8,13 @@ var/obj/machinery/account_database/affected_db /datum/event/money_hacker/setup() - for(var/obj/machinery/account_database/DB in world) - if( DB.z == 1 && !(DB.stat&NOPOWER) && DB.activated && DB.accounts.len) - affected_db = DB - break + if(all_money_accounts.len) + for(var/obj/machinery/account_database/DB in world) + if( DB.z == 1 && !(DB.stat&NOPOWER) && DB.activated ) + affected_db = DB + break if(affected_db) - affected_account = pick(affected_db.accounts) + affected_account = pick(all_money_accounts.len) else kill() return diff --git a/code/modules/events/money_lotto.dm b/code/modules/events/money_lotto.dm index a03d6f29690..3ac17a7f4c6 100644 --- a/code/modules/events/money_lotto.dm +++ b/code/modules/events/money_lotto.dm @@ -7,8 +7,8 @@ /datum/event/money_lotto/start() winner_sum = pick(5000, 10000, 50000, 100000, 500000, 1000000, 1500000) - if(centcomm_account_db.accounts.len) - var/datum/money_account/D = pick(centcomm_account_db.accounts) + if(all_money_accounts.len) + var/datum/money_account/D = pick(all_money_accounts) D.money += winner_sum var/datum/transaction/T = new() From e4b448676885c21a93888127fdc76902d0fcf43c Mon Sep 17 00:00:00 2001 From: Cael_Aislinn Date: Fri, 12 Jul 2013 03:40:38 +1000 Subject: [PATCH 2/2] added a spawning guide to EFTPOS devices Signed-off-by: Cael_Aislinn --- .../Cael_Aislinn/Economy/EFTPOS.dm | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/code/WorkInProgress/Cael_Aislinn/Economy/EFTPOS.dm b/code/WorkInProgress/Cael_Aislinn/Economy/EFTPOS.dm index 7df719a2e09..f3160a3f8a5 100644 --- a/code/WorkInProgress/Cael_Aislinn/Economy/EFTPOS.dm +++ b/code/WorkInProgress/Cael_Aislinn/Economy/EFTPOS.dm @@ -21,6 +21,30 @@ spawn(0) print_reference() + //create a short manual as well + var/obj/item/weapon/paper/R = new(src.loc) + R.name = "Steps to success: Correct EFTPOS Usage" + R.info += "When first setting up your EFTPOS device:" + R.info += "1. Memorise your EFTPOS command code (provided with all EFTPOS devices).
" + R.info += "2. Confirm that your EFTPOS device is connected to your local accounts database. For additional assistance with this step, contact NanoTrasen IT Support
" + R.info += "3. Confirm that your EFTPOS device has been linked to the account that you wish to recieve funds for all transactions processed on this device.
" + R.info += "When starting a new transaction with your EFTPOS device:" + R.info += "1. Ensure the device is UNLOCKED so that new data may be entered.
" + R.info += "2. Enter a sum of money and reference message for the new transaction.
" + R.info += "3. Lock the transaction, it is now ready for your customer.
" + R.info += "4. If at this stage you wish to modify or cancel your transaction, you may simply reset (unlock) your EFTPOS device.
" + R.info += "5. Give your EFTPOS device to the customer, they must authenticate the transaction by swiping their ID card and entering their PIN number.
" + R.info += "6. If done correctly, the transaction will be logged to both accounts with the reference you have entered, the terminal ID of your EFTPOS device and the money transferred across accounts.
" + + //stamp the paper + var/image/stampoverlay = image('icons/obj/bureaucracy.dmi') + stampoverlay.icon_state = "paper_stamp-cent" + if(!R.stamped) + R.stamped = new + R.stamped += /obj/item/weapon/stamp + R.overlays += stampoverlay + R.stamps += "
This paper has been stamped by the EFTPOS device." + //by default, connect to the station account //the user of the EFTPOS device can change the target account though, and no-one will be the wiser (except whoever's being charged) linked_account = station_account
#[D.account_number][D.owner_name]