2012-12-02 13:27:13 -07:00
|
|
|
/*
|
2016-06-27 11:04:51 -06:00
|
|
|
* Labor manager (formerly Autolabor 2) module for dfhack
|
2012-12-02 13:27:13 -07:00
|
|
|
*
|
|
|
|
* */
|
|
|
|
|
2012-03-16 22:45:52 -06:00
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
#include <Console.h>
|
|
|
|
#include <Export.h>
|
|
|
|
#include <PluginManager.h>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
2012-11-30 19:22:58 -07:00
|
|
|
#include <queue>
|
|
|
|
#include <map>
|
|
|
|
#include <iterator>
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-09-13 13:42:17 -06:00
|
|
|
#include "modules/Units.h"
|
2012-04-05 00:33:26 -06:00
|
|
|
#include "modules/World.h"
|
2012-12-27 01:52:54 -07:00
|
|
|
#include "modules/Maps.h"
|
|
|
|
#include "modules/MapCache.h"
|
|
|
|
#include "modules/Items.h"
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-03-16 22:45:52 -06:00
|
|
|
// DF data structure definition headers
|
|
|
|
#include "DataDefs.h"
|
2012-12-27 01:52:54 -07:00
|
|
|
#include <MiscUtils.h>
|
|
|
|
|
2012-03-16 22:45:52 -06:00
|
|
|
#include <df/ui.h>
|
|
|
|
#include <df/world.h>
|
|
|
|
#include <df/unit.h>
|
2016-08-11 21:42:58 -06:00
|
|
|
#include <df/unit_relationship_type.h>
|
2012-03-16 22:45:52 -06:00
|
|
|
#include <df/unit_soul.h>
|
|
|
|
#include <df/unit_labor.h>
|
|
|
|
#include <df/unit_skill.h>
|
|
|
|
#include <df/job.h>
|
2012-03-22 01:33:18 -06:00
|
|
|
#include <df/building.h>
|
|
|
|
#include <df/workshop_type.h>
|
2012-03-16 22:45:52 -06:00
|
|
|
#include <df/unit_misc_trait.h>
|
2012-04-26 08:38:25 -06:00
|
|
|
#include <df/entity_position_responsibility.h>
|
|
|
|
#include <df/historical_figure.h>
|
|
|
|
#include <df/historical_entity.h>
|
|
|
|
#include <df/histfig_entity_link.h>
|
|
|
|
#include <df/histfig_entity_link_positionst.h>
|
|
|
|
#include <df/entity_position_assignment.h>
|
|
|
|
#include <df/entity_position.h>
|
2012-04-26 12:46:38 -06:00
|
|
|
#include <df/building_tradedepotst.h>
|
2012-07-22 11:16:50 -06:00
|
|
|
#include <df/building_stockpilest.h>
|
|
|
|
#include <df/items_other_id.h>
|
|
|
|
#include <df/ui.h>
|
|
|
|
#include <df/activity_info.h>
|
2012-10-01 16:48:47 -06:00
|
|
|
#include <df/tile_dig_designation.h>
|
|
|
|
#include <df/item_weaponst.h>
|
|
|
|
#include <df/itemdef_weaponst.h>
|
|
|
|
#include <df/general_ref_unit_workerst.h>
|
|
|
|
#include <df/general_ref_building_holderst.h>
|
|
|
|
#include <df/building_workshopst.h>
|
2012-12-01 01:26:06 -07:00
|
|
|
#include <df/building_furnacest.h>
|
|
|
|
#include <df/building_def.h>
|
2012-10-01 16:48:47 -06:00
|
|
|
#include <df/reaction.h>
|
2012-12-01 01:26:06 -07:00
|
|
|
#include <df/job_item.h>
|
|
|
|
#include <df/job_item_ref.h>
|
2012-12-01 13:08:15 -07:00
|
|
|
#include <df/unit_health_info.h>
|
|
|
|
#include <df/unit_health_flags.h>
|
2012-12-01 22:12:41 -07:00
|
|
|
#include <df/building_design.h>
|
2012-12-03 03:28:08 -07:00
|
|
|
#include <df/vehicle.h>
|
2012-12-06 00:38:43 -07:00
|
|
|
#include <df/units_other_id.h>
|
|
|
|
#include <df/ui.h>
|
|
|
|
#include <df/training_assignment.h>
|
2012-12-08 01:42:22 -07:00
|
|
|
#include <df/general_ref_contains_itemst.h>
|
2017-07-29 18:54:51 -06:00
|
|
|
#include <df/personality_facet_type.h>
|
2017-07-29 17:46:45 -06:00
|
|
|
#include <df/cultural_identity.h>
|
|
|
|
#include <df/ethic_type.h>
|
2012-04-26 08:38:25 -06:00
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
#include "labormanager.h"
|
2017-07-28 22:03:23 -06:00
|
|
|
#include "joblabormapper.h"
|
2017-07-22 03:31:30 -06:00
|
|
|
|
2013-10-08 07:41:49 -06:00
|
|
|
using namespace std;
|
2012-04-02 23:12:06 -06:00
|
|
|
using std::string;
|
|
|
|
using std::endl;
|
2012-03-16 22:45:52 -06:00
|
|
|
using namespace DFHack;
|
|
|
|
using namespace df::enums;
|
|
|
|
using df::global::ui;
|
|
|
|
using df::global::world;
|
|
|
|
|
2012-03-22 01:33:18 -06:00
|
|
|
#define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0]))
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
DFHACK_PLUGIN_IS_ENABLED(enable_labormanager);
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-04-02 21:55:02 -06:00
|
|
|
static bool print_debug = 0;
|
2016-06-27 19:58:38 -06:00
|
|
|
static bool pause_on_error = 1;
|
2012-04-02 21:55:02 -06:00
|
|
|
|
2012-04-02 23:12:06 -06:00
|
|
|
static std::vector<int> state_count(5);
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
static PersistentDataItem config;
|
|
|
|
|
|
|
|
enum ConfigFlags {
|
|
|
|
CF_ENABLED = 1,
|
2012-12-04 19:23:19 -07:00
|
|
|
CF_ALLOW_FISHING = 2,
|
|
|
|
CF_ALLOW_HUNTING = 4,
|
2012-04-05 00:33:26 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-03-16 22:45:52 -06:00
|
|
|
// Here go all the command declarations...
|
|
|
|
// mostly to allow having the mandatory stuff on top of the file and commands on the bottom
|
2017-07-22 03:31:30 -06:00
|
|
|
command_result labormanager(color_ostream &out, std::vector <std::string> & parameters);
|
2012-03-16 22:45:52 -06:00
|
|
|
|
|
|
|
// A plugin must be able to return its name and version.
|
2016-06-27 11:04:51 -06:00
|
|
|
// The name string provided must correspond to the filename - labormanager.plug.so or labormanager.plug.dll in this case
|
|
|
|
DFHACK_PLUGIN("labormanager");
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-08-02 19:28:29 -06:00
|
|
|
static void generate_labor_to_skill_map();
|
2012-07-22 11:16:50 -06:00
|
|
|
|
2012-03-16 22:45:52 -06:00
|
|
|
enum dwarf_state {
|
2012-07-17 09:27:30 -06:00
|
|
|
// Ready for a new task
|
|
|
|
IDLE,
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
// Busy with a useful task
|
|
|
|
BUSY,
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
// In the military, can't work
|
|
|
|
MILITARY,
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
// Child or noble, can't work
|
|
|
|
CHILD,
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
// Doing something that precludes working, may be busy for a while
|
|
|
|
OTHER
|
2012-03-16 22:45:52 -06:00
|
|
|
};
|
|
|
|
|
2012-04-02 23:12:06 -06:00
|
|
|
const int NUM_STATE = 5;
|
|
|
|
|
2012-04-02 21:55:02 -06:00
|
|
|
static const char *state_names[] = {
|
2012-07-17 09:27:30 -06:00
|
|
|
"IDLE",
|
|
|
|
"BUSY",
|
|
|
|
"MILITARY",
|
|
|
|
"CHILD",
|
|
|
|
"OTHER",
|
2012-04-02 21:55:02 -06:00
|
|
|
};
|
|
|
|
|
2012-03-16 22:45:52 -06:00
|
|
|
static const dwarf_state dwarf_states[] = {
|
2012-07-17 09:27:30 -06:00
|
|
|
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 */,
|
2016-06-30 22:58:56 -06:00
|
|
|
OTHER /* PickupEquipment */,
|
2012-07-17 09:27:30 -06:00
|
|
|
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 */,
|
2012-09-13 13:42:17 -06:00
|
|
|
BUSY /* TrainAnimal */,
|
|
|
|
BUSY /* CarveTrack */,
|
|
|
|
BUSY /* PushTrackVehicle */,
|
|
|
|
BUSY /* PlaceTrackVehicle */,
|
2016-02-22 10:40:52 -07:00
|
|
|
BUSY /* StoreItemInVehicle */,
|
|
|
|
BUSY /* GeldAnimal */,
|
|
|
|
BUSY /* MakeFigurine */,
|
|
|
|
BUSY /* MakeAmulet */,
|
|
|
|
BUSY /* MakeScepter */,
|
|
|
|
BUSY /* MakeCrown */,
|
|
|
|
BUSY /* MakeRing */,
|
|
|
|
BUSY /* MakeEarring */,
|
|
|
|
BUSY /* MakeBracelet */,
|
2017-12-27 11:48:53 -07:00
|
|
|
BUSY /* MakeGem */,
|
|
|
|
BUSY /* PutItemOnDisplay */,
|
2012-03-16 22:45:52 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct labor_info
|
2012-04-05 00:33:26 -06:00
|
|
|
{
|
|
|
|
PersistentDataItem config;
|
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
int active_dwarfs;
|
2012-12-27 01:52:54 -07:00
|
|
|
int idle_dwarfs;
|
|
|
|
int busy_dwarfs;
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-12-02 13:27:13 -07:00
|
|
|
int priority() { return config.ival(1); }
|
|
|
|
void set_priority(int priority) { config.ival(1) = priority; }
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
int maximum_dwarfs() { return config.ival(2); }
|
|
|
|
void set_maximum_dwarfs(int maximum_dwarfs) { config.ival(2) = maximum_dwarfs; }
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
int time_since_last_assigned()
|
|
|
|
{
|
|
|
|
return (*df::global::cur_year - config.ival(3)) * 403200 + *df::global::cur_year_tick - config.ival(4);
|
2012-12-02 13:27:13 -07:00
|
|
|
}
|
|
|
|
void mark_assigned() {
|
2017-07-22 03:31:30 -06:00
|
|
|
config.ival(3) = (*df::global::cur_year);
|
|
|
|
config.ival(4) = (*df::global::cur_year_tick);
|
2012-12-02 13:27:13 -07:00
|
|
|
}
|
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
};
|
|
|
|
|
2012-12-12 13:28:11 -07:00
|
|
|
enum tools_enum {
|
|
|
|
TOOL_NONE, TOOL_PICK, TOOL_AXE, TOOL_CROSSBOW,
|
|
|
|
TOOLS_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
struct labor_default
|
2012-03-16 22:45:52 -06:00
|
|
|
{
|
2012-12-02 13:27:13 -07:00
|
|
|
int priority;
|
2012-07-17 09:27:30 -06:00
|
|
|
int maximum_dwarfs;
|
2012-12-12 13:28:11 -07:00
|
|
|
tools_enum tool;
|
2012-03-16 22:45:52 -06:00
|
|
|
};
|
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
static std::vector<struct labor_info> labor_infos;
|
2012-03-28 09:25:36 -06:00
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
static const struct labor_default default_labor_infos[] = {
|
2016-11-08 11:01:24 -07:00
|
|
|
/* MINE */ {100, 0, TOOL_PICK},
|
2012-12-12 13:28:11 -07:00
|
|
|
/* HAUL_STONE */ {100, 0, TOOL_NONE},
|
|
|
|
/* HAUL_WOOD */ {100, 0, TOOL_NONE},
|
2016-11-08 11:01:24 -07:00
|
|
|
/* HAUL_BODY */ {1000, 0, TOOL_NONE},
|
|
|
|
/* HAUL_FOOD */ {500, 0, TOOL_NONE},
|
|
|
|
/* HAUL_REFUSE */ {200, 0, TOOL_NONE},
|
2012-12-12 13:28:11 -07:00
|
|
|
/* HAUL_ITEM */ {100, 0, TOOL_NONE},
|
|
|
|
/* HAUL_FURNITURE */ {100, 0, TOOL_NONE},
|
|
|
|
/* HAUL_ANIMAL */ {100, 0, TOOL_NONE},
|
2016-11-08 11:01:24 -07:00
|
|
|
/* CLEAN */ {100, 0, TOOL_NONE},
|
|
|
|
/* CUTWOOD */ {100, 0, TOOL_AXE},
|
|
|
|
/* CARPENTER */ {100, 0, TOOL_NONE},
|
|
|
|
/* DETAIL */ {100, 0, TOOL_NONE},
|
|
|
|
/* MASON */ {100, 0, TOOL_NONE},
|
|
|
|
/* ARCHITECT */ {100, 0, TOOL_NONE},
|
|
|
|
/* ANIMALTRAIN */ {100, 0, TOOL_NONE},
|
|
|
|
/* ANIMALCARE */ {100, 0, TOOL_NONE},
|
2012-12-12 13:28:11 -07:00
|
|
|
/* DIAGNOSE */ {1000, 0, TOOL_NONE},
|
|
|
|
/* SURGERY */ {1000, 0, TOOL_NONE},
|
|
|
|
/* BONE_SETTING */ {1000, 0, TOOL_NONE},
|
|
|
|
/* SUTURING */ {1000, 0, TOOL_NONE},
|
|
|
|
/* DRESSING_WOUNDS */ {1000, 0, TOOL_NONE},
|
|
|
|
/* FEED_WATER_CIVILIANS */ {1000, 0, TOOL_NONE},
|
|
|
|
/* RECOVER_WOUNDED */ {200, 0, TOOL_NONE},
|
2016-11-08 11:01:24 -07:00
|
|
|
/* BUTCHER */ {500, 0, TOOL_NONE},
|
|
|
|
/* TRAPPER */ {100, 0, TOOL_NONE},
|
|
|
|
/* DISSECT_VERMIN */ {100, 0, TOOL_NONE},
|
|
|
|
/* LEATHER */ {100, 0, TOOL_NONE},
|
|
|
|
/* TANNER */ {100, 0, TOOL_NONE},
|
|
|
|
/* BREWER */ {100, 0, TOOL_NONE},
|
|
|
|
/* ALCHEMIST */ {100, 0, TOOL_NONE},
|
|
|
|
/* SOAP_MAKER */ {100, 0, TOOL_NONE},
|
|
|
|
/* WEAVER */ {100, 0, TOOL_NONE},
|
|
|
|
/* CLOTHESMAKER */ {100, 0, TOOL_NONE},
|
|
|
|
/* MILLER */ {100, 0, TOOL_NONE},
|
|
|
|
/* PROCESS_PLANT */ {100, 0, TOOL_NONE},
|
|
|
|
/* MAKE_CHEESE */ {100, 0, TOOL_NONE},
|
|
|
|
/* MILK */ {100, 0, TOOL_NONE},
|
|
|
|
/* COOK */ {100, 0, TOOL_NONE},
|
|
|
|
/* PLANT */ {100, 0, TOOL_NONE},
|
|
|
|
/* HERBALIST */ {100, 0, TOOL_NONE},
|
2012-12-12 13:28:11 -07:00
|
|
|
/* FISH */ {100, 0, TOOL_NONE},
|
2016-11-08 11:01:24 -07:00
|
|
|
/* CLEAN_FISH */ {100, 0, TOOL_NONE},
|
|
|
|
/* DISSECT_FISH */ {100, 0, TOOL_NONE},
|
2012-12-12 13:28:11 -07:00
|
|
|
/* HUNT */ {100, 0, TOOL_CROSSBOW},
|
2016-11-08 11:01:24 -07:00
|
|
|
/* SMELT */ {100, 0, TOOL_NONE},
|
|
|
|
/* FORGE_WEAPON */ {100, 0, TOOL_NONE},
|
|
|
|
/* FORGE_ARMOR */ {100, 0, TOOL_NONE},
|
|
|
|
/* FORGE_FURNITURE */ {100, 0, TOOL_NONE},
|
|
|
|
/* METAL_CRAFT */ {100, 0, TOOL_NONE},
|
|
|
|
/* CUT_GEM */ {100, 0, TOOL_NONE},
|
|
|
|
/* ENCRUST_GEM */ {100, 0, TOOL_NONE},
|
|
|
|
/* WOOD_CRAFT */ {100, 0, TOOL_NONE},
|
|
|
|
/* STONE_CRAFT */ {100, 0, TOOL_NONE},
|
|
|
|
/* BONE_CARVE */ {100, 0, TOOL_NONE},
|
|
|
|
/* GLASSMAKER */ {100, 0, TOOL_NONE},
|
|
|
|
/* EXTRACT_STRAND */ {100, 0, TOOL_NONE},
|
|
|
|
/* SIEGECRAFT */ {100, 0, TOOL_NONE},
|
|
|
|
/* SIEGEOPERATE */ {100, 0, TOOL_NONE},
|
|
|
|
/* BOWYER */ {100, 0, TOOL_NONE},
|
|
|
|
/* MECHANIC */ {100, 0, TOOL_NONE},
|
|
|
|
/* POTASH_MAKING */ {100, 0, TOOL_NONE},
|
|
|
|
/* LYE_MAKING */ {100, 0, TOOL_NONE},
|
|
|
|
/* DYER */ {100, 0, TOOL_NONE},
|
|
|
|
/* BURN_WOOD */ {100, 0, TOOL_NONE},
|
|
|
|
/* OPERATE_PUMP */ {100, 0, TOOL_NONE},
|
|
|
|
/* SHEARER */ {100, 0, TOOL_NONE},
|
|
|
|
/* SPINNER */ {100, 0, TOOL_NONE},
|
|
|
|
/* POTTERY */ {100, 0, TOOL_NONE},
|
|
|
|
/* GLAZING */ {100, 0, TOOL_NONE},
|
|
|
|
/* PRESSING */ {100, 0, TOOL_NONE},
|
|
|
|
/* BEEKEEPING */ {100, 0, TOOL_NONE},
|
|
|
|
/* WAX_WORKING */ {100, 0, TOOL_NONE},
|
|
|
|
/* PUSH_HAUL_VEHICLES */ {100, 0, TOOL_NONE},
|
|
|
|
/* HAUL_TRADE */ {1000, 0, TOOL_NONE},
|
|
|
|
/* PULL_LEVER */ {1000, 0, TOOL_NONE},
|
|
|
|
/* REMOVE_CONSTRUCTION */ {100, 0, TOOL_NONE},
|
|
|
|
/* HAUL_WATER */ {100, 0, TOOL_NONE},
|
|
|
|
/* GELD */ {100, 0, TOOL_NONE},
|
|
|
|
/* BUILD_ROAD */ {100, 0, TOOL_NONE},
|
|
|
|
/* BUILD_CONSTRUCTION */ {100, 0, TOOL_NONE},
|
|
|
|
/* PAPERMAKING */ {100, 0, TOOL_NONE},
|
|
|
|
/* BOOKBINDING */ {100, 0, TOOL_NONE}
|
2012-03-16 22:45:52 -06:00
|
|
|
};
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
|
2012-03-29 12:00:26 -06:00
|
|
|
struct dwarf_info_t
|
2012-03-16 22:45:52 -06:00
|
|
|
{
|
2012-12-01 01:26:06 -07:00
|
|
|
df::unit* dwarf;
|
2012-07-17 09:27:30 -06:00
|
|
|
dwarf_state state;
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
bool clear_all;
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-12 13:28:11 -07:00
|
|
|
bool has_tool[TOOLS_MAX];
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 22:12:41 -07:00
|
|
|
int high_skill;
|
|
|
|
|
2012-12-08 09:55:44 -07:00
|
|
|
bool has_children;
|
2012-12-10 07:34:11 -07:00
|
|
|
bool armed;
|
2012-12-08 09:55:44 -07:00
|
|
|
|
2012-12-08 01:42:22 -07:00
|
|
|
df::unit_labor using_labor;
|
|
|
|
|
2018-04-06 13:17:34 -06:00
|
|
|
dwarf_info_t(df::unit* dw) : dwarf(dw), state(OTHER),
|
|
|
|
clear_all(false), high_skill(0), has_children(false), armed(false), using_labor(df::unit_labor::NONE)
|
2012-12-01 22:12:41 -07:00
|
|
|
{
|
2015-02-14 20:53:06 -07:00
|
|
|
for (int e = TOOL_NONE; e < TOOLS_MAX; e++)
|
2012-12-12 13:28:11 -07:00
|
|
|
has_tool[e] = false;
|
2012-12-01 22:12:41 -07:00
|
|
|
}
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
~dwarf_info_t()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-03-16 22:45:52 -06:00
|
|
|
};
|
|
|
|
|
2012-12-02 01:02:16 -07:00
|
|
|
color_ostream* debug_stream;
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
void debug(const char* fmt, ...)
|
2012-12-02 01:02:16 -07:00
|
|
|
{
|
|
|
|
if (debug_stream)
|
|
|
|
{
|
|
|
|
va_list args;
|
2017-07-22 03:31:30 -06:00
|
|
|
va_start(args, fmt);
|
2012-12-02 01:02:16 -07:00
|
|
|
debug_stream->vprint(fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
void debug_pause()
|
2016-06-27 19:58:38 -06:00
|
|
|
{
|
|
|
|
if (pause_on_error)
|
|
|
|
{
|
|
|
|
debug("LABORMANAGER: Game paused so you can investigate the above message.\nUse 'labormanager pause-on-error no' to disable autopausing.\n");
|
|
|
|
*df::global::pause_state = true;
|
|
|
|
}
|
|
|
|
}
|
2012-12-02 01:02:16 -07:00
|
|
|
|
2012-12-08 01:42:22 -07:00
|
|
|
static JobLaborMapper* labor_mapper = 0;
|
2012-12-01 13:08:15 -07:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
static bool initialized = false;
|
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
static bool isOptionEnabled(unsigned flag)
|
|
|
|
{
|
|
|
|
return config.isValid() && (config.ival(0) & flag) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setOptionEnabled(ConfigFlags flag, bool on)
|
|
|
|
{
|
|
|
|
if (!config.isValid())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (on)
|
|
|
|
config.ival(0) |= flag;
|
|
|
|
else
|
|
|
|
config.ival(0) &= ~flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cleanup_state()
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
enable_labormanager = false;
|
2012-07-17 09:27:30 -06:00
|
|
|
labor_infos.clear();
|
2016-06-27 11:04:51 -06:00
|
|
|
initialized = false;
|
2012-04-05 00:33:26 -06:00
|
|
|
}
|
|
|
|
|
2012-09-13 13:42:17 -06:00
|
|
|
static void reset_labor(df::unit_labor labor)
|
2012-04-05 00:33:26 -06:00
|
|
|
{
|
2012-12-02 13:27:13 -07:00
|
|
|
labor_infos[labor].set_priority(default_labor_infos[labor].priority);
|
2012-07-17 09:27:30 -06:00
|
|
|
labor_infos[labor].set_maximum_dwarfs(default_labor_infos[labor].maximum_dwarfs);
|
2012-04-05 00:33:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void init_state()
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
config = World::GetPersistentData("labormanager/2.0/config");
|
2012-04-05 00:33:26 -06:00
|
|
|
if (config.isValid() && config.ival(0) == -1)
|
|
|
|
config.ival(0) = 0;
|
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
enable_labormanager = isOptionEnabled(CF_ENABLED);
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
if (!enable_labormanager)
|
2012-07-17 09:27:30 -06:00
|
|
|
return;
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
// Load labors from save
|
|
|
|
labor_infos.resize(ARRAY_COUNT(default_labor_infos));
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
std::vector<PersistentDataItem> items;
|
2016-06-27 11:04:51 -06:00
|
|
|
World::GetPersistentData(&items, "labormanager/2.0/labors/", true);
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
for (auto p = items.begin(); p != items.end(); p++)
|
|
|
|
{
|
|
|
|
string key = p->key();
|
2016-06-27 11:04:51 -06:00
|
|
|
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("labormanager/2.0/labors/")).c_str());
|
2018-04-10 12:29:00 -06:00
|
|
|
if (labor >= 0 && size_t(labor) < labor_infos.size())
|
2012-07-17 09:27:30 -06:00
|
|
|
{
|
|
|
|
labor_infos[labor].config = *p;
|
|
|
|
labor_infos[labor].active_dwarfs = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add default labors for those not in save
|
2018-04-06 13:17:34 -06:00
|
|
|
for (size_t i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
|
2012-07-17 09:27:30 -06:00
|
|
|
if (labor_infos[i].config.isValid())
|
|
|
|
continue;
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
std::stringstream name;
|
2016-06-27 11:04:51 -06:00
|
|
|
name << "labormanager/2.0/labors/" << i;
|
2012-04-05 21:34:06 -06:00
|
|
|
|
2012-10-06 03:46:20 -06:00
|
|
|
labor_infos[i].config = World::AddPersistentData(name.str());
|
2012-12-02 13:27:13 -07:00
|
|
|
labor_infos[i].mark_assigned();
|
2012-07-17 09:27:30 -06:00
|
|
|
labor_infos[i].active_dwarfs = 0;
|
2012-09-13 13:42:17 -06:00
|
|
|
reset_labor((df::unit_labor) i);
|
2012-04-05 00:33:26 -06:00
|
|
|
}
|
2012-07-22 11:16:50 -06:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
initialized = true;
|
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
}
|
|
|
|
|
2012-07-22 11:16:50 -06:00
|
|
|
static df::job_skill labor_to_skill[ENUM_LAST_ITEM(unit_labor) + 1];
|
|
|
|
|
|
|
|
static void generate_labor_to_skill_map()
|
|
|
|
{
|
2012-08-02 09:32:25 -06:00
|
|
|
// Generate labor -> skill mapping
|
2012-07-22 11:16:50 -06:00
|
|
|
|
2012-08-02 09:32:25 -06:00
|
|
|
for (int i = 0; i <= ENUM_LAST_ITEM(unit_labor); i++)
|
2012-09-13 13:42:17 -06:00
|
|
|
labor_to_skill[i] = job_skill::NONE;
|
2012-07-22 11:16:50 -06:00
|
|
|
|
2012-08-02 09:32:25 -06:00
|
|
|
FOR_ENUM_ITEMS(job_skill, skill)
|
|
|
|
{
|
|
|
|
int labor = ENUM_ATTR(job_skill, labor, skill);
|
2012-09-13 13:42:17 -06:00
|
|
|
if (labor != unit_labor::NONE)
|
2012-08-02 09:32:25 -06:00
|
|
|
{
|
2012-07-22 11:16:50 -06:00
|
|
|
/*
|
2012-08-02 09:32:25 -06:00
|
|
|
assert(labor >= 0);
|
|
|
|
assert(labor < ARRAY_COUNT(labor_to_skill));
|
|
|
|
*/
|
2012-07-22 11:16:50 -06:00
|
|
|
|
2012-08-02 09:32:25 -06:00
|
|
|
labor_to_skill[labor] = skill;
|
|
|
|
}
|
|
|
|
}
|
2012-04-05 00:33:26 -06:00
|
|
|
}
|
|
|
|
|
2016-11-26 16:37:26 -07:00
|
|
|
struct skill_attr_weight {
|
2017-07-22 03:31:30 -06:00
|
|
|
int phys_attr_weights[6];
|
|
|
|
int mental_attr_weights[13];
|
2016-11-26 16:37:26 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct skill_attr_weight skill_attr_weights[ENUM_LAST_ITEM(job_skill) + 1] =
|
|
|
|
{
|
|
|
|
// S A T E R D AA F W C I P M LA SS M KS E SA
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* MINING */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* WOODCUTTING */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* CARPENTRY */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* DETAILSTONE */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* MASONRY */,
|
|
|
|
{ { 0, 1, 1, 1, 0, 0 }, { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0 } } /* ANIMALTRAIN */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 } } /* ANIMALCARE */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* DISSECT_FISH */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* DISSECT_VERMIN */,
|
|
|
|
{ { 0, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PROCESSFISH */,
|
|
|
|
{ { 0, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* BUTCHER */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* TRAPPING */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* TANNER */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* WEAVING */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* BREWING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* ALCHEMY */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* CLOTHESMAKING */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* MILLING */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PROCESSPLANTS */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* CHEESEMAKING */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* MILK */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* COOK */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PLANT */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 } } /* HERBALISM */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 } } /* FISH */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* SMELT */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* EXTRACT_STRAND */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* FORGE_WEAPON */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* FORGE_ARMOR */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* FORGE_FURNITURE */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* CUTGEM */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* ENCRUSTGEM */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* WOODCRAFT */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* STONECRAFT */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* METALCRAFT */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* GLASSMAKER */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* LEATHERWORK */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* BONECARVE */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* AXE */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SWORD */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* DAGGER */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* MACE */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* HAMMER */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SPEAR */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* CROSSBOW */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SHIELD */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* ARMOR */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* SIEGECRAFT */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SIEGEOPERATE */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* BOWYER */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* PIKE */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* WHIP */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* BOW */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* BLOWGUN */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* THROW */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* MECHANICS */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* MAGIC_NATURE */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SNEAK */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* DESIGNBUILDING */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 } } /* DRESS_WOUNDS */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 } } /* DIAGNOSE */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SURGERY */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SET_BONE */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SUTURE */,
|
|
|
|
{ { 0, 1, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* CRUTCH_WALK */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* WOOD_BURNING */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* LYE_MAKING */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* SOAP_MAKING */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* POTASH_MAKING */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* DYER */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* OPERATE_PUMP */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SWIMMING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } /* PERSUASION */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } /* NEGOTIATION */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1 } } /* JUDGING_INTENT */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 } } /* APPRAISAL */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 } } /* ORGANIZATION */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 } } /* RECORD_KEEPING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 } } /* LYING */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } } /* INTIMIDATION */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } /* CONVERSATION */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 } } /* COMEDY */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } /* FLATTERY */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 } } /* CONSOLE */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } /* PACIFY */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* TRACKING */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 } } /* KNOWLEDGE_ACQUISITION */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 } } /* CONCENTRATION */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* DISCIPLINE */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SITUATIONAL_AWARENESS */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* WRITING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PROSE */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* POETRY */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* READING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* SPEAKING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* COORDINATION */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* BALANCE */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } /* LEADERSHIP */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 } } /* TEACHING */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* MELEE_COMBAT */,
|
|
|
|
{ { 1, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* RANGED_COMBAT */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* WRESTLING */,
|
|
|
|
{ { 1, 0, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* BITE */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* GRASP_STRIKE */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* STANCE_STRIKE */,
|
|
|
|
{ { 0, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* DODGING */,
|
|
|
|
{ { 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* MISC_WEAPON */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* KNAPPING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* MILITARY_TACTICS */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* SHEARING */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* SPINNING */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* POTTERY */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* GLAZING */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PRESSING */,
|
|
|
|
{ { 1, 1, 0, 1, 0, 0 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* BEEKEEPING */,
|
|
|
|
{ { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 } } /* WAX_WORKING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* CLIMBING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* GELD */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* DANCE */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* MAKE_MUSIC */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* SING_MUSIC */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PLAY_KEYBOARD_INSTRUMENT */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PLAY_STRINGED_INSTRUMENT */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PLAY_WIND_INSTRUMENT */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PLAY_PERCUSSION_INSTRUMENT */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* CRITICAL_THINKING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* LOGIC */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* MATHEMATICS */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* ASTRONOMY */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* CHEMISTRY */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* GEOGRAPHY */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* OPTICS_ENGINEER */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* FLUID_ENGINEER */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* PAPERMAKING */,
|
|
|
|
{ { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } /* BOOKBINDING */
|
|
|
|
};
|
2012-07-22 11:16:50 -06:00
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
static void enable_plugin(color_ostream &out)
|
|
|
|
{
|
|
|
|
if (!config.isValid())
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
config = World::AddPersistentData("labormanager/2.0/config");
|
2012-04-05 00:33:26 -06:00
|
|
|
config.ival(0) = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
setOptionEnabled(CF_ENABLED, true);
|
2016-06-27 11:04:51 -06:00
|
|
|
enable_labormanager = true;
|
2012-04-05 00:33:26 -06:00
|
|
|
out << "Enabling the plugin." << endl;
|
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
cleanup_state();
|
|
|
|
init_state();
|
2012-04-05 00:33:26 -06:00
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands)
|
2012-03-22 01:33:18 -06:00
|
|
|
{
|
2012-03-28 18:49:44 -06:00
|
|
|
// initialize labor infos table from default table
|
2017-07-22 03:31:30 -06:00
|
|
|
if (ARRAY_COUNT(default_labor_infos) != ENUM_LAST_ITEM(unit_labor) + 1)
|
2012-03-28 18:49:44 -06:00
|
|
|
return CR_FAILURE;
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-03-28 18:49:44 -06:00
|
|
|
// Fill the command list with your commands.
|
2012-03-22 01:33:18 -06:00
|
|
|
commands.push_back(PluginCommand(
|
2016-06-27 11:04:51 -06:00
|
|
|
"labormanager", "Automatically manage dwarf labors.",
|
|
|
|
labormanager, false, /* true means that the command can't be used from non-interactive user interface */
|
2012-03-22 01:33:18 -06:00
|
|
|
// Extended help string. Used by CR_WRONG_USAGE and the help command:
|
2016-06-27 11:04:51 -06:00
|
|
|
" labormanager enable\n"
|
|
|
|
" labormanager disable\n"
|
2012-07-17 09:27:30 -06:00
|
|
|
" Enables or disables the plugin.\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" labormanager max <labor> <maximum>\n"
|
2012-12-02 13:27:13 -07:00
|
|
|
" Set max number of dwarves assigned to a labor.\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" labormanager max <labor> none\n"
|
2012-12-02 13:27:13 -07:00
|
|
|
" Unrestrict the number of dwarves assigned to a labor.\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" labormanager priority <labor> <priority>\n"
|
2012-12-02 13:27:13 -07:00
|
|
|
" Change the assignment priority of a labor (default is 100)\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" labormanager reset <labor>\n"
|
2012-07-17 09:27:30 -06:00
|
|
|
" Return a labor to the default handling.\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" labormanager reset-all\n"
|
2012-07-17 09:27:30 -06:00
|
|
|
" Return all labors to the default handling.\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" labormanager list\n"
|
2012-07-17 09:27:30 -06:00
|
|
|
" List current status of all labors.\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" labormanager status\n"
|
2012-07-17 09:27:30 -06:00
|
|
|
" Show basic status information.\n"
|
|
|
|
"Function:\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" When enabled, labormanager periodically checks your dwarves and enables or\n"
|
2012-12-02 13:27:13 -07:00
|
|
|
" disables labors. Generally, each dwarf will be assigned exactly one labor.\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" Warning: labormanager will override any manual changes you make to labors\n"
|
2016-08-11 15:56:34 -06:00
|
|
|
" while it is enabled. Do not try to run both autolabor and labormanager at\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
" the same time.\n"
|
2017-07-22 03:31:30 -06:00
|
|
|
));
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-12-08 01:42:22 -07:00
|
|
|
generate_labor_to_skill_map();
|
|
|
|
|
|
|
|
labor_mapper = new JobLaborMapper();
|
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
init_state();
|
2012-04-05 00:33:26 -06:00
|
|
|
|
2012-03-22 01:33:18 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
DFhackCExport command_result plugin_shutdown(color_ostream &out)
|
2012-03-22 01:33:18 -06:00
|
|
|
{
|
2012-07-17 09:27:30 -06:00
|
|
|
cleanup_state();
|
2012-03-28 09:25:36 -06:00
|
|
|
|
2012-12-08 01:42:22 -07:00
|
|
|
delete labor_mapper;
|
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
return CR_OK;
|
2012-03-22 01:33:18 -06:00
|
|
|
}
|
|
|
|
|
2012-10-01 16:48:47 -06:00
|
|
|
class AutoLaborManager {
|
2012-12-01 01:26:06 -07:00
|
|
|
color_ostream& out;
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
public:
|
2012-12-01 01:26:06 -07:00
|
|
|
AutoLaborManager(color_ostream& o) : out(o)
|
|
|
|
{
|
2012-12-08 01:42:22 -07:00
|
|
|
dwarf_info.clear();
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
~AutoLaborManager()
|
|
|
|
{
|
2012-12-08 01:42:22 -07:00
|
|
|
for (auto d = dwarf_info.begin(); d != dwarf_info.end(); d++)
|
|
|
|
{
|
|
|
|
delete (*d);
|
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
dwarf_info_t* add_dwarf(df::unit* u)
|
|
|
|
{
|
|
|
|
dwarf_info_t* dwarf = new dwarf_info_t(u);
|
|
|
|
dwarf_info.push_back(dwarf);
|
|
|
|
return dwarf;
|
|
|
|
}
|
2012-10-01 16:48:47 -06:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
2012-12-01 01:26:06 -07:00
|
|
|
bool has_butchers;
|
|
|
|
bool has_fishery;
|
|
|
|
bool trader_requested;
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
int dig_count;
|
|
|
|
int tree_count;
|
|
|
|
int plant_count;
|
|
|
|
int detail_count;
|
2012-12-12 13:28:11 -07:00
|
|
|
|
2016-06-29 13:54:03 -06:00
|
|
|
bool labors_changed;
|
|
|
|
|
2012-12-12 13:28:11 -07:00
|
|
|
int tool_count[TOOLS_MAX];
|
2016-06-30 22:58:56 -06:00
|
|
|
int tool_in_use[TOOLS_MAX];
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 13:08:15 -07:00
|
|
|
int cnt_recover_wounded;
|
|
|
|
int cnt_diagnosis;
|
2015-02-14 20:53:06 -07:00
|
|
|
int cnt_immobilize;
|
2012-12-01 13:08:15 -07:00
|
|
|
int cnt_dressing;
|
|
|
|
int cnt_cleaning;
|
|
|
|
int cnt_surgery;
|
|
|
|
int cnt_suture;
|
|
|
|
int cnt_setting;
|
|
|
|
int cnt_traction;
|
|
|
|
int cnt_crutch;
|
|
|
|
|
2012-12-03 03:28:08 -07:00
|
|
|
int need_food_water;
|
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
int priority_food;
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
std::map<df::unit_labor, int> labor_needed;
|
2016-06-28 21:57:12 -06:00
|
|
|
std::map<df::unit_labor, int> labor_in_use;
|
2012-12-08 09:55:44 -07:00
|
|
|
std::map<df::unit_labor, bool> labor_outside;
|
2012-12-01 01:26:06 -07:00
|
|
|
std::vector<dwarf_info_t*> dwarf_info;
|
2012-12-01 22:12:41 -07:00
|
|
|
std::list<dwarf_info_t*> available_dwarfs;
|
2016-06-27 11:04:51 -06:00
|
|
|
std::list<dwarf_info_t*> busy_dwarfs;
|
2012-10-01 16:48:47 -06:00
|
|
|
|
|
|
|
private:
|
2017-07-22 03:31:30 -06:00
|
|
|
void set_labor(dwarf_info_t* dwarf, df::unit_labor labor, bool value)
|
2016-06-29 13:54:03 -06:00
|
|
|
{
|
|
|
|
if (labor >= 0 && labor <= ENUM_LAST_ITEM(unit_labor))
|
|
|
|
{
|
|
|
|
bool old = dwarf->dwarf->status.labors[labor];
|
|
|
|
dwarf->dwarf->status.labors[labor] = value;
|
|
|
|
if (old != value)
|
2016-06-30 22:58:56 -06:00
|
|
|
{
|
2016-06-29 13:54:03 -06:00
|
|
|
labors_changed = true;
|
2016-06-30 22:58:56 -06:00
|
|
|
|
|
|
|
tools_enum tool = default_labor_infos[labor].tool;
|
|
|
|
if (tool != TOOL_NONE)
|
|
|
|
tool_in_use[tool] += value ? 1 : -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
void process_job(df::job* j)
|
2016-06-30 22:58:56 -06:00
|
|
|
{
|
|
|
|
if (j->flags.bits.suspend || j->flags.bits.item_lost)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int worker = -1;
|
|
|
|
int bld = -1;
|
|
|
|
|
2018-04-06 13:17:34 -06:00
|
|
|
for (auto ref : j->general_refs)
|
2016-06-30 22:58:56 -06:00
|
|
|
{
|
2018-04-06 13:17:34 -06:00
|
|
|
if (ref->getType() == df::general_ref_type::UNIT_WORKER)
|
|
|
|
worker = ((df::general_ref_unit_workerst *)ref)->unit_id;
|
|
|
|
if (ref->getType() == df::general_ref_type::BUILDING_HOLDER)
|
|
|
|
bld = ((df::general_ref_building_holderst *)ref)->building_id;
|
2016-06-30 22:58:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bld != -1)
|
|
|
|
{
|
|
|
|
df::building* b = binsearch_in_vector(world->buildings.all, bld);
|
2016-11-08 11:01:24 -07:00
|
|
|
|
2016-06-30 22:58:56 -06:00
|
|
|
// check if this job is the first nonsuspended job on this building; if not, ignore it
|
|
|
|
// (except for farms and trade depots)
|
2016-11-08 11:01:24 -07:00
|
|
|
|
|
|
|
if (b->getType() != df::building_type::FarmPlot &&
|
2016-11-26 17:08:48 -07:00
|
|
|
b->getType() != df::building_type::TradeDepot)
|
2016-11-08 11:01:24 -07:00
|
|
|
{
|
|
|
|
int fjid = -1;
|
2018-04-06 13:17:34 -06:00
|
|
|
for (size_t jn = 0; jn < b->jobs.size(); jn++)
|
2016-11-08 11:01:24 -07:00
|
|
|
{
|
|
|
|
if (b->jobs[jn]->flags.bits.suspend)
|
|
|
|
continue;
|
|
|
|
fjid = b->jobs[jn]->id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (fjid != j->id)
|
|
|
|
return;
|
|
|
|
}
|
2016-06-30 22:58:56 -06:00
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
df::unit_labor labor = labor_mapper->find_job_labor(j);
|
2016-06-30 22:58:56 -06:00
|
|
|
|
|
|
|
if (labor != df::unit_labor::NONE)
|
|
|
|
{
|
|
|
|
labor_needed[labor]++;
|
|
|
|
if (worker == -1)
|
|
|
|
{
|
|
|
|
if (j->pos.isValid())
|
|
|
|
{
|
|
|
|
df::tile_designation* d = Maps::getTileDesignation(j->pos);
|
|
|
|
if (d->bits.outside)
|
|
|
|
labor_outside[labor] = true;
|
|
|
|
}
|
2017-07-22 03:31:30 -06:00
|
|
|
}
|
|
|
|
else {
|
2016-06-30 22:58:56 -06:00
|
|
|
labor_infos[labor].mark_assigned();
|
|
|
|
labor_in_use[labor]++;
|
|
|
|
}
|
|
|
|
|
2016-06-29 13:54:03 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
void scan_buildings()
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
has_butchers = false;
|
|
|
|
has_fishery = false;
|
|
|
|
trader_requested = false;
|
2016-06-29 13:54:03 -06:00
|
|
|
labors_changed = false;
|
2016-06-27 11:04:51 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
for (auto b = world->buildings.all.begin(); b != world->buildings.all.end(); b++)
|
|
|
|
{
|
|
|
|
df::building *build = *b;
|
|
|
|
auto type = build->getType();
|
|
|
|
if (building_type::Workshop == type)
|
|
|
|
{
|
|
|
|
df::workshop_type subType = (df::workshop_type)build->getSubtype();
|
|
|
|
if (workshop_type::Butchers == subType)
|
|
|
|
has_butchers = true;
|
|
|
|
if (workshop_type::Fishery == subType)
|
|
|
|
has_fishery = true;
|
|
|
|
}
|
|
|
|
else if (building_type::TradeDepot == type)
|
|
|
|
{
|
|
|
|
df::building_tradedepotst* depot = (df::building_tradedepotst*) build;
|
|
|
|
trader_requested = depot->trade_flags.bits.trader_requested;
|
2016-06-28 21:36:45 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
if (print_debug)
|
|
|
|
{
|
|
|
|
if (trader_requested)
|
|
|
|
out.print("Trade depot found and trader requested, trader will be excluded from all labors.\n");
|
|
|
|
else
|
|
|
|
out.print("Trade depot found but trader is not requested.\n");
|
|
|
|
}
|
2016-06-30 22:58:56 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void count_map_designations()
|
|
|
|
{
|
|
|
|
dig_count = 0;
|
2015-02-14 20:53:06 -07:00
|
|
|
tree_count = 0;
|
2012-12-01 01:26:06 -07:00
|
|
|
plant_count = 0;
|
|
|
|
detail_count = 0;
|
|
|
|
|
2018-04-06 13:17:34 -06:00
|
|
|
for (size_t i = 0; i < world->map.map_blocks.size(); ++i)
|
2012-12-01 01:26:06 -07:00
|
|
|
{
|
|
|
|
df::map_block* bl = world->map.map_blocks[i];
|
|
|
|
|
|
|
|
if (!bl->flags.bits.designated)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (int x = 0; x < 16; x++)
|
|
|
|
for (int y = 0; y < 16; y++)
|
|
|
|
{
|
2012-12-12 09:37:09 -07:00
|
|
|
if (bl->designation[x][y].bits.hidden)
|
2012-12-27 01:52:54 -07:00
|
|
|
{
|
|
|
|
df::coord p = bl->map_pos;
|
2018-03-19 23:55:17 -06:00
|
|
|
if (! Maps::isTileVisible(p.x, p.y, p.z-1))
|
2012-12-27 01:52:54 -07:00
|
|
|
continue;
|
|
|
|
}
|
2012-12-12 13:28:11 -07:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
df::tile_dig_designation dig = bl->designation[x][y].bits.dig;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dig != df::enums::tile_dig_designation::No)
|
2012-12-01 01:26:06 -07:00
|
|
|
{
|
|
|
|
df::tiletype tt = bl->tiletype[x][y];
|
2016-06-27 11:04:51 -06:00
|
|
|
df::tiletype_material ttm = ENUM_ATTR(tiletype, material, tt);
|
2012-12-01 01:26:06 -07:00
|
|
|
df::tiletype_shape tts = ENUM_ATTR(tiletype, shape, tt);
|
2016-06-27 11:04:51 -06:00
|
|
|
if (ttm == df::enums::tiletype_material::TREE)
|
|
|
|
tree_count++;
|
|
|
|
else if (tts == df::enums::tiletype_shape::SHRUB)
|
|
|
|
plant_count++;
|
|
|
|
else
|
|
|
|
dig_count++;
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
|
|
|
if (bl->designation[x][y].bits.smooth != 0)
|
|
|
|
detail_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_debug)
|
|
|
|
out.print("Dig count = %d, Cut tree count = %d, gather plant count = %d, detail count = %d\n", dig_count, tree_count, plant_count, detail_count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void count_tools()
|
|
|
|
{
|
2012-12-12 13:28:11 -07:00
|
|
|
for (int e = TOOL_NONE; e < TOOLS_MAX; e++)
|
2016-06-30 22:58:56 -06:00
|
|
|
{
|
2012-12-12 13:28:11 -07:00
|
|
|
tool_count[e] = 0;
|
2016-06-30 22:58:56 -06:00
|
|
|
tool_in_use[e] = 0;
|
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
priority_food = 0;
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
df::item_flags bad_flags;
|
|
|
|
bad_flags.whole = 0;
|
2012-08-02 09:32:25 -06:00
|
|
|
|
2012-10-01 16:48:47 -06:00
|
|
|
#define F(x) bad_flags.bits.x = true;
|
2012-12-01 01:26:06 -07:00
|
|
|
F(dump); F(forbid); F(garbage_collect);
|
|
|
|
F(hostile); F(on_fire); F(rotten); F(trader);
|
2016-06-27 11:04:51 -06:00
|
|
|
F(in_building); F(construction);
|
2012-10-01 16:48:47 -06:00
|
|
|
#undef F
|
2012-08-02 09:32:25 -06:00
|
|
|
|
2012-12-04 00:59:44 -07:00
|
|
|
auto& v = world->items.all;
|
2012-12-02 13:27:13 -07:00
|
|
|
for (auto i = v.begin(); i != v.end(); i++)
|
2012-12-01 01:26:06 -07:00
|
|
|
{
|
2012-12-02 13:27:13 -07:00
|
|
|
df::item* item = *i;
|
2012-12-04 00:59:44 -07:00
|
|
|
|
|
|
|
if (item->flags.bits.dump)
|
|
|
|
labor_needed[df::unit_labor::HAUL_REFUSE]++;
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
if (item->flags.whole & bad_flags.whole)
|
|
|
|
continue;
|
2012-12-01 13:08:15 -07:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
df::item_type t = item->getType();
|
|
|
|
|
|
|
|
if (item->materialRots() && t != df::item_type::CORPSEPIECE && t != df::item_type::CORPSE && item->getRotTimer() > 1)
|
|
|
|
priority_food++;
|
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
if (!item->isWeapon())
|
2012-12-01 01:26:06 -07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
df::itemdef_weaponst* weapondef = ((df::item_weaponst*)item)->subtype;
|
|
|
|
df::job_skill weaponsk = (df::job_skill) weapondef->skill_melee;
|
2012-12-12 13:28:11 -07:00
|
|
|
df::job_skill weaponsk2 = (df::job_skill) weapondef->skill_ranged;
|
2012-12-01 01:26:06 -07:00
|
|
|
if (weaponsk == df::job_skill::AXE)
|
2012-12-12 13:28:11 -07:00
|
|
|
tool_count[TOOL_AXE]++;
|
2012-12-01 01:26:06 -07:00
|
|
|
else if (weaponsk == df::job_skill::MINING)
|
2012-12-12 13:28:11 -07:00
|
|
|
tool_count[TOOL_PICK]++;
|
2018-04-06 00:18:15 -06:00
|
|
|
else if (weaponsk2 == df::job_skill::CROSSBOW)
|
2012-12-12 13:28:11 -07:00
|
|
|
tool_count[TOOL_CROSSBOW]++;
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2012-08-02 09:32:25 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
void collect_job_list()
|
|
|
|
{
|
2017-11-24 22:59:59 -07:00
|
|
|
for (df::job_list_link* jll = world->jobs.list.next; jll; jll = jll->next)
|
2012-12-01 01:26:06 -07:00
|
|
|
{
|
|
|
|
df::job* j = jll->item;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (!j)
|
2012-12-01 01:26:06 -07:00
|
|
|
continue;
|
2016-06-30 22:58:56 -06:00
|
|
|
process_job(j);
|
|
|
|
}
|
2012-08-02 09:32:25 -06:00
|
|
|
|
2017-11-24 22:59:59 -07:00
|
|
|
for (auto jp = world->jobs.postings.begin(); jp != world->jobs.postings.end(); jp++)
|
2016-06-30 22:58:56 -06:00
|
|
|
{
|
|
|
|
if ((*jp)->flags.bits.dead)
|
2012-12-01 01:26:06 -07:00
|
|
|
continue;
|
2012-08-02 09:32:25 -06:00
|
|
|
|
2016-06-30 22:58:56 -06:00
|
|
|
process_job((*jp)->job);
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2012-08-02 09:32:25 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2012-08-02 09:32:25 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
void collect_dwarf_list()
|
|
|
|
{
|
2017-11-23 09:55:37 -07:00
|
|
|
state_count.clear();
|
|
|
|
state_count.resize(NUM_STATE);
|
2012-08-02 09:32:25 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
for (auto u = world->units.active.begin(); u != world->units.active.end(); ++u)
|
|
|
|
{
|
|
|
|
df::unit* cre = *u;
|
|
|
|
|
|
|
|
if (Units::isCitizen(cre))
|
|
|
|
{
|
|
|
|
dwarf_info_t* dwarf = add_dwarf(cre);
|
|
|
|
|
|
|
|
df::historical_figure* hf = df::historical_figure::find(dwarf->dwarf->hist_figure_id);
|
2018-04-06 13:17:34 -06:00
|
|
|
for (size_t i = 0; i < hf->entity_links.size(); i++)
|
2012-12-01 01:26:06 -07:00
|
|
|
{
|
|
|
|
df::histfig_entity_link* hfelink = hf->entity_links.at(i);
|
|
|
|
if (hfelink->getType() == df::histfig_entity_link_type::POSITION)
|
|
|
|
{
|
|
|
|
df::histfig_entity_link_positionst *epos =
|
|
|
|
(df::histfig_entity_link_positionst*) hfelink;
|
|
|
|
df::historical_entity* entity = df::historical_entity::find(epos->entity_id);
|
|
|
|
if (!entity)
|
|
|
|
continue;
|
|
|
|
df::entity_position_assignment* assignment = binsearch_in_vector(entity->positions.assignments, epos->assignment_id);
|
|
|
|
if (!assignment)
|
|
|
|
continue;
|
|
|
|
df::entity_position* position = binsearch_in_vector(entity->positions.own, assignment->position_id);
|
|
|
|
if (!position)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (position->responsibilities[df::entity_position_responsibility::TRADE])
|
|
|
|
if (trader_requested)
|
|
|
|
dwarf->clear_all = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// identify dwarfs who are needed for meetings and mark them for exclusion
|
|
|
|
|
2018-04-06 13:17:34 -06:00
|
|
|
for (size_t i = 0; i < ui->activities.size(); ++i)
|
2012-12-01 01:26:06 -07:00
|
|
|
{
|
|
|
|
df::activity_info *act = ui->activities[i];
|
|
|
|
if (!act) continue;
|
2017-07-29 08:26:19 -06:00
|
|
|
|
2014-04-04 12:34:39 -06:00
|
|
|
bool p1 = act->unit_actor == dwarf->dwarf;
|
|
|
|
bool p2 = act->unit_noble == dwarf->dwarf;
|
2012-12-01 01:26:06 -07:00
|
|
|
|
|
|
|
if (p1 || p2)
|
|
|
|
{
|
2017-07-29 08:26:19 -06:00
|
|
|
df::unit* other = p1 ? act->unit_noble : act->unit_actor;
|
2018-06-14 04:31:52 -06:00
|
|
|
if (other && !(!Units::isActive(other) ||
|
2017-08-05 20:48:41 -06:00
|
|
|
(other->job.current_job &&
|
|
|
|
(other->job.current_job->job_type == df::job_type::Sleep ||
|
2017-08-04 10:29:48 -06:00
|
|
|
other->job.current_job->job_type == df::job_type::Rest)) ||
|
|
|
|
ENUM_ATTR(profession, military, other->profession))) {
|
2017-07-29 08:26:19 -06:00
|
|
|
dwarf->clear_all = true;
|
|
|
|
if (print_debug)
|
|
|
|
out.print("Dwarf \"%s\" has a meeting, will be cleared of all labors\n", dwarf->dwarf->name.first_name.c_str());
|
|
|
|
break;
|
2017-07-29 11:26:32 -06:00
|
|
|
}
|
2017-07-29 08:26:19 -06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (print_debug)
|
|
|
|
out.print("Dwarf \"%s\" has a meeting, but with someone who can't make the meeting.\n", dwarf->dwarf->name.first_name.c_str());
|
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-08 09:55:44 -07:00
|
|
|
// check to see if dwarf has minor children
|
|
|
|
|
|
|
|
for (auto u2 = world->units.active.begin(); u2 != world->units.active.end(); ++u2)
|
|
|
|
{
|
2016-08-11 21:42:58 -06:00
|
|
|
if ((*u2)->relationship_ids[df::unit_relationship_type::Mother] == dwarf->dwarf->id &&
|
2018-06-14 04:31:52 -06:00
|
|
|
Units::isActive(*u2) &&
|
2012-12-08 09:55:44 -07:00
|
|
|
((*u2)->profession == df::profession::CHILD || (*u2)->profession == df::profession::BABY))
|
|
|
|
{
|
|
|
|
dwarf->has_children = true;
|
|
|
|
if (print_debug)
|
|
|
|
out.print("Dwarf %s has minor children\n", dwarf->dwarf->name.first_name.c_str());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-30 22:58:56 -06:00
|
|
|
// check if dwarf has an axe, pick, or crossbow
|
|
|
|
|
2018-04-06 13:17:34 -06:00
|
|
|
for (size_t j = 0; j < dwarf->dwarf->inventory.size(); j++)
|
2016-06-30 22:58:56 -06:00
|
|
|
{
|
|
|
|
df::unit_inventory_item* ui = dwarf->dwarf->inventory[j];
|
|
|
|
if (ui->mode == df::unit_inventory_item::Weapon && ui->item->isWeapon())
|
|
|
|
{
|
|
|
|
dwarf->armed = true;
|
|
|
|
df::itemdef_weaponst* weapondef = ((df::item_weaponst*)(ui->item))->subtype;
|
|
|
|
df::job_skill weaponsk = (df::job_skill) weapondef->skill_melee;
|
|
|
|
df::job_skill rangesk = (df::job_skill) weapondef->skill_ranged;
|
|
|
|
if (weaponsk == df::job_skill::AXE)
|
|
|
|
{
|
|
|
|
dwarf->has_tool[TOOL_AXE] = true;
|
|
|
|
}
|
|
|
|
else if (weaponsk == df::job_skill::MINING)
|
|
|
|
{
|
|
|
|
dwarf->has_tool[TOOL_PICK] = true;
|
|
|
|
}
|
|
|
|
else if (rangesk == df::job_skill::CROSSBOW)
|
|
|
|
{
|
|
|
|
dwarf->has_tool[TOOL_CROSSBOW] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-01 22:12:41 -07:00
|
|
|
// Find the activity state for each dwarf
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2016-08-11 15:56:34 -06:00
|
|
|
bool is_migrant = false;
|
2012-12-01 01:26:06 -07:00
|
|
|
dwarf_state state = OTHER;
|
|
|
|
|
|
|
|
for (auto p = dwarf->dwarf->status.misc_traits.begin(); p < dwarf->dwarf->status.misc_traits.end(); p++)
|
|
|
|
{
|
2016-08-11 15:56:34 -06:00
|
|
|
if ((*p)->id == misc_trait_type::Migrant)
|
|
|
|
is_migrant = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwarf->dwarf->social_activities.size() > 0)
|
|
|
|
{
|
|
|
|
if (print_debug)
|
2017-07-22 03:31:30 -06:00
|
|
|
out.print("Dwarf %s is engaged in a social activity. Info only.\n", dwarf->dwarf->name.first_name.c_str());
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dwarf->dwarf->profession == profession::BABY ||
|
|
|
|
dwarf->dwarf->profession == profession::CHILD ||
|
|
|
|
dwarf->dwarf->profession == profession::DRUNK)
|
|
|
|
{
|
|
|
|
state = CHILD;
|
|
|
|
}
|
2016-06-27 11:04:51 -06:00
|
|
|
|
2012-12-12 21:25:23 -07:00
|
|
|
else if (ENUM_ATTR(profession, military, dwarf->dwarf->profession))
|
2012-12-01 01:26:06 -07:00
|
|
|
state = MILITARY;
|
2016-06-27 11:04:51 -06:00
|
|
|
|
|
|
|
else if (dwarf->dwarf->burrows.size() > 0)
|
|
|
|
state = OTHER; // dwarfs assigned to burrows are treated as if permanently busy
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
else if (dwarf->dwarf->job.current_job == NULL)
|
|
|
|
{
|
2016-08-11 15:56:34 -06:00
|
|
|
if (is_migrant || dwarf->dwarf->flags1.bits.chained || dwarf->dwarf->flags1.bits.caged)
|
2016-06-27 11:04:51 -06:00
|
|
|
{
|
2012-12-01 01:26:06 -07:00
|
|
|
state = OTHER;
|
2016-06-27 11:04:51 -06:00
|
|
|
dwarf->clear_all = true;
|
|
|
|
}
|
2013-02-13 15:00:09 -07:00
|
|
|
else if (dwarf->dwarf->status2.limbs_grasp_count == 0)
|
2012-12-02 01:02:16 -07:00
|
|
|
{
|
|
|
|
state = OTHER; // dwarfs unable to grasp are incapable of nearly all labors
|
|
|
|
dwarf->clear_all = true;
|
2012-12-08 20:14:23 -07:00
|
|
|
if (print_debug)
|
2017-07-22 03:31:30 -06:00
|
|
|
out.print("Dwarf %s is disabled, will not be assigned labors\n", dwarf->dwarf->name.first_name.c_str());
|
2012-12-02 01:02:16 -07:00
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
else
|
2012-12-27 01:52:54 -07:00
|
|
|
{
|
2012-12-01 01:26:06 -07:00
|
|
|
state = IDLE;
|
2012-12-27 01:52:54 -07:00
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-12-08 01:42:22 -07:00
|
|
|
df::job_type job = dwarf->dwarf->job.current_job->job_type;
|
2018-04-06 13:17:34 -06:00
|
|
|
if (job >= 0 && size_t(job) < ARRAY_COUNT(dwarf_states))
|
2012-12-01 01:26:06 -07:00
|
|
|
state = dwarf_states[job];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out.print("Dwarf \"%s\" has unknown job %i\n", dwarf->dwarf->name.first_name.c_str(), job);
|
2016-06-27 19:58:38 -06:00
|
|
|
debug_pause();
|
2012-12-01 01:26:06 -07:00
|
|
|
state = OTHER;
|
|
|
|
}
|
2012-12-08 01:42:22 -07:00
|
|
|
if (state == BUSY)
|
|
|
|
{
|
|
|
|
df::unit_labor labor = labor_mapper->find_job_labor(dwarf->dwarf->job.current_job);
|
2016-06-27 11:04:51 -06:00
|
|
|
|
|
|
|
dwarf->using_labor = labor;
|
|
|
|
|
2012-12-08 01:42:22 -07:00
|
|
|
if (labor != df::unit_labor::NONE)
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
labor_infos[labor].busy_dwarfs++;
|
2016-06-30 22:58:56 -06:00
|
|
|
if (default_labor_infos[labor].tool != TOOL_NONE)
|
2012-12-08 01:42:22 -07:00
|
|
|
{
|
2016-06-30 22:58:56 -06:00
|
|
|
tool_in_use[default_labor_infos[labor].tool]++;
|
2012-12-08 01:42:22 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
dwarf->state = state;
|
|
|
|
|
2013-01-01 16:53:24 -07:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
|
|
|
{
|
2015-02-14 20:53:06 -07:00
|
|
|
if (l == df::unit_labor::NONE)
|
2013-01-01 16:53:24 -07:00
|
|
|
continue;
|
|
|
|
if (dwarf->dwarf->status.labors[l])
|
|
|
|
if (state == IDLE)
|
|
|
|
labor_infos[l].idle_dwarfs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
if (print_debug)
|
2012-12-08 20:14:23 -07:00
|
|
|
out.print("Dwarf \"%s\": state %s %d\n", dwarf->dwarf->name.first_name.c_str(), state_names[dwarf->state], dwarf->clear_all);
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2017-11-23 09:55:37 -07:00
|
|
|
state_count[dwarf->state]++;
|
|
|
|
|
2012-12-01 13:08:15 -07:00
|
|
|
// determine if dwarf has medical needs
|
2017-07-20 02:53:45 -06:00
|
|
|
if (dwarf->dwarf->health && !(
|
|
|
|
// on-duty military will not necessarily break to get minor injuries attended
|
|
|
|
ENUM_ATTR(profession, military, dwarf->dwarf->profession) ||
|
|
|
|
// babies cannot currently receive health care even if they need it
|
|
|
|
dwarf->dwarf->profession == profession::BABY)
|
|
|
|
)
|
2012-12-01 13:08:15 -07:00
|
|
|
{
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.needs_recovery)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_recover_wounded++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_diagnosis)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_diagnosis++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_immobilize)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_immobilize++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_dressing)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_dressing++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_cleaning)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_cleaning++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_surgery)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_surgery++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_suture)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_suture++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_setting)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_setting++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_traction)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_traction++;
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->dwarf->health->flags.bits.rq_crutch)
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_crutch++;
|
|
|
|
}
|
|
|
|
|
2012-12-03 03:28:08 -07:00
|
|
|
if (dwarf->dwarf->counters2.hunger_timer > 60000 || dwarf->dwarf->counters2.thirst_timer > 40000)
|
|
|
|
need_food_water++;
|
|
|
|
|
2012-12-01 22:12:41 -07:00
|
|
|
// find dwarf's highest effective skill
|
|
|
|
|
|
|
|
int high_skill = 0;
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, labor)
|
2012-12-01 22:12:41 -07:00
|
|
|
{
|
2012-12-08 01:42:22 -07:00
|
|
|
if (labor == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
|
2012-12-07 14:41:39 -07:00
|
|
|
df::job_skill skill = labor_to_skill[labor];
|
|
|
|
if (skill != df::job_skill::NONE)
|
|
|
|
{
|
2015-02-14 20:53:06 -07:00
|
|
|
int skill_level = Units::getNominalSkill(dwarf->dwarf, skill, false);
|
2012-12-07 14:41:39 -07:00
|
|
|
high_skill = std::max(high_skill, skill_level);
|
|
|
|
}
|
2012-12-01 22:12:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
dwarf->high_skill = high_skill;
|
2012-12-01 01:26:06 -07:00
|
|
|
|
|
|
|
|
2012-12-01 13:08:15 -07:00
|
|
|
// clear labors of dwarfs with clear_all set
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
if (dwarf->clear_all)
|
2012-12-01 01:26:06 -07:00
|
|
|
{
|
|
|
|
FOR_ENUM_ITEMS(unit_labor, labor)
|
|
|
|
{
|
2015-02-14 20:53:06 -07:00
|
|
|
if (labor == unit_labor::NONE)
|
2012-12-01 01:26:06 -07:00
|
|
|
continue;
|
|
|
|
|
2016-06-29 13:54:03 -06:00
|
|
|
set_labor(dwarf, labor, false);
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2017-07-22 03:31:30 -06:00
|
|
|
}
|
|
|
|
else {
|
2016-06-27 11:04:51 -06:00
|
|
|
if (state == IDLE)
|
|
|
|
available_dwarfs.push_back(dwarf);
|
|
|
|
|
|
|
|
if (state == BUSY)
|
|
|
|
busy_dwarfs.push_back(dwarf);
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2016-06-27 11:04:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
void release_dwarf_list()
|
|
|
|
{
|
|
|
|
while (!dwarf_info.empty()) {
|
|
|
|
auto d = dwarf_info.begin();
|
|
|
|
delete *d;
|
|
|
|
dwarf_info.erase(d);
|
|
|
|
}
|
|
|
|
available_dwarfs.clear();
|
|
|
|
busy_dwarfs.clear();
|
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
int score_labor(dwarf_info_t* d, df::unit_labor labor)
|
2016-06-27 11:04:51 -06:00
|
|
|
{
|
|
|
|
int skill_level = 0;
|
|
|
|
int xp = 0;
|
2016-11-26 16:37:26 -07:00
|
|
|
int attr_weight = 0;
|
2016-06-27 11:04:51 -06:00
|
|
|
|
|
|
|
if (labor != df::unit_labor::NONE)
|
|
|
|
{
|
|
|
|
df::job_skill skill = labor_to_skill[labor];
|
|
|
|
if (skill != df::job_skill::NONE)
|
|
|
|
{
|
|
|
|
skill_level = Units::getEffectiveSkill(d->dwarf, skill);
|
|
|
|
xp = Units::getExperience(d->dwarf, skill, false);
|
2016-11-26 16:37:26 -07:00
|
|
|
|
2016-11-26 17:08:48 -07:00
|
|
|
for (int pa = 0; pa < 6; pa++)
|
2016-11-26 16:37:26 -07:00
|
|
|
attr_weight += (skill_attr_weights[skill].phys_attr_weights[pa]) * (d->dwarf->body.physical_attrs[pa].value - 1000);
|
|
|
|
|
2016-11-26 17:08:48 -07:00
|
|
|
for (int ma = 0; ma < 13; ma++)
|
2016-11-26 16:37:26 -07:00
|
|
|
attr_weight += (skill_attr_weights[skill].mental_attr_weights[ma]) * (d->dwarf->status.current_soul->mental_attrs[ma].value - 1000);
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2017-07-29 17:46:45 -06:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
}
|
2012-07-22 11:16:50 -06:00
|
|
|
|
2016-11-26 16:37:26 -07:00
|
|
|
int score = skill_level * 1000 - (d->high_skill - skill_level) * 2000 + (xp / (skill_level + 5) * 10) + attr_weight;
|
2016-06-27 11:04:51 -06:00
|
|
|
|
|
|
|
if (labor != df::unit_labor::NONE)
|
|
|
|
{
|
|
|
|
if (d->dwarf->status.labors[labor])
|
2018-04-06 00:18:15 -06:00
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (labor == df::unit_labor::OPERATE_PUMP)
|
|
|
|
score += 50000;
|
|
|
|
else
|
2016-11-08 11:01:24 -07:00
|
|
|
score += 25000;
|
2018-04-06 00:18:15 -06:00
|
|
|
}
|
2016-06-27 11:04:51 -06:00
|
|
|
if (default_labor_infos[labor].tool != TOOL_NONE &&
|
|
|
|
d->has_tool[default_labor_infos[labor].tool])
|
2016-11-08 11:01:24 -07:00
|
|
|
score += 10000000;
|
2016-06-27 11:04:51 -06:00
|
|
|
if (d->has_children && labor_outside[labor])
|
|
|
|
score -= 15000;
|
|
|
|
if (d->armed && labor_outside[labor])
|
|
|
|
score += 5000;
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2016-06-27 11:04:51 -06:00
|
|
|
|
2017-07-29 18:54:51 -06:00
|
|
|
// Favor/disfavor RECOVER_WOUNDED based on ALTRUISM personality facet
|
|
|
|
|
|
|
|
if (labor == df::unit_labor::RECOVER_WOUNDED)
|
|
|
|
{
|
|
|
|
int altruism = d->dwarf->status.current_soul->personality.traits[df::personality_facet_type::ALTRUISM];
|
|
|
|
if (altruism >= 61)
|
|
|
|
score += 5000;
|
|
|
|
else if (altruism <= 24)
|
|
|
|
score -= 50000;
|
|
|
|
}
|
2017-07-29 17:46:45 -06:00
|
|
|
// This should reweight assigning CUTWOOD jobs based on a citizen's ethic toward killing plants
|
|
|
|
|
|
|
|
if (labor == df::unit_labor::CUTWOOD)
|
|
|
|
{
|
2017-11-23 09:55:37 -07:00
|
|
|
if (auto culture = df::cultural_identity::find(d->dwarf->cultural_identity))
|
|
|
|
{
|
|
|
|
auto ethics = culture->ethic[df::ethic_type::KILL_PLANT];
|
|
|
|
if (ethics != df::ethic_response::NOT_APPLICABLE && ethics != df::ethic_response::REQUIRED)
|
|
|
|
score += 10000 * (df::ethic_response::ACCEPTABLE - ethics);
|
|
|
|
}
|
2017-07-29 17:46:45 -06:00
|
|
|
}
|
2017-07-29 18:54:51 -06:00
|
|
|
|
2016-11-26 16:37:26 -07:00
|
|
|
score -= Units::computeMovementSpeed(d->dwarf);
|
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
return score;
|
2015-02-14 20:53:06 -07:00
|
|
|
}
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
public:
|
|
|
|
void process()
|
|
|
|
{
|
2016-06-29 13:54:03 -06:00
|
|
|
if (*df::global::process_dig || *df::global::process_jobs)
|
|
|
|
return;
|
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
release_dwarf_list();
|
2012-12-08 01:42:22 -07:00
|
|
|
|
2012-12-12 13:28:11 -07:00
|
|
|
dig_count = tree_count = plant_count = detail_count = 0;
|
2012-12-01 13:08:15 -07:00
|
|
|
cnt_recover_wounded = cnt_diagnosis = cnt_immobilize = cnt_dressing = cnt_cleaning = cnt_surgery = cnt_suture =
|
|
|
|
cnt_setting = cnt_traction = cnt_crutch = 0;
|
2012-12-03 03:28:08 -07:00
|
|
|
need_food_water = 0;
|
2012-12-01 13:08:15 -07:00
|
|
|
|
2016-06-30 22:58:56 -06:00
|
|
|
labor_needed.clear();
|
|
|
|
|
2012-12-12 13:28:11 -07:00
|
|
|
for (int e = 0; e < TOOLS_MAX; e++)
|
|
|
|
tool_count[e] = 0;
|
|
|
|
|
2012-12-08 20:14:23 -07:00
|
|
|
trader_requested = false;
|
|
|
|
|
2012-12-03 00:41:02 -07:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
|
|
|
{
|
|
|
|
if (l == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
|
2012-12-27 01:52:54 -07:00
|
|
|
labor_infos[l].active_dwarfs = labor_infos[l].busy_dwarfs = labor_infos[l].idle_dwarfs = 0;
|
2012-12-03 00:41:02 -07:00
|
|
|
}
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
// scan for specific buildings of interest
|
|
|
|
|
|
|
|
scan_buildings();
|
|
|
|
|
|
|
|
// count number of squares designated for dig, wood cutting, detailing, and plant harvesting
|
|
|
|
|
|
|
|
count_map_designations();
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
// collect current job list
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
collect_job_list();
|
2012-11-30 19:22:58 -07:00
|
|
|
|
2012-12-01 22:12:41 -07:00
|
|
|
// count number of picks and axes available for use
|
|
|
|
|
|
|
|
count_tools();
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
// collect list of dwarfs
|
2012-10-01 16:48:47 -06:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
collect_dwarf_list();
|
|
|
|
|
2012-12-01 13:08:15 -07:00
|
|
|
// add job entries for designation-related jobs
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
labor_needed[df::unit_labor::MINE] += dig_count;
|
|
|
|
labor_needed[df::unit_labor::CUTWOOD] += tree_count;
|
|
|
|
labor_needed[df::unit_labor::DETAIL] += detail_count;
|
2012-12-01 13:08:15 -07:00
|
|
|
labor_needed[df::unit_labor::HERBALIST] += plant_count;
|
|
|
|
|
|
|
|
// add job entries for health care
|
|
|
|
|
|
|
|
labor_needed[df::unit_labor::RECOVER_WOUNDED] += cnt_recover_wounded;
|
2017-07-22 03:31:30 -06:00
|
|
|
labor_needed[df::unit_labor::DIAGNOSE] += cnt_diagnosis;
|
|
|
|
labor_needed[df::unit_labor::BONE_SETTING] += cnt_immobilize;
|
2012-12-01 13:08:15 -07:00
|
|
|
labor_needed[df::unit_labor::DRESSING_WOUNDS] += cnt_dressing;
|
2012-12-11 08:06:37 -07:00
|
|
|
labor_needed[df::unit_labor::DRESSING_WOUNDS] += cnt_cleaning;
|
2017-07-22 03:31:30 -06:00
|
|
|
labor_needed[df::unit_labor::SURGERY] += cnt_surgery;
|
|
|
|
labor_needed[df::unit_labor::SUTURING] += cnt_suture;
|
|
|
|
labor_needed[df::unit_labor::BONE_SETTING] += cnt_setting;
|
|
|
|
labor_needed[df::unit_labor::BONE_SETTING] += cnt_traction;
|
|
|
|
labor_needed[df::unit_labor::BONE_SETTING] += cnt_crutch;
|
2012-12-01 13:08:15 -07:00
|
|
|
|
2012-12-03 03:28:08 -07:00
|
|
|
labor_needed[df::unit_labor::FEED_WATER_CIVILIANS] += need_food_water;
|
|
|
|
|
2012-12-02 01:02:16 -07:00
|
|
|
// add entries for hauling jobs
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
labor_needed[df::unit_labor::HAUL_STONE] += world->stockpile.num_jobs[1];
|
|
|
|
labor_needed[df::unit_labor::HAUL_WOOD] += world->stockpile.num_jobs[2];
|
|
|
|
labor_needed[df::unit_labor::HAUL_ITEM] += world->stockpile.num_jobs[3];
|
|
|
|
labor_needed[df::unit_labor::HAUL_ITEM] += world->stockpile.num_jobs[4];
|
|
|
|
labor_needed[df::unit_labor::HAUL_BODY] += world->stockpile.num_jobs[5];
|
|
|
|
labor_needed[df::unit_labor::HAUL_FOOD] += world->stockpile.num_jobs[6];
|
|
|
|
labor_needed[df::unit_labor::HAUL_REFUSE] += world->stockpile.num_jobs[7];
|
2012-12-02 01:02:16 -07:00
|
|
|
labor_needed[df::unit_labor::HAUL_FURNITURE] += world->stockpile.num_jobs[8];
|
2017-07-22 03:31:30 -06:00
|
|
|
labor_needed[df::unit_labor::HAUL_ANIMALS] += world->stockpile.num_jobs[9];
|
|
|
|
|
|
|
|
labor_needed[df::unit_labor::HAUL_STONE] += (world->stockpile.num_jobs[1] >= world->stockpile.num_haulers[1]) ? 1 : 0;
|
|
|
|
labor_needed[df::unit_labor::HAUL_WOOD] += (world->stockpile.num_jobs[2] >= world->stockpile.num_haulers[2]) ? 1 : 0;
|
|
|
|
labor_needed[df::unit_labor::HAUL_ITEM] += (world->stockpile.num_jobs[3] >= world->stockpile.num_haulers[3]) ? 1 : 0;
|
|
|
|
labor_needed[df::unit_labor::HAUL_BODY] += (world->stockpile.num_jobs[5] >= world->stockpile.num_haulers[5]) ? 1 : 0;
|
|
|
|
labor_needed[df::unit_labor::HAUL_FOOD] += (world->stockpile.num_jobs[6] >= world->stockpile.num_haulers[6]) ? 1 : 0;
|
|
|
|
labor_needed[df::unit_labor::HAUL_REFUSE] += (world->stockpile.num_jobs[7] >= world->stockpile.num_haulers[7]) ? 1 : 0;
|
2016-06-27 11:04:51 -06:00
|
|
|
labor_needed[df::unit_labor::HAUL_FURNITURE] += (world->stockpile.num_jobs[8] >= world->stockpile.num_haulers[8]) ? 1 : 0;
|
2017-07-22 03:31:30 -06:00
|
|
|
labor_needed[df::unit_labor::HAUL_ANIMALS] += (world->stockpile.num_jobs[9] >= world->stockpile.num_haulers[9]) ? 1 : 0;
|
2016-06-27 11:04:51 -06:00
|
|
|
|
|
|
|
int binjobs = world->stockpile.num_jobs[4] + ((world->stockpile.num_jobs[4] >= world->stockpile.num_haulers[4]) ? 1 : 0);
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
labor_needed[df::unit_labor::HAUL_ITEM] += binjobs;
|
|
|
|
labor_needed[df::unit_labor::HAUL_FOOD] += priority_food;
|
2012-12-02 01:02:16 -07:00
|
|
|
|
2012-12-03 03:28:08 -07:00
|
|
|
// add entries for vehicle hauling
|
|
|
|
|
|
|
|
for (auto v = world->vehicles.all.begin(); v != world->vehicles.all.end(); v++)
|
2015-02-14 20:53:06 -07:00
|
|
|
if ((*v)->route_id != -1)
|
2016-06-27 11:04:51 -06:00
|
|
|
labor_needed[df::unit_labor::HANDLE_VEHICLES]++;
|
2012-12-03 03:28:08 -07:00
|
|
|
|
2012-12-04 19:23:19 -07:00
|
|
|
// add fishing & hunting
|
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
labor_needed[df::unit_labor::FISH] =
|
2012-12-27 01:52:54 -07:00
|
|
|
(isOptionEnabled(CF_ALLOW_FISHING) && has_fishery) ? 1 : 0;
|
2012-12-04 19:23:19 -07:00
|
|
|
|
2012-12-27 01:52:54 -07:00
|
|
|
labor_needed[df::unit_labor::HUNT] =
|
|
|
|
(isOptionEnabled(CF_ALLOW_HUNTING) && has_butchers) ? 1 : 0;
|
2012-12-04 19:23:19 -07:00
|
|
|
|
2012-12-06 00:38:43 -07:00
|
|
|
/* add animal trainers */
|
|
|
|
for (auto a = df::global::ui->equipment.training_assignments.begin();
|
|
|
|
a != df::global::ui->equipment.training_assignments.end();
|
|
|
|
a++)
|
|
|
|
{
|
|
|
|
labor_needed[df::unit_labor::ANIMALTRAIN]++;
|
|
|
|
// note: this doesn't test to see if the trainer is actually needed, and thus will overallocate trainers. bleah.
|
|
|
|
}
|
|
|
|
|
2016-06-28 21:57:12 -06:00
|
|
|
/* set requirements to zero for labors with currently idle dwarfs, and remove from requirement dwarfs actually working */
|
2016-06-27 11:04:51 -06:00
|
|
|
|
2016-06-28 21:57:12 -06:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l) {
|
2016-06-29 13:54:03 -06:00
|
|
|
if (l == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
|
2016-06-30 22:58:56 -06:00
|
|
|
int before = labor_needed[l];
|
|
|
|
|
2016-07-07 01:10:43 -06:00
|
|
|
labor_needed[l] = max(0, labor_needed[l] - labor_in_use[l]);
|
2016-06-30 22:58:56 -06:00
|
|
|
|
|
|
|
if (default_labor_infos[l].tool != TOOL_NONE)
|
|
|
|
labor_needed[l] = std::min(labor_needed[l], tool_count[default_labor_infos[l].tool] - tool_in_use[default_labor_infos[l].tool]);
|
|
|
|
|
|
|
|
if (print_debug && before != labor_needed[l])
|
2017-07-22 03:31:30 -06:00
|
|
|
out.print("labor %s reduced from %d to %d\n", ENUM_KEY_STR(unit_labor, l).c_str(), before, labor_needed[l]);
|
2016-06-30 22:58:56 -06:00
|
|
|
|
2016-06-28 21:57:12 -06:00
|
|
|
}
|
2016-06-27 11:04:51 -06:00
|
|
|
|
|
|
|
/* assign food haulers for rotting food items */
|
|
|
|
|
|
|
|
if (priority_food > 0 && labor_infos[df::unit_labor::HAUL_FOOD].idle_dwarfs > 0)
|
|
|
|
priority_food = 1;
|
|
|
|
|
|
|
|
if (print_debug)
|
2017-07-22 03:31:30 -06:00
|
|
|
out.print("priority food count = %d\n", priority_food);
|
2016-06-27 11:04:51 -06:00
|
|
|
|
|
|
|
while (!available_dwarfs.empty() && priority_food > 0)
|
|
|
|
{
|
|
|
|
std::list<dwarf_info_t*>::iterator bestdwarf = available_dwarfs.begin();
|
|
|
|
|
|
|
|
int best_score = INT_MIN;
|
|
|
|
|
|
|
|
for (std::list<dwarf_info_t*>::iterator k = available_dwarfs.begin(); k != available_dwarfs.end(); k++)
|
2013-01-01 15:35:09 -07:00
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
dwarf_info_t* d = (*k);
|
2013-01-01 16:53:24 -07:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
int score = score_labor(d, df::unit_labor::HAUL_FOOD);
|
|
|
|
|
|
|
|
if (score > best_score)
|
|
|
|
{
|
|
|
|
bestdwarf = k;
|
|
|
|
best_score = score;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (best_score > INT_MIN)
|
|
|
|
{
|
2013-01-01 15:35:09 -07:00
|
|
|
if (print_debug)
|
2016-06-27 11:04:51 -06:00
|
|
|
out.print("LABORMANAGER: assign \"%s\" labor %s score=%d (priority food)\n", (*bestdwarf)->dwarf->name.first_name.c_str(), ENUM_KEY_STR(unit_labor, df::unit_labor::HAUL_FOOD).c_str(), best_score);
|
|
|
|
|
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
|
|
|
{
|
|
|
|
if (l == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
set_labor(*bestdwarf, l, l == df::unit_labor::HAUL_FOOD);
|
2016-06-27 11:04:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
available_dwarfs.erase(bestdwarf);
|
|
|
|
priority_food--;
|
2013-01-01 15:35:09 -07:00
|
|
|
}
|
2016-06-27 11:04:51 -06:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
2012-12-27 01:52:54 -07:00
|
|
|
}
|
|
|
|
|
2012-12-01 13:08:15 -07:00
|
|
|
if (print_debug)
|
|
|
|
{
|
|
|
|
for (auto i = labor_needed.begin(); i != labor_needed.end(); i++)
|
|
|
|
{
|
2017-07-22 03:31:30 -06:00
|
|
|
out.print("labor_needed [%s] = %d, busy = %d, outside = %d, idle = %d\n", ENUM_KEY_STR(unit_labor, i->first).c_str(), i->second,
|
2016-06-27 11:04:51 -06:00
|
|
|
labor_infos[i->first].busy_dwarfs, labor_outside[i->first], labor_infos[i->first].idle_dwarfs);
|
2015-02-14 20:53:06 -07:00
|
|
|
}
|
2012-12-01 13:08:15 -07:00
|
|
|
}
|
|
|
|
|
2016-11-08 11:01:24 -07:00
|
|
|
std::map<df::unit_labor, int> base_priority;
|
2012-12-01 01:26:06 -07:00
|
|
|
priority_queue<pair<int, df::unit_labor>> pq;
|
2016-11-08 11:01:24 -07:00
|
|
|
priority_queue<pair<int, df::unit_labor>> pq2;
|
2012-12-01 13:08:15 -07:00
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
for (auto i = labor_needed.begin(); i != labor_needed.end(); i++)
|
|
|
|
{
|
2012-12-02 13:27:13 -07:00
|
|
|
df::unit_labor l = i->first;
|
2016-06-29 13:54:03 -06:00
|
|
|
if (l == df::unit_labor::NONE)
|
2016-06-28 22:28:44 -06:00
|
|
|
continue;
|
|
|
|
|
2012-12-02 13:27:13 -07:00
|
|
|
if (labor_infos[l].maximum_dwarfs() > 0 &&
|
|
|
|
i->second > labor_infos[l].maximum_dwarfs())
|
|
|
|
i->second = labor_infos[l].maximum_dwarfs();
|
2016-08-11 15:56:34 -06:00
|
|
|
|
2016-11-08 11:01:24 -07:00
|
|
|
int priority = labor_infos[l].priority();
|
2016-11-26 17:08:48 -07:00
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
priority += labor_infos[l].time_since_last_assigned() / 12;
|
2016-11-08 11:01:24 -07:00
|
|
|
priority -= labor_infos[l].busy_dwarfs;
|
2016-11-26 17:08:48 -07:00
|
|
|
|
2016-11-08 11:01:24 -07:00
|
|
|
base_priority[l] = priority;
|
2016-08-11 15:56:34 -06:00
|
|
|
|
2016-11-08 11:01:24 -07:00
|
|
|
if (i->second > 0)
|
|
|
|
{
|
2012-12-02 13:27:13 -07:00
|
|
|
pq.push(make_pair(priority, l));
|
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
2012-12-01 13:08:15 -07:00
|
|
|
|
2012-12-01 15:09:52 -07:00
|
|
|
if (print_debug)
|
2018-06-11 10:57:06 -06:00
|
|
|
out.print("available count = %zu, distinct labors needed = %zu\n", available_dwarfs.size(), pq.size());
|
2012-12-01 15:09:52 -07:00
|
|
|
|
2012-12-04 19:23:19 -07:00
|
|
|
std::map<df::unit_labor, int> to_assign;
|
|
|
|
|
|
|
|
to_assign.clear();
|
2012-12-08 02:51:07 -07:00
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
size_t av = available_dwarfs.size();
|
2012-12-04 19:23:19 -07:00
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
while (!pq.empty() && av > 0)
|
2012-12-04 19:23:19 -07:00
|
|
|
{
|
|
|
|
df::unit_labor labor = pq.top().second;
|
|
|
|
int priority = pq.top().first;
|
|
|
|
to_assign[labor]++;
|
|
|
|
pq.pop();
|
|
|
|
av--;
|
|
|
|
|
|
|
|
if (print_debug)
|
|
|
|
out.print("Will assign: %s priority %d (%d)\n", ENUM_KEY_STR(unit_labor, labor).c_str(), priority, to_assign[labor]);
|
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
if (--labor_needed[labor] > 0)
|
2012-12-04 19:23:19 -07:00
|
|
|
{
|
2017-07-22 03:31:30 -06:00
|
|
|
priority -= 10;
|
2016-11-08 11:01:24 -07:00
|
|
|
pq2.push(make_pair(priority, labor));
|
2012-12-04 19:23:19 -07:00
|
|
|
}
|
2016-11-08 11:01:24 -07:00
|
|
|
|
2016-11-26 17:08:48 -07:00
|
|
|
if (pq.empty())
|
2017-07-22 03:31:30 -06:00
|
|
|
while (!pq2.empty())
|
2016-11-08 11:01:24 -07:00
|
|
|
{
|
|
|
|
pq.push(pq2.top());
|
|
|
|
pq2.pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!pq2.empty())
|
|
|
|
{
|
|
|
|
pq.push(pq2.top());
|
|
|
|
pq2.pop();
|
2012-12-04 19:23:19 -07:00
|
|
|
}
|
|
|
|
|
2012-12-02 01:02:16 -07:00
|
|
|
int canary = (1 << df::unit_labor::HAUL_STONE) |
|
|
|
|
(1 << df::unit_labor::HAUL_WOOD) |
|
|
|
|
(1 << df::unit_labor::HAUL_BODY) |
|
|
|
|
(1 << df::unit_labor::HAUL_FOOD) |
|
|
|
|
(1 << df::unit_labor::HAUL_REFUSE) |
|
|
|
|
(1 << df::unit_labor::HAUL_ITEM) |
|
|
|
|
(1 << df::unit_labor::HAUL_FURNITURE) |
|
2016-06-27 11:04:51 -06:00
|
|
|
(1 << df::unit_labor::HAUL_ANIMALS);
|
2012-12-02 01:02:16 -07:00
|
|
|
|
2012-12-04 19:23:19 -07:00
|
|
|
while (!available_dwarfs.empty())
|
2012-12-01 01:26:06 -07:00
|
|
|
{
|
2012-12-01 22:12:41 -07:00
|
|
|
std::list<dwarf_info_t*>::iterator bestdwarf = available_dwarfs.begin();
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2012-12-08 09:55:44 -07:00
|
|
|
int best_score = INT_MIN;
|
2016-06-29 13:54:03 -06:00
|
|
|
df::unit_labor best_labor = df::unit_labor::NONE;
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2015-02-14 20:53:06 -07:00
|
|
|
for (auto j = to_assign.begin(); j != to_assign.end(); j++)
|
2012-12-01 22:12:41 -07:00
|
|
|
{
|
2015-02-14 20:53:06 -07:00
|
|
|
if (j->second <= 0)
|
2012-12-04 19:23:19 -07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
df::unit_labor labor = j->first;
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2012-12-04 19:23:19 -07:00
|
|
|
for (std::list<dwarf_info_t*>::iterator k = available_dwarfs.begin(); k != available_dwarfs.end(); k++)
|
2012-12-01 22:12:41 -07:00
|
|
|
{
|
2012-12-04 19:23:19 -07:00
|
|
|
dwarf_info_t* d = (*k);
|
2016-06-27 11:04:51 -06:00
|
|
|
int score = score_labor(d, labor);
|
2012-12-04 19:23:19 -07:00
|
|
|
if (score > best_score)
|
|
|
|
{
|
|
|
|
bestdwarf = k;
|
|
|
|
best_score = score;
|
|
|
|
best_labor = labor;
|
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-29 13:54:03 -06:00
|
|
|
if (best_labor == df::unit_labor::NONE)
|
|
|
|
break;
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
if (print_debug)
|
2012-12-08 02:51:07 -07:00
|
|
|
out.print("assign \"%s\" labor %s score=%d\n", (*bestdwarf)->dwarf->name.first_name.c_str(), ENUM_KEY_STR(unit_labor, best_labor).c_str(), best_score);
|
2012-12-04 19:23:19 -07:00
|
|
|
|
2012-12-01 22:12:41 -07:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
|
|
|
{
|
2012-12-04 19:23:19 -07:00
|
|
|
if (l == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
|
2016-06-30 22:58:56 -06:00
|
|
|
tools_enum t = default_labor_infos[l].tool;
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
if (l == best_labor && (t == TOOL_NONE || tool_in_use[t] < tool_count[t]))
|
2012-12-12 13:28:11 -07:00
|
|
|
{
|
2016-06-29 13:54:03 -06:00
|
|
|
set_labor(*bestdwarf, l, true);
|
2016-11-08 11:01:24 -07:00
|
|
|
if (t != TOOL_NONE && !((*bestdwarf)->has_tool[t]))
|
2012-12-12 13:28:11 -07:00
|
|
|
{
|
2016-06-30 22:58:56 -06:00
|
|
|
df::job_type j;
|
|
|
|
j = df::job_type::NONE;
|
|
|
|
|
|
|
|
if ((*bestdwarf)->dwarf->job.current_job)
|
|
|
|
j = (*bestdwarf)->dwarf->job.current_job->job_type;
|
|
|
|
|
|
|
|
if (print_debug)
|
|
|
|
out.print("LABORMANAGER: asking %s to pick up tools, current job %s\n", (*bestdwarf)->dwarf->name.first_name.c_str(), ENUM_KEY_STR(job_type, j).c_str());
|
|
|
|
|
|
|
|
(*bestdwarf)->dwarf->military.pickup_flags.bits.update = true;
|
|
|
|
labors_changed = true;
|
2012-12-12 13:28:11 -07:00
|
|
|
}
|
|
|
|
}
|
2013-01-22 15:34:51 -07:00
|
|
|
else if ((*bestdwarf)->state == IDLE)
|
2016-06-30 22:58:56 -06:00
|
|
|
{
|
2016-06-29 13:54:03 -06:00
|
|
|
set_labor(*bestdwarf, l, false);
|
2016-06-30 22:58:56 -06:00
|
|
|
}
|
2012-12-01 22:12:41 -07:00
|
|
|
}
|
2012-12-01 01:26:06 -07:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
if (best_labor == df::unit_labor::HAUL_FOOD && priority_food > 0)
|
|
|
|
priority_food--;
|
|
|
|
|
|
|
|
if (best_labor >= df::unit_labor::HAUL_STONE && best_labor <= df::unit_labor::HAUL_ANIMALS)
|
2012-12-04 19:23:19 -07:00
|
|
|
canary &= ~(1 << best_labor);
|
2012-12-08 02:51:07 -07:00
|
|
|
|
|
|
|
if (best_labor != df::unit_labor::NONE)
|
|
|
|
{
|
|
|
|
labor_infos[best_labor].active_dwarfs++;
|
|
|
|
to_assign[best_labor]--;
|
|
|
|
}
|
|
|
|
|
2016-06-28 21:57:12 -06:00
|
|
|
busy_dwarfs.push_back(*bestdwarf);
|
2012-12-01 22:12:41 -07:00
|
|
|
available_dwarfs.erase(bestdwarf);
|
2012-12-01 01:26:06 -07:00
|
|
|
}
|
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
for (auto d = busy_dwarfs.begin(); d != busy_dwarfs.end(); d++)
|
2012-12-02 01:02:16 -07:00
|
|
|
{
|
2017-07-22 03:31:30 -06:00
|
|
|
int current_score = score_labor(*d, (*d)->using_labor);
|
2016-06-27 11:04:51 -06:00
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
2012-12-02 01:02:16 -07:00
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (l == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
if (l == (*d)->using_labor)
|
|
|
|
continue;
|
|
|
|
if (labor_needed[l] <= 0)
|
|
|
|
continue;
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
int score = score_labor(*d, l);
|
2016-11-08 11:01:24 -07:00
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
if (l == df::unit_labor::HAUL_FOOD && priority_food > 0)
|
|
|
|
score += 1000000;
|
|
|
|
|
|
|
|
if (score > current_score)
|
|
|
|
{
|
|
|
|
tools_enum t = default_labor_infos[l].tool;
|
|
|
|
if (t == TOOL_NONE || (*d)->has_tool[t])
|
|
|
|
{
|
2016-06-29 13:54:03 -06:00
|
|
|
set_labor(*d, l, true);
|
2016-06-27 11:04:51 -06:00
|
|
|
}
|
2016-11-26 17:08:48 -07:00
|
|
|
if ((*d)->using_labor != df::unit_labor::NONE &&
|
|
|
|
(score > current_score + 5000 || base_priority[(*d)->using_labor] < base_priority[l]) &&
|
2016-11-08 11:01:24 -07:00
|
|
|
default_labor_infos[(*d)->using_labor].tool == TOOL_NONE)
|
2016-06-30 22:58:56 -06:00
|
|
|
set_labor(*d, (*d)->using_labor, false);
|
2016-06-27 11:04:51 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-28 21:36:45 -06:00
|
|
|
dwarf_info_t* canary_dwarf = 0;
|
2016-06-27 11:04:51 -06:00
|
|
|
|
2016-06-28 21:36:45 -06:00
|
|
|
for (auto di = busy_dwarfs.begin(); di != busy_dwarfs.end(); di++)
|
|
|
|
if (!(*di)->clear_all)
|
2016-06-27 11:04:51 -06:00
|
|
|
{
|
2016-06-28 21:36:45 -06:00
|
|
|
canary_dwarf = *di;
|
|
|
|
break;
|
2016-06-27 11:04:51 -06:00
|
|
|
}
|
2016-06-28 21:36:45 -06:00
|
|
|
|
|
|
|
if (canary_dwarf)
|
|
|
|
{
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
2016-06-27 11:04:51 -06:00
|
|
|
{
|
2016-06-28 21:36:45 -06:00
|
|
|
if (l >= df::unit_labor::HAUL_STONE && l <= df::unit_labor::HAUL_ANIMALS &&
|
|
|
|
canary & (1 << l))
|
2016-06-29 13:54:03 -06:00
|
|
|
set_labor(canary_dwarf, l, true);
|
2012-12-02 01:02:16 -07:00
|
|
|
}
|
2016-06-28 21:36:45 -06:00
|
|
|
|
2016-06-28 21:57:12 -06:00
|
|
|
/* Also set the canary to remove constructions, because we have no way yet to tell if there are constructions needing removal */
|
2016-06-28 21:36:45 -06:00
|
|
|
|
2016-06-29 13:54:03 -06:00
|
|
|
set_labor(canary_dwarf, df::unit_labor::REMOVE_CONSTRUCTION, true);
|
2016-06-28 21:36:45 -06:00
|
|
|
|
2018-02-21 17:46:21 -07:00
|
|
|
/* Set HAUL_WATER so we can detect ponds that need to be filled ponds. */
|
|
|
|
|
|
|
|
set_labor(canary_dwarf, df::unit_labor::HAUL_WATER, true);
|
|
|
|
|
2016-06-28 21:36:45 -06:00
|
|
|
if (print_debug)
|
2017-07-22 03:31:30 -06:00
|
|
|
out.print("Setting %s as the hauling canary\n", canary_dwarf->dwarf->name.first_name.c_str());
|
2016-06-28 21:36:45 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (print_debug)
|
2017-07-22 03:31:30 -06:00
|
|
|
out.print("No dwarf available to set as the hauling canary!\n");
|
2012-12-02 01:02:16 -07:00
|
|
|
}
|
|
|
|
|
2016-06-28 21:57:12 -06:00
|
|
|
/* Assign any leftover dwarfs to "standard" labors */
|
2016-06-28 21:36:45 -06:00
|
|
|
|
2016-11-08 11:01:24 -07:00
|
|
|
if (print_debug)
|
2018-06-11 10:57:06 -06:00
|
|
|
out.print("After assignment, %zu dwarfs left over\n", available_dwarfs.size());
|
2016-11-08 11:01:24 -07:00
|
|
|
|
2016-06-28 21:57:12 -06:00
|
|
|
for (auto d = available_dwarfs.begin(); d != available_dwarfs.end(); d++)
|
|
|
|
{
|
2017-07-22 03:31:30 -06:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
2016-06-28 21:36:45 -06:00
|
|
|
{
|
2016-11-08 11:01:24 -07:00
|
|
|
if (l == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
|
2016-11-26 17:08:48 -07:00
|
|
|
set_labor(*d, l,
|
|
|
|
(l >= df::unit_labor::HAUL_STONE && l <= df::unit_labor::HAUL_ANIMALS) ||
|
|
|
|
l == df::unit_labor::CLEAN ||
|
2018-02-21 17:46:21 -07:00
|
|
|
l == df::unit_labor::HAUL_WATER ||
|
2016-11-26 17:08:48 -07:00
|
|
|
l == df::unit_labor::REMOVE_CONSTRUCTION ||
|
2016-11-08 11:01:24 -07:00
|
|
|
l == df::unit_labor::PULL_LEVER ||
|
|
|
|
l == df::unit_labor::HAUL_TRADE);
|
2017-07-22 03:31:30 -06:00
|
|
|
}
|
2016-06-28 21:57:12 -06:00
|
|
|
}
|
2016-06-28 21:36:45 -06:00
|
|
|
|
2016-08-11 15:56:34 -06:00
|
|
|
/* check for dwarfs assigned no labors and assign them the bucket list if there are */
|
|
|
|
for (auto d = dwarf_info.begin(); d != dwarf_info.end(); d++)
|
|
|
|
{
|
2016-08-11 15:58:35 -06:00
|
|
|
if ((*d)->state == CHILD)
|
2016-08-11 15:56:34 -06:00
|
|
|
continue;
|
|
|
|
|
|
|
|
bool any = false;
|
2017-07-22 03:31:30 -06:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
2016-08-11 15:56:34 -06:00
|
|
|
{
|
2016-08-11 15:58:35 -06:00
|
|
|
if (l == df::unit_labor::NONE)
|
2016-08-11 15:56:34 -06:00
|
|
|
continue;
|
|
|
|
if ((*d)->dwarf->status.labors[l])
|
|
|
|
{
|
|
|
|
any = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
set_labor(*d, df::unit_labor::PULL_LEVER, true);
|
2016-08-11 15:56:34 -06:00
|
|
|
|
|
|
|
if (any) continue;
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
2016-08-11 15:56:34 -06:00
|
|
|
{
|
|
|
|
if (l == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (to_assign[l] > 0 || l == df::unit_labor::CLEAN)
|
|
|
|
set_labor(*d, l, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-12 13:28:11 -07:00
|
|
|
/* set reequip on any dwarfs who are carrying tools needed by others */
|
|
|
|
|
|
|
|
for (auto d = dwarf_info.begin(); d != dwarf_info.end(); d++)
|
|
|
|
{
|
2016-06-30 22:58:56 -06:00
|
|
|
if ((*d)->dwarf->job.current_job && (*d)->dwarf->job.current_job->job_type == df::job_type::PickupEquipment)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((*d)->dwarf->military.pickup_flags.bits.update)
|
|
|
|
continue;
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
FOR_ENUM_ITEMS(unit_labor, l)
|
2012-12-12 13:28:11 -07:00
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (l == df::unit_labor::NONE)
|
|
|
|
continue;
|
|
|
|
|
2012-12-12 13:28:11 -07:00
|
|
|
tools_enum t = default_labor_infos[l].tool;
|
2016-06-30 22:58:56 -06:00
|
|
|
if (t == TOOL_NONE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bool has_tool = (*d)->has_tool[t];
|
|
|
|
bool needs_tool = (*d)->dwarf->status.labors[l];
|
|
|
|
|
2016-11-08 11:01:24 -07:00
|
|
|
if ((needs_tool && !has_tool) ||
|
|
|
|
(has_tool && !needs_tool && tool_in_use[t] >= tool_count[t]))
|
2012-12-12 13:28:11 -07:00
|
|
|
{
|
2016-06-30 22:58:56 -06:00
|
|
|
df::job_type j = df::job_type::NONE;
|
|
|
|
|
|
|
|
if ((*d)->dwarf->job.current_job)
|
|
|
|
j = (*d)->dwarf->job.current_job->job_type;
|
|
|
|
|
|
|
|
if (print_debug)
|
|
|
|
out.print("LABORMANAGER: asking %s to %s tools, current job %s, %d %d \n", (*d)->dwarf->name.first_name.c_str(), (has_tool) ? "drop" : "pick up", ENUM_KEY_STR(job_type, j).c_str(), has_tool, needs_tool);
|
|
|
|
|
|
|
|
(*d)->dwarf->military.pickup_flags.bits.update = true;
|
|
|
|
labors_changed = true;
|
|
|
|
|
|
|
|
if (needs_tool)
|
|
|
|
tool_in_use[t]++;
|
2012-12-12 13:28:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
release_dwarf_list();
|
|
|
|
|
2016-06-29 13:54:03 -06:00
|
|
|
if (labors_changed)
|
|
|
|
{
|
|
|
|
*df::global::process_dig = true;
|
|
|
|
*df::global::process_jobs = true;
|
|
|
|
}
|
2013-01-04 12:14:20 -07:00
|
|
|
|
2016-11-08 11:01:24 -07:00
|
|
|
if (print_debug) {
|
|
|
|
*df::global::pause_state = true;
|
|
|
|
}
|
|
|
|
|
2012-12-01 01:26:06 -07:00
|
|
|
print_debug = 0;
|
|
|
|
|
|
|
|
}
|
2012-10-01 16:48:47 -06:00
|
|
|
|
|
|
|
};
|
2012-07-22 11:16:50 -06:00
|
|
|
|
|
|
|
|
2012-04-05 00:33:26 -06:00
|
|
|
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event)
|
|
|
|
{
|
|
|
|
switch (event) {
|
|
|
|
case SC_MAP_LOADED:
|
|
|
|
cleanup_state();
|
|
|
|
init_state();
|
|
|
|
break;
|
|
|
|
case SC_MAP_UNLOADED:
|
|
|
|
cleanup_state();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
DFhackCExport command_result plugin_onupdate(color_ostream &out)
|
2012-03-16 22:45:52 -06:00
|
|
|
{
|
2018-04-06 00:18:15 -06:00
|
|
|
// static int step_count = 0;
|
2012-03-31 19:46:17 -06:00
|
|
|
// check run conditions
|
2017-07-22 03:31:30 -06:00
|
|
|
if (!initialized || !world || !world->map.block_index || !enable_labormanager)
|
2012-03-31 19:46:17 -06:00
|
|
|
{
|
|
|
|
// give up if we shouldn't be running'
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
// if (++step_count < 60)
|
|
|
|
// return CR_OK;
|
2016-11-08 11:01:24 -07:00
|
|
|
|
2016-11-26 17:08:48 -07:00
|
|
|
if (*df::global::process_jobs)
|
2012-07-17 09:27:30 -06:00
|
|
|
return CR_OK;
|
2016-11-08 11:01:24 -07:00
|
|
|
|
2018-04-06 00:18:15 -06:00
|
|
|
// step_count = 0;
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-12-02 01:02:16 -07:00
|
|
|
debug_stream = &out;
|
2012-12-01 01:26:06 -07:00
|
|
|
AutoLaborManager alm(out);
|
|
|
|
alm.process();
|
2012-03-22 01:33:18 -06:00
|
|
|
|
2012-03-16 22:45:52 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
void print_labor(df::unit_labor labor, color_ostream &out)
|
2012-04-02 23:12:06 -06:00
|
|
|
{
|
2012-07-17 09:27:30 -06:00
|
|
|
string labor_name = ENUM_KEY_STR(unit_labor, labor);
|
|
|
|
out << labor_name << ": ";
|
|
|
|
for (int i = 0; i < 20 - (int)labor_name.length(); i++)
|
|
|
|
out << ' ';
|
2012-12-02 13:27:13 -07:00
|
|
|
out << "priority " << labor_infos[labor].priority()
|
|
|
|
<< ", maximum " << labor_infos[labor].maximum_dwarfs()
|
2013-01-01 15:35:09 -07:00
|
|
|
<< ", currently " << labor_infos[labor].active_dwarfs << " dwarfs ("
|
2015-02-14 20:53:06 -07:00
|
|
|
<< labor_infos[labor].busy_dwarfs << " busy, "
|
2013-01-01 15:35:09 -07:00
|
|
|
<< labor_infos[labor].idle_dwarfs << " idle)"
|
|
|
|
<< endl;
|
2012-12-02 13:27:13 -07:00
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
df::unit_labor lookup_labor_by_name(std::string& name)
|
2012-12-02 13:27:13 -07:00
|
|
|
{
|
|
|
|
df::unit_labor labor = df::unit_labor::NONE;
|
|
|
|
|
|
|
|
FOR_ENUM_ITEMS(unit_labor, test_labor)
|
2012-07-17 09:27:30 -06:00
|
|
|
{
|
2012-12-02 13:27:13 -07:00
|
|
|
if (name == ENUM_KEY_STR(unit_labor, test_labor))
|
|
|
|
labor = test_labor;
|
2012-07-17 09:27:30 -06:00
|
|
|
}
|
2012-12-02 13:27:13 -07:00
|
|
|
|
|
|
|
return labor;
|
2012-04-02 23:12:06 -06:00
|
|
|
}
|
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
DFhackCExport command_result plugin_enable(color_ostream &out, bool enable)
|
2013-09-30 03:19:51 -06:00
|
|
|
{
|
|
|
|
if (!Core::getInstance().isWorldLoaded()) {
|
2016-06-27 11:04:51 -06:00
|
|
|
out.printerr("World is not loaded: please load a fort first.\n");
|
2013-09-30 03:19:51 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
if (enable && !enable_labormanager)
|
2013-09-30 03:19:51 -06:00
|
|
|
{
|
|
|
|
enable_plugin(out);
|
|
|
|
}
|
2017-07-22 03:31:30 -06:00
|
|
|
else if (!enable && enable_labormanager)
|
2013-09-30 03:19:51 -06:00
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
enable_labormanager = false;
|
2013-09-30 03:19:51 -06:00
|
|
|
setOptionEnabled(CF_ENABLED, false);
|
|
|
|
|
2016-06-27 11:04:51 -06:00
|
|
|
out << "LaborManager is disabled." << endl;
|
2013-09-30 03:19:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-07-22 11:16:50 -06:00
|
|
|
|
2017-07-22 03:31:30 -06:00
|
|
|
command_result labormanager(color_ostream &out, std::vector <std::string> & parameters)
|
2012-03-16 22:45:52 -06:00
|
|
|
{
|
2012-04-05 00:33:26 -06:00
|
|
|
CoreSuspender suspend;
|
|
|
|
|
|
|
|
if (!Core::getInstance().isWorldLoaded()) {
|
|
|
|
out.printerr("World is not loaded: please load a game first.\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
if (parameters.size() == 1 &&
|
2012-12-02 13:27:13 -07:00
|
|
|
(parameters[0] == "enable" || parameters[0] == "disable"))
|
2012-03-16 22:45:52 -06:00
|
|
|
{
|
2012-12-02 13:27:13 -07:00
|
|
|
bool enable = (parameters[0] == "enable");
|
2013-09-30 03:19:51 -06:00
|
|
|
return plugin_enable(out, enable);
|
2012-03-16 22:45:52 -06:00
|
|
|
}
|
2015-02-14 20:53:06 -07:00
|
|
|
else if (parameters.size() == 3 &&
|
2012-12-02 13:27:13 -07:00
|
|
|
(parameters[0] == "max" || parameters[0] == "priority"))
|
2012-08-02 09:32:25 -06:00
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (!enable_labormanager)
|
2012-08-02 09:32:25 -06:00
|
|
|
{
|
|
|
|
out << "Error: The plugin is not enabled." << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-12-02 13:27:13 -07:00
|
|
|
df::unit_labor labor = lookup_labor_by_name(parameters[1]);
|
|
|
|
|
|
|
|
if (labor == df::unit_labor::NONE)
|
|
|
|
{
|
|
|
|
out.printerr("Could not find labor %s.\n", parameters[0].c_str());
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int v;
|
|
|
|
|
|
|
|
if (parameters[2] == "none")
|
|
|
|
v = 0;
|
2015-02-14 20:53:06 -07:00
|
|
|
else
|
2017-07-22 03:31:30 -06:00
|
|
|
v = atoi(parameters[2].c_str());
|
2012-12-02 13:27:13 -07:00
|
|
|
|
|
|
|
if (parameters[0] == "max")
|
|
|
|
labor_infos[labor].set_maximum_dwarfs(v);
|
|
|
|
else if (parameters[0] == "priority")
|
|
|
|
labor_infos[labor].set_priority(v);
|
|
|
|
|
|
|
|
print_labor(labor, out);
|
2012-08-02 09:32:25 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-12-02 13:27:13 -07:00
|
|
|
else if (parameters.size() == 2 && parameters[0] == "reset")
|
2012-09-13 13:42:17 -06:00
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (!enable_labormanager)
|
2012-07-17 09:27:30 -06:00
|
|
|
{
|
|
|
|
out << "Error: The plugin is not enabled." << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-12-02 13:27:13 -07:00
|
|
|
df::unit_labor labor = lookup_labor_by_name(parameters[1]);
|
2012-07-17 09:27:30 -06:00
|
|
|
|
2012-12-02 13:27:13 -07:00
|
|
|
if (labor == df::unit_labor::NONE)
|
2012-07-17 09:27:30 -06:00
|
|
|
{
|
|
|
|
out.printerr("Could not find labor %s.\n", parameters[0].c_str());
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
}
|
2012-12-02 13:27:13 -07:00
|
|
|
reset_labor(labor);
|
2012-07-17 09:27:30 -06:00
|
|
|
print_labor(labor, out);
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-12-04 19:23:19 -07:00
|
|
|
else if (parameters.size() == 1 && (parameters[0] == "allow-fishing" || parameters[0] == "forbid-fishing"))
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (!enable_labormanager)
|
2012-12-04 19:23:19 -07:00
|
|
|
{
|
|
|
|
out << "Error: The plugin is not enabled." << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
setOptionEnabled(CF_ALLOW_FISHING, (parameters[0] == "allow-fishing"));
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
else if (parameters.size() == 1 && (parameters[0] == "allow-hunting" || parameters[0] == "forbid-hunting"))
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (!enable_labormanager)
|
2012-12-04 19:23:19 -07:00
|
|
|
{
|
|
|
|
out << "Error: The plugin is not enabled." << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
setOptionEnabled(CF_ALLOW_HUNTING, (parameters[0] == "allow-hunting"));
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-09-13 13:42:17 -06:00
|
|
|
else if (parameters.size() == 1 && parameters[0] == "reset-all")
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (!enable_labormanager)
|
2012-07-17 09:27:30 -06:00
|
|
|
{
|
|
|
|
out << "Error: The plugin is not enabled." << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2018-04-06 13:17:34 -06:00
|
|
|
for (size_t i = 0; i < labor_infos.size(); i++)
|
2012-07-17 09:27:30 -06:00
|
|
|
{
|
2012-09-13 13:42:17 -06:00
|
|
|
reset_labor((df::unit_labor) i);
|
2012-07-17 09:27:30 -06:00
|
|
|
}
|
|
|
|
out << "All labors reset." << endl;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2018-04-06 00:18:15 -06:00
|
|
|
else if (parameters.size() == 1 && (parameters[0] == "list" || parameters[0] == "status"))
|
2012-09-13 13:42:17 -06:00
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (!enable_labormanager)
|
2012-07-17 09:27:30 -06:00
|
|
|
{
|
|
|
|
out << "Error: The plugin is not enabled." << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool need_comma = 0;
|
|
|
|
for (int i = 0; i < NUM_STATE; i++)
|
|
|
|
{
|
|
|
|
if (state_count[i] == 0)
|
|
|
|
continue;
|
|
|
|
if (need_comma)
|
|
|
|
out << ", ";
|
|
|
|
out << state_count[i] << ' ' << state_names[i];
|
|
|
|
need_comma = 1;
|
|
|
|
}
|
|
|
|
out << endl;
|
|
|
|
|
|
|
|
if (parameters[0] == "list")
|
|
|
|
{
|
|
|
|
FOR_ENUM_ITEMS(unit_labor, labor)
|
|
|
|
{
|
2012-09-13 13:42:17 -06:00
|
|
|
if (labor == unit_labor::NONE)
|
2012-07-17 09:27:30 -06:00
|
|
|
continue;
|
|
|
|
|
|
|
|
print_labor(labor, out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2016-06-27 19:58:38 -06:00
|
|
|
else if (parameters.size() == 2 && parameters[0] == "pause-on-error")
|
|
|
|
{
|
|
|
|
if (!enable_labormanager)
|
|
|
|
{
|
|
|
|
out << "Error: The plugin is not enabled." << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pause_on_error = parameters[1] == "yes" || parameters[1] == "true";
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-08-02 09:32:25 -06:00
|
|
|
else if (parameters.size() == 1 && parameters[0] == "debug")
|
|
|
|
{
|
2016-06-27 11:04:51 -06:00
|
|
|
if (!enable_labormanager)
|
2012-07-17 09:27:30 -06:00
|
|
|
{
|
|
|
|
out << "Error: The plugin is not enabled." << endl;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_debug = 1;
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
else
|
2012-03-16 22:45:52 -06:00
|
|
|
{
|
|
|
|
out.print("Automatically assigns labors to dwarves.\n"
|
2016-06-27 11:04:51 -06:00
|
|
|
"Activate with 'labormanager enable', deactivate with 'labormanager disable'.\n"
|
|
|
|
"Current state: %s.\n", enable_labormanager ? "enabled" : "disabled");
|
2012-03-16 22:45:52 -06:00
|
|
|
|
2012-07-17 09:27:30 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-03-16 22:45:52 -06:00
|
|
|
}
|
2012-07-22 11:16:50 -06:00
|
|
|
|