Merge remote-tracking branch 'upstream/master'

develop
Mike Stewart 2012-01-29 12:04:33 -08:00
commit 3dece3395d
14 changed files with 272 additions and 216 deletions

@ -204,6 +204,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue
"by clicking on the program icon in the top bar of the window.\n\n" "by clicking on the program icon in the top bar of the window.\n\n"
"Basic commands:\n" "Basic commands:\n"
" help|? - This text.\n" " help|? - This text.\n"
" help COMMAND - Usage help for the given command.\n"
" ls|dir [PLUGIN] - List available commands. Optionally for single plugin.\n" " ls|dir [PLUGIN] - List available commands. Optionally for single plugin.\n"
" cls - Clear the console.\n" " cls - Clear the console.\n"
" fpause - Force DF to pause.\n" " fpause - Force DF to pause.\n"

@ -44,9 +44,20 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("autodump", commands.push_back(PluginCommand(
"Teleport items marked for dumping to the cursor.", "autodump", "Teleport items marked for dumping to the cursor.",
df_autodump)); df_autodump, false,
" This utility lets you quickly move all items designated to be dumped.\n"
" Items are instantly moved to the cursor position, the dump flag is unset,\n"
" and the forbid flag is set, as if it had been dumped normally.\n"
" Be aware that any active dump item tasks still point at the item.\n"
"Options:\n"
" destroy - instead of dumping, destroy the items instantly.\n"
" destroy-here - only affect the tile under cursor.\n"
" visible - only process items that are not hidden.\n"
" hidden - only process hidden items.\n"
" forbidden - only process forbidden items (default: only unforbidden).\n"
));
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"autodump-destroy-here", "Destroy items marked for dumping under cursor.", "autodump-destroy-here", "Destroy items marked for dumping under cursor.",
df_autodump_destroy_here, cursor_hotkey, df_autodump_destroy_here, cursor_hotkey,
@ -74,26 +85,30 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
// Command line options // Command line options
bool destroy = false; bool destroy = false;
bool here = false; bool here = false;
if(parameters.size() > 0) bool need_visible = false;
bool need_hidden = false;
bool need_forbidden = false;
for (unsigned i = 0; i < parameters.size(); i++)
{ {
string & p = parameters[0]; string & p = parameters[i];
if(p == "destroy") if(p == "destroy")
destroy = true; destroy = true;
else if (p == "destroy-here") else if (p == "destroy-here")
destroy = here = true; destroy = here = true;
else if(p == "?" || p == "help") else if (p == "visible")
{ need_visible = true;
c->con.print( else if (p == "hidden")
"This utility lets you quickly move all items designated to be dumped.\n" need_hidden = true;
"Items are instantly moved to the cursor position, the dump flag is unset,\n" else if (p == "forbidden")
"and the forbid flag is set, as if it had been dumped normally.\n" need_forbidden = true;
"Be aware that any active dump item tasks still point at the item.\n\n" else
"Options:\n" return CR_WRONG_USAGE;
"destroy - instead of dumping, destroy the items instantly.\n"
"destroy-here - only affect the tile under cursor.\n"
);
return CR_OK;
} }
if (need_visible && need_hidden)
{
c->con.printerr("An item can't be both hidden and visible.\n");
return CR_WRONG_USAGE;
} }
DFHack::VersionInfo *mem = c->vinfo; DFHack::VersionInfo *mem = c->vinfo;
@ -161,7 +176,6 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
if ( !itm->flags.bits.dump if ( !itm->flags.bits.dump
|| !itm->flags.bits.on_ground || !itm->flags.bits.on_ground
|| itm->flags.bits.construction || itm->flags.bits.construction
|| itm->flags.bits.hidden
|| itm->flags.bits.in_building || itm->flags.bits.in_building
|| itm->flags.bits.in_chest || itm->flags.bits.in_chest
|| itm->flags.bits.in_inventory || itm->flags.bits.in_inventory
@ -169,6 +183,15 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
) )
continue; continue;
if (need_visible && itm->flags.bits.hidden)
continue;
if (need_hidden && !itm->flags.bits.hidden)
continue;
if (need_forbidden && !itm->flags.bits.forbid)
continue;
if (!need_forbidden && itm->flags.bits.forbid)
continue;
if(!destroy) // move to cursor if(!destroy) // move to cursor
{ {
// Change flags to indicate the dump was completed, as if by super-dwarfs // Change flags to indicate the dump was completed, as if by super-dwarfs

@ -148,7 +148,6 @@ DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
DFhackCExport command_result clean (Core * c, vector <string> & parameters) DFhackCExport command_result clean (Core * c, vector <string> & parameters)
{ {
bool help = false;
bool map = false; bool map = false;
bool snow = false; bool snow = false;
bool mud = false; bool mud = false;
@ -168,33 +167,16 @@ DFhackCExport command_result clean (Core * c, vector <string> & parameters)
items = true; items = true;
units = true; units = true;
} }
if(parameters[i] == "snow") else if(parameters[i] == "snow")
snow = true; snow = true;
else if(parameters[i] == "mud") else if(parameters[i] == "mud")
mud = true; mud = true;
else if(parameters[i] == "help" ||parameters[i] == "?") else
{ return CR_WRONG_USAGE;
help = true;
}
} }
if(!map && !units && !items) if(!map && !units && !items)
help = true; return CR_WRONG_USAGE;
if(help)
{
c->con.print("Removes contaminants from map tiles, items and creatures.\n"
"Options:\n"
"map - clean the map tiles\n"
"items - clean all items\n"
"units - clean all creatures\n"
"all - clean everything.\n"
"More options for 'map':\n"
"snow - also remove snow\n"
"mud - also remove mud\n"
"Example: clean all mud snow\n"
"This removes all spatter, including mud and snow from map tiles.\n"
);
return CR_OK;
}
CoreSuspender suspend(c); CoreSuspender suspend(c);
if(map) if(map)
cleanmap(c,snow,mud); cleanmap(c,snow,mud);
@ -213,8 +195,26 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("clean","Removes contaminants from map tiles, items and creatures.",clean)); commands.push_back(PluginCommand(
commands.push_back(PluginCommand("spotclean","Cleans map tile under cursor.",spotclean,cursor_hotkey)); "clean","Removes contaminants from map tiles, items and creatures.",
clean, false,
" Removes contaminants from map tiles, items and creatures.\n"
"Options:\n"
" map - clean the map tiles\n"
" items - clean all items\n"
" units - clean all creatures\n"
" all - clean everything.\n"
"More options for 'map':\n"
" snow - also remove snow\n"
" mud - also remove mud\n"
"Example:\n"
" clean all mud snow\n"
" Removes all spatter, including mud and snow from map tiles.\n"
));
commands.push_back(PluginCommand(
"spotclean","Cleans map tile under cursor.",
spotclean,cursor_hotkey
));
return CR_OK; return CR_OK;
} }

