From cf3cd4b22ee7d6c3e1ee3b6c1c23af7b5e1f2e25 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 18 Feb 2021 23:14:58 +0100 Subject: [PATCH] [MIRROR] Build mode fill tool asks for confirmation if filling area is large (#3497) * Build mode fill tool asks for confirmation if filling area is large (#57007) Prompts admins to confirm their selection with the build mode fill tool if the selected area is over 150 tiles. I've seen this happen a few times now (to both myself and others), accidentally filling a massive area because they either forgot that the tool was still on or were moved unexpectedly. This should prevent these kinds of mistakes from happening easily. * Build mode fill tool asks for confirmation if filling area is large Co-authored-by: dragomagol <66640614+dragomagol@users.noreply.github.com> --- code/modules/buildmode/submodes/fill.dm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/modules/buildmode/submodes/fill.dm b/code/modules/buildmode/submodes/fill.dm index 6d79fdc22d1..b8b5cd718ba 100644 --- a/code/modules/buildmode/submodes/fill.dm +++ b/code/modules/buildmode/submodes/fill.dm @@ -1,6 +1,8 @@ +#define FILL_WARNING_MIN 150 + /datum/buildmode_mode/fill key = "fill" - + use_corner_selection = TRUE var/objholder = null @@ -34,7 +36,7 @@ /datum/buildmode_mode/fill/handle_selected_area(client/c, params) var/list/modifiers = params2list(params) - + if(LAZYACCESS(modifiers, LEFT_CLICK)) //rectangular if(LAZYACCESS(modifiers, ALT_CLICK)) var/list/deletion_area = block(get_turf(cornerA),get_turf(cornerB)) @@ -51,6 +53,13 @@ // if there's an analogous proc for this on tg lmk // empty_region(block(get_turf(cornerA),get_turf(cornerB))) else + var/selection_size = abs(cornerA.x - cornerB.x) * abs(cornerA.y - cornerB.y) + + if(selection_size > FILL_WARNING_MIN) // Confirm fill if the number of tiles in the selection is greater than FILL_WARNING_MIN + var/choice = alert("Your selected area is [selection_size] tiles! Continue?", "Large Fill Confirmation", "Yes", "No") + if(choice != "Yes") + return + for(var/turf/T in block(get_turf(cornerA),get_turf(cornerB))) if(ispath(objholder,/turf)) T.PlaceOnTop(objholder) @@ -58,3 +67,5 @@ var/obj/A = new objholder(T) A.setDir(BM.build_dir) log_admin("Build Mode: [key_name(c)] with path [objholder], filled the region from [AREACOORD(cornerA)] through [AREACOORD(cornerB)]") + +#undef FILL_WARNING_MIN