diff --git a/LUA_API.rst b/LUA_API.rst
index 093dd943c..d8d53a4d1 100644
--- a/LUA_API.rst
+++ b/LUA_API.rst
@@ -1066,7 +1066,7 @@ Events:
Emitted when a burrow might have been renamed either through
the game UI, or ``renameBurrow()``.
-* ``onDigComplete.foo = function(job_type,pos,old_tiletype,new_tiletype)``
+* ``onDigComplete.foo = function(job_type,pos,old_tiletype,new_tiletype,worker)``
Emitted when a tile might have been dug out. Only tracked if the
auto-growing burrows feature is enabled.
diff --git a/Lua API.html b/Lua API.html
index b6242712a..846299a35 100644
--- a/Lua API.html
+++ b/Lua API.html
@@ -1245,7 +1245,7 @@ module file is still necessary for require to
Emitted when a burrow might have been renamed either through
the game UI, or renameBurrow().
-onDigComplete.foo = function(job_type,pos,old_tiletype,new_tiletype)
+onDigComplete.foo = function(job_type,pos,old_tiletype,new_tiletype,worker)
Emitted when a tile might have been dug out. Only tracked if the
auto-growing burrows feature is enabled.
diff --git a/library/include/DataFuncs.h b/library/include/DataFuncs.h
index 8b917ad70..aff04128c 100644
--- a/library/include/DataFuncs.h
+++ b/library/include/DataFuncs.h
@@ -143,6 +143,23 @@ INSTANTIATE_WRAPPERS(4, (OSTREAM_ARG,A1,A2,A3,A4), (out,vA1,vA2,vA3,vA4),
INSTANTIATE_RETURN_TYPE((A1,A2,A3,A4,A5))
INSTANTIATE_WRAPPERS(5, (A1,A2,A3,A4,A5), (vA1,vA2,vA3,vA4,vA5),
LOAD_ARG(A1); LOAD_ARG(A2); LOAD_ARG(A3); LOAD_ARG(A4); LOAD_ARG(A5);)
+INSTANTIATE_WRAPPERS(5, (OSTREAM_ARG,A1,A2,A3,A4,A5), (out,vA1,vA2,vA3,vA4,vA5),
+ LOAD_OSTREAM(out); LOAD_ARG(A1); LOAD_ARG(A2);
+ LOAD_ARG(A3); LOAD_ARG(A4); LOAD_ARG(A5);)
+#undef FW_TARGS
+
+#define FW_TARGS class A1, class A2, class A3, class A4, class A5, class A6
+INSTANTIATE_RETURN_TYPE((A1,A2,A3,A4,A5,A6))
+INSTANTIATE_WRAPPERS(6, (A1,A2,A3,A4,A5,A6), (vA1,vA2,vA3,vA4,vA5,vA6),
+ LOAD_ARG(A1); LOAD_ARG(A2); LOAD_ARG(A3);
+ LOAD_ARG(A4); LOAD_ARG(A5); LOAD_ARG(A6);)
+INSTANTIATE_WRAPPERS(6, (OSTREAM_ARG,A1,A2,A3,A4,A5,A6), (out,vA1,vA2,vA3,vA4,vA5,vA6),
+ LOAD_OSTREAM(out); LOAD_ARG(A1); LOAD_ARG(A2); LOAD_ARG(A3);
+ LOAD_ARG(A4); LOAD_ARG(A5); LOAD_ARG(A6);)
+#undef FW_TARGS
+
+#define FW_TARGS class A1, class A2, class A3, class A4, class A5, class A6, class A7
+INSTANTIATE_RETURN_TYPE((A1,A2,A3,A4,A5,A6,A7))
#undef FW_TARGS
#undef FW_TARGSC
diff --git a/library/include/LuaTools.h b/library/include/LuaTools.h
index c3a7921c3..a52db2572 100644
--- a/library/include/LuaTools.h
+++ b/library/include/LuaTools.h
@@ -424,3 +424,17 @@ namespace DFHack {namespace Lua {
name##_event.invoke(out, 4); \
} \
}
+
+#define DEFINE_LUA_EVENT_5(name, handler, arg_type1, arg_type2, arg_type3, arg_type4, arg_type5) \
+ static DFHack::Lua::Notification name##_event(df::wrap_function(handler, true)); \
+ void name(color_ostream &out, arg_type1 arg1, arg_type2 arg2, arg_type3 arg3, arg_type4 arg4, arg_type5 arg5) { \
+ handler(out, arg1, arg2, arg3, arg4, arg5); \
+ if (auto state = name##_event.get_state()) { \
+ DFHack::Lua::Push(state, arg1); \
+ DFHack::Lua::Push(state, arg2); \
+ DFHack::Lua::Push(state, arg3); \
+ DFHack::Lua::Push(state, arg4); \
+ DFHack::Lua::Push(state, arg5); \
+ name##_event.invoke(out, 5); \
+ } \
+ }
diff --git a/plugins/burrows.cpp b/plugins/burrows.cpp
index a6df3524b..9ff902c3d 100644
--- a/plugins/burrows.cpp
+++ b/plugins/burrows.cpp
@@ -153,10 +153,10 @@ static int next_job_id_save = 0;
static std::map diggers;
static void handle_dig_complete(color_ostream &out, df::job_type job, df::coord pos,
- df::tiletype old_tile, df::tiletype new_tile);
+ df::tiletype old_tile, df::tiletype new_tile, df::unit *worker);
-DEFINE_LUA_EVENT_4(onDigComplete, handle_dig_complete,
- df::job_type, df::coord, df::tiletype, df::tiletype);
+DEFINE_LUA_EVENT_5(onDigComplete, handle_dig_complete,
+ df::job_type, df::coord, df::tiletype, df::tiletype, df::unit*);
static void detect_digging(color_ostream &out)
{
@@ -179,10 +179,7 @@ static void detect_digging(color_ostream &out)
if (new_tile != it->second.old_tile)
{
- onDigComplete(out, it->second.job, pos, it->second.old_tile, new_tile);
-
- //if (worker && !worker->job.current_job)
- // worker->counters.think_counter = worker->counters.job_counter = 0;
+ onDigComplete(out, it->second.job, pos, it->second.old_tile, new_tile, worker);
}
}
@@ -370,7 +367,7 @@ static void add_walls_to_burrows(color_ostream &out, std::vector &b
}
static void handle_dig_complete(color_ostream &out, df::job_type job, df::coord pos,
- df::tiletype old_tile, df::tiletype new_tile)
+ df::tiletype old_tile, df::tiletype new_tile, df::unit *worker)
{
if (!isWalkable(new_tile))
return;
@@ -390,9 +387,11 @@ static void handle_dig_complete(color_ostream &out, df::job_type job, df::coord
return;
MapExtras::MapCache mc;
+ bool changed = false;
if (!isWalkable(old_tile))
{
+ changed = true;
add_walls_to_burrows(out, to_grow, mc, pos+df::coord(-1,-1,0), pos+df::coord(1,1,0));
if (isWalkableUp(new_tile))
@@ -407,6 +406,7 @@ static void handle_dig_complete(color_ostream &out, df::job_type job, df::coord
if (LowPassable(new_tile) && !LowPassable(old_tile))
{
+ changed = true;
add_to_burrows(to_grow, pos-df::coord(0,0,1));
if (tileShape(new_tile) == tiletype_shape::RAMP_TOP)
@@ -415,6 +415,9 @@ static void handle_dig_complete(color_ostream &out, df::job_type job, df::coord
pos+df::coord(-1,-1,-1), pos+df::coord(1,1,-1));
}
}
+
+ if (changed && worker && !worker->job.current_job)
+ Job::checkDesignationsNow();
}
static void renameBurrow(color_ostream &out, df::burrow *burrow, std::string name)