@ -36,9 +36,23 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("cleanowned", commands.push_back(PluginCommand(
"Confiscates and dumps garbage owned by dwarfs.", "cleanowned", "Confiscates and dumps garbage owned by dwarfs.",
df_cleanowned)); df_cleanowned, false,
" This tool lets you confiscate and dump all the garbage\n"
" dwarves ultimately accumulate.\n"
" By default, only rotten and dropped food is confiscated.\n"
"Options:\n"
" dryrun - don't actually do anything, just print what would be done.\n"
" scattered - confiscate owned items on the ground\n"
" all - confiscate everything\n"
" x - confiscate & dump 'x' and worse damaged items\n"
" X - confiscate & dump 'X' and worse damaged items\n"
"Example:\n"
" confiscate scattered X\n"
" This will confiscate rotten and dropped food, garbage on the floors\n"
" and any worn items wit 'X' damage and above.\n"
));
return CR_OK; return CR_OK;
} }
@ -67,30 +81,8 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete
wear_dump_level = 1; wear_dump_level = 1;
else if(param == "X") else if(param == "X")
wear_dump_level = 2; wear_dump_level = 2;
else if(param == "?" || param == "help")
{
c->con.print("This tool lets you confiscate and dump all the garbage\n"
"dwarves ultimately accumulate.\n"
"By default, only rotten and dropped food is confiscated.\n"
"Options:\n"
" dryrun - don't actually do anything, just print what would be done.\n"
" scattered - confiscate owned items on the ground\n"
" all - confiscate everything\n"
" x - confiscate & dump 'x' and worse damaged items\n"
" X - confiscate & dump 'X' and worse damaged items\n"
" ? - this help\n"
"Example:\n"
" confiscate scattered X\n"
" This will confiscate rotten and dropped food, garbage on the floors\n"
" and any worn items wit 'X' damage and above.\n"
);
return CR_OK;
}
else else
{ return CR_WRONG_USAGE;
c->con.printerr("Parameter '%s' is not valid. See 'cleanowned help'.\n",param.c_str());
return CR_FAILURE;
}
} }
CoreSuspender suspend(c); CoreSuspender suspend(c);

