detect buildingplan buildings in the resume plugin

develop
myk002 2020-11-13 12:43:46 -08:00
parent bd278bbe68
commit 59e76ae407
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 22 additions and 2 deletions

@ -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)

@ -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<SuspendedBuilding> 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();