From d780dc684747f5cfb16310ed16e23c3f794bfdc0 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Sun, 29 Jan 2023 22:55:11 -0600 Subject: [PATCH] reenable autolabor for testing minimum required to make work: * realign the job table * add code to flip/flop the work detail enable flag --- plugins/CMakeLists.txt | 2 +- plugins/autolabor/CMakeLists.txt | 2 +- plugins/autolabor/autolabor.cpp | 7 +++++++ plugins/autolabor/laborstatemap.h | 16 +++++++--------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index d5f35fb21..76c80b156 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -81,7 +81,7 @@ dfhack_plugin(autoclothing autoclothing.cpp) dfhack_plugin(autodump autodump.cpp) dfhack_plugin(autofarm autofarm.cpp) #dfhack_plugin(autogems autogems.cpp LINK_LIBRARIES jsoncpp_static) -#add_subdirectory(autolabor) +add_subdirectory(autolabor) #dfhack_plugin(automaterial automaterial.cpp LINK_LIBRARIES lua) dfhack_plugin(automelt automelt.cpp LINK_LIBRARIES lua) #dfhack_plugin(autonestbox autonestbox.cpp LINK_LIBRARIES lua) diff --git a/plugins/autolabor/CMakeLists.txt b/plugins/autolabor/CMakeLists.txt index 554a02ecf..b443a156f 100644 --- a/plugins/autolabor/CMakeLists.txt +++ b/plugins/autolabor/CMakeLists.txt @@ -10,6 +10,6 @@ set_source_files_properties(${COMMON_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) # mash them together (headers are marked as headers and nothing will try to compile them) list(APPEND COMMON_SRCS ${COMMON_HDRS}) -dfhack_plugin(labormanager labormanager.cpp joblabormapper.cpp ${COMMON_SRCS}) +#dfhack_plugin(labormanager labormanager.cpp joblabormapper.cpp ${COMMON_SRCS}) dfhack_plugin(autolabor autolabor.cpp ${COMMON_SRCS}) diff --git a/plugins/autolabor/autolabor.cpp b/plugins/autolabor/autolabor.cpp index 0af4be5e2..66aaa2f75 100644 --- a/plugins/autolabor/autolabor.cpp +++ b/plugins/autolabor/autolabor.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include @@ -49,6 +51,7 @@ using namespace df::enums; DFHACK_PLUGIN("autolabor"); REQUIRE_GLOBAL(plotinfo); REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(game); #define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0])) @@ -399,6 +402,8 @@ static void enable_plugin(color_ostream &out) cleanup_state(); init_state(); + + df::global::game->external_flag |= 1; // shut down DF's work detail system } DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) @@ -1065,6 +1070,8 @@ DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable ) enable_autolabor = false; setOptionEnabled(CF_ENABLED, false); + df::global::game->external_flag &= ~1; // reenable DF's work detail system + out << "Autolabor is disabled." << std::endl; } diff --git a/plugins/autolabor/laborstatemap.h b/plugins/autolabor/laborstatemap.h index 789685930..61cebdd9c 100644 --- a/plugins/autolabor/laborstatemap.h +++ b/plugins/autolabor/laborstatemap.h @@ -42,6 +42,8 @@ char const* state_names[] { const dwarf_state dwarf_states[] = { dwarf_state::BUSY /* CarveFortification */, + dwarf_state::BUSY /* SmoothWall */, + dwarf_state::BUSY /* SmoothFloor */, dwarf_state::BUSY /* DetailWall */, dwarf_state::BUSY /* DetailFloor */, dwarf_state::EXCLUSIVE /* Dig */, @@ -75,21 +77,17 @@ const dwarf_state dwarf_states[] = { dwarf_state::BUSY /* CatchLiveLandAnimal */, dwarf_state::BUSY /* CatchLiveFish */, dwarf_state::BUSY /* ReturnKill */, - dwarf_state::BUSY /* CheckChest */, dwarf_state::BUSY /* StoreOwnedItem */, dwarf_state::BUSY /* PlaceItemInTomb */, dwarf_state::BUSY /* StoreItemInStockpile */, dwarf_state::BUSY /* StoreItemInBag */, - dwarf_state::BUSY /* StoreItemInHospital */, - dwarf_state::BUSY /* StoreItemInChest */, - dwarf_state::BUSY /* StoreItemInCabinet */, + dwarf_state::BUSY /* StoreItemInLocation */, dwarf_state::BUSY /* StoreWeapon */, dwarf_state::BUSY /* StoreArmor */, dwarf_state::BUSY /* StoreItemInBarrel */, dwarf_state::BUSY /* StoreItemInBin */, dwarf_state::BUSY /* SeekArtifact */, dwarf_state::BUSY /* SeekInfant */, - dwarf_state::OTHER /* AttendParty */, dwarf_state::OTHER /* GoShopping */, dwarf_state::OTHER /* GoShopping2 */, dwarf_state::BUSY /* Clean */, @@ -117,6 +115,7 @@ const dwarf_state dwarf_states[] = { dwarf_state::BUSY /* ConstructCoffin */, dwarf_state::BUSY /* ConstructTable */, dwarf_state::BUSY /* ConstructChest */, + dwarf_state::BUSY /* ConstructBag */, dwarf_state::BUSY /* ConstructBin */, dwarf_state::BUSY /* ConstructArmorStand */, dwarf_state::BUSY /* ConstructWeaponRack */, @@ -153,7 +152,7 @@ const dwarf_state dwarf_states[] = { dwarf_state::BUSY /* MilkCreature */, dwarf_state::BUSY /* MakeCheese */, dwarf_state::BUSY /* ProcessPlants */, - dwarf_state::BUSY /* ProcessPlantsBag */, + dwarf_state::BUSY /* PolishStones */, dwarf_state::BUSY /* ProcessPlantsVial */, dwarf_state::BUSY /* ProcessPlantsBarrel */, dwarf_state::BUSY /* PrepareMeal */, @@ -165,7 +164,6 @@ const dwarf_state dwarf_states[] = { dwarf_state::BUSY /* MakeChain */, dwarf_state::BUSY /* MakeFlask */, dwarf_state::BUSY /* MakeGoblet */, - dwarf_state::BUSY /* MakeInstrument */, dwarf_state::BUSY /* MakeToy */, dwarf_state::BUSY /* MakeAnimalTrap */, dwarf_state::BUSY /* MakeBarrel */, @@ -188,10 +186,10 @@ const dwarf_state dwarf_states[] = { dwarf_state::BUSY /* LoadStoneTrap */, dwarf_state::BUSY /* LoadWeaponTrap */, dwarf_state::BUSY /* CleanTrap */, - dwarf_state::BUSY /* CastSpell */, + dwarf_state::BUSY /* EncrustWithStones */, dwarf_state::BUSY /* LinkBuildingToTrigger */, dwarf_state::BUSY /* PullLever */, - dwarf_state::BUSY /* BrewDrink */, + dwarf_state::OTHER /* _unk_0x94*/, dwarf_state::BUSY /* ExtractFromPlants */, dwarf_state::BUSY /* ExtractFromRawFish */, dwarf_state::BUSY /* ExtractFromLandAnimal */,