@ -22,9 +22,14 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("colonies", commands.push_back(PluginCommand(
"List or change wild colonies (ants hills and such)", "colonies", "List or change wild colonies (ants hills and such)",
colonies)); colonies, false,
" Without any options, this command lists all the vermin colonies present.\n"
"Options:\n"
" kill - destroy colonies\n"
" bees - turn colonies into honey bees\n"
));
return CR_OK; return CR_OK;
} }
@ -41,7 +46,6 @@ DFhackCExport command_result colonies (Core * c, vector <string> & parameters)
{ {
bool destroy = false; bool destroy = false;
bool convert = false; bool convert = false;
bool help = false;
for(int i = 0; i < parameters.size();i++) for(int i = 0; i < parameters.size();i++)
{ {
@ -49,19 +53,8 @@ DFhackCExport command_result colonies (Core * c, vector <string> & parameters)
destroy = true; destroy = true;
else if(parameters[i] == "bees") else if(parameters[i] == "bees")
convert = true; convert = true;
else if(parameters[i] == "help" || parameters[i] == "?") else
{ return CR_WRONG_USAGE;
help = true;
}
}
if(help)
{
c->con.print("Without any options, this command lists all the vermin colonies present.\n"
"Options:\n"
"kill - destroy colonies\n"
"bees - turn colonies into honey bees\n"
);
return CR_OK;
} }
if (destroy && convert) if (destroy && convert)
{ {

@ -19,17 +19,8 @@ using df::global::world;
DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters) DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters)
{ {
for(int i = 0; i < parameters.size();i++) if (!parameters.empty())
{ return CR_WRONG_USAGE;
if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("This command does two things:\n"
"If there are any ramps designated for removal, they will be instantly removed.\n"
"Any ramps that don't have their counterpart will be removed (fixes bugs with caveins)\n"
);
return CR_OK;
}
}
CoreSuspender suspend(c); CoreSuspender suspend(c);
@ -97,9 +88,13 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("deramp", commands.push_back(PluginCommand(
"De-ramp. All ramps marked for removal are replaced with floors.", "deramp", "De-ramp. All ramps marked for removal are replaced with floors.",
df_deramp)); df_deramp, false,
" If there are any ramps designated for removal, they will be instantly\n"
" removed. Any ramps that don't have their counterpart will also be removed\n"
" (fixes bugs with caveins)\n"
));
return CR_OK; return CR_OK;
} }

