|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
* Simulates completion of dig designations.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "dig-now.h"
|
|
|
|
|
|
|
|
|
|
#include "DataFuncs.h"
|
|
|
|
|
#include "PluginManager.h"
|
|
|
|
|
#include "TileTypes.h"
|
|
|
|
@ -790,25 +792,16 @@ static void print_help(color_ostream &out) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
command_result dig_now(color_ostream &out, std::vector<std::string> ¶ms) {
|
|
|
|
|
CoreSuspender suspend;
|
|
|
|
|
|
|
|
|
|
dig_now_options options;
|
|
|
|
|
if (!get_options(out, options, params) || options.help)
|
|
|
|
|
{
|
|
|
|
|
print_help(out);
|
|
|
|
|
return options.help ? CR_OK : CR_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dig_now_impl(color_ostream &out, const dig_now_options &options) {
|
|
|
|
|
if (!Maps::IsValid()) {
|
|
|
|
|
out.printerr("Map is not available!\n");
|
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// required for boulder generation
|
|
|
|
|
if (world->units.active.size() == 0) {
|
|
|
|
|
out.printerr("At least one unit must be alive!\n");
|
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// track which positions were modified and where to produce items
|
|
|
|
@ -817,12 +810,25 @@ command_result dig_now(color_ostream &out, std::vector<std::string> ¶ms) {
|
|
|
|
|
|
|
|
|
|
do_dig(out, dug_coords, item_coords, options);
|
|
|
|
|
create_boulders(out, item_coords, options);
|
|
|
|
|
post_process_dug_tiles (out, dug_coords);
|
|
|
|
|
post_process_dug_tiles(out, dug_coords);
|
|
|
|
|
|
|
|
|
|
// force the game to recompute its walkability cache
|
|
|
|
|
world->reindex_pathfinding = true;
|
|
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
command_result dig_now(color_ostream &out, std::vector<std::string> ¶ms) {
|
|
|
|
|
CoreSuspender suspend;
|
|
|
|
|
|
|
|
|
|
dig_now_options options;
|
|
|
|
|
if (!get_options(out, options, params) || options.help)
|
|
|
|
|
{
|
|
|
|
|
print_help(out);
|
|
|
|
|
return options.help ? CR_OK : CR_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dig_now_impl(out, options) ? CR_OK : CR_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init(color_ostream &,
|
|
|
|
@ -835,3 +841,14 @@ DFhackCExport command_result plugin_init(color_ostream &,
|
|
|
|
|
DFhackCExport command_result plugin_shutdown(color_ostream &) {
|
|
|
|
|
return CR_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// External API
|
|
|
|
|
|
|
|
|
|
// runs dig-now for the specified tile. default options apply.
|
|
|
|
|
bool dig_now_tile (color_ostream& out, const DFCoord& pos)
|
|
|
|
|
{
|
|
|
|
|
dig_now_options options;
|
|
|
|
|
options.start = pos;
|
|
|
|
|
options.end = pos;
|
|
|
|
|
return dig_now_impl(out, options);
|
|
|
|
|
}
|
|
|
|
|