From 340068a25abc756aab4f1ca89336fc3cc8b412d0 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Sun, 29 Nov 2015 18:30:30 -0500 Subject: [PATCH 1/3] fixed various inputs to be cancel-able --- code/game/dna/genes/vg_powers.dm | 5 ++++- code/game/objects/items/weapons/explosives.dm | 4 +++- code/modules/admin/verbs/adminhelp.dm | 5 +++-- code/modules/economy/EFTPOS.dm | 10 +++++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/code/game/dna/genes/vg_powers.dm b/code/game/dna/genes/vg_powers.dm index 3c8168d4157..a830e80fe6c 100644 --- a/code/game/dna/genes/vg_powers.dm +++ b/code/game/dna/genes/vg_powers.dm @@ -240,7 +240,10 @@ Obviously, requires DNA2. /obj/effect/proc_holder/spell/targeted/remotetalk/cast(list/targets) if(!ishuman(usr)) return - var/say = strip_html(input("What do you wish to say")) + var/say = input("What do you wish to say") as text|null + if(say == null || length(say) == 0) + return + say = strip_html(say) for(var/mob/living/target in targets) log_say("Project Mind: [key_name(usr)]->[key_name(target)]: [say]") diff --git a/code/game/objects/items/weapons/explosives.dm b/code/game/objects/items/weapons/explosives.dm index 2d70a119b0d..dd182d394aa 100644 --- a/code/game/objects/items/weapons/explosives.dm +++ b/code/game/objects/items/weapons/explosives.dm @@ -62,7 +62,9 @@ ..() /obj/item/weapon/c4/attack_self(mob/user as mob) - var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num + var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num|null + if(newtime == null) + return if(newtime < 10) newtime = 10 if(newtime > 60000) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index b7f2f2d91bb..e90adf458ca 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -18,10 +18,11 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," var/list/type = list("Question","Player Complaint") var/selected_type = input("Pick a category.", "Admin Help", null, null) as null|anything in type if(selected_type) - msg = input("Please enter your message.", "Admin Help", null, null) as text + msg = input("Please enter your message.", "Admin Help", null, null) as text|null //clean the input msg - if(!msg) return + if(msg == null || length(msg) == 0) + return if(src.handle_spam_prevention(msg,MUTE_ADMINHELP)) return diff --git a/code/modules/economy/EFTPOS.dm b/code/modules/economy/EFTPOS.dm index efef8616f7f..41cfc2bb8e6 100644 --- a/code/modules/economy/EFTPOS.dm +++ b/code/modules/economy/EFTPOS.dm @@ -133,8 +133,10 @@ if("change_id") var/attempt_code = text2num(input("Re-enter the current EFTPOS access code", "Confirm EFTPOS code")) if(attempt_code == access_code) - eftpos_name = input("Enter a new terminal ID for this device", "Enter new EFTPOS ID") + " EFTPOS scanner" - print_reference() + var name = input("Enter a new terminal ID for this device", "Enter new EFTPOS ID") as text|null + if(name && length(name) > 0) + eftpos_name = name + " EFTPOS scanner" + print_reference() else usr << "\icon[src]Incorrect code entered." if("link_account") @@ -147,7 +149,9 @@ else usr << "\icon[src]Unable to connect to accounts database." if("trans_purpose") - transaction_purpose = input("Enter reason for EFTPOS transaction", "Transaction purpose") + var/purpose = input("Enter reason for EFTPOS transaction", "Transaction purpose") as text|null + if(purpose && length(purpose) > 0) + transaction_purpose = purpose if("trans_value") var/try_num = input("Enter amount for EFTPOS transaction", "Transaction amount") as num if(try_num < 0) From 57ae7e1c9aed1d6df46f6c8eb8d12699ecfe653a Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Sun, 29 Nov 2015 19:40:23 -0500 Subject: [PATCH 2/3] made AI tracking cancel-able, fixed folder labelling --- code/_onclick/hud/screen_objects.dm | 2 +- code/game/machinery/camera/tracking.dm | 7 +++---- code/modules/paperwork/folders.dm | 8 ++++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index cf0f56cdad9..5ac8bdb15fc 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -495,7 +495,7 @@ if("Track With Camera") if(isAI(usr)) var/mob/living/silicon/ai/AI = usr - var/target_name = input(AI) in AI.trackable_mobs() + var/target_name = input(AI) as null|anything in AI.trackable_mobs() AI.ai_camera_track(target_name) if("Toggle Camera Light") diff --git a/code/game/machinery/camera/tracking.dm b/code/game/machinery/camera/tracking.dm index 1672fde7d02..7317450e02d 100644 --- a/code/game/machinery/camera/tracking.dm +++ b/code/game/machinery/camera/tracking.dm @@ -157,7 +157,7 @@ src.track = TB return targets -/mob/living/silicon/ai/proc/ai_camera_track(var/target_name in trackable_mobs()) +/mob/living/silicon/ai/proc/ai_camera_track(target_name in trackable_mobs()) set category = "AI Commands" set name = "Track With Camera" set desc = "Select who you would like to track." @@ -187,7 +187,7 @@ U.cameraFollow = target U << "Now tracking [target.name] on camera." target.tracking_initiated() - + spawn (0) while (U.cameraFollow == target) if (U.cameraFollow == null) @@ -229,7 +229,7 @@ return 0 if(istype(M.loc,/obj/effect/dummy)) return 0 - + if((T && (T.z in config.contact_levels)) && ((hassensorlevel(M, SUIT_SENSOR_TRACKING) || M in aibots))) return 1 @@ -259,4 +259,3 @@ tracking_entities-- if(!tracking_entities && has_zeroth_law()) src << "Internal camera is no longer being accessed." - \ No newline at end of file diff --git a/code/modules/paperwork/folders.dm b/code/modules/paperwork/folders.dm index 8d8242cba70..173723bf4cb 100644 --- a/code/modules/paperwork/folders.dm +++ b/code/modules/paperwork/folders.dm @@ -35,8 +35,12 @@ user << "You put the [W] into \the [src]." update_icon() else if(istype(W, /obj/item/weapon/pen)) - var/n_name = sanitize(copytext(input(usr, "What would you like to label the folder?", "Folder Labelling", null) as text, 1, MAX_NAME_LEN)) - if((loc == usr && usr.stat == 0)) + var/n_name = input(usr, "What would you like to label the folder?", "Folder Labelling", null) as text|null + if(!n_name) + return + n_name = sanitize(copytext(n_name, 1, MAX_NAME_LEN)) + + if((loc == usr || Adjacent(usr)) && usr.stat == 0) name = "folder[(n_name ? text("- '[n_name]'") : null)]" return From e562d9d0c2eef2184ec11c602aaf47280fdeae35 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Mon, 30 Nov 2015 01:00:15 -0500 Subject: [PATCH 3/3] added input cancelling to pda msg, chemmaster ops, borg mod selection --- code/game/objects/items/devices/PDA/PDA.dm | 4 ++- code/modules/mob/living/silicon/robot/life.dm | 11 ++++--- .../modules/mob/living/silicon/robot/robot.dm | 4 ++- code/modules/reagents/Chemistry-Machinery.dm | 32 +++++++++++++++---- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index cfb3cd14c7c..85a664ad9fd 100755 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -849,7 +849,9 @@ var/global/list/obj/item/device/pda/PDAs = list() /obj/item/device/pda/proc/create_message(var/mob/living/U = usr, var/obj/item/device/pda/P) - var/t = input(U, "Please enter message", name, null) as text + var/t = input(U, "Please enter message", name, null) as text|null + if(!t) + return t = sanitize(copytext(t, 1, MAX_MESSAGE_LEN)) t = readd_quotes(t) if (!t || !istype(P)) diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index eac013eb8b1..4d572377700 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -26,11 +26,12 @@ /mob/living/silicon/robot/proc/use_power() if (is_component_functioning("power cell") && cell) - for(var/obj/item/borg/B in module.modules) - if(B.powerneeded) - if((cell.charge * 100 / cell.maxcharge) < B.powerneeded) - src << "Deactivating [B.name] due to lack of power!" - unEquip(B) + if(module) + for(var/obj/item/borg/B in module.modules) + if(B.powerneeded) + if((cell.charge * 100 / cell.maxcharge) < B.powerneeded) + src << "Deactivating [B.name] due to lack of power!" + unEquip(B) if(src.cell.charge <= 0) uneq_all() update_headlamp(1) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index ce0e238fb31..06bd83ed96f 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -224,7 +224,9 @@ var/list/robot_verbs_default = list( modules = list("Peacekeeper") if(mmi != null && mmi.alien) modules = "Hunter" - modtype = input("Please, select a module!", "Robot", null, null) in modules + modtype = input("Please, select a module!", "Robot", null, null) as null|anything in modules + if(!modtype) + return designation = modtype var/module_sprites[0] //Used to store the associations between sprite names and sprite index. diff --git a/code/modules/reagents/Chemistry-Machinery.dm b/code/modules/reagents/Chemistry-Machinery.dm index 55ba20e3880..7f090a72be6 100644 --- a/code/modules/reagents/Chemistry-Machinery.dm +++ b/code/modules/reagents/Chemistry-Machinery.dm @@ -569,12 +569,19 @@ else if (href_list["createpill"] || href_list["createpill_multiple"]) if(!condi) var/count = 1 - if (href_list["createpill_multiple"]) count = isgoodnumber(input("Select the number of pills to make.", 10, pillamount) as num) + if (href_list["createpill_multiple"]) + count = input("Select the number of pills to make.", 10, pillamount) as num|null + if(count == null) + return + count = isgoodnumber(count) if (count > 20) count = 20 //Pevent people from creating huge stacks of pills easily. Maybe move the number to defines? if (count <= 0) return var/amount_per_pill = reagents.total_volume/count if (amount_per_pill > 50) amount_per_pill = 50 - var/name = reject_bad_text(input(usr,"Name:","Name your pill!","[reagents.get_master_reagent_name()] ([amount_per_pill] units)")) + var/name = input(usr,"Name:","Name your pill!","[reagents.get_master_reagent_name()] ([amount_per_pill] units)") as text|null + if(!name) + return + name = reject_bad_text(name) while (count--) var/obj/item/weapon/reagent_containers/pill/P = new/obj/item/weapon/reagent_containers/pill(src.loc) if(!name) name = reagents.get_master_reagent_name() @@ -588,7 +595,10 @@ P.forceMove(loaded_pill_bottle) src.updateUsrDialog() else - var/name = reject_bad_text(input(usr,"Name:","Name your bag!",reagents.get_master_reagent_name())) + var/name = input(usr,"Name:","Name your bag!",reagents.get_master_reagent_name()) as text|null + if(!name) + return + name = reject_bad_text(name) var/obj/item/weapon/reagent_containers/food/condiment/pack/P = new/obj/item/weapon/reagent_containers/food/condiment/pack(src.loc) if(!name) name = reagents.get_master_reagent_name() P.originalname = name @@ -598,13 +608,20 @@ else if (href_list["createpatch"] || href_list["createpatch_multiple"]) if(!condi) var/count = 1 - if (href_list["createpatch_multiple"]) count = isgoodnumber(input("Select the number of patches to make.", 10, patchamount) as num) + if (href_list["createpatch_multiple"]) + count = input("Select the number of patches to make.", 10, patchamount) as num|null + if(count == null) + return + count = isgoodnumber(count) if(!count || count <= 0) return if (count > 20) count = 20 //Pevent people from creating huge stacks of patches easily. Maybe move the number to defines? var/amount_per_patch = reagents.total_volume/count if (amount_per_patch > 40) amount_per_patch = 40 - var/name = reject_bad_text(input(usr,"Name:","Name your patch!","[reagents.get_master_reagent_name()] ([amount_per_patch] units)")) + var/name = input(usr,"Name:","Name your patch!","[reagents.get_master_reagent_name()] ([amount_per_patch] units)") as text|null + if(!name) + return + name = reject_bad_text(name) while (count--) var/obj/item/weapon/reagent_containers/pill/patch/P = new/obj/item/weapon/reagent_containers/pill/patch(src.loc) if(!name) name = reagents.get_master_reagent_name() @@ -614,7 +631,10 @@ reagents.trans_to(P,amount_per_patch) else if (href_list["createbottle"]) if(!condi) - var/name = reject_bad_text(input(usr,"Name:","Name your bottle!",reagents.get_master_reagent_name())) + var/name = input(usr,"Name:","Name your bottle!",reagents.get_master_reagent_name()) as text|null + if(!name) + return + name = reject_bad_text(name) var/obj/item/weapon/reagent_containers/glass/bottle/P = new/obj/item/weapon/reagent_containers/glass/bottle(src.loc) if(!name) name = reagents.get_master_reagent_name() P.name = "[name] bottle"