@ -42,9 +42,34 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("filltraffic","Flood-fill with selected traffic designation from cursor",filltraffic)); commands.push_back(PluginCommand(
commands.push_back(PluginCommand("alltraffic","Set traffic for the entire map",alltraffic)); "filltraffic","Flood-fill with selected traffic designation from cursor",
filltraffic, cursor_hotkey,
" Flood-fill selected traffic type from the cursor.\n"
"Traffic Type Codes:\n"
" H: High Traffic\n"
" N: Normal Traffic\n"
" L: Low Traffic\n"
" R: Restricted Traffic\n"
"Other Options:\n"
" X: Fill across z-levels.\n"
" B: Include buildings and stockpiles.\n"
" P: Include empty space.\n"
"Example:\n"
" filltraffic H\n"
" When used in a room with doors,\n"
" it will set traffic to HIGH in just that room.\n"
));
commands.push_back(PluginCommand(
"alltraffic","Set traffic for the entire map",
alltraffic, false,
" Set traffic types for all tiles on the map.\n"
"Traffic Type Codes:\n"
" H: High Traffic\n"
" N: Normal Traffic\n"
" L: Low Traffic\n"
" R: Restricted Traffic\n"
));
return CR_OK; return CR_OK;
} }
@ -55,6 +80,8 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::string> & params) DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::string> & params)
{ {
// HOTKEY COMMAND; CORE ALREADY SUSPENDED
//Maximum map size. //Maximum map size.
uint32_t x_max,y_max,z_max; uint32_t x_max,y_max,z_max;
//Source and target traffic types. //Source and target traffic types.
@ -68,24 +95,8 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
//Loop through parameters //Loop through parameters
for(int i = 0; i < params.size();i++) for(int i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if (params[i] == "help" || params[i] == "?" || params[i].size() != 1)
{ return CR_WRONG_USAGE;
c->con.print("Flood-fill selected traffic type from the cursor.\n"
"Traffic Type Codes:\n"
"\tH: High Traffic\n"
"\tN: Normal Traffic\n"
"\tL: Low Traffic\n"
"\tR: Restricted Traffic\n"
"Other Options:\n"
"\tX: Fill across z-levels.\n"
"\tB: Include buildings and stockpiles.\n"
"\tP: Include empty space.\n"
"Example:\n"
"'filltraffic H' - When used in a room with doors,\n"
" it will set traffic to HIGH in just that room."
);
return CR_OK;
}
switch (toupper(params[i][0])) switch (toupper(params[i][0]))
{ {
@ -103,12 +114,11 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
checkbuilding = false; break; checkbuilding = false; break;
case 'P': case 'P':
checkpit = false; break; checkpit = false; break;
default:
return CR_WRONG_USAGE;
} }
} }
//Initialization.
CoreSuspender suspend(c);
DFHack::Gui * Gui = c->getGui(); DFHack::Gui * Gui = c->getGui();
if (!Maps::IsValid()) if (!Maps::IsValid())
{ {
@ -238,17 +248,8 @@ DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector<std::strin
//Loop through parameters //Loop through parameters
for(int i = 0; i < params.size();i++) for(int i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if (params[i] == "help" || params[i] == "?" || params[i].size() != 1)
{ return CR_WRONG_USAGE;
c->con.print("Set traffic types for all tiles on the map.\n"
"Traffic Type Codes:\n"
" H: High Traffic\n"
" N: Normal Traffic\n"
" L: Low Traffic\n"
" R: Restricted Traffic\n"
);
return CR_OK;
}
//Pick traffic type. Possibly set bounding rectangle later. //Pick traffic type. Possibly set bounding rectangle later.
switch (toupper(params[i][0])) switch (toupper(params[i][0]))
@ -261,6 +262,8 @@ DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector<std::strin
proc = allLow; break; proc = allLow; break;
case 'R': case 'R':
proc = allRestricted; break; proc = allRestricted; break;
default:
return CR_WRONG_USAGE;
} }
} }

@ -34,18 +34,7 @@ DFhackCExport command_result df_getplants (Core * c, vector <string> & parameter
for (size_t i = 0; i < parameters.size(); i++) for (size_t i = 0; i < parameters.size(); i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("Specify the types of trees to cut down and/or shrubs to gather by their plant IDs, separated by spaces.\n"
"Options:\n"
"\t-t - Select trees only (exclude shrubs)\n"
"\t-s - Select shrubs only (exclude trees)\n"
"\t-c - Clear designations instead of setting them\n"
"\t-x - Apply selected action to all plants except those specified\n"
"Specifying both -t and -s will have no effect.\n"
"If no plant IDs are specified, all valid plant IDs will be listed.\n"
);
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
}
else if(parameters[i] == "-t") else if(parameters[i] == "-t")
treesonly = true; treesonly = true;
else if(parameters[i] == "-s") else if(parameters[i] == "-s")
@ -152,7 +141,19 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("getplants", "Cut down all of the specified trees or gather all of the specified shrubs", df_getplants)); commands.push_back(PluginCommand(
"getplants", "Cut down all of the specified trees or gather specified shrubs",
df_getplants, false,
" Specify the types of trees to cut down and/or shrubs to gather by their\n"
" plant IDs, separated by spaces.\n"
"Options:\n"
" -t - Select trees only (exclude shrubs)\n"
" -s - Select shrubs only (exclude trees)\n"
" -c - Clear designations instead of setting them\n"
" -x - Apply selected action to all plants except those specified\n"
"Specifying both -t and -s will have no effect.\n"
"If no plant IDs are specified, all valid plant IDs will be listed.\n"
));
return CR_OK; return CR_OK;
} }

