From 4af03523949217f63060cfa51ce2d905fb4bbaeb Mon Sep 17 00:00:00 2001 From: Toastical Date: Sat, 18 Jan 2025 21:38:52 +0200 Subject: [PATCH] Fix: Economy machinery now uses TGUI input + global bank pin range defines (#27913) * economy machinery now uses tgui_input_number * Update code/modules/economy/economy_machinery/economy_machinery.dm Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> * pin range defines + replacing hardcoded ranges * account pin generator uses defines --------- Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com> Co-authored-by: Toastical Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> Co-authored-by: Toastical --- code/__DEFINES/misc_defines.dm | 4 ++++ .../economy/economy_machinery/economy_machinery.dm | 8 ++++---- code/modules/economy/economy_machinery/eftpos.dm | 2 +- code/modules/economy/money_account.dm | 2 +- code/modules/pda/nanobank.dm | 4 ++-- code/modules/supply/supply_console.dm | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/code/__DEFINES/misc_defines.dm b/code/__DEFINES/misc_defines.dm index 60ec94d3dbf..17d241fed8b 100644 --- a/code/__DEFINES/misc_defines.dm +++ b/code/__DEFINES/misc_defines.dm @@ -732,3 +732,7 @@ do { \ #define LAVALAND_TENDRIL_COLLAPSE_RANGE 2 //! The radius of the chasm created by killed tendrils. #define ALPHA_VISIBLE 255 // the max alpha + +/// Economy account defines +#define BANK_PIN_MIN 10000 +#define BANK_PIN_MAX 99999 diff --git a/code/modules/economy/economy_machinery/economy_machinery.dm b/code/modules/economy/economy_machinery/economy_machinery.dm index 31a7a1fb79d..ac7b999a8ed 100644 --- a/code/modules/economy/economy_machinery/economy_machinery.dm +++ b/code/modules/economy/economy_machinery/economy_machinery.dm @@ -33,10 +33,10 @@ /obj/machinery/economy/proc/attempt_account_authentification(datum/money_account/customer_account, attempted_pin, mob/user) var/attempt_pin = attempted_pin - if(customer_account.security_level != ACCOUNT_SECURITY_ID && !attempted_pin) - //if pin is not given, we'll prompt them here - attempt_pin = input("Enter pin code", "Vendor transaction") as num - if(!Adjacent(user)) + if(customer_account.security_level != ACCOUNT_SECURITY_ID && !attempt_pin) + // if pin is not given, we'll prompt them here + attempt_pin = tgui_input_number(user, "Enter pin code", "Vendor transaction", max_value = BANK_PIN_MAX, min_value = BANK_PIN_MIN) + if(!Adjacent(user) || !attempt_pin) return FALSE var/is_admin = is_admin(user) if(!account_database.try_authenticate_login(customer_account, attempt_pin, restricted_bypass, FALSE, is_admin)) diff --git a/code/modules/economy/economy_machinery/eftpos.dm b/code/modules/economy/economy_machinery/eftpos.dm index c28cda4a1e9..ef7dd5c8300 100644 --- a/code/modules/economy/economy_machinery/eftpos.dm +++ b/code/modules/economy/economy_machinery/eftpos.dm @@ -167,7 +167,7 @@ //if security level high enough, prompt for pin var/attempt_pin if(D.security_level != ACCOUNT_SECURITY_ID) - attempt_pin = tgui_input_number(user, "Enter pin code", "EFTPOS transaction", max_value = 9999, min_value = 1000) + attempt_pin = tgui_input_number(user, "Enter pin code", "EFTPOS transaction", max_value = BANK_PIN_MAX, min_value = BANK_PIN_MIN) if(!attempt_pin || !Adjacent(user)) return //given the credentials, can the associated account be accessed right now? diff --git a/code/modules/economy/money_account.dm b/code/modules/economy/money_account.dm index 2202838ac06..8a8faf13f44 100644 --- a/code/modules/economy/money_account.dm +++ b/code/modules/economy/money_account.dm @@ -47,7 +47,7 @@ security_level = _security_level account_number = SSeconomy.generate_account_number() account_type = _account_type - account_pin = rand(10000, 99999) + account_pin = rand(BANK_PIN_MIN, BANK_PIN_MAX) // defines are currently housed in misc_defines.dm //update SSeconomy stats SSeconomy.total_space_credits += starting_balance diff --git a/code/modules/pda/nanobank.dm b/code/modules/pda/nanobank.dm index 2d992b96851..ab3f5356152 100644 --- a/code/modules/pda/nanobank.dm +++ b/code/modules/pda/nanobank.dm @@ -331,7 +331,7 @@ error_message(user, "Incorrect Credentials") /datum/data/pda/app/nanobank/proc/input_account_pin(mob/user) - var/attempt_pin = tgui_input_number(user, "Enter pin code", "NanoBank Account Auth", max_value = 99999) + var/attempt_pin = tgui_input_number(user, "Enter pin code", "NanoBank Account Auth", max_value = BANK_PIN_MAX, min_value = BANK_PIN_MIN) if(!user_account || isnull(attempt_pin)) return return attempt_pin @@ -467,7 +467,7 @@ var/attempt_pin = pin if(customer_account.security_level != ACCOUNT_SECURITY_ID && !attempt_pin) //if pin is not given, we'll prompt them here - attempt_pin = tgui_input_number(user, "Enter pin code", "Vendor transaction") + attempt_pin = tgui_input_number(user, "Enter pin code", "Vendor transaction", max_value = BANK_PIN_MAX, min_value = BANK_PIN_MIN) if(!attempt_pin) return FALSE var/is_admin = is_admin(user) diff --git a/code/modules/supply/supply_console.dm b/code/modules/supply/supply_console.dm index eb371ac7cc2..dbb5db07006 100644 --- a/code/modules/supply/supply_console.dm +++ b/code/modules/supply/supply_console.dm @@ -462,7 +462,7 @@ var/attempt_pin = pin if(customer_account.security_level != ACCOUNT_SECURITY_ID && !attempt_pin) //if pin is not given, we'll prompt them here - attempt_pin = tgui_input_number(user, "Enter pin code", "Vendor transaction", max_value = 99999) + attempt_pin = tgui_input_number(user, "Enter pin code", "Vendor transaction", max_value = BANK_PIN_MAX, min_value = BANK_PIN_MIN) if(!Adjacent(user) || !attempt_pin) return FALSE var/is_admin = is_admin(user)