summaryrefslogtreecommitdiff
path: root/plugins/autolabor.cpp
diff options
context:
space:
mode:
authorPetr Mrázek2012-03-29 02:49:44 +0200
committerPetr Mrázek2012-03-29 02:49:44 +0200
commitd82120a3db65e82cb54b558fa3da6e28dbe767f2 (patch)
tree772f856e9118e725434842ffb7ea3113b5ad511b /plugins/autolabor.cpp
parent757ad3334cdfacc886338481ae8f3e894ec6fc0d (diff)
downloaddfhack-d82120a3db65e82cb54b558fa3da6e28dbe767f2.tar.gz
dfhack-d82120a3db65e82cb54b558fa3da6e28dbe767f2.tar.bz2
dfhack-d82120a3db65e82cb54b558fa3da6e28dbe767f2.tar.xz
More fixes
Include unistd.h in linux process file Fix assert in autolabor Don't print 'script missing' error on DF start
Diffstat (limited to 'plugins/autolabor.cpp')
-rw-r--r--plugins/autolabor.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp
index 733f0806..6511f72d 100644
--- a/plugins/autolabor.cpp
+++ b/plugins/autolabor.cpp
@@ -397,17 +397,14 @@ struct dwarf_info
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
- // initialize labor infos table from default table
-
- labor_infos = new struct labor_info[ARRAY_COUNT(default_labor_infos)];
- for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
- labor_infos[i] = default_labor_infos[i];
- }
-
- assert(ARRAY_COUNT(labor_infos) > ENUM_LAST_ITEM(unit_labor));
-
- // Fill the command list with your commands.
- commands.clear();
+ // initialize labor infos table from default table
+ if(ARRAY_COUNT(default_labor_infos) != ENUM_LAST_ITEM(unit_labor) + 1)
+ return CR_FAILURE;
+ labor_infos = new struct labor_info[ARRAY_COUNT(default_labor_infos)];
+ for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) {
+ labor_infos[i] = default_labor_infos[i];
+ }
+ // Fill the command list with your commands.
commands.push_back(PluginCommand(
"autolabor", "Automatically manage dwarf labors.",
autolabor, false, /* true means that the command can't be used from non-interactive user interface */