Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[quickfort] allow farm plots to be built on muddy stone #1184

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Template for new versions:
- `caravan`: fix errors in trade dialog if all fort items are traded away while the trade dialog is showing fort items and the `confirm` trade confirmation is shown
- `control-panel`: restore non-default values of per-save enabled/disabled settings for repeat-based commands
- `confirm`: fix confirmation prompt for overwriting a hotkey zoom location
- `quickfort`: allow farm plots to be built on muddy stone

## Misc Improvements
- `gui/launcher`: "space space to toggle pause" behavior is skipped if the game was paused when `gui/launcher` came up to prevent accidental unpausing
Expand Down
37 changes: 27 additions & 10 deletions internal/quickfort/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,39 @@ local function is_valid_tile_dirt(pos)
local mat = tileattrs.material
local bad_shape =
shape == df.tiletype_shape.BOULDER or
shape == df.tiletype_shape.PEBBLES
shape == df.tiletype_shape.PEBBLES or
shape == df.tiletype_shape.WALL
local good_material =
mat == df.tiletype_material.SOIL or
mat == df.tiletype_material.GRASS_LIGHT or
mat == df.tiletype_material.GRASS_DARK or
mat == df.tiletype_material.GRASS_DRY or
mat == df.tiletype_material.GRASS_DEAD or
mat == df.tiletype_material.PLANT
return is_valid_tile_generic(pos) and not bad_shape and good_material
return good_material and not bad_shape and is_valid_tile_generic(pos)
end

local function is_floor(pos)
local tt = dfhack.maps.getTileType(pos)
if not tt then return false end
local shape = df.tiletype.attrs[tt].shape
return df.tiletype_shape.attrs[shape].basic_shape == df.tiletype_shape_basic.Floor
end

local function has_mud(pos)
local block = dfhack.maps.getTileBlock(pos)
for _, bev in ipairs(block.block_events) do
if bev:getType() ~= df.block_square_event_type.material_spatter then goto continue end
if bev.mat_type == df.builtin_mats.MUD and bev.mat_state == df.matter_state.Solid then
return true
end
::continue::
end
return false
end

local function is_valid_tile_farm(pos)
return is_valid_tile_dirt(pos) or (is_floor(pos) and has_mud(pos))
end

-- essentially, anywhere you could build a construction, plus constructed floors
Expand Down Expand Up @@ -159,13 +183,6 @@ local function is_tile_generic_and_wall_adjacent(pos)
is_shape_at(xyz2pos(pos.x, pos.y-1, pos.z), allowed_door_shapes)
end

local function is_floor(pos)
local tt = dfhack.maps.getTileType(pos)
if not tt then return false end
local shape = df.tiletype.attrs[tt].shape
return df.tiletype_shape.attrs[shape].basic_shape == df.tiletype_shape_basic.Floor
end

local function is_tile_floor_adjacent(pos)
return is_floor(xyz2pos(pos.x+1, pos.y, pos.z)) or
is_floor(xyz2pos(pos.x-1, pos.y, pos.z)) or
Expand Down Expand Up @@ -827,7 +844,7 @@ local building_db_raw = {
p={label='Farm Plot',
type=df.building_type.FarmPlot, has_extents=true,
no_extents_if_solid=true,
is_valid_tile_fn=is_valid_tile_dirt,
is_valid_tile_fn=is_valid_tile_farm,
is_valid_extent_fn=is_extent_nonempty,
ignore_extent_errors=true,
props_fn=do_farm_props},
Expand Down