diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 9f5b2c679..822ab531b 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -154,7 +154,7 @@ if(BUILD_SUPPORTED) add_subdirectory(remotefortressreader) dfhack_plugin(rename rename.cpp LINK_LIBRARIES lua PROTOBUFS rename) add_subdirectory(rendermax) - dfhack_plugin(resume resume.cpp) + dfhack_plugin(resume resume.cpp LINK_LIBRARIES lua) dfhack_plugin(reveal reveal.cpp) dfhack_plugin(search search.cpp) dfhack_plugin(seedwatch seedwatch.cpp) diff --git a/plugins/resume.cpp b/plugins/resume.cpp index 5909c0956..b4398dd24 100644 --- a/plugins/resume.cpp +++ b/plugins/resume.cpp @@ -11,6 +11,7 @@ // DF data structure definition headers #include "DataDefs.h" +#include "LuaTools.h" #include "MiscUtils.h" #include "Types.h" #include "df/viewscreen_dwarfmodest.h" @@ -85,6 +86,25 @@ struct SuspendedBuilding } }; +static bool is_planned_building(df::building *bld) +{ + auto L = Lua::Core::State; + color_ostream_proxy out(Core::getInstance().getConsole()); + Lua::StackUnwinder top(L); + + if (!lua_checkstack(L, 2) || + !Lua::PushModulePublic( + out, L, "plugins.buildingplan", "isPlannedBuilding")) + return false; + + Lua::Push(L, bld); + + if (!Lua::SafeCall(out, L, 1, 1)) + return false; + + return lua_toboolean(L, -1); +} + DFHACK_PLUGIN_IS_ENABLED(enabled); static bool buildings_scanned = false; static vector suspended_buildings, resumed_buildings; @@ -101,7 +121,7 @@ void scan_for_suspended_buildings() if (job) { SuspendedBuilding sb(bld); - sb.is_planned = job->job_items.size() == 1 && job->job_items[0]->item_type == item_type::NONE; + sb.is_planned = is_planned_building(bld); auto it = resumed_buildings.begin();