From f5602de8117505e376f66958ae0654041c2df046 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Fri, 12 Dec 2014 15:43:29 +0100 Subject: [PATCH] Fixes #7427. Station funds can no longer go into the negative from creating a new account. Limits how much/little money a single account is allowed. --- code/modules/economy/Accounts_DB.dm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/modules/economy/Accounts_DB.dm b/code/modules/economy/Accounts_DB.dm index 19ea76ed4e..163e7ac5c8 100644 --- a/code/modules/economy/Accounts_DB.dm +++ b/code/modules/economy/Accounts_DB.dm @@ -11,6 +11,7 @@ var/obj/item/weapon/card/id/held_card var/datum/money_account/detailed_account_view var/creating_new_account = 0 + var/const/fund_cap = 1000000 proc/get_access_level() if (!held_card) @@ -125,12 +126,12 @@ if("add_funds") var/amount = input("Enter the amount you wish to add", "Silently add funds") as num if(detailed_account_view) - detailed_account_view.money += amount + detailed_account_view.money = min(detailed_account_view.money + amount, fund_cap) if("remove_funds") var/amount = input("Enter the amount you wish to remove", "Silently remove funds") as num if(detailed_account_view) - detailed_account_view.money -= amount + detailed_account_view.money = max(detailed_account_view.money - amount, -fund_cap) if("toggle_suspension") if(detailed_account_view) @@ -141,6 +142,9 @@ var/account_name = href_list["holder_name"] var/starting_funds = max(text2num(href_list["starting_funds"]), 0) create_account(account_name, starting_funds, src) + + starting_funds = Clamp(starting_funds, 0, station_account.money) // Not authorized to put the station in debt. + starting_funds = min(starting_funds, fund_cap) // Not authrorized to give more than the fund cap. if(starting_funds > 0) //subtract the money station_account.money -= starting_funds