@ -61,9 +61,10 @@ DFhackCExport command_result plugin_init (Core *c, std::vector <PluginCommand> &
"job", "General job query and manipulation.", "job", "General job query and manipulation.",
job_cmd, false, job_cmd, false,
" job [query]\n" " job [query]\n"
" Print details of the current job.\n" " Print details of the current job. The job can be\n"
" selected in a workshop, or the unit/jobs screen.\n"
" job list\n" " job list\n"
" Print details of all jobs in the workshop.\n" " Print details of all jobs in the selected workshop.\n"
" job item-material <item-idx> <material[:subtoken]>\n" " job item-material <item-idx> <material[:subtoken]>\n"
" Replace the exact material id in the job item.\n" " Replace the exact material id in the job item.\n"
" job item-type <item-idx> <type[:subtype]>\n" " job item-type <item-idx> <type[:subtype]>\n"
@ -79,7 +80,8 @@ DFhackCExport command_result plugin_init (Core *c, std::vector <PluginCommand> &
" job-material <inorganic-token>\n" " job-material <inorganic-token>\n"
"Intended to be used as a keybinding:\n" "Intended to be used as a keybinding:\n"
" - In 'q' mode, when a job is highlighted within a workshop\n" " - In 'q' mode, when a job is highlighted within a workshop\n"
" or furnace, changes the material of the job.\n" " or furnace, changes the material of the job. Only inorganic\n"
" materials can be used in this mode.\n"
" - In 'b' mode, during selection of building components\n" " - In 'b' mode, during selection of building components\n"
" positions the cursor over the first available choice\n" " positions the cursor over the first available choice\n"
" with the matching material.\n" " with the matching material.\n"
@ -322,13 +324,16 @@ static command_result job_cmd(Core * c, vector <string> & parameters)
std::string cmd = (parameters.empty() ? "query" : parameters[0]); std::string cmd = (parameters.empty() ? "query" : parameters[0]);
if (cmd == "query" || cmd == "list") if (cmd == "query" || cmd == "list")
{ {
df::job *job = getSelectedWorkshopJob(c); df::job *job = getSelectedJob(c);
if (!job) if (!job)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
if (cmd == "query") { if (cmd == "query") {
printJobDetails(c, job); printJobDetails(c, job);
} else { } else {
if (!workshop_job_hotkey(c, c->getTopViewscreen()))
return CR_WRONG_USAGE;
df::building *selected = world->selected_building; df::building *selected = world->selected_building;
for (unsigned i = 0; i < selected->jobs.size(); i++) for (unsigned i = 0; i < selected->jobs.size(); i++)
printJobDetails(c, selected->jobs[i]); printJobDetails(c, selected->jobs[i]);
@ -339,7 +344,7 @@ static command_result job_cmd(Core * c, vector <string> & parameters)
if (parameters.size() != 3) if (parameters.size() != 3)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
df::job *job = getSelectedWorkshopJob(c); df::job *job = getSelectedJob(c);
df::job_item *item = getJobItem(c, job, parameters[1]); df::job_item *item = getJobItem(c, job, parameters[1]);
if (!item) if (!item)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
@ -383,7 +388,7 @@ static command_result job_cmd(Core * c, vector <string> & parameters)
if (parameters.size() != 3) if (parameters.size() != 3)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
df::job *job = getSelectedWorkshopJob(c); df::job *job = getSelectedJob(c);
df::job_item *item = getJobItem(c, job, parameters[1]); df::job_item *item = getJobItem(c, job, parameters[1]);
if (!item) if (!item)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;

@ -22,7 +22,13 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("mode","View, change and track game mode.", mode, true)); commands.push_back(PluginCommand(
"mode","View, change and track game mode.",
mode, true,
" Without any parameters, this command prints the current game mode\n"
" You can interactively set the game mode with 'mode set'.\n"
"!!Setting the game modes can be dangerous and break your game!!\n"
));
return CR_OK; return CR_OK;
} }
@ -96,17 +102,8 @@ DFhackCExport command_result mode (Core * c, vector <string> & parameters)
{ {
set = true; set = true;
} }
else if(parameters[0] == "?" || parameters[0] == "help")
{
c->con.print("Without any parameters, this command prints the current game mode\n"
"You can interactively set the game mode with 'mode set'.\n");
c->con.printerr("!!Setting the game modes can be dangerous and break your game!!\n");
return CR_OK;
}
else else
{ return CR_WRONG_USAGE;
c->con.printerr("Unrecognized parameter: %s\n",parameters[0].c_str());
}
} }
c->Suspend(); c->Suspend();
World *world = c->getWorld(); World *world = c->getWorld();

@ -178,7 +178,16 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("prospect","Show stats of available raw resources. Use option 'all' to show hidden resources.",prospector)); commands.push_back(PluginCommand(
"prospect", "Show stats of available raw resources.",
prospector, false,
" Prints a big list of all the present minerals.\n"
" By default, only the visible part of the map is scanned.\n"
"Options:\n"
" all - Scan the whole map, as if it was revealed.\n"
" value - Show material value in the output. Most useful for gems.\n"
" hell - Show the Z range of HFS tubes. Implies 'all'.\n"
));
return CR_OK; return CR_OK;
} }
@ -210,18 +219,8 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
{ {
showHidden = showTube = true; showHidden = showTube = true;
} }
else if(parameters[i] == "help" || parameters[i] == "?") else
{ return CR_WRONG_USAGE;
c->con.print("Prints a big list of all the present minerals.\n"
"By default, only the visible part of the map is scanned.\n"
"\n"
"Options:\n"
"all - Scan the whole map, as if it was revealed.\n"
"value - Show material value in the output.\n"
"hell - Show the Z range of HFS tubes.\n"
);
return CR_OK;
}
} }
uint32_t x_max = 0, y_max = 0, z_max = 0; uint32_t x_max = 0, y_max = 0, z_max = 0;
CoreSuspender suspend(c); CoreSuspender suspend(c);

