summaryrefslogtreecommitdiff
path: root/plugins/autolabor.cpp
diff options
context:
space:
mode:
authorKelly Martin2012-04-26 13:46:38 -0500
committerKelly Martin2012-04-26 13:46:38 -0500
commit7c606da636e77280b6a7281464d7e8cd38f7530a (patch)
treef17ece798841f393703d29c461e81aa79580eb06 /plugins/autolabor.cpp
parent53e0ba8b8d047a8cd4edd1a8067c218080e6e889 (diff)
downloaddfhack-7c606da636e77280b6a7281464d7e8cd38f7530a.tar.gz
dfhack-7c606da636e77280b6a7281464d7e8cd38f7530a.tar.bz2
dfhack-7c606da636e77280b6a7281464d7e8cd38f7530a.tar.xz
Autolabor will exclude the trade broker from all labors if the "trader requested" flag is on at the trade depot.
Diffstat (limited to 'plugins/autolabor.cpp')
-rw-r--r--plugins/autolabor.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp
index f489c229..49bd2afc 100644
--- a/plugins/autolabor.cpp
+++ b/plugins/autolabor.cpp
@@ -30,6 +30,7 @@
#include <df/histfig_entity_link_positionst.h>
#include <df/entity_position_assignment.h>
#include <df/entity_position.h>
+#include <df/building_tradedepotst.h>
#include <MiscUtils.h>
@@ -493,6 +494,7 @@ struct dwarf_info_t
bool has_exclusive_labor;
int noble_penalty; // penalty for assignment due to noble status
bool medical; // this dwarf has medical responsibility
+ bool trader; // this dwarf has trade responsibility
};
static bool isOptionEnabled(unsigned flag)
@@ -715,6 +717,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
bool has_butchers = false;
bool has_fishery = false;
+ bool trader_requested = false;
for (int i = 0; i < world->buildings.all.size(); ++i)
{
@@ -727,7 +730,14 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
has_butchers = true;
if (df::enums::workshop_type::Fishery == subType)
has_fishery = true;
- }
+ }
+ else if (df::enums::building_type::TradeDepot == type)
+ {
+ df::building_tradedepotst* depot = (df::building_tradedepotst*) build;
+ trader_requested = depot->flags.bits.trader_requested;
+ if (print_debug)
+ out.print("Trade depot found and trader requested, trader will be excluded from all labors.\n");
+ }
}
for (int i = 0; i < world->units.all.size(); ++i)
@@ -783,6 +793,9 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
if (position->responsibilities[df::entity_position_responsibility::HEALTH_MANAGEMENT])
dwarf_info[dwarf].medical = true;
+ if (position->responsibilities[df::entity_position_responsibility::TRADE])
+ dwarf_info[dwarf].trader = true;
+
}
dwarf_info[dwarf].noble_penalty = noble_penalty;
}
@@ -1069,8 +1082,6 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
assert(dwarf >= 0);
assert(dwarf < n_dwarfs);
-
-
bool preferred_dwarf = false;
if (want_idle_dwarf && dwarf_info[dwarf].state == IDLE)
preferred_dwarf = true;
@@ -1080,6 +1091,8 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
preferred_dwarf = true;
if (dwarf_info[dwarf].medical && labor == df::unit_labor::DIAGNOSE)
preferred_dwarf = true;
+ if (dwarf_info[dwarf].trader && trader_requested)
+ continue;
if (labor_infos[labor].active_dwarfs >= min_dwarfs && !preferred_dwarf)
continue;