diff --git a/changelog.txt b/changelog.txt index 9d95cb3c5..dd2bdd70d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/gui/liquids.lua b/gui/liquids.lua index bc89747ed..858af75f2 100644 --- a/gui/liquids.lua +++ b/gui/liquids.lua @@ -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