@ -5,7 +5,13 @@
#include <Console.h> #include <Console.h>
#include <Export.h> #include <Export.h>
#include <PluginManager.h> #include <PluginManager.h>
// DF data structure definition headers
#include "DataDefs.h"
//#include "df/world.h"
using namespace DFHack; using namespace DFHack;
using namespace df::enums;
// our own, empty header. // our own, empty header.
#include "skeleton.h" #include "skeleton.h"
@ -13,7 +19,7 @@ using namespace DFHack;
// Here go all the command declarations... // Here go all the command declarations...
// mostly to allow having the mandatory stuff on top of the file and commands on the bottom // mostly to allow having the mandatory stuff on top of the file and commands on the bottom
DFhackCExport command_result skeleton (Core * c, std::vector <std::string> & parameters); command_result skeleton (Core * c, std::vector <std::string> & parameters);
// A plugins must be able to return its name. This must correspond to the filename - skeleton.plug.so or skeleton.plug.dll // A plugins must be able to return its name. This must correspond to the filename - skeleton.plug.so or skeleton.plug.dll
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
@ -26,10 +32,15 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
{ {
// Fill the command list with your commands. // Fill the command list with your commands.
commands.clear(); commands.clear();
commands.push_back(PluginCommand("skeleton", commands.push_back(PluginCommand(
"Do nothing, look pretty.", "skeleton", "Do nothing, look pretty.",
skeleton /*, skeleton, false, /* true means that the command can't be used from non-interactive user interface */
true or false - true means that the command can't be used from non-interactive user interface'*/)); // Extended help string. Used by CR_WRONG_USAGE and the help command:
" This command does nothing at all.\n"
"Example:\n"
" skeleton\n"
" Does nothing.\n"
));
return CR_OK; return CR_OK;
} }
@ -42,6 +53,26 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
// Called to notify the plugin about important state changes.
// Invoked with DF suspended, and always before the matching plugin_onupdate.
// More event codes may be added in the future.
/*
DFhackCExport command_result plugin_onstatechange(Core* c, state_change_event event)
{
switch (event) {
case SC_GAME_LOADED:
// initialize from the world just loaded
break;
case SC_GAME_UNLOADED:
// cleanup
break;
default:
break;
}
return CR_OK;
}
*/
// Whatever you put here will be done in each game step. Don't abuse it. // Whatever you put here will be done in each game step. Don't abuse it.
// It's optional, so you can just comment it out like this if you don't need it. // It's optional, so you can just comment it out like this if you don't need it.
/* /*
@ -53,26 +84,23 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
*/ */
// A command! It sits around and looks pretty. And it's nice and friendly. // A command! It sits around and looks pretty. And it's nice and friendly.
DFhackCExport command_result skeleton (Core * c, std::vector <std::string> & parameters) command_result skeleton (Core * c, std::vector <std::string> & parameters)
{
// It's nice to provide a 'help' option for your command.
// It's also nice to print the same help if you get invalid options from the user instead of just acting strange
for(int i = 0; i < parameters.size();i++)
{
if(parameters[i] == "help" || parameters[i] == "?")
{ {
// Core has a handle to the console. The console is thread-safe. // It's nice to print a help message you get invalid options
// Only one thing can read from it at a time though... // from the user instead of just acting strange.
c->con.print("This command does nothing!\n"); // This can be achieved by adding the extended help string to the
return CR_OK; // PluginCommand registration as show above, and then returning
} // CR_WRONG_USAGE from the function. The same string will also
} // be used by 'help your-command'.
if (!parameters.empty())
return CR_WRONG_USAGE;
// Commands are called from threads other than the DF one. // Commands are called from threads other than the DF one.
// Suspend this thread until DF has time for us. // Suspend this thread until DF has time for us. If you
c->Suspend(); // use CoreSuspender, it'll automatically resume DF when
// execution leaves the current scope.
CoreSuspender suspend(c);
// Actually do something here. Yay. // Actually do something here. Yay.
c->con.print("Hello! I do nothing, remember?\n"); c->con.print("Hello! I do nothing, remember?\n");
// Give control back to DF. // Give control back to DF.
c->Resume();
return CR_OK; return CR_OK;
} }

