Merge remote-tracking branch 'myk002/myk_resume' into develop

develop
lethosor 2020-11-13 23:36:46 -05:00
commit 63bb1afcb6
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 22 additions and 2 deletions

@ -154,7 +154,7 @@ if(BUILD_SUPPORTED)
add_subdirectory(remotefortressreader) add_subdirectory(remotefortressreader)
dfhack_plugin(rename rename.cpp LINK_LIBRARIES lua PROTOBUFS rename) dfhack_plugin(rename rename.cpp LINK_LIBRARIES lua PROTOBUFS rename)
add_subdirectory(rendermax) add_subdirectory(rendermax)
dfhack_plugin(resume resume.cpp) dfhack_plugin(resume resume.cpp LINK_LIBRARIES lua)
dfhack_plugin(reveal reveal.cpp) dfhack_plugin(reveal reveal.cpp)
dfhack_plugin(search search.cpp) dfhack_plugin(search search.cpp)
dfhack_plugin(seedwatch seedwatch.cpp) dfhack_plugin(seedwatch seedwatch.cpp)

@ -11,6 +11,7 @@
// DF data structure definition headers // DF data structure definition headers
#include "DataDefs.h" #include "DataDefs.h"
#include "LuaTools.h"
#include "MiscUtils.h" #include "MiscUtils.h"
#include "Types.h" #include "Types.h"
#include "df/viewscreen_dwarfmodest.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); DFHACK_PLUGIN_IS_ENABLED(enabled);
static bool buildings_scanned = false; static bool buildings_scanned = false;
static vector<SuspendedBuilding> suspended_buildings, resumed_buildings; static vector<SuspendedBuilding> suspended_buildings, resumed_buildings;
@ -101,7 +121,7 @@ void scan_for_suspended_buildings()
if (job) if (job)
{ {
SuspendedBuilding sb(bld); 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(); auto it = resumed_buildings.begin();