refactor common labor state map table

eliminates code duplication
develop
Kelly Kinkade 2022-11-20 10:09:52 -06:00
parent aa78c626f9
commit 2453b34194
5 changed files with 302 additions and 836 deletions

@ -3,7 +3,7 @@ project(autolahor)
set(COMMON_SRCS
)
# A list of headers
set(COMMON_HDRS
set(COMMON_HDRS laborstatemap.h
)
set_source_files_properties(${COMMON_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)

@ -43,6 +43,8 @@
#include "modules/Items.h"
#include "modules/Units.h"
#include "laborstatemap.h"
// Not sure what this does, but may have to figure it out later
#define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0]))
@ -127,290 +129,7 @@ static void setOptionEnabled(ConfigFlags flag, bool on)
}
// This is a vector of states and number of dwarves in that state
static std::vector<int> state_count(5);
// Employment status of dwarves
enum dwarf_state {
// Ready for a new task
IDLE,
// Busy with a useful task
BUSY,
// In the military, can't work
MILITARY,
// Baby or Child, can't work
CHILD,
// Doing something that precludes working, may be busy for a while
OTHER
};
// I presume this is the number of states in the following enumeration.
static const int NUM_STATE = 5;
// This is a list of strings to be associated with aforementioned dwarf_state
// struct
static const char *state_names[] = {
"IDLE",
"BUSY",
"MILITARY",
"CHILD",
"OTHER"
};
// List of possible activites of a dwarf that will be further narrowed to states
// IDLE - Specifically waiting to be assigned a task (No Job)
// BUSY - Performing a toggleable labor, or a support action for that labor.
// OTHER - Doing something else
static const dwarf_state dwarf_states[] = {
BUSY /* CarveFortification */,
BUSY /* DetailWall */,
BUSY /* DetailFloor */,
BUSY /* Dig */,
BUSY /* CarveUpwardStaircase */,
BUSY /* CarveDownwardStaircase */,
BUSY /* CarveUpDownStaircase */,
BUSY /* CarveRamp */,
BUSY /* DigChannel */,
BUSY /* FellTree */,
BUSY /* GatherPlants */,
BUSY /* RemoveConstruction */,
BUSY /* CollectWebs */,
BUSY /* BringItemToDepot */,
BUSY /* BringItemToShop */,
OTHER /* Eat */,
OTHER /* GetProvisions */,
OTHER /* Drink */,
OTHER /* Drink2 */,
OTHER /* FillWaterskin */,
OTHER /* FillWaterskin2 */,
OTHER /* Sleep */,
BUSY /* CollectSand */,
BUSY /* Fish */,
BUSY /* Hunt */,
BUSY /* HuntVermin */,
OTHER /* Kidnap */,
OTHER /* BeatCriminal */,
OTHER /* StartingFistFight */,
OTHER /* CollectTaxes */,
OTHER /* GuardTaxCollector */,
BUSY /* CatchLiveLandAnimal */,
BUSY /* CatchLiveFish */,
OTHER /* ReturnKill */,
OTHER /* CheckChest */,
OTHER /* StoreOwnedItem */,
BUSY /* PlaceItemInTomb */,
BUSY /* StoreItemInStockpile */,
BUSY /* StoreItemInBag */,
BUSY /* StoreItemInHospital */,
BUSY /* StoreItemInChest */,
BUSY /* StoreItemInCabinet */,
BUSY /* StoreWeapon */,
BUSY /* StoreArmor */,
BUSY /* StoreItemInBarrel */,
BUSY /* StoreItemInBin */,
OTHER /* SeekArtifact */,
OTHER /* SeekInfant */,
OTHER /* AttendParty */,
OTHER /* GoShopping */,
OTHER /* GoShopping2 */,
OTHER /* Clean */,
OTHER /* Rest */,
BUSY /* PickupEquipment */,
BUSY /* DumpItem */,
OTHER /* StrangeMoodCrafter */,
OTHER /* StrangeMoodJeweller */,
OTHER /* StrangeMoodForge */,
OTHER /* StrangeMoodMagmaForge */,
OTHER /* StrangeMoodBrooding */,
OTHER /* StrangeMoodFell */,
OTHER /* StrangeMoodCarpenter */,
OTHER /* StrangeMoodMason */,
OTHER /* StrangeMoodBowyer */,
OTHER /* StrangeMoodTanner */,
OTHER /* StrangeMoodWeaver */,
OTHER /* StrangeMoodGlassmaker */,
OTHER /* StrangeMoodMechanics */,
BUSY /* ConstructBuilding */,
BUSY /* ConstructDoor */,
BUSY /* ConstructFloodgate */,
BUSY /* ConstructBed */,
BUSY /* ConstructThrone */,
BUSY /* ConstructCoffin */,
BUSY /* ConstructTable */,
BUSY /* ConstructChest */,
BUSY /* ConstructBin */,
BUSY /* ConstructArmorStand */,
BUSY /* ConstructWeaponRack */,
BUSY /* ConstructCabinet */,
BUSY /* ConstructStatue */,
BUSY /* ConstructBlocks */,
BUSY /* MakeRawGlass */,
BUSY /* MakeCrafts */,
BUSY /* MintCoins */,
BUSY /* CutGems */,
BUSY /* CutGlass */,
BUSY /* EncrustWithGems */,
BUSY /* EncrustWithGlass */,
BUSY /* DestroyBuilding */,
BUSY /* SmeltOre */,
BUSY /* MeltMetalObject */,
BUSY /* ExtractMetalStrands */,
BUSY /* PlantSeeds */,
BUSY /* HarvestPlants */,
BUSY /* TrainHuntingAnimal */,
BUSY /* TrainWarAnimal */,
BUSY /* MakeWeapon */,
BUSY /* ForgeAnvil */,
BUSY /* ConstructCatapultParts */,
BUSY /* ConstructBallistaParts */,
BUSY /* MakeArmor */,
BUSY /* MakeHelm */,
BUSY /* MakePants */,
BUSY /* StudWith */,
BUSY /* ButcherAnimal */,
BUSY /* PrepareRawFish */,
BUSY /* MillPlants */,
BUSY /* BaitTrap */,
BUSY /* MilkCreature */,
BUSY /* MakeCheese */,
BUSY /* ProcessPlants */,
BUSY /* ProcessPlantsBag */,
BUSY /* ProcessPlantsVial */,
BUSY /* ProcessPlantsBarrel */,
BUSY /* PrepareMeal */,
BUSY /* WeaveCloth */,
BUSY /* MakeGloves */,
BUSY /* MakeShoes */,
BUSY /* MakeShield */,
BUSY /* MakeCage */,
BUSY /* MakeChain */,
BUSY /* MakeFlask */,
BUSY /* MakeGoblet */,
BUSY /* MakeInstrument */,
BUSY /* MakeToy */,
BUSY /* MakeAnimalTrap */,
BUSY /* MakeBarrel */,
BUSY /* MakeBucket */,
BUSY /* MakeWindow */,
BUSY /* MakeTotem */,
BUSY /* MakeAmmo */,
BUSY /* DecorateWith */,
BUSY /* MakeBackpack */,
BUSY /* MakeQuiver */,
BUSY /* MakeBallistaArrowHead */,
BUSY /* AssembleSiegeAmmo */,
BUSY /* LoadCatapult */,
BUSY /* LoadBallista */,
BUSY /* FireCatapult */,
BUSY /* FireBallista */,
BUSY /* ConstructMechanisms */,
BUSY /* MakeTrapComponent */,
BUSY /* LoadCageTrap */,
BUSY /* LoadStoneTrap */,
BUSY /* LoadWeaponTrap */,
BUSY /* CleanTrap */,
OTHER /* CastSpell */,
BUSY /* LinkBuildingToTrigger */,
BUSY /* PullLever */,
BUSY /* BrewDrink */,
BUSY /* ExtractFromPlants */,
BUSY /* ExtractFromRawFish */,
BUSY /* ExtractFromLandAnimal */,
BUSY /* TameVermin */,
BUSY /* TameAnimal */,
BUSY /* ChainAnimal */,
BUSY /* UnchainAnimal */,
BUSY /* UnchainPet */,
BUSY /* ReleaseLargeCreature */,
BUSY /* ReleasePet */,
BUSY /* ReleaseSmallCreature */,
BUSY /* HandleSmallCreature */,
BUSY /* HandleLargeCreature */,
BUSY /* CageLargeCreature */,
BUSY /* CageSmallCreature */,
BUSY /* RecoverWounded */,
BUSY /* DiagnosePatient */,
BUSY /* ImmobilizeBreak */,
BUSY /* DressWound */,
BUSY /* CleanPatient */,
BUSY /* Surgery */,
BUSY /* Suture */,
BUSY /* SetBone */,
BUSY /* PlaceInTraction */,
BUSY /* DrainAquarium */,
BUSY /* FillAquarium */,
BUSY /* FillPond */,
BUSY /* GiveWater */,
BUSY /* GiveFood */,
BUSY /* GiveWater2 */,
BUSY /* GiveFood2 */,
BUSY /* RecoverPet */,
BUSY /* PitLargeAnimal */,
BUSY /* PitSmallAnimal */,
BUSY /* SlaughterAnimal */,
BUSY /* MakeCharcoal */,
BUSY /* MakeAsh */,
BUSY /* MakeLye */,
BUSY /* MakePotashFromLye */,
BUSY /* FertilizeField */,
BUSY /* MakePotashFromAsh */,
BUSY /* DyeThread */,
BUSY /* DyeCloth */,
BUSY /* SewImage */,
BUSY /* MakePipeSection */,
BUSY /* OperatePump */,
OTHER /* ManageWorkOrders */,
OTHER /* UpdateStockpileRecords */,
OTHER /* TradeAtDepot */,
BUSY /* ConstructHatchCover */,
BUSY /* ConstructGrate */,
BUSY /* RemoveStairs */,
BUSY /* ConstructQuern */,
BUSY /* ConstructMillstone */,
BUSY /* ConstructSplint */,
BUSY /* ConstructCrutch */,
BUSY /* ConstructTractionBench */,
OTHER /* CleanSelf */,
BUSY /* BringCrutch */,
BUSY /* ApplyCast */,
BUSY /* CustomReaction */,
BUSY /* ConstructSlab */,
BUSY /* EngraveSlab */,
BUSY /* ShearCreature */,
BUSY /* SpinThread */,
BUSY /* PenLargeAnimal */,
BUSY /* PenSmallAnimal */,
BUSY /* MakeTool */,
BUSY /* CollectClay */,
BUSY /* InstallColonyInHive */,
BUSY /* CollectHiveProducts */,
OTHER /* CauseTrouble */,
OTHER /* DrinkBlood */,
OTHER /* ReportCrime */,
OTHER /* ExecuteCriminal */,
BUSY /* TrainAnimal */,
BUSY /* CarveTrack */,
BUSY /* PushTrackVehicle */,
BUSY /* PlaceTrackVehicle */,
BUSY /* StoreItemInVehicle */,
BUSY /* GeldAnimal */,
BUSY /* MakeFigurine */,
BUSY /* MakeAmulet */,
BUSY /* MakeScepter */,
BUSY /* MakeCrown */,
BUSY /* MakeRing */,
BUSY /* MakeEarring */,
BUSY /* MakeBracelet */,
BUSY /* MakeGem */,
BUSY /* PutItemOnDisplay */,
OTHER /* unk_fake_no_job */,
OTHER /* InterrogateSubject */,
OTHER /* unk_fake_no_activity */,
};
static std::vector<int> state_count(NUM_STATE);
// Mode assigned to labors. Either it's a hauling job, or it's not.
enum labor_mode {

@ -40,6 +40,8 @@
#include "modules/Items.h"
#include "modules/Units.h"
#include "laborstatemap.h"
using std::string;
using std::endl;
using std::vector;
@ -102,283 +104,6 @@ enum labor_mode {
AUTOMATIC,
};
enum dwarf_state {
// Ready for a new task
IDLE,
// Busy with a useful task
BUSY,
// Busy with a useful task that requires a tool
EXCLUSIVE,
// In the military, can't work
MILITARY,
// Child or noble, can't work
CHILD,
// Doing something that precludes working, may be busy for a while
OTHER
};
const int NUM_STATE = 6;
static const char *state_names[] = {
"IDLE",
"BUSY",
"EXCLUSIVE",
"MILITARY",
"CHILD",
"OTHER",
};
static const dwarf_state dwarf_states[] = {
BUSY /* CarveFortification */,
BUSY /* DetailWall */,
BUSY /* DetailFloor */,
EXCLUSIVE /* Dig */,
EXCLUSIVE /* CarveUpwardStaircase */,
EXCLUSIVE /* CarveDownwardStaircase */,
EXCLUSIVE /* CarveUpDownStaircase */,
EXCLUSIVE /* CarveRamp */,
EXCLUSIVE /* DigChannel */,
EXCLUSIVE /* FellTree */,
BUSY /* GatherPlants */,
BUSY /* RemoveConstruction */,
BUSY /* CollectWebs */,
BUSY /* BringItemToDepot */,
BUSY /* BringItemToShop */,
OTHER /* Eat */,
OTHER /* GetProvisions */,
OTHER /* Drink */,
OTHER /* Drink2 */,
OTHER /* FillWaterskin */,
OTHER /* FillWaterskin2 */,
OTHER /* Sleep */,
BUSY /* CollectSand */,
BUSY /* Fish */,
EXCLUSIVE /* Hunt */,
OTHER /* HuntVermin */,
BUSY /* Kidnap */,
BUSY /* BeatCriminal */,
BUSY /* StartingFistFight */,
BUSY /* CollectTaxes */,
BUSY /* GuardTaxCollector */,
BUSY /* CatchLiveLandAnimal */,
BUSY /* CatchLiveFish */,
BUSY /* ReturnKill */,
BUSY /* CheckChest */,
BUSY /* StoreOwnedItem */,
BUSY /* PlaceItemInTomb */,
BUSY /* StoreItemInStockpile */,
BUSY /* StoreItemInBag */,
BUSY /* StoreItemInHospital */,
BUSY /* StoreItemInChest */,
BUSY /* StoreItemInCabinet */,
BUSY /* StoreWeapon */,
BUSY /* StoreArmor */,
BUSY /* StoreItemInBarrel */,
BUSY /* StoreItemInBin */,
BUSY /* SeekArtifact */,
BUSY /* SeekInfant */,
OTHER /* AttendParty */,
OTHER /* GoShopping */,
OTHER /* GoShopping2 */,
BUSY /* Clean */,
OTHER /* Rest */,
EXCLUSIVE /* PickupEquipment */,
BUSY /* DumpItem */,
OTHER /* StrangeMoodCrafter */,
OTHER /* StrangeMoodJeweller */,
OTHER /* StrangeMoodForge */,
OTHER /* StrangeMoodMagmaForge */,
OTHER /* StrangeMoodBrooding */,
OTHER /* StrangeMoodFell */,
OTHER /* StrangeMoodCarpenter */,
OTHER /* StrangeMoodMason */,
OTHER /* StrangeMoodBowyer */,
OTHER /* StrangeMoodTanner */,
OTHER /* StrangeMoodWeaver */,
OTHER /* StrangeMoodGlassmaker */,
OTHER /* StrangeMoodMechanics */,
BUSY /* ConstructBuilding */,
BUSY /* ConstructDoor */,
BUSY /* ConstructFloodgate */,
BUSY /* ConstructBed */,
BUSY /* ConstructThrone */,
BUSY /* ConstructCoffin */,
BUSY /* ConstructTable */,
BUSY /* ConstructChest */,
BUSY /* ConstructBin */,
BUSY /* ConstructArmorStand */,
BUSY /* ConstructWeaponRack */,
BUSY /* ConstructCabinet */,
BUSY /* ConstructStatue */,
BUSY /* ConstructBlocks */,
BUSY /* MakeRawGlass */,
BUSY /* MakeCrafts */,
BUSY /* MintCoins */,
BUSY /* CutGems */,
BUSY /* CutGlass */,
BUSY /* EncrustWithGems */,
BUSY /* EncrustWithGlass */,
BUSY /* DestroyBuilding */,
BUSY /* SmeltOre */,
BUSY /* MeltMetalObject */,
BUSY /* ExtractMetalStrands */,
BUSY /* PlantSeeds */,
BUSY /* HarvestPlants */,
BUSY /* TrainHuntingAnimal */,
BUSY /* TrainWarAnimal */,
BUSY /* MakeWeapon */,
BUSY /* ForgeAnvil */,
BUSY /* ConstructCatapultParts */,
BUSY /* ConstructBallistaParts */,
BUSY /* MakeArmor */,
BUSY /* MakeHelm */,
BUSY /* MakePants */,
BUSY /* StudWith */,
BUSY /* ButcherAnimal */,
BUSY /* PrepareRawFish */,
BUSY /* MillPlants */,
BUSY /* BaitTrap */,
BUSY /* MilkCreature */,
BUSY /* MakeCheese */,
BUSY /* ProcessPlants */,
BUSY /* ProcessPlantsBag */,
BUSY /* ProcessPlantsVial */,
BUSY /* ProcessPlantsBarrel */,
BUSY /* PrepareMeal */,
BUSY /* WeaveCloth */,
BUSY /* MakeGloves */,
BUSY /* MakeShoes */,
BUSY /* MakeShield */,
BUSY /* MakeCage */,
BUSY /* MakeChain */,
BUSY /* MakeFlask */,
BUSY /* MakeGoblet */,
BUSY /* MakeInstrument */,
BUSY /* MakeToy */,
BUSY /* MakeAnimalTrap */,
BUSY /* MakeBarrel */,
BUSY /* MakeBucket */,
BUSY /* MakeWindow */,
BUSY /* MakeTotem */,
BUSY /* MakeAmmo */,
BUSY /* DecorateWith */,
BUSY /* MakeBackpack */,
BUSY /* MakeQuiver */,
BUSY /* MakeBallistaArrowHead */,
BUSY /* AssembleSiegeAmmo */,
BUSY /* LoadCatapult */,
BUSY /* LoadBallista */,
BUSY /* FireCatapult */,
BUSY /* FireBallista */,
BUSY /* ConstructMechanisms */,
BUSY /* MakeTrapComponent */,
BUSY /* LoadCageTrap */,
BUSY /* LoadStoneTrap */,
BUSY /* LoadWeaponTrap */,
BUSY /* CleanTrap */,
BUSY /* CastSpell */,
BUSY /* LinkBuildingToTrigger */,
BUSY /* PullLever */,
BUSY /* BrewDrink */,
BUSY /* ExtractFromPlants */,
BUSY /* ExtractFromRawFish */,
BUSY /* ExtractFromLandAnimal */,
BUSY /* TameVermin */,
BUSY /* TameAnimal */,
BUSY /* ChainAnimal */,
BUSY /* UnchainAnimal */,
BUSY /* UnchainPet */,
BUSY /* ReleaseLargeCreature */,
BUSY /* ReleasePet */,
BUSY /* ReleaseSmallCreature */,
BUSY /* HandleSmallCreature */,
BUSY /* HandleLargeCreature */,
BUSY /* CageLargeCreature */,
BUSY /* CageSmallCreature */,
BUSY /* RecoverWounded */,
BUSY /* DiagnosePatient */,
BUSY /* ImmobilizeBreak */,
BUSY /* DressWound */,
BUSY /* CleanPatient */,
BUSY /* Surgery */,
BUSY /* Suture */,
BUSY /* SetBone */,
BUSY /* PlaceInTraction */,
BUSY /* DrainAquarium */,
BUSY /* FillAquarium */,
BUSY /* FillPond */,
BUSY /* GiveWater */,
BUSY /* GiveFood */,
BUSY /* GiveWater2 */,
BUSY /* GiveFood2 */,
BUSY /* RecoverPet */,
BUSY /* PitLargeAnimal */,
BUSY /* PitSmallAnimal */,
BUSY /* SlaughterAnimal */,
BUSY /* MakeCharcoal */,
BUSY /* MakeAsh */,
BUSY /* MakeLye */,
BUSY /* MakePotashFromLye */,
BUSY /* FertilizeField */,
BUSY /* MakePotashFromAsh */,
BUSY /* DyeThread */,
BUSY /* DyeCloth */,
BUSY /* SewImage */,
BUSY /* MakePipeSection */,
BUSY /* OperatePump */,
OTHER /* ManageWorkOrders */,
OTHER /* UpdateStockpileRecords */,
OTHER /* TradeAtDepot */,
BUSY /* ConstructHatchCover */,
BUSY /* ConstructGrate */,
BUSY /* RemoveStairs */,
BUSY /* ConstructQuern */,
BUSY /* ConstructMillstone */,
BUSY /* ConstructSplint */,
BUSY /* ConstructCrutch */,
BUSY /* ConstructTractionBench */,
BUSY /* CleanSelf */,
BUSY /* BringCrutch */,
BUSY /* ApplyCast */,
BUSY /* CustomReaction */,
BUSY /* ConstructSlab */,
BUSY /* EngraveSlab */,
BUSY /* ShearCreature */,
BUSY /* SpinThread */,
BUSY /* PenLargeAnimal */,
BUSY /* PenSmallAnimal */,
BUSY /* MakeTool */,
BUSY /* CollectClay */,
BUSY /* InstallColonyInHive */,
BUSY /* CollectHiveProducts */,
OTHER /* CauseTrouble */,
OTHER /* DrinkBlood */,
OTHER /* ReportCrime */,
OTHER /* ExecuteCriminal */,
BUSY /* TrainAnimal */,
BUSY /* CarveTrack */,
BUSY /* PushTrackVehicle */,
BUSY /* PlaceTrackVehicle */,
BUSY /* StoreItemInVehicle */,
BUSY /* GeldAnimal */,
BUSY /* MakeFigurine */,
BUSY /* MakeAmulet */,
BUSY /* MakeScepter */,
BUSY /* MakeCrown */,
BUSY /* MakeRing */,
BUSY /* MakeEarring */,
BUSY /* MakeBracelet */,
BUSY /* MakeGem */,
BUSY /* PutItemOnDisplay */,
OTHER /* unk_fake_no_job */,
OTHER /* InterrogateSubject */,
OTHER /* unk_fake_no_activity */,
};
struct labor_info
{

@ -75,6 +75,8 @@
#include "labormanager.h"
#include "joblabormapper.h"
#include "laborstatemap.h"
using namespace std;
using std::string;
using std::endl;
@ -116,280 +118,6 @@ DFHACK_PLUGIN("labormanager");
static void generate_labor_to_skill_map();
enum dwarf_state {
// Ready for a new task
IDLE,
// Busy with a useful task
BUSY,
// In the military, can't work
MILITARY,
// Child or noble, can't work
CHILD,
// Doing something that precludes working, may be busy for a while
OTHER
};
const int NUM_STATE = 5;
static const char *state_names[] = {
"IDLE",
"BUSY",
"MILITARY",
"CHILD",
"OTHER",
};
static const dwarf_state dwarf_states[] = {
BUSY /* CarveFortification */,
BUSY /* DetailWall */,
BUSY /* DetailFloor */,
BUSY /* Dig */,
BUSY /* CarveUpwardStaircase */,
BUSY /* CarveDownwardStaircase */,
BUSY /* CarveUpDownStaircase */,
BUSY /* CarveRamp */,
BUSY /* DigChannel */,
BUSY /* FellTree */,
BUSY /* GatherPlants */,
BUSY /* RemoveConstruction */,
BUSY /* CollectWebs */,
BUSY /* BringItemToDepot */,
BUSY /* BringItemToShop */,
OTHER /* Eat */,
OTHER /* GetProvisions */,
OTHER /* Drink */,
OTHER /* Drink2 */,
OTHER /* FillWaterskin */,
OTHER /* FillWaterskin2 */,
OTHER /* Sleep */,
BUSY /* CollectSand */,
BUSY /* Fish */,
BUSY /* Hunt */,
OTHER /* HuntVermin */,
BUSY /* Kidnap */,
BUSY /* BeatCriminal */,
BUSY /* StartingFistFight */,
BUSY /* CollectTaxes */,
BUSY /* GuardTaxCollector */,
BUSY /* CatchLiveLandAnimal */,
BUSY /* CatchLiveFish */,
BUSY /* ReturnKill */,
BUSY /* CheckChest */,
BUSY /* StoreOwnedItem */,
BUSY /* PlaceItemInTomb */,
BUSY /* StoreItemInStockpile */,
BUSY /* StoreItemInBag */,
BUSY /* StoreItemInHospital */,
BUSY /* StoreItemInChest */,
BUSY /* StoreItemInCabinet */,
BUSY /* StoreWeapon */,
BUSY /* StoreArmor */,
BUSY /* StoreItemInBarrel */,
BUSY /* StoreItemInBin */,
BUSY /* SeekArtifact */,
BUSY /* SeekInfant */,
OTHER /* AttendParty */,
OTHER /* GoShopping */,
OTHER /* GoShopping2 */,
BUSY /* Clean */,
OTHER /* Rest */,
OTHER /* PickupEquipment */,
BUSY /* DumpItem */,
OTHER /* StrangeMoodCrafter */,
OTHER /* StrangeMoodJeweller */,
OTHER /* StrangeMoodForge */,
OTHER /* StrangeMoodMagmaForge */,
OTHER /* StrangeMoodBrooding */,
OTHER /* StrangeMoodFell */,
OTHER /* StrangeMoodCarpenter */,
OTHER /* StrangeMoodMason */,
OTHER /* StrangeMoodBowyer */,
OTHER /* StrangeMoodTanner */,
OTHER /* StrangeMoodWeaver */,
OTHER /* StrangeMoodGlassmaker */,
OTHER /* StrangeMoodMechanics */,
BUSY /* ConstructBuilding */,
BUSY /* ConstructDoor */,
BUSY /* ConstructFloodgate */,
BUSY /* ConstructBed */,
BUSY /* ConstructThrone */,
BUSY /* ConstructCoffin */,
BUSY /* ConstructTable */,
BUSY /* ConstructChest */,
BUSY /* ConstructBin */,
BUSY /* ConstructArmorStand */,
BUSY /* ConstructWeaponRack */,
BUSY /* ConstructCabinet */,
BUSY /* ConstructStatue */,
BUSY /* ConstructBlocks */,
BUSY /* MakeRawGlass */,
BUSY /* MakeCrafts */,
BUSY /* MintCoins */,
BUSY /* CutGems */,
BUSY /* CutGlass */,
BUSY /* EncrustWithGems */,
BUSY /* EncrustWithGlass */,
BUSY /* DestroyBuilding */,
BUSY /* SmeltOre */,
BUSY /* MeltMetalObject */,
BUSY /* ExtractMetalStrands */,
BUSY /* PlantSeeds */,
BUSY /* HarvestPlants */,
BUSY /* TrainHuntingAnimal */,
BUSY /* TrainWarAnimal */,
BUSY /* MakeWeapon */,
BUSY /* ForgeAnvil */,
BUSY /* ConstructCatapultParts */,
BUSY /* ConstructBallistaParts */,
BUSY /* MakeArmor */,
BUSY /* MakeHelm */,
BUSY /* MakePants */,
BUSY /* StudWith */,
BUSY /* ButcherAnimal */,
BUSY /* PrepareRawFish */,
BUSY /* MillPlants */,
BUSY /* BaitTrap */,
BUSY /* MilkCreature */,
BUSY /* MakeCheese */,
BUSY /* ProcessPlants */,
BUSY /* ProcessPlantsBag */,
BUSY /* ProcessPlantsVial */,
BUSY /* ProcessPlantsBarrel */,
BUSY /* PrepareMeal */,
BUSY /* WeaveCloth */,
BUSY /* MakeGloves */,
BUSY /* MakeShoes */,
BUSY /* MakeShield */,
BUSY /* MakeCage */,
BUSY /* MakeChain */,
BUSY /* MakeFlask */,
BUSY /* MakeGoblet */,
BUSY /* MakeInstrument */,
BUSY /* MakeToy */,
BUSY /* MakeAnimalTrap */,
BUSY /* MakeBarrel */,
BUSY /* MakeBucket */,
BUSY /* MakeWindow */,
BUSY /* MakeTotem */,
BUSY /* MakeAmmo */,
BUSY /* DecorateWith */,
BUSY /* MakeBackpack */,
BUSY /* MakeQuiver */,
BUSY /* MakeBallistaArrowHead */,
BUSY /* AssembleSiegeAmmo */,
BUSY /* LoadCatapult */,
BUSY /* LoadBallista */,
BUSY /* FireCatapult */,
BUSY /* FireBallista */,
BUSY /* ConstructMechanisms */,
BUSY /* MakeTrapComponent */,
BUSY /* LoadCageTrap */,
BUSY /* LoadStoneTrap */,
BUSY /* LoadWeaponTrap */,
BUSY /* CleanTrap */,
BUSY /* CastSpell */,
BUSY /* LinkBuildingToTrigger */,
BUSY /* PullLever */,
BUSY /* BrewDrink */,
BUSY /* ExtractFromPlants */,
BUSY /* ExtractFromRawFish */,
BUSY /* ExtractFromLandAnimal */,
BUSY /* TameVermin */,
BUSY /* TameAnimal */,
BUSY /* ChainAnimal */,
BUSY /* UnchainAnimal */,
BUSY /* UnchainPet */,
BUSY /* ReleaseLargeCreature */,
BUSY /* ReleasePet */,
BUSY /* ReleaseSmallCreature */,
BUSY /* HandleSmallCreature */,
BUSY /* HandleLargeCreature */,
BUSY /* CageLargeCreature */,
BUSY /* CageSmallCreature */,
BUSY /* RecoverWounded */,
BUSY /* DiagnosePatient */,
BUSY /* ImmobilizeBreak */,
BUSY /* DressWound */,
BUSY /* CleanPatient */,
BUSY /* Surgery */,
BUSY /* Suture */,
BUSY /* SetBone */,
BUSY /* PlaceInTraction */,
BUSY /* DrainAquarium */,
BUSY /* FillAquarium */,
BUSY /* FillPond */,
BUSY /* GiveWater */,
BUSY /* GiveFood */,
BUSY /* GiveWater2 */,
BUSY /* GiveFood2 */,
BUSY /* RecoverPet */,
BUSY /* PitLargeAnimal */,
BUSY /* PitSmallAnimal */,
BUSY /* SlaughterAnimal */,
BUSY /* MakeCharcoal */,
BUSY /* MakeAsh */,
BUSY /* MakeLye */,
BUSY /* MakePotashFromLye */,
BUSY /* FertilizeField */,
BUSY /* MakePotashFromAsh */,
BUSY /* DyeThread */,
BUSY /* DyeCloth */,
BUSY /* SewImage */,
BUSY /* MakePipeSection */,
BUSY /* OperatePump */,
OTHER /* ManageWorkOrders */,
OTHER /* UpdateStockpileRecords */,
OTHER /* TradeAtDepot */,
BUSY /* ConstructHatchCover */,
BUSY /* ConstructGrate */,
BUSY /* RemoveStairs */,
BUSY /* ConstructQuern */,
BUSY /* ConstructMillstone */,
BUSY /* ConstructSplint */,
BUSY /* ConstructCrutch */,
BUSY /* ConstructTractionBench */,
BUSY /* CleanSelf */,
BUSY /* BringCrutch */,
BUSY /* ApplyCast */,
BUSY /* CustomReaction */,
BUSY /* ConstructSlab */,
BUSY /* EngraveSlab */,
BUSY /* ShearCreature */,
BUSY /* SpinThread */,
BUSY /* PenLargeAnimal */,
BUSY /* PenSmallAnimal */,
BUSY /* MakeTool */,
BUSY /* CollectClay */,
BUSY /* InstallColonyInHive */,
BUSY /* CollectHiveProducts */,
OTHER /* CauseTrouble */,
OTHER /* DrinkBlood */,
OTHER /* ReportCrime */,
OTHER /* ExecuteCriminal */,
BUSY /* TrainAnimal */,
BUSY /* CarveTrack */,
BUSY /* PushTrackVehicle */,
BUSY /* PlaceTrackVehicle */,
BUSY /* StoreItemInVehicle */,
BUSY /* GeldAnimal */,
BUSY /* MakeFigurine */,
BUSY /* MakeAmulet */,
BUSY /* MakeScepter */,
BUSY /* MakeCrown */,
BUSY /* MakeRing */,
BUSY /* MakeEarring */,
BUSY /* MakeBracelet */,
BUSY /* MakeGem */,
BUSY /* PutItemOnDisplay */,
OTHER /* unk_fake_no_job */,
OTHER /* InterrogateSubject */,
OTHER /* unk_fake_no_activity */,
};
struct labor_info
{
PersistentDataItem config;

@ -0,0 +1,294 @@
#pragma once
#include <Core.h>
#include "df/job.h"
#include "df/job_type.h"
#include "df/unit_labor.h"
using namespace DFHack;
using namespace df::enums;
const enum dwarf_state : const int {
// Ready for a new task
IDLE=0,
// Busy with a useful task
BUSY,
// Busy with a useful task that requires a tool
EXCLUSIVE,
// In the military, can't work
MILITARY,
// Child or noble, can't work
CHILD,
// Doing something that precludes working, may be busy for a while
OTHER
};
const int NUM_STATE = 6;
char const* state_names[] {
"IDLE",
"BUSY",
"EXCLUSIVE",
"MILITARY",
"CHILD",
"OTHER",
};
const dwarf_state dwarf_states[] = {
dwarf_state::BUSY /* CarveFortification */,
dwarf_state::BUSY /* DetailWall */,
dwarf_state::BUSY /* DetailFloor */,
dwarf_state::EXCLUSIVE /* Dig */,
dwarf_state::EXCLUSIVE /* CarveUpwardStaircase */,
dwarf_state::EXCLUSIVE /* CarveDownwardStaircase */,
dwarf_state::EXCLUSIVE /* CarveUpDownStaircase */,
dwarf_state::EXCLUSIVE /* CarveRamp */,
dwarf_state::EXCLUSIVE /* DigChannel */,
dwarf_state::EXCLUSIVE /* FellTree */,
dwarf_state::BUSY /* GatherPlants */,
dwarf_state::BUSY /* RemoveConstruction */,
dwarf_state::BUSY /* CollectWebs */,
dwarf_state::BUSY /* BringItemToDepot */,
dwarf_state::BUSY /* BringItemToShop */,
dwarf_state::OTHER /* Eat */,
dwarf_state::OTHER /* GetProvisions */,
dwarf_state::OTHER /* Drink */,
dwarf_state::OTHER /* Drink2 */,
dwarf_state::OTHER /* FillWaterskin */,
dwarf_state::OTHER /* FillWaterskin2 */,
dwarf_state::OTHER /* Sleep */,
dwarf_state::BUSY /* CollectSand */,
dwarf_state::BUSY /* Fish */,
dwarf_state::EXCLUSIVE /* Hunt */,
dwarf_state::OTHER /* HuntVermin */,
dwarf_state::BUSY /* Kidnap */,
dwarf_state::BUSY /* BeatCriminal */,
dwarf_state::BUSY /* StartingFistFight */,
dwarf_state::BUSY /* CollectTaxes */,
dwarf_state::BUSY /* GuardTaxCollector */,
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 /* 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 */,
dwarf_state::OTHER /* Rest */,
dwarf_state::EXCLUSIVE /* PickupEquipment */,
dwarf_state::BUSY /* DumpItem */,
dwarf_state::OTHER /* StrangeMoodCrafter */,
dwarf_state::OTHER /* StrangeMoodJeweller */,
dwarf_state::OTHER /* StrangeMoodForge */,
dwarf_state::OTHER /* StrangeMoodMagmaForge */,
dwarf_state::OTHER /* StrangeMoodBrooding */,
dwarf_state::OTHER /* StrangeMoodFell */,
dwarf_state::OTHER /* StrangeMoodCarpenter */,
dwarf_state::OTHER /* StrangeMoodMason */,
dwarf_state::OTHER /* StrangeMoodBowyer */,
dwarf_state::OTHER /* StrangeMoodTanner */,
dwarf_state::OTHER /* StrangeMoodWeaver */,
dwarf_state::OTHER /* StrangeMoodGlassmaker */,
dwarf_state::OTHER /* StrangeMoodMechanics */,
dwarf_state::BUSY /* ConstructBuilding */,
dwarf_state::BUSY /* ConstructDoor */,
dwarf_state::BUSY /* ConstructFloodgate */,
dwarf_state::BUSY /* ConstructBed */,
dwarf_state::BUSY /* ConstructThrone */,
dwarf_state::BUSY /* ConstructCoffin */,
dwarf_state::BUSY /* ConstructTable */,
dwarf_state::BUSY /* ConstructChest */,
dwarf_state::BUSY /* ConstructBin */,
dwarf_state::BUSY /* ConstructArmorStand */,
dwarf_state::BUSY /* ConstructWeaponRack */,
dwarf_state::BUSY /* ConstructCabinet */,
dwarf_state::BUSY /* ConstructStatue */,
dwarf_state::BUSY /* ConstructBlocks */,
dwarf_state::BUSY /* MakeRawGlass */,
dwarf_state::BUSY /* MakeCrafts */,
dwarf_state::BUSY /* MintCoins */,
dwarf_state::BUSY /* CutGems */,
dwarf_state::BUSY /* CutGlass */,
dwarf_state::BUSY /* EncrustWithGems */,
dwarf_state::BUSY /* EncrustWithGlass */,
dwarf_state::BUSY /* DestroyBuilding */,
dwarf_state::BUSY /* SmeltOre */,
dwarf_state::BUSY /* MeltMetalObject */,
dwarf_state::BUSY /* ExtractMetalStrands */,
dwarf_state::BUSY /* PlantSeeds */,
dwarf_state::BUSY /* HarvestPlants */,
dwarf_state::BUSY /* TrainHuntingAnimal */,
dwarf_state::BUSY /* TrainWarAnimal */,
dwarf_state::BUSY /* MakeWeapon */,
dwarf_state::BUSY /* ForgeAnvil */,
dwarf_state::BUSY /* ConstructCatapultParts */,
dwarf_state::BUSY /* ConstructBallistaParts */,
dwarf_state::BUSY /* MakeArmor */,
dwarf_state::BUSY /* MakeHelm */,
dwarf_state::BUSY /* MakePants */,
dwarf_state::BUSY /* StudWith */,
dwarf_state::BUSY /* ButcherAnimal */,
dwarf_state::BUSY /* PrepareRawFish */,
dwarf_state::BUSY /* MillPlants */,
dwarf_state::BUSY /* BaitTrap */,
dwarf_state::BUSY /* MilkCreature */,
dwarf_state::BUSY /* MakeCheese */,
dwarf_state::BUSY /* ProcessPlants */,
dwarf_state::BUSY /* ProcessPlantsBag */,
dwarf_state::BUSY /* ProcessPlantsVial */,
dwarf_state::BUSY /* ProcessPlantsBarrel */,
dwarf_state::BUSY /* PrepareMeal */,
dwarf_state::BUSY /* WeaveCloth */,
dwarf_state::BUSY /* MakeGloves */,
dwarf_state::BUSY /* MakeShoes */,
dwarf_state::BUSY /* MakeShield */,
dwarf_state::BUSY /* MakeCage */,
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 */,
dwarf_state::BUSY /* MakeBucket */,
dwarf_state::BUSY /* MakeWindow */,
dwarf_state::BUSY /* MakeTotem */,
dwarf_state::BUSY /* MakeAmmo */,
dwarf_state::BUSY /* DecorateWith */,
dwarf_state::BUSY /* MakeBackpack */,
dwarf_state::BUSY /* MakeQuiver */,
dwarf_state::BUSY /* MakeBallistaArrowHead */,
dwarf_state::BUSY /* AssembleSiegeAmmo */,
dwarf_state::BUSY /* LoadCatapult */,
dwarf_state::BUSY /* LoadBallista */,
dwarf_state::BUSY /* FireCatapult */,
dwarf_state::BUSY /* FireBallista */,
dwarf_state::BUSY /* ConstructMechanisms */,
dwarf_state::BUSY /* MakeTrapComponent */,
dwarf_state::BUSY /* LoadCageTrap */,
dwarf_state::BUSY /* LoadStoneTrap */,
dwarf_state::BUSY /* LoadWeaponTrap */,
dwarf_state::BUSY /* CleanTrap */,
dwarf_state::BUSY /* CastSpell */,
dwarf_state::BUSY /* LinkBuildingToTrigger */,
dwarf_state::BUSY /* PullLever */,
dwarf_state::BUSY /* BrewDrink */,
dwarf_state::BUSY /* ExtractFromPlants */,
dwarf_state::BUSY /* ExtractFromRawFish */,
dwarf_state::BUSY /* ExtractFromLandAnimal */,
dwarf_state::BUSY /* TameVermin */,
dwarf_state::BUSY /* TameAnimal */,
dwarf_state::BUSY /* ChainAnimal */,
dwarf_state::BUSY /* UnchainAnimal */,
dwarf_state::BUSY /* UnchainPet */,
dwarf_state::BUSY /* ReleaseLargeCreature */,
dwarf_state::BUSY /* ReleasePet */,
dwarf_state::BUSY /* ReleaseSmallCreature */,
dwarf_state::BUSY /* HandleSmallCreature */,
dwarf_state::BUSY /* HandleLargeCreature */,
dwarf_state::BUSY /* CageLargeCreature */,
dwarf_state::BUSY /* CageSmallCreature */,
dwarf_state::BUSY /* RecoverWounded */,
dwarf_state::BUSY /* DiagnosePatient */,
dwarf_state::BUSY /* ImmobilizeBreak */,
dwarf_state::BUSY /* DressWound */,
dwarf_state::BUSY /* CleanPatient */,
dwarf_state::BUSY /* Surgery */,
dwarf_state::BUSY /* Suture */,
dwarf_state::BUSY /* SetBone */,
dwarf_state::BUSY /* PlaceInTraction */,
dwarf_state::BUSY /* DrainAquarium */,
dwarf_state::BUSY /* FillAquarium */,
dwarf_state::BUSY /* FillPond */,
dwarf_state::BUSY /* GiveWater */,
dwarf_state::BUSY /* GiveFood */,
dwarf_state::BUSY /* GiveWater2 */,
dwarf_state::BUSY /* GiveFood2 */,
dwarf_state::BUSY /* RecoverPet */,
dwarf_state::BUSY /* PitLargeAnimal */,
dwarf_state::BUSY /* PitSmallAnimal */,
dwarf_state::BUSY /* SlaughterAnimal */,
dwarf_state::BUSY /* MakeCharcoal */,
dwarf_state::BUSY /* MakeAsh */,
dwarf_state::BUSY /* MakeLye */,
dwarf_state::BUSY /* MakePotashFromLye */,
dwarf_state::BUSY /* FertilizeField */,
dwarf_state::BUSY /* MakePotashFromAsh */,
dwarf_state::BUSY /* DyeThread */,
dwarf_state::BUSY /* DyeCloth */,
dwarf_state::BUSY /* SewImage */,
dwarf_state::BUSY /* MakePipeSection */,
dwarf_state::BUSY /* OperatePump */,
dwarf_state::OTHER /* ManageWorkOrders */,
dwarf_state::OTHER /* UpdateStockpileRecords */,
dwarf_state::OTHER /* TradeAtDepot */,
dwarf_state::BUSY /* ConstructHatchCover */,
dwarf_state::BUSY /* ConstructGrate */,
dwarf_state::BUSY /* RemoveStairs */,
dwarf_state::BUSY /* ConstructQuern */,
dwarf_state::BUSY /* ConstructMillstone */,
dwarf_state::BUSY /* ConstructSplint */,
dwarf_state::BUSY /* ConstructCrutch */,
dwarf_state::BUSY /* ConstructTractionBench */,
dwarf_state::BUSY /* CleanSelf */,
dwarf_state::BUSY /* BringCrutch */,
dwarf_state::BUSY /* ApplyCast */,
dwarf_state::BUSY /* CustomReaction */,
dwarf_state::BUSY /* ConstructSlab */,
dwarf_state::BUSY /* EngraveSlab */,
dwarf_state::BUSY /* ShearCreature */,
dwarf_state::BUSY /* SpinThread */,
dwarf_state::BUSY /* PenLargeAnimal */,
dwarf_state::BUSY /* PenSmallAnimal */,
dwarf_state::BUSY /* MakeTool */,
dwarf_state::BUSY /* CollectClay */,
dwarf_state::BUSY /* InstallColonyInHive */,
dwarf_state::BUSY /* CollectHiveProducts */,
dwarf_state::OTHER /* CauseTrouble */,
dwarf_state::OTHER /* DrinkBlood */,
dwarf_state::OTHER /* ReportCrime */,
dwarf_state::OTHER /* ExecuteCriminal */,
dwarf_state::BUSY /* TrainAnimal */,
dwarf_state::BUSY /* CarveTrack */,
dwarf_state::BUSY /* PushTrackVehicle */,
dwarf_state::BUSY /* PlaceTrackVehicle */,
dwarf_state::BUSY /* StoreItemInVehicle */,
dwarf_state::BUSY /* GeldAnimal */,
dwarf_state::BUSY /* MakeFigurine */,
dwarf_state::BUSY /* MakeAmulet */,
dwarf_state::BUSY /* MakeScepter */,
dwarf_state::BUSY /* MakeCrown */,
dwarf_state::BUSY /* MakeRing */,
dwarf_state::BUSY /* MakeEarring */,
dwarf_state::BUSY /* MakeBracelet */,
dwarf_state::BUSY /* MakeGem */,
dwarf_state::BUSY /* PutItemOnDisplay */,
dwarf_state::OTHER /* unk_fake_no_job */,
dwarf_state::OTHER /* InterrogateSubject */,
dwarf_state::OTHER /* unk_fake_no_activity */,
};
#define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0]))
const int dwarf_state_count = ARRAY_COUNT(dwarf_states);
#undef ARRAY_COUNT