@ -23,7 +23,15 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("weather", "Print the weather map or change weather.",weather)); commands.push_back(PluginCommand(
"weather", "Print the weather map or change weather.",
weather, false,
" Prints the current weather map by default.\n"
"Options:\n"
" snow - make it snow everywhere.\n"
" rain - make it rain.\n"
" clear - clear the sky.\n"
));
return CR_OK; return CR_OK;
} }
@ -40,7 +48,6 @@ DFhackCExport command_result weather (Core * c, vector <string> & parameters)
bool snow = false; bool snow = false;
bool rain = false; bool rain = false;
bool clear = false; bool clear = false;
bool help = false;
for(int i = 0; i < parameters.size();i++) for(int i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "rain") if(parameters[i] == "rain")
@ -53,18 +60,8 @@ DFhackCExport command_result weather (Core * c, vector <string> & parameters)
lock = true; lock = true;
else if(parameters[i] == "unlock") else if(parameters[i] == "unlock")
unlock = true; unlock = true;
else if(parameters[i] == "help" || parameters[i] == "?") else
help = true; return CR_WRONG_USAGE;
}
if(help)
{
c->con.print("Prints the current weather map by default.\n"
"Options:\n"
"snow - make it snow everywhere.\n"
"rain - make it rain.\n"
"clear - clear the sky.\n"
);
return CR_OK;
} }
if(lock && unlock) if(lock && unlock)
{ {

@ -1086,9 +1086,25 @@ static void map_job_items(Core *c)
int16_t imattype = item->getActualMaterial(); int16_t imattype = item->getActualMaterial();
int32_t imatindex = item->getActualMaterialIndex(); int32_t imatindex = item->getActualMaterialIndex();
bool is_invalid = false;
// Special handling // Special handling
if (dry_buckets && itype == item_type::BUCKET && !item->flags.bits.in_job) switch (itype) {
case item_type::BUCKET:
if (dry_buckets && !item->flags.bits.in_job)
dryBucket(item); dryBucket(item);
break;
case item_type::THREAD:
if (item->getTotalDimension() < 15000)
is_invalid = true;
break;
case item_type::CLOTH:
if (item->getTotalDimension() < 10000)
is_invalid = true;
break;
}
if (item->flags.bits.melt && !item->flags.bits.owned && !itemBusy(item)) if (item->flags.bits.melt && !item->flags.bits.owned && !itemBusy(item))
meltable_count++; meltable_count++;
@ -1119,7 +1135,8 @@ static void map_job_items(Core *c)
if (!ok) if (!ok)
continue; continue;
if (item->flags.bits.owned || if (is_invalid ||
item->flags.bits.owned ||
item->flags.bits.in_chest || item->flags.bits.in_chest ||
item->isAssignedToStockpile() || item->isAssignedToStockpile() ||
itemInRealJob(item) || itemInRealJob(item) ||
@ -1385,6 +1402,11 @@ static command_result workflow_cmd(Core *c, vector <string> & parameters)
{ {
CoreSuspender suspend(c); CoreSuspender suspend(c);
if (!c->isWorldLoaded()) {
c->con.printerr("World is not loaded: please load a game first.\n");
return CR_FAILURE;
}
if (enabled) { if (enabled) {
check_lost_jobs(c, 0); check_lost_jobs(c, 0);
recover_jobs(c); recover_jobs(c);