mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 14:08:31 +01:00
[MIRROR] SSeconomy/var/bank_accounts is now an association list of account identifiers and datums for O(1) performance (#1363)
* SSeconomy/var/bank_accounts is now an association list of account identifiers and datums for O(1) performance (#54430) Title. Also added some precautions to bank_account/new() and the crab17 gear. The fact the majority of functions pertinent to the bank_accounts list was O(n) disquieted me. * SSeconomy/var/bank_accounts is now an association list of account identifiers and datums for O(1) performance Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -200,17 +200,16 @@
|
||||
to_chat(user, "<span class='warning'>The account ID was already assigned to this card.</span>")
|
||||
return
|
||||
|
||||
for(var/A in SSeconomy.bank_accounts)
|
||||
var/datum/bank_account/B = A
|
||||
if(B.account_id == new_bank_id)
|
||||
if (old_account)
|
||||
old_account.bank_cards -= src
|
||||
var/datum/bank_account/B = SSeconomy.bank_accounts_by_id["[new_bank_id]"]
|
||||
if(B)
|
||||
if (old_account)
|
||||
old_account.bank_cards -= src
|
||||
|
||||
B.bank_cards += src
|
||||
registered_account = B
|
||||
to_chat(user, "<span class='notice'>The provided account has been linked to this ID card.</span>")
|
||||
B.bank_cards += src
|
||||
registered_account = B
|
||||
to_chat(user, "<span class='notice'>The provided account has been linked to this ID card.</span>")
|
||||
|
||||
return TRUE
|
||||
return TRUE
|
||||
|
||||
to_chat(user, "<span class='warning'>The account ID number provided is invalid.</span>")
|
||||
return
|
||||
@@ -419,12 +418,11 @@ update_label()
|
||||
if(ishuman(user))
|
||||
var/mob/living/carbon/human/accountowner = user
|
||||
|
||||
for(var/bank_account in SSeconomy.bank_accounts)
|
||||
var/datum/bank_account/account = bank_account
|
||||
if(account.account_id == accountowner.account_id)
|
||||
account.bank_cards += src
|
||||
registered_account = account
|
||||
to_chat(user, "<span class='notice'>Your account number has been automatically assigned.</span>")
|
||||
var/datum/bank_account/account = SSeconomy.bank_accounts_by_id["[accountowner.account_id]"]
|
||||
if(account)
|
||||
account.bank_cards += src
|
||||
registered_account = account
|
||||
to_chat(user, "<span class='notice'>Your account number has been automatically assigned.</span>")
|
||||
return
|
||||
else if (popup_input == "Forge/Reset" && forged)
|
||||
registered_name = initial(registered_name)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
var/turf/targetturf = get_safe_random_station_turf()
|
||||
if (!targetturf)
|
||||
return FALSE
|
||||
var/list/accounts_to_rob = SSeconomy.bank_accounts.Copy()
|
||||
var/list/accounts_to_rob = flatten_list(SSeconomy.bank_accounts_by_id)
|
||||
var/mob/living/carbon/human/H = user
|
||||
accounts_to_rob -= H.get_bank_account()
|
||||
for(var/i in accounts_to_rob)
|
||||
@@ -161,7 +161,7 @@
|
||||
return ..()
|
||||
|
||||
/obj/structure/checkoutmachine/proc/start_dumping()
|
||||
accounts_to_rob = SSeconomy.bank_accounts.Copy()
|
||||
accounts_to_rob = flatten_list(SSeconomy.bank_accounts_by_id)
|
||||
accounts_to_rob -= bogdanoff.get_bank_account()
|
||||
for(var/i in accounts_to_rob)
|
||||
var/datum/bank_account/B = i
|
||||
@@ -172,7 +172,8 @@
|
||||
var/percentage_lost = (rand(5, 15) / 100)
|
||||
for(var/i in accounts_to_rob)
|
||||
var/datum/bank_account/B = i
|
||||
if(!B.being_dumped)
|
||||
if(!(B?.being_dumped))
|
||||
accounts_to_rob -= B
|
||||
continue
|
||||
var/amount = B.account_balance * percentage_lost
|
||||
var/datum/bank_account/account = bogdanoff.get_bank_account()
|
||||
@@ -189,7 +190,8 @@
|
||||
/obj/structure/checkoutmachine/proc/stop_dumping()
|
||||
for(var/i in accounts_to_rob)
|
||||
var/datum/bank_account/B = i
|
||||
B.being_dumped = FALSE
|
||||
if(B)
|
||||
B.being_dumped = FALSE
|
||||
|
||||
/obj/effect/dumpeet_fall //Falling pod
|
||||
name = ""
|
||||
|
||||
Reference in New Issue
Block a user