Skip to content
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 @@ -50,6 +50,7 @@ Template for new versions:
- `idle-crafting`: do not assign crafting jobs to nobles holding meetings (avoid dangling jobs)
- `rejuvenate`: update unit portrait and sprite when aging up babies and children
- `rejuvenate`: recalculate labor assignments for unit when aging up babies and children (so they can start accepting jobs)
- `gui/liquids`: don't add liquids to wall tiles

## Misc Improvements
- `hide-tutorials`: handle tutorial popups for adventure mode
Expand Down
64 changes: 34 additions & 30 deletions gui/liquids.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,39 +163,43 @@ function SpawnLiquid:decreaseLiquidLevel()
self.level = math.max(self.level - 1, 1)
end

local function isFlowPassable(pos)
local tt = dfhack.maps.getTileType(pos)
local tile = dfhack.maps.getTileFlags(pos)
return tt and tile and df.tiletype_shape.attrs[df.tiletype.attrs[tt].shape].passable_flow
end

function SpawnLiquid:spawn(pos)
if dfhack.maps.isValidTilePos(pos) and dfhack.maps.isTileVisible(pos) then
local map_block = dfhack.maps.getTileBlock(pos)

if self.mode == SpawnLiquidMode.CLEAN then
local tile = dfhack.maps.getTileFlags(pos)

tile.water_salt = false
tile.water_stagnant = false
elseif self.type == df.tiletype.RiverSource then
if self.mode == SpawnLiquidMode.REMOVE then
local commands = {
'f', 'any', ';',
'f', 'sp', 'river_source', ';',
'p', 'any', ';',
'p', 's', 'floor', ';',
'p', 'sp', 'normal', ';',
'p', 'm', 'stone', ';',
}
dfhack.run_command('tiletypes-command', table.unpack(commands))
dfhack.run_command('tiletypes-here', '--quiet', ('--cursor=%d,%d,%d'):format(pos2xyz(pos)))
liquids.spawnLiquid(pos, 0, df.tile_liquid.Water)
else
map_block.tiletype[pos.x % 16][pos.y % 16] = df.tiletype.RiverSource
liquids.spawnLiquid(pos, 7, df.tile_liquid.Water)
end
if not dfhack.maps.isValidTilePos(pos) or not dfhack.maps.isTileVisible(pos) or not isFlowPassable(pos) then
return
end

local map_block = dfhack.maps.getTileBlock(pos)

if self.mode == SpawnLiquidMode.CLEAN then
local tile = dfhack.maps.getTileFlags(pos)

tile.water_salt = false
tile.water_stagnant = false
elseif self.type == df.tiletype.RiverSource then
if self.mode == SpawnLiquidMode.REMOVE then
local commands = {
'f', 'any', ';',
'f', 'sp', 'river_source', ';',
'p', 'any', ';',
'p', 's', 'floor', ';',
'p', 'sp', 'normal', ';',
'p', 'm', 'stone', ';',
}
dfhack.run_command('tiletypes-command', table.unpack(commands))
dfhack.run_command('tiletypes-here', '--quiet', ('--cursor=%d,%d,%d'):format(pos2xyz(pos)))
liquids.spawnLiquid(pos, 0, df.tile_liquid.Water)
else
liquids.spawnLiquid(pos, self:getLiquidLevel(pos), self.type)
map_block.tiletype[pos.x % 16][pos.y % 16] = df.tiletype.RiverSource
liquids.spawnLiquid(pos, 7, df.tile_liquid.Water)
end

-- Regardless of spawning or removing liquids, we need to reindex to
-- ensure pathability is up to date.
df.global.world.reindex_pathfinding = true
else
liquids.spawnLiquid(pos, self:getLiquidLevel(pos), self.type)
end
end

Expand Down
Loading