@ -414,23 +414,23 @@ struct labor_default
static std : : vector < struct labor_info > labor_infos ;
static const struct labor_default default_labor_infos [ ] = {
/* MINE a */ { 2 00, 0 , TOOL_PICK } ,
/* MINE */ { 1 00, 0 , TOOL_PICK } ,
/* HAUL_STONE */ { 100 , 0 , TOOL_NONE } ,
/* HAUL_WOOD */ { 100 , 0 , TOOL_NONE } ,
/* HAUL_BODY */ { 2 00, 0 , TOOL_NONE } ,
/* HAUL_FOOD */ { 3 00, 0 , TOOL_NONE } ,
/* HAUL_REFUSE */ { 1 00, 0 , TOOL_NONE } ,
/* HAUL_BODY */ { 10 00, 0 , TOOL_NONE } ,
/* HAUL_FOOD */ { 5 00, 0 , TOOL_NONE } ,
/* HAUL_REFUSE */ { 2 00, 0 , TOOL_NONE } ,
/* HAUL_ITEM */ { 100 , 0 , TOOL_NONE } ,
/* HAUL_FURNITURE */ { 100 , 0 , TOOL_NONE } ,
/* HAUL_ANIMAL */ { 100 , 0 , TOOL_NONE } ,
/* CLEAN */ { 2 00, 0 , TOOL_NONE } ,
/* CUTWOOD */ { 2 00, 0 , TOOL_AXE } ,
/* CARPENTER */ { 2 00, 0 , TOOL_NONE } ,
/* DETAIL */ { 2 00, 0 , TOOL_NONE } ,
/* MASON */ { 2 00, 0 , TOOL_NONE } ,
/* ARCHITECT */ { 4 00, 0 , TOOL_NONE } ,
/* ANIMALTRAIN */ { 2 00, 0 , TOOL_NONE } ,
/* ANIMALCARE */ { 2 00, 0 , TOOL_NONE } ,
/* CLEAN */ { 1 00, 0 , TOOL_NONE } ,
/* CUTWOOD */ { 1 00, 0 , TOOL_AXE } ,
/* CARPENTER */ { 1 00, 0 , TOOL_NONE } ,
/* DETAIL */ { 1 00, 0 , TOOL_NONE } ,
/* MASON */ { 1 00, 0 , TOOL_NONE } ,
/* ARCHITECT */ { 1 00, 0 , TOOL_NONE } ,
/* ANIMALTRAIN */ { 1 00, 0 , TOOL_NONE } ,
/* ANIMALCARE */ { 1 00, 0 , TOOL_NONE } ,
/* DIAGNOSE */ { 1000 , 0 , TOOL_NONE } ,
/* SURGERY */ { 1000 , 0 , TOOL_NONE } ,
/* BONE_SETTING */ { 1000 , 0 , TOOL_NONE } ,
@ -438,65 +438,65 @@ static const struct labor_default default_labor_infos[] = {
/* DRESSING_WOUNDS */ { 1000 , 0 , TOOL_NONE } ,
/* FEED_WATER_CIVILIANS */ { 1000 , 0 , TOOL_NONE } ,
/* RECOVER_WOUNDED */ { 200 , 0 , TOOL_NONE } ,
/* BUTCHER */ { 2 00, 0 , TOOL_NONE } ,
/* TRAPPER */ { 2 00, 0 , TOOL_NONE } ,
/* DISSECT_VERMIN */ { 2 00, 0 , TOOL_NONE } ,
/* LEATHER */ { 2 00, 0 , TOOL_NONE } ,
/* TANNER */ { 2 00, 0 , TOOL_NONE } ,
/* BREWER */ { 2 00, 0 , TOOL_NONE } ,
/* ALCHEMIST */ { 2 00, 0 , TOOL_NONE } ,
/* SOAP_MAKER */ { 2 00, 0 , TOOL_NONE } ,
/* WEAVER */ { 2 00, 0 , TOOL_NONE } ,
/* CLOTHESMAKER */ { 2 00, 0 , TOOL_NONE } ,
/* MILLER */ { 2 00, 0 , TOOL_NONE } ,
/* PROCESS_PLANT */ { 2 00, 0 , TOOL_NONE } ,
/* MAKE_CHEESE */ { 2 00, 0 , TOOL_NONE } ,
/* MILK */ { 2 00, 0 , TOOL_NONE } ,
/* COOK */ { 2 00, 0 , TOOL_NONE } ,
/* PLANT */ { 2 00, 0 , TOOL_NONE } ,
/* HERBALIST */ { 2 00, 0 , TOOL_NONE } ,
/* BUTCHER */ { 5 00, 0 , TOOL_NONE } ,
/* TRAPPER */ { 1 00, 0 , TOOL_NONE } ,
/* DISSECT_VERMIN */ { 1 00, 0 , TOOL_NONE } ,
/* LEATHER */ { 1 00, 0 , TOOL_NONE } ,
/* TANNER */ { 1 00, 0 , TOOL_NONE } ,
/* BREWER */ { 1 00, 0 , TOOL_NONE } ,
/* ALCHEMIST */ { 1 00, 0 , TOOL_NONE } ,
/* SOAP_MAKER */ { 1 00, 0 , TOOL_NONE } ,
/* WEAVER */ { 1 00, 0 , TOOL_NONE } ,
/* CLOTHESMAKER */ { 1 00, 0 , TOOL_NONE } ,
/* MILLER */ { 1 00, 0 , TOOL_NONE } ,
/* PROCESS_PLANT */ { 1 00, 0 , TOOL_NONE } ,
/* MAKE_CHEESE */ { 1 00, 0 , TOOL_NONE } ,
/* MILK */ { 1 00, 0 , TOOL_NONE } ,
/* COOK */ { 1 00, 0 , TOOL_NONE } ,
/* PLANT */ { 1 00, 0 , TOOL_NONE } ,
/* HERBALIST */ { 1 00, 0 , TOOL_NONE } ,
/* FISH */ { 100 , 0 , TOOL_NONE } ,
/* CLEAN_FISH */ { 2 00, 0 , TOOL_NONE } ,
/* DISSECT_FISH */ { 2 00, 0 , TOOL_NONE } ,
/* CLEAN_FISH */ { 1 00, 0 , TOOL_NONE } ,
/* DISSECT_FISH */ { 1 00, 0 , TOOL_NONE } ,
/* HUNT */ { 100 , 0 , TOOL_CROSSBOW } ,
/* SMELT */ { 2 00, 0 , TOOL_NONE } ,
/* FORGE_WEAPON */ { 2 00, 0 , TOOL_NONE } ,
/* FORGE_ARMOR */ { 2 00, 0 , TOOL_NONE } ,
/* FORGE_FURNITURE */ { 2 00, 0 , TOOL_NONE } ,
/* METAL_CRAFT */ { 2 00, 0 , TOOL_NONE } ,
/* CUT_GEM */ { 2 00, 0 , TOOL_NONE } ,
/* ENCRUST_GEM */ { 2 00, 0 , TOOL_NONE } ,
/* WOOD_CRAFT */ { 2 00, 0 , TOOL_NONE } ,
/* STONE_CRAFT */ { 2 00, 0 , TOOL_NONE } ,
/* BONE_CARVE */ { 2 00, 0 , TOOL_NONE } ,
/* GLASSMAKER */ { 2 00, 0 , TOOL_NONE } ,
/* EXTRACT_STRAND */ { 2 00, 0 , TOOL_NONE } ,
/* SIEGECRAFT */ { 2 00, 0 , TOOL_NONE } ,
/* SIEGEOPERATE */ { 2 00, 0 , TOOL_NONE } ,
/* BOWYER */ { 2 00, 0 , TOOL_NONE } ,
/* MECHANIC */ { 2 00, 0 , TOOL_NONE } ,
/* POTASH_MAKING */ { 2 00, 0 , TOOL_NONE } ,
/* LYE_MAKING */ { 2 00, 0 , TOOL_NONE } ,
/* DYER */ { 2 00, 0 , TOOL_NONE } ,
/* BURN_WOOD */ { 2 00, 0 , TOOL_NONE } ,
/* OPERATE_PUMP */ { 2 00, 0 , TOOL_NONE } ,
/* SHEARER */ { 2 00, 0 , TOOL_NONE } ,
/* SPINNER */ { 2 00, 0 , TOOL_NONE } ,
/* POTTERY */ { 2 00, 0 , TOOL_NONE } ,
/* GLAZING */ { 2 00, 0 , TOOL_NONE } ,
/* PRESSING */ { 2 00, 0 , TOOL_NONE } ,
/* BEEKEEPING */ { 2 00, 0 , TOOL_NONE } ,
/* WAX_WORKING */ { 2 00, 0 , TOOL_NONE } ,
/* PUSH_HAUL_VEHICLES */ { 2 00, 0 , TOOL_NONE } ,
/* HAUL_TRADE */ { 2 00, 0 , TOOL_NONE } ,
/* PULL_LEVER */ { 2 00, 0 , TOOL_NONE } ,
/* REMOVE_CONSTRUCTION */ { 2 00, 0 , TOOL_NONE } ,
/* HAUL_WATER */ { 2 00, 0 , TOOL_NONE } ,
/* GELD */ { 2 00, 0 , TOOL_NONE } ,
/* BUILD_ROAD */ { 2 00, 0 , TOOL_NONE } ,
/* BUILD_CONSTRUCTION */ { 2 00, 0 , TOOL_NONE } ,
/* PAPERMAKING */ { 2 00, 0 , TOOL_NONE } ,
/* BOOKBINDING */ { 2 00, 0 , TOOL_NONE }
/* SMELT */ { 1 00, 0 , TOOL_NONE } ,
/* FORGE_WEAPON */ { 1 00, 0 , TOOL_NONE } ,
/* FORGE_ARMOR */ { 1 00, 0 , TOOL_NONE } ,
/* FORGE_FURNITURE */ { 1 00, 0 , TOOL_NONE } ,
/* METAL_CRAFT */ { 1 00, 0 , TOOL_NONE } ,
/* CUT_GEM */ { 1 00, 0 , TOOL_NONE } ,
/* ENCRUST_GEM */ { 1 00, 0 , TOOL_NONE } ,
/* WOOD_CRAFT */ { 1 00, 0 , TOOL_NONE } ,
/* STONE_CRAFT */ { 1 00, 0 , TOOL_NONE } ,
/* BONE_CARVE */ { 1 00, 0 , TOOL_NONE } ,
/* GLASSMAKER */ { 1 00, 0 , TOOL_NONE } ,
/* EXTRACT_STRAND */ { 1 00, 0 , TOOL_NONE } ,
/* SIEGECRAFT */ { 1 00, 0 , TOOL_NONE } ,
/* SIEGEOPERATE */ { 1 00, 0 , TOOL_NONE } ,
/* BOWYER */ { 1 00, 0 , TOOL_NONE } ,
/* MECHANIC */ { 1 00, 0 , TOOL_NONE } ,
/* POTASH_MAKING */ { 1 00, 0 , TOOL_NONE } ,
/* LYE_MAKING */ { 1 00, 0 , TOOL_NONE } ,
/* DYER */ { 1 00, 0 , TOOL_NONE } ,
/* BURN_WOOD */ { 1 00, 0 , TOOL_NONE } ,
/* OPERATE_PUMP */ { 1 00, 0 , TOOL_NONE } ,
/* SHEARER */ { 1 00, 0 , TOOL_NONE } ,
/* SPINNER */ { 1 00, 0 , TOOL_NONE } ,
/* POTTERY */ { 1 00, 0 , TOOL_NONE } ,
/* GLAZING */ { 1 00, 0 , TOOL_NONE } ,
/* PRESSING */ { 1 00, 0 , TOOL_NONE } ,
/* BEEKEEPING */ { 1 00, 0 , TOOL_NONE } ,
/* WAX_WORKING */ { 1 00, 0 , TOOL_NONE } ,
/* PUSH_HAUL_VEHICLES */ { 1 00, 0 , TOOL_NONE } ,
/* HAUL_TRADE */ { 10 00, 0 , TOOL_NONE } ,
/* PULL_LEVER */ { 10 00, 0 , TOOL_NONE } ,
/* REMOVE_CONSTRUCTION */ { 1 00, 0 , TOOL_NONE } ,
/* HAUL_WATER */ { 1 00, 0 , TOOL_NONE } ,
/* GELD */ { 1 00, 0 , TOOL_NONE } ,
/* BUILD_ROAD */ { 1 00, 0 , TOOL_NONE } ,
/* BUILD_CONSTRUCTION */ { 1 00, 0 , TOOL_NONE } ,
/* PAPERMAKING */ { 1 00, 0 , TOOL_NONE } ,
/* BOOKBINDING */ { 1 00, 0 , TOOL_NONE }
} ;
void debug ( char * fmt , . . . ) ;
@ -852,12 +852,13 @@ private:
return df : : unit_labor : : TRAPPER ;
case df : : building_type : : Civzone :
case df : : building_type : : Nest :
case df : : building_type : : RoadDirt :
case df : : building_type : : Stockpile :
case df : : building_type : : Weapon :
return df : : unit_labor : : NONE ;
case df : : building_type : : SiegeEngine :
return df : : unit_labor : : SIEGECRAFT ;
case df : : building_type : : RoadDirt :
return df : : unit_labor : : BUILD_ROAD ;
}
debug ( " LABORMANAGER: Cannot deduce labor for construct building job of type %s \n " ,
@ -1167,13 +1168,13 @@ public:
job_to_labor_table [ df : : job_type : : CheckChest ] = jlf_no_labor ;
job_to_labor_table [ df : : job_type : : StoreOwnedItem ] = jlf_no_labor ;
job_to_labor_table [ df : : job_type : : PlaceItemInTomb ] = jlf_const ( df : : unit_labor : : HAUL_BODY ) ;
job_to_labor_table [ df : : job_type : : StoreItemInStockpile ] = jlf_ no_labor; // Can arise from many different labors, but will never appear in a pending job list
job_to_labor_table [ df : : job_type : : StoreItemInBag ] = jlf_ no_labor; // Can arise from many different labors, but will never appear in a pending job list
job_to_labor_table [ df : : job_type : : StoreItemInStockpile ] = jlf_ hauling;
job_to_labor_table [ df : : job_type : : StoreItemInBag ] = jlf_ hauling;
job_to_labor_table [ df : : job_type : : StoreItemInHospital ] = jlf_hauling ;
job_to_labor_table [ df : : job_type : : StoreWeapon ] = jlf_hauling ;
job_to_labor_table [ df : : job_type : : StoreArmor ] = jlf_hauling ;
job_to_labor_table [ df : : job_type : : StoreItemInBarrel ] = jlf_ no_labor; // Can arise from many different labors, but will never appear in a pending job list
job_to_labor_table [ df : : job_type : : StoreItemInBin ] = jlf_ no_labor; // Can arise from many different labors, but will never appear in a pending job list
job_to_labor_table [ df : : job_type : : StoreItemInBarrel ] = jlf_ hauling;
job_to_labor_table [ df : : job_type : : StoreItemInBin ] = jlf_ hauling;
job_to_labor_table [ df : : job_type : : SeekArtifact ] = jlf_no_labor ;
job_to_labor_table [ df : : job_type : : SeekInfant ] = jlf_no_labor ;
job_to_labor_table [ df : : job_type : : AttendParty ] = jlf_no_labor ;
@ -1676,20 +1677,24 @@ private:
if ( bld ! = - 1 )
{
df : : building * b = binsearch_in_vector ( world - > buildings . all , bld ) ;
int fjid = - 1 ;
for ( int jn = 0 ; jn < b - > jobs . size ( ) ; jn + + )
{
if ( b - > jobs [ jn ] - > flags . bits . suspend )
continue ;
fjid = b - > jobs [ jn ] - > id ;
break ;
}
// check if this job is the first nonsuspended job on this building; if not, ignore it
// (except for farms and trade depots)
if ( fjid ! = j - > id & &
b - > getType ( ) ! = df : : building_type : : FarmPlot & &
if ( b - > getType ( ) ! = df : : building_type : : FarmPlot & &
b - > getType ( ) ! = df : : building_type : : TradeDepot )
return ;
{
int fjid = - 1 ;
for ( int jn = 0 ; jn < b - > jobs . size ( ) ; jn + + )
{
if ( b - > jobs [ jn ] - > flags . bits . suspend )
continue ;
fjid = b - > jobs [ jn ] - > id ;
break ;
}
if ( fjid ! = j - > id )
return ;
}
}
df : : unit_labor labor = labor_mapper - > find_job_labor ( j ) ;
@ -2056,7 +2061,8 @@ private:
out . print ( " Dwarf \" %s \" : state %s %d \n " , dwarf - > dwarf - > name . first_name . c_str ( ) , state_names [ dwarf - > state ] , dwarf - > clear_all ) ;
// determine if dwarf has medical needs
if ( dwarf - > dwarf - > health )
// babies cannot currently receive health care even if they need it
if ( dwarf - > dwarf - > profession ! = profession : : BABY & & dwarf - > dwarf - > health )
{
if ( dwarf - > dwarf - > health - > flags . bits . needs_recovery )
cnt_recover_wounded + + ;
@ -2160,13 +2166,10 @@ private:
if ( labor = = df : : unit_labor : : OPERATE_PUMP )
score + = 50000 ;
else
score + = 1 000;
score + = 25 000;
if ( default_labor_infos [ labor ] . tool ! = TOOL_NONE & &
d - > has_tool [ default_labor_infos [ labor ] . tool ] )
score + = 30000 ;
if ( default_labor_infos [ labor ] . tool ! = TOOL_NONE & &
! d - > has_tool [ default_labor_infos [ labor ] . tool ] )
score - = 30000 ;
score + = 10000000 ;
if ( d - > has_children & & labor_outside [ labor ] )
score - = 15000 ;
if ( d - > armed & & labor_outside [ labor ] )
@ -2361,8 +2364,6 @@ public:
}
labor_needed [ df : : unit_labor : : CLEAN ] = 1 ;
if ( print_debug )
{
for ( auto i = labor_needed . begin ( ) ; i ! = labor_needed . end ( ) ; i + + )
@ -2372,7 +2373,9 @@ public:
}
}
std : : map < df : : unit_labor , int > base_priority ;
priority_queue < pair < int , df : : unit_labor > > pq ;
priority_queue < pair < int , df : : unit_labor > > pq2 ;
for ( auto i = labor_needed . begin ( ) ; i ! = labor_needed . end ( ) ; i + + )
{
@ -2383,15 +2386,16 @@ public:
if ( labor_infos [ l ] . maximum_dwarfs ( ) > 0 & &
i - > second > labor_infos [ l ] . maximum_dwarfs ( ) )
i - > second = labor_infos [ l ] . maximum_dwarfs ( ) ;
if ( i - > second > 0 )
{
int priority = labor_infos [ l ] . priority ( ) ;
if ( l < df : : unit_labor : : HAUL_STONE | | l > df : : unit_labor : : HAUL_ANIMALS )
priority + = labor_infos [ l ] . time_since_last_assigned ( ) / 12 ;
int priority = labor_infos [ l ] . priority ( ) ;
priority + = labor_infos [ l ] . time_since_last_assigned ( ) / 12 ;
priority - = labor_infos [ l ] . busy_dwarfs ;
base_priority [ l ] = priority ;
for ( int n = 0 ; n < labor_infos [ l ] . busy_dwarfs ; n + + )
priority / = 2 ;
if ( i - > second > 0 )
{
pq . push ( make_pair ( priority , l ) ) ;
}
}
@ -2418,9 +2422,22 @@ public:
if ( - - labor_needed [ labor ] > 0 )
{
priority / = 2 ;
pq . push ( make_pair ( priority , labor ) ) ;
priority - = 10 ;
pq 2 . push ( make_pair ( priority , labor ) ) ;
}
if ( pq . empty ( ) )
while ( ! pq2 . empty ( ) )
{
pq . push ( pq2 . top ( ) ) ;
pq2 . pop ( ) ;
}
}
while ( ! pq2 . empty ( ) )
{
pq . push ( pq2 . top ( ) ) ;
pq2 . pop ( ) ;
}
int canary = ( 1 < < df : : unit_labor : : HAUL_STONE ) |
@ -2475,7 +2492,7 @@ public:
if ( l = = best_labor & & ( t = = TOOL_NONE | | tool_in_use [ t ] < tool_count [ t ] ) )
{
set_labor ( * bestdwarf , l , true ) ;
if ( t ! = TOOL_NONE & & ( * bestdwarf ) - > has_tool [ t ] )
if ( t ! = TOOL_NONE & & ! ( ( * bestdwarf ) - > has_tool [ t ] ) )
{
df : : job_type j ;
j = df : : job_type : : NONE ;
@ -2526,8 +2543,7 @@ public:
continue ;
int score = score_labor ( * d , l ) ;
if ( l < df : : unit_labor : : HAUL_STONE | | l > df : : unit_labor : : HAUL_ANIMALS )
score + = labor_infos [ l ] . time_since_last_assigned ( ) / 12 ;
if ( l = = df : : unit_labor : : HAUL_FOOD & & priority_food > 0 )
score + = 1000000 ;
@ -2538,7 +2554,9 @@ public:
{
set_labor ( * d , l , true ) ;
}
if ( ( * d ) - > using_labor ! = df : : unit_labor : : NONE & & score > current_score + 5000 & & default_labor_infos [ ( * d ) - > using_labor ] . tool = = TOOL_NONE )
if ( ( * d ) - > using_labor ! = df : : unit_labor : : NONE & &
( score > current_score + 5000 | | base_priority [ ( * d ) - > using_labor ] < base_priority [ l ] ) & &
default_labor_infos [ ( * d ) - > using_labor ] . tool = = TOOL_NONE )
set_labor ( * d , ( * d ) - > using_labor , false ) ;
}
}
@ -2579,18 +2597,23 @@ public:
/* Assign any leftover dwarfs to "standard" labors */
if ( print_debug )
out . print ( " After assignment, %d dwarfs left over \n " , available_dwarfs . size ( ) ) ;
for ( auto d = available_dwarfs . begin ( ) ; d ! = available_dwarfs . end ( ) ; d + + )
{
FOR_ENUM_ITEMS ( unit_labor , l )
{
if ( l > = df : : unit_labor : : HAUL_STONE & & l < = df : : unit_labor : : HAUL_ANIMALS & &
canary & ( 1 < < l ) )
set_labor ( * d , l , true ) ;
else if ( l = = df : : unit_labor : : CLEAN | | l = = df : : unit_labor : : REMOVE_CONSTRUCTION | | l = = df : : unit_labor : : PULL_LEVER )
set_labor ( * d , l , true ) ;
else
set_labor ( * d , l , false ) ;
}
if ( l = = df : : unit_labor : : NONE )
continue ;
set_labor ( * d , l ,
( l > = df : : unit_labor : : HAUL_STONE & & l < = df : : unit_labor : : HAUL_ANIMALS ) | |
l = = df : : unit_labor : : CLEAN | |
l = = df : : unit_labor : : REMOVE_CONSTRUCTION | |
l = = df : : unit_labor : : PULL_LEVER | |
l = = df : : unit_labor : : HAUL_TRADE ) ;
}
}
/* check for dwarfs assigned no labors and assign them the bucket list if there are */
@ -2648,7 +2671,8 @@ public:
bool has_tool = ( * d ) - > has_tool [ t ] ;
bool needs_tool = ( * d ) - > dwarf - > status . labors [ l ] ;
if ( has_tool ! = needs_tool )
if ( ( needs_tool & & ! has_tool ) | |
( has_tool & & ! needs_tool & & tool_in_use [ t ] > = tool_count [ t ] ) )
{
df : : job_type j = df : : job_type : : NONE ;
@ -2675,6 +2699,10 @@ public:
* df : : global : : process_jobs = true ;
}
if ( print_debug ) {
* df : : global : : pause_state = true ;
}
print_debug = 0 ;
}
@ -2709,8 +2737,12 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
return CR_OK ;
}
if ( + + step_count < 60 )
// if (++step_count < 60)
// return CR_OK;
if ( * df : : global : : process_jobs )
return CR_OK ;
step_count = 0 ;
debug_stream = & out ;