@@ -2,32 +2,52 @@ local argparse = require('argparse')
2
2
3
3
local zmin = 0
4
4
local zmax = df .global .world .map .z_count - 1
5
+ local aqtype = null
5
6
6
7
local function drain ()
7
8
local layers = {} -- as:bool[]
8
9
local layer_count = 0
9
10
local tile_count = 0
11
+ local aqTypeToDrain = 3
12
+ if aqtype == " light" then
13
+ aqTypeToDrain = 1
14
+ elseif aqtype == " heavy" then
15
+ aqTypeToDrain = 2
16
+ elseif aqtype ~= nil then
17
+ qerror (" Invalid aquifer type " .. aqtype )
18
+ end
10
19
11
20
for _ , block in ipairs (df .global .world .map .map_blocks ) do
21
+ local aquiferInBlock = false
22
+
12
23
if not block .flags .has_aquifer then goto continue end
13
24
if block .map_pos .z < zmin or block .map_pos .z > zmax then goto continue end
14
-
15
- block .flags . has_aquifer = false
16
- block . flags . check_aquifer = false
17
-
18
- for _ , row in ipairs (block .designation ) do
19
- for _ , tile in ipairs ( row ) do
20
- if tile .water_table then
25
+ local oldTileCount = tile_count
26
+ for i , row in ipairs ( block .designation ) do
27
+ for j , tile in ipairs ( row ) do
28
+ if ( aqTypeToDrain == 3 or
29
+ (block .occupancy [ i ][ j ]. heavy_aquifer and aqTypeToDrain == 2 ) or
30
+ ( not block . occupancy [ i ][ j ]. heavy_aquifer and aqTypeToDrain == 1 )) and
31
+ tile .water_table then
21
32
tile .water_table = false
22
33
tile_count = tile_count + 1
23
34
end
35
+ if tile .water_table then
36
+ aquiferInBlock = true
37
+ end
24
38
end
25
39
end
26
40
27
41
if not layers [block .map_pos .z ] then
28
42
layers [block .map_pos .z ] = true
29
43
layer_count = layer_count + 1
30
44
end
45
+
46
+ if aquiferInBlock == false then
47
+ block .flags .has_aquifer = false
48
+ block .flags .check_aquifer = false
49
+ end
50
+
31
51
:: continue::
32
52
end
33
53
@@ -44,6 +64,7 @@ local positionals = argparse.processArgsGetopt({...}, {
44
64
{' d' , ' zdown' , handler = function () zmax = df .global .window_z end },
45
65
{' u' , ' zup' , handler = function () zmin = df .global .window_z end },
46
66
{' z' , ' cur-zlevel' , handler = function () zmax , zmin = df .global .window_z , df .global .window_z end },
67
+ {' f' , ' filter' , hasArg = true , handler = function (fil ) aqtype = string.lower (fil ) end },
47
68
})
48
69
49
70
if help or positionals [1 ] == ' help' then
0 commit comments