Skip to content

Commit e0c645f

Browse files
authored
Merge pull request #1418 from myk002/myk_liquid_snake
[gui/liquids] don't add liquids to wall tiles
2 parents 43a4e22 + abff16c commit e0c645f

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Template for new versions:
5050
- `idle-crafting`: do not assign crafting jobs to nobles holding meetings (avoid dangling jobs)
5151
- `rejuvenate`: update unit portrait and sprite when aging up babies and children
5252
- `rejuvenate`: recalculate labor assignments for unit when aging up babies and children (so they can start accepting jobs)
53+
- `gui/liquids`: don't add liquids to wall tiles
5354

5455
## Misc Improvements
5556
- `hide-tutorials`: handle tutorial popups for adventure mode

gui/liquids.lua

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -163,39 +163,43 @@ function SpawnLiquid:decreaseLiquidLevel()
163163
self.level = math.max(self.level - 1, 1)
164164
end
165165

166+
local function isFlowPassable(pos)
167+
local tt = dfhack.maps.getTileType(pos)
168+
local tile = dfhack.maps.getTileFlags(pos)
169+
return tt and tile and df.tiletype_shape.attrs[df.tiletype.attrs[tt].shape].passable_flow
170+
end
171+
166172
function SpawnLiquid:spawn(pos)
167-
if dfhack.maps.isValidTilePos(pos) and dfhack.maps.isTileVisible(pos) then
168-
local map_block = dfhack.maps.getTileBlock(pos)
169-
170-
if self.mode == SpawnLiquidMode.CLEAN then
171-
local tile = dfhack.maps.getTileFlags(pos)
172-
173-
tile.water_salt = false
174-
tile.water_stagnant = false
175-
elseif self.type == df.tiletype.RiverSource then
176-
if self.mode == SpawnLiquidMode.REMOVE then
177-
local commands = {
178-
'f', 'any', ';',
179-
'f', 'sp', 'river_source', ';',
180-
'p', 'any', ';',
181-
'p', 's', 'floor', ';',
182-
'p', 'sp', 'normal', ';',
183-
'p', 'm', 'stone', ';',
184-
}
185-
dfhack.run_command('tiletypes-command', table.unpack(commands))
186-
dfhack.run_command('tiletypes-here', '--quiet', ('--cursor=%d,%d,%d'):format(pos2xyz(pos)))
187-
liquids.spawnLiquid(pos, 0, df.tile_liquid.Water)
188-
else
189-
map_block.tiletype[pos.x % 16][pos.y % 16] = df.tiletype.RiverSource
190-
liquids.spawnLiquid(pos, 7, df.tile_liquid.Water)
191-
end
173+
if not dfhack.maps.isValidTilePos(pos) or not dfhack.maps.isTileVisible(pos) or not isFlowPassable(pos) then
174+
return
175+
end
176+
177+
local map_block = dfhack.maps.getTileBlock(pos)
178+
179+
if self.mode == SpawnLiquidMode.CLEAN then
180+
local tile = dfhack.maps.getTileFlags(pos)
181+
182+
tile.water_salt = false
183+
tile.water_stagnant = false
184+
elseif self.type == df.tiletype.RiverSource then
185+
if self.mode == SpawnLiquidMode.REMOVE then
186+
local commands = {
187+
'f', 'any', ';',
188+
'f', 'sp', 'river_source', ';',
189+
'p', 'any', ';',
190+
'p', 's', 'floor', ';',
191+
'p', 'sp', 'normal', ';',
192+
'p', 'm', 'stone', ';',
193+
}
194+
dfhack.run_command('tiletypes-command', table.unpack(commands))
195+
dfhack.run_command('tiletypes-here', '--quiet', ('--cursor=%d,%d,%d'):format(pos2xyz(pos)))
196+
liquids.spawnLiquid(pos, 0, df.tile_liquid.Water)
192197
else
193-
liquids.spawnLiquid(pos, self:getLiquidLevel(pos), self.type)
198+
map_block.tiletype[pos.x % 16][pos.y % 16] = df.tiletype.RiverSource
199+
liquids.spawnLiquid(pos, 7, df.tile_liquid.Water)
194200
end
195-
196-
-- Regardless of spawning or removing liquids, we need to reindex to
197-
-- ensure pathability is up to date.
198-
df.global.world.reindex_pathfinding = true
201+
else
202+
liquids.spawnLiquid(pos, self:getLiquidLevel(pos), self.type)
199203
end
200204
end
201205

0 commit comments

Comments
 (0)