From 4afd2f7c715d3aa060a386676deb0f506c86ff46 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 15 Oct 2023 16:45:43 -0700 Subject: [PATCH] allow constructions to be built on top of constructions but skip floors being built on top of floors and ramps on top of ramps. this allows blueprints to continue to be idempotent --- changelog.txt | 1 + docs/gui/quickfort.rst | 11 ++++++++--- internal/quickfort/build.lua | 20 +++++++++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/changelog.txt b/changelog.txt index 4c8c70b2a7..79b55859be 100644 --- a/changelog.txt +++ b/changelog.txt @@ -44,6 +44,7 @@ Template for new versions: ## Misc Improvements - `prioritize`: refuse to automatically prioritize dig and smooth/carve job types since it can break the DF job scheduler; instead, print a suggestion that the player use specialized units and vanilla designation priorities +- `quickfort`: now allows constructions to be built on top of constructed floors and ramps, just like vanilla. however, to allow blueprints to be safely reapplied to the same area, for example to fill in buildings whose constructions were canceled due to lost items, floors will not be rebuilt on top of floors and ramps will not be rebuilt on top of ramps ## Removed diff --git a/docs/gui/quickfort.rst b/docs/gui/quickfort.rst index 39e322c131..467339e710 100644 --- a/docs/gui/quickfort.rst +++ b/docs/gui/quickfort.rst @@ -9,9 +9,14 @@ This is the graphical interface for the `quickfort` script. Once you load a blueprint, you will see a highlight over the tiles that will be modified. You can use the mouse cursor to reposition the blueprint and the hotkeys to rotate and repeat the blueprint up or down z-levels. Once you are satisfied, -click the mouse or hit :kbd:`Enter` to apply the blueprint to the map. You can -apply the blueprint as many times as you wish to different spots on the map. -Right click or hit :kbd:`Esc` to stop. +click the mouse or hit :kbd:`Enter` to apply the blueprint to the map. + +You can apply the blueprint as many times as you wish to different spots on the +map. If a blueprint that you designated was only partially applied (due to job +cancellations, incomplete dig area, or any other reason) you can apply the +blueprint a second time to fill in any gaps. Any part of the blueprint that has +already been completed will be harmlessly skipped. Right click or hit +:kbd:`Esc` to close the `gui/quickfort` UI. Usage ----- diff --git a/internal/quickfort/build.lua b/internal/quickfort/build.lua index 750c6f050b..3d09c0f53f 100644 --- a/internal/quickfort/build.lua +++ b/internal/quickfort/build.lua @@ -114,12 +114,26 @@ local function is_valid_tile_bridge(pos, db_entry, b) return is_valid_tile_has_space_or_is_ramp(pos) end -local function is_valid_tile_construction(pos) +-- although vanilla allows constructions to be built on top of constructed +-- floors or ramps, we want to offer an idempotency guarantee for quickfort. +-- this means that the user should be able to apply the same blueprint to the +-- same area more than once to complete any bits that failed on the first attempt. +-- therefore, we check that we're not building a construction on top of an +-- existing construction of the same shape +local function is_valid_tile_construction(pos, db_entry) + if not is_valid_tile_has_space_or_is_ramp(pos) then return false end local tileattrs = df.tiletype.attrs[dfhack.maps.getTileType(pos)] local shape = tileattrs.shape local mat = tileattrs.material - return is_valid_tile_has_space_or_is_ramp(pos) and - mat ~= df.tiletype_material.CONSTRUCTION + if mat == df.tiletype_material.CONSTRUCTION and + ( + (shape == df.tiletype_shape.FLOOR and db_entry.subtype == df.construction_type.Floor) or + (shape == df.tiletype_shape.RAMP and db_entry.subtype == df.construction_type.Ramp) + ) + then + return false + end + return true end local function is_shape_at(pos, allowed_shapes)