2021-05-16 15:16:21 -06:00
|
|
|
/*
|
|
|
|
* Simulates completion of dig designations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "DataFuncs.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
#include "TileTypes.h"
|
2021-06-02 23:18:42 -06:00
|
|
|
#include "LuaTools.h"
|
2021-05-16 15:16:21 -06:00
|
|
|
|
2021-06-02 23:18:42 -06:00
|
|
|
#include "modules/Maps.h"
|
2021-06-01 18:38:04 -06:00
|
|
|
#include "modules/MapCache.h"
|
2021-05-16 15:16:21 -06:00
|
|
|
|
|
|
|
#include <df/tile_designation.h>
|
|
|
|
#include <df/tile_occupancy.h>
|
|
|
|
#include <df/world.h>
|
|
|
|
#include <df/map_block.h>
|
|
|
|
|
2021-06-02 14:31:15 -06:00
|
|
|
DFHACK_PLUGIN("dig-now");
|
2021-05-16 15:16:21 -06:00
|
|
|
REQUIRE_GLOBAL(world);
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
|
2021-06-02 23:18:42 -06:00
|
|
|
static void flood_unhide(color_ostream &out, const DFCoord &pos) {
|
|
|
|
auto L = Lua::Core::State;
|
|
|
|
Lua::StackUnwinder top(L);
|
2021-05-16 15:16:21 -06:00
|
|
|
|
2021-06-02 23:18:42 -06:00
|
|
|
if (!lua_checkstack(L, 2)
|
|
|
|
|| !Lua::PushModulePublic(out, L, "plugins.reveal", "unhideFlood"))
|
2021-05-16 15:16:21 -06:00
|
|
|
return;
|
|
|
|
|
2021-06-02 23:18:42 -06:00
|
|
|
Lua::Push(L, pos);
|
|
|
|
Lua::SafeCall(out, L, 1, 0);
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// inherit flags from passable tiles above and propagate to passable tiles below
|
2021-06-01 18:38:04 -06:00
|
|
|
static void propagate_vertical_flags(MapExtras::MapCache &map,
|
|
|
|
const DFCoord &pos) {
|
|
|
|
df::tile_designation td = map.designationAt(pos);
|
2021-05-16 15:16:21 -06:00
|
|
|
|
2021-06-02 23:18:42 -06:00
|
|
|
if (!map.ensureBlockAt(DFCoord(pos.x, pos.y, pos.z+1))) {
|
2021-05-16 15:16:21 -06:00
|
|
|
// only the sky above
|
|
|
|
td.bits.light = true;
|
|
|
|
td.bits.outside = true;
|
|
|
|
td.bits.subterranean = false;
|
|
|
|
}
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
int32_t zlevel = pos.z;
|
|
|
|
df::tiletype_shape shape =
|
|
|
|
tileShape(map.tiletypeAt(DFCoord(pos.x, pos.y, zlevel)));
|
2021-05-16 15:16:21 -06:00
|
|
|
while ((shape == df::tiletype_shape::EMPTY
|
|
|
|
|| shape == df::tiletype_shape::RAMP_TOP)
|
2021-06-01 18:38:04 -06:00
|
|
|
&& map.ensureBlockAt(DFCoord(pos.x, pos.y, --zlevel))) {
|
|
|
|
DFCoord pos_below(pos.x, pos.y, zlevel);
|
|
|
|
df::tile_designation td_below = map.designationAt(pos_below);
|
|
|
|
if (td_below.bits.light == td.bits.light
|
|
|
|
&& td_below.bits.outside == td.bits.outside
|
|
|
|
&& td_below.bits.subterranean == td.bits.subterranean)
|
2021-05-16 15:16:21 -06:00
|
|
|
break;
|
2021-06-01 18:38:04 -06:00
|
|
|
td_below.bits.light = td.bits.light;
|
|
|
|
td_below.bits.outside = td.bits.outside;
|
|
|
|
td_below.bits.subterranean = td.bits.subterranean;
|
|
|
|
map.setDesignationAt(pos_below, td_below);
|
|
|
|
shape = tileShape(map.tiletypeAt(pos_below));
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-01 12:58:32 -06:00
|
|
|
static bool can_dig_default(df::tiletype tt) {
|
|
|
|
df::tiletype_shape shape = tileShape(tt);
|
|
|
|
return shape == df::tiletype_shape::WALL ||
|
|
|
|
shape == df::tiletype_shape::FORTIFICATION ||
|
|
|
|
shape == df::tiletype_shape::RAMP ||
|
|
|
|
shape == df::tiletype_shape::STAIR_UP ||
|
|
|
|
shape == df::tiletype_shape::STAIR_UPDOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool can_dig_channel(df::tiletype tt) {
|
|
|
|
df::tiletype_shape shape = tileShape(tt);
|
|
|
|
return shape != df::tiletype_shape::EMPTY &&
|
|
|
|
shape != df::tiletype_shape::ENDLESS_PIT &&
|
|
|
|
shape != df::tiletype_shape::NONE &&
|
|
|
|
shape != df::tiletype_shape::RAMP_TOP &&
|
|
|
|
shape != df::tiletype_shape::TRUNK_BRANCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool can_dig_up_stair(df::tiletype tt) {
|
|
|
|
df::tiletype_shape shape = tileShape(tt);
|
|
|
|
return shape == df::tiletype_shape::WALL ||
|
|
|
|
shape == df::tiletype_shape::FORTIFICATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool can_dig_down_stair(df::tiletype tt) {
|
|
|
|
df::tiletype_shape shape = tileShape(tt);
|
|
|
|
return shape == df::tiletype_shape::BOULDER ||
|
|
|
|
shape == df::tiletype_shape::BROOK_BED ||
|
|
|
|
shape == df::tiletype_shape::BROOK_TOP ||
|
|
|
|
shape == df::tiletype_shape::FLOOR ||
|
|
|
|
shape == df::tiletype_shape::FORTIFICATION ||
|
|
|
|
shape == df::tiletype_shape::PEBBLES ||
|
|
|
|
shape == df::tiletype_shape::RAMP ||
|
|
|
|
shape == df::tiletype_shape::SAPLING ||
|
|
|
|
shape == df::tiletype_shape::SHRUB ||
|
|
|
|
shape == df::tiletype_shape::TWIG ||
|
|
|
|
shape == df::tiletype_shape::WALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool can_dig_up_down_stair(df::tiletype tt) {
|
|
|
|
df::tiletype_shape shape = tileShape(tt);
|
|
|
|
return shape == df::tiletype_shape::WALL ||
|
|
|
|
shape == df::tiletype_shape::FORTIFICATION ||
|
|
|
|
shape == df::tiletype_shape::STAIR_UP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool can_dig_ramp(df::tiletype tt) {
|
|
|
|
df::tiletype_shape shape = tileShape(tt);
|
|
|
|
return shape == df::tiletype_shape::WALL ||
|
|
|
|
shape == df::tiletype_shape::FORTIFICATION;
|
|
|
|
}
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
static void dig_type(MapExtras::MapCache &map, const DFCoord &pos,
|
|
|
|
df::tiletype tt) {
|
|
|
|
auto blk = map.BlockAtTile(pos);
|
|
|
|
if (!blk)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// ensure we run this even if one of the later steps fails (e.g. OpenSpace)
|
|
|
|
map.setTiletypeAt(pos, tt);
|
|
|
|
|
|
|
|
// digging a tile reverts it to the layer soil/stone material
|
|
|
|
if (!blk->setStoneAt(pos, tt, map.layerMaterialAt(pos)) &&
|
|
|
|
!blk->setSoilAt(pos, tt, map.layerMaterialAt(pos)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// un-smooth dug tiles
|
|
|
|
tt = map.tiletypeAt(pos);
|
|
|
|
tt = findTileType(tileShape(tt), tileMaterial(tt), tileVariant(tt),
|
|
|
|
df::tiletype_special::NORMAL, tileDirection(tt));
|
|
|
|
map.setTiletypeAt(pos, tt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dig_shape(MapExtras::MapCache &map, const DFCoord &pos,
|
|
|
|
df::tiletype tt, df::tiletype_shape shape) {
|
|
|
|
dig_type(map, pos, findSimilarTileType(tt, shape));
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
static void remove_ramp_top(MapExtras::MapCache &map, const DFCoord &pos) {
|
|
|
|
if (!map.ensureBlockAt(pos))
|
2021-06-01 12:58:32 -06:00
|
|
|
return;
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
if (tileShape(map.tiletypeAt(pos)) == df::tiletype_shape::RAMP_TOP)
|
|
|
|
dig_type(map, pos, df::tiletype::OpenSpace);
|
2021-06-01 12:58:32 -06:00
|
|
|
}
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
static bool is_wall(MapExtras::MapCache &map, const DFCoord &pos) {
|
|
|
|
if (!map.ensureBlockAt(pos))
|
2021-06-01 12:58:32 -06:00
|
|
|
return false;
|
2021-06-01 18:38:04 -06:00
|
|
|
return tileShape(map.tiletypeAt(pos)) == df::tiletype_shape::WALL;
|
2021-06-01 12:58:32 -06:00
|
|
|
}
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
static void clean_ramp(MapExtras::MapCache &map, const DFCoord &pos) {
|
|
|
|
if (!map.ensureBlockAt(pos))
|
2021-06-01 12:58:32 -06:00
|
|
|
return;
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
df::tiletype tt = map.tiletypeAt(pos);
|
2021-06-01 12:58:32 -06:00
|
|
|
if (tileShape(tt) != df::tiletype_shape::RAMP)
|
|
|
|
return;
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
if (is_wall(map, DFCoord(pos.x-1, pos.y, pos.z)) ||
|
|
|
|
is_wall(map, DFCoord(pos.x+1, pos.y, pos.z)) ||
|
|
|
|
is_wall(map, DFCoord(pos.x, pos.y-1, pos.z)) ||
|
|
|
|
is_wall(map, DFCoord(pos.x, pos.y+1, pos.z)))
|
2021-06-01 12:58:32 -06:00
|
|
|
return;
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
remove_ramp_top(map, DFCoord(pos.x, pos.y, pos.z+1));
|
|
|
|
dig_shape(map,pos, tt, df::tiletype_shape::FLOOR);
|
2021-06-01 12:58:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// removes self and/or orthogonally adjacent ramps that are no longer adjacent
|
|
|
|
// to a wall
|
2021-06-01 18:38:04 -06:00
|
|
|
static void clean_ramps(MapExtras::MapCache &map, const DFCoord &pos) {
|
|
|
|
clean_ramp(map, pos);
|
|
|
|
clean_ramp(map, DFCoord(pos.x-1, pos.y, pos.z));
|
|
|
|
clean_ramp(map, DFCoord(pos.x+1, pos.y, pos.z));
|
|
|
|
clean_ramp(map, DFCoord(pos.x, pos.y-1, pos.z));
|
|
|
|
clean_ramp(map, DFCoord(pos.x, pos.y+1, pos.z));
|
2021-06-01 12:58:32 -06:00
|
|
|
}
|
|
|
|
|
2021-05-16 15:16:21 -06:00
|
|
|
// TODO: if requested, create boulders
|
2021-06-01 18:38:04 -06:00
|
|
|
static bool dig_tile(color_ostream &out, MapExtras::MapCache &map,
|
|
|
|
const DFCoord &pos, df::tile_dig_designation designation) {
|
|
|
|
df::tiletype tt = map.tiletypeAt(pos);
|
2021-06-01 12:58:32 -06:00
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
// TODO: handle tree trunks, roots, and surface tiles
|
2021-06-01 12:58:32 -06:00
|
|
|
if (!isGroundMaterial(tileMaterial(tt)))
|
|
|
|
return false;
|
|
|
|
|
2021-05-16 15:16:21 -06:00
|
|
|
df::tiletype target_type = df::tiletype::Void;
|
|
|
|
switch(designation) {
|
|
|
|
case df::tile_dig_designation::Default:
|
2021-06-01 12:58:32 -06:00
|
|
|
// TODO: should not leave a smooth floor when removing stairs/ramps
|
|
|
|
if (can_dig_default(tt)) {
|
|
|
|
df::tiletype_shape shape = tileShape(tt);
|
|
|
|
df::tiletype_shape target_shape = df::tiletype_shape::FLOOR;
|
|
|
|
if (shape == df::tiletype_shape::STAIR_UPDOWN)
|
|
|
|
target_shape = df::tiletype_shape::STAIR_DOWN;
|
|
|
|
else if (shape == df::tiletype_shape::RAMP)
|
2021-06-01 18:38:04 -06:00
|
|
|
remove_ramp_top(map, DFCoord(pos.x, pos.y, pos.z+1));
|
2021-06-01 12:58:32 -06:00
|
|
|
target_type = findSimilarTileType(tt, target_shape);
|
|
|
|
}
|
2021-05-16 15:16:21 -06:00
|
|
|
break;
|
|
|
|
case df::tile_dig_designation::Channel:
|
2021-06-01 12:58:32 -06:00
|
|
|
if (can_dig_channel(tt)) {
|
2021-06-01 18:38:04 -06:00
|
|
|
remove_ramp_top(map, DFCoord(pos.x, pos.y, pos.z+1));
|
2021-06-01 12:58:32 -06:00
|
|
|
target_type = df::tiletype::OpenSpace;
|
2021-06-01 18:38:04 -06:00
|
|
|
DFCoord pos_below(pos.x, pos.y, pos.z-1);
|
|
|
|
if (map.ensureBlockAt(pos_below) &&
|
|
|
|
dig_tile(out, map, pos_below,
|
2021-06-01 12:58:32 -06:00
|
|
|
df::tile_dig_designation::Ramp)) {
|
2021-06-01 18:38:04 -06:00
|
|
|
clean_ramps(map, pos_below);
|
2021-06-01 12:58:32 -06:00
|
|
|
// if we successfully dug out the ramp below, that took care
|
|
|
|
// of the ramp top here
|
2021-06-01 18:38:04 -06:00
|
|
|
return true;
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
2021-06-01 12:58:32 -06:00
|
|
|
break;
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
2021-06-01 12:58:32 -06:00
|
|
|
case df::tile_dig_designation::UpStair:
|
|
|
|
if (can_dig_up_stair(tt))
|
|
|
|
target_type =
|
|
|
|
findSimilarTileType(tt, df::tiletype_shape::STAIR_UP);
|
2021-05-16 15:16:21 -06:00
|
|
|
break;
|
|
|
|
case df::tile_dig_designation::DownStair:
|
2021-06-01 12:58:32 -06:00
|
|
|
if (can_dig_down_stair(tt)) {
|
|
|
|
target_type =
|
|
|
|
findSimilarTileType(tt, df::tiletype_shape::STAIR_DOWN);
|
|
|
|
|
|
|
|
}
|
2021-05-16 15:16:21 -06:00
|
|
|
break;
|
2021-06-01 12:58:32 -06:00
|
|
|
case df::tile_dig_designation::UpDownStair:
|
|
|
|
if (can_dig_up_down_stair(tt)) {
|
|
|
|
target_type =
|
|
|
|
findSimilarTileType(tt,
|
|
|
|
df::tiletype_shape::STAIR_UPDOWN);
|
|
|
|
}
|
2021-05-16 15:16:21 -06:00
|
|
|
break;
|
2021-06-01 12:58:32 -06:00
|
|
|
case df::tile_dig_designation::Ramp:
|
|
|
|
{
|
|
|
|
if (can_dig_ramp(tt)) {
|
|
|
|
target_type = findSimilarTileType(tt, df::tiletype_shape::RAMP);
|
2021-06-01 18:38:04 -06:00
|
|
|
DFCoord pos_above(pos.x, pos.y, pos.z+1);
|
|
|
|
if (target_type != tt && map.ensureBlockAt(pos_above)) {
|
|
|
|
// set tile type directly instead of calling dig_shape
|
2021-06-01 12:58:32 -06:00
|
|
|
// because we need to use *this* tile's material, not the
|
|
|
|
// material of the tile above
|
2021-06-01 18:38:04 -06:00
|
|
|
map.setTiletypeAt(pos_above,
|
|
|
|
findSimilarTileType(tt, df::tiletype_shape::RAMP_TOP));
|
2021-06-01 12:58:32 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-05-16 15:16:21 -06:00
|
|
|
case df::tile_dig_designation::No:
|
|
|
|
default:
|
|
|
|
out.printerr(
|
|
|
|
"unhandled dig designation for tile (%d, %d, %d): %d\n",
|
2021-06-01 18:38:04 -06:00
|
|
|
pos.x, pos.y, pos.z, designation);
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
|
|
|
|
2021-06-02 23:18:42 -06:00
|
|
|
// fail if unhandled or no change to tile
|
2021-06-01 12:58:32 -06:00
|
|
|
if (target_type == df::tiletype::Void || target_type == tt)
|
|
|
|
return false;
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
dig_type(map, pos, target_type);
|
2021-05-16 15:16:21 -06:00
|
|
|
|
2021-06-02 23:18:42 -06:00
|
|
|
// let light filter down to newly exposed tiles
|
|
|
|
propagate_vertical_flags(map, pos);
|
2021-06-01 12:58:32 -06:00
|
|
|
|
|
|
|
return true;
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
static bool smooth_tile(color_ostream &out, MapExtras::MapCache &map,
|
|
|
|
const DFCoord &pos, bool engrave) {
|
2021-05-16 15:16:21 -06:00
|
|
|
// TODO
|
2021-06-01 18:38:04 -06:00
|
|
|
return false;
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
static bool carve_tile(color_ostream &out, MapExtras::MapCache &map,
|
|
|
|
const DFCoord &pos, df::tile_occupancy &to) {
|
2021-05-16 15:16:21 -06:00
|
|
|
// TODO
|
2021-06-01 18:38:04 -06:00
|
|
|
return false;
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
|
|
|
|
2021-06-02 23:43:23 -06:00
|
|
|
static void do_dig(color_ostream &out, std::vector<DFCoord> &dug_coords,
|
|
|
|
const DFCoord &start, const DFCoord &end) {
|
2021-06-02 23:18:42 -06:00
|
|
|
// use the proxy layer for the layer material-setting ease-of-use functions.
|
2021-06-01 18:38:04 -06:00
|
|
|
MapExtras::MapCache map;
|
|
|
|
|
2021-06-02 23:43:23 -06:00
|
|
|
for (uint32_t z = start.z; z <= end.z; ++z) {
|
|
|
|
for (uint32_t y = start.y; y <= end.y; ++y) {
|
|
|
|
for (uint32_t x = start.x; x <= end.x; ++x) {
|
2021-05-16 15:16:21 -06:00
|
|
|
// this will return NULL if the map block hasn't been allocated
|
|
|
|
// yet, but that means there aren't any designations anyway.
|
|
|
|
if (!Maps::getTileBlock(x, y, z))
|
|
|
|
continue;
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
DFCoord pos(x, y, z);
|
|
|
|
df::tile_designation td = map.designationAt(pos);
|
|
|
|
df::tile_occupancy to = map.occupancyAt(pos);
|
2021-05-16 15:16:21 -06:00
|
|
|
if (td.bits.dig != df::tile_dig_designation::No) {
|
2021-06-01 18:38:04 -06:00
|
|
|
if (dig_tile(out, map, pos, td.bits.dig)) {
|
|
|
|
td = map.designationAt(pos);
|
|
|
|
td.bits.dig = df::tile_dig_designation::No;
|
|
|
|
map.setDesignationAt(pos, td);
|
2021-06-02 23:18:42 -06:00
|
|
|
dug_coords.push_back(pos);
|
2021-06-01 18:38:04 -06:00
|
|
|
}
|
2021-05-16 15:16:21 -06:00
|
|
|
} else if (td.bits.smooth > 0) {
|
|
|
|
bool want_engrave = td.bits.smooth == 2;
|
2021-06-01 18:38:04 -06:00
|
|
|
if (smooth_tile(out, map, pos, want_engrave)) {
|
|
|
|
to = map.occupancyAt(pos);
|
|
|
|
td.bits.smooth = 0;
|
|
|
|
map.setDesignationAt(pos, td);
|
|
|
|
}
|
2021-05-16 15:16:21 -06:00
|
|
|
} else if (to.bits.carve_track_north == 1
|
2021-06-01 18:38:04 -06:00
|
|
|
|| to.bits.carve_track_east == 1
|
|
|
|
|| to.bits.carve_track_south == 1
|
|
|
|
|| to.bits.carve_track_west == 1) {
|
|
|
|
if (carve_tile(out, map, pos, to)) {
|
|
|
|
to = map.occupancyAt(pos);
|
|
|
|
to.bits.carve_track_north = 0;
|
|
|
|
to.bits.carve_track_east = 0;
|
|
|
|
to.bits.carve_track_south = 0;
|
|
|
|
to.bits.carve_track_west = 0;
|
|
|
|
map.setOccupancyAt(pos, to);
|
|
|
|
}
|
2021-05-16 15:16:21 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-01 18:38:04 -06:00
|
|
|
map.WriteAll();
|
2021-06-02 23:43:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
command_result dig_now(color_ostream &out, std::vector<std::string> &) {
|
|
|
|
CoreSuspender suspend;
|
|
|
|
|
|
|
|
if (!Maps::IsValid()) {
|
|
|
|
out.printerr("Map is not available!\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// tracks which positions to unhide
|
|
|
|
std::vector<DFCoord> dug_coords;
|
|
|
|
|
|
|
|
// scan the whole map for now. we can add in configurable boundaries later
|
|
|
|
DFCoord start(0, 0, 0);
|
|
|
|
uint32_t endx, endy, endz;
|
|
|
|
Maps::getTileSize(endx, endy, endz);
|
|
|
|
DFCoord end(endx, endy, endz);
|
|
|
|
|
|
|
|
do_dig(out, dug_coords, start, end);
|
2021-06-01 18:38:04 -06:00
|
|
|
|
2021-06-02 23:43:23 -06:00
|
|
|
// unhide newly dug tiles. we can't do this in do_dig() since our MapCache
|
|
|
|
// wouldn't detect the changes made by reveal.unhideFlood() without
|
|
|
|
// invalidating and reinitializing on every call
|
2021-06-02 23:18:42 -06:00
|
|
|
for (DFCoord pos : dug_coords) {
|
|
|
|
if (Maps::getTileDesignation(pos)->bits.hidden)
|
|
|
|
flood_unhide(out, pos);
|
|
|
|
}
|
|
|
|
|
2021-06-02 23:43:23 -06:00
|
|
|
// force the game to recompute its walkability cache
|
2021-05-16 15:16:21 -06:00
|
|
|
world->reindex_pathfinding = true;
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init(color_ostream &,
|
|
|
|
std::vector<PluginCommand> &commands) {
|
|
|
|
commands.push_back(PluginCommand(
|
2021-06-02 23:43:23 -06:00
|
|
|
"dig-now", "Instantly complete dig designations", dig_now, false));
|
2021-05-16 15:16:21 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown(color_ostream &) {
|
|
|
|
return CR_OK;
|
|
|
|
}
|