diff --git a/plugins/cleaners.cpp b/plugins/cleaners.cpp index 638ca7afa..209ce79b1 100644 --- a/plugins/cleaners.cpp +++ b/plugins/cleaners.cpp @@ -5,15 +5,18 @@ #include #include #include +#include + +using namespace DFHack; + #include #include #include - using std::vector; using std::string; -using namespace DFHack; DFhackCExport command_result clean (Core * c, vector & parameters); +DFhackCExport command_result spotclean (Core * c, vector & parameters); DFhackCExport const char * plugin_name ( void ) { @@ -24,6 +27,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector { commands.clear(); commands.push_back(PluginCommand("clean","Removes contaminants from map tiles, items and creatures.",clean)); + commands.push_back(PluginCommand("spotclean","Cleans map tile under cursor.",spotclean)); return CR_OK; } @@ -155,6 +159,40 @@ command_result cleanunits (Core * c) return CR_OK; } +DFhackCExport command_result spotclean (Core * c, vector & parameters) +{ + c->Suspend(); + vector splatter; + DFHack::Maps *Mapz = c->getMaps(); + DFHack::Gui *Gui = c->getGui(); + // init the map + if(!Mapz->Start()) + { + c->con.printerr("Can't init map.\n"); + c->Resume(); + return CR_FAILURE; + } + int32_t cursorX, cursorY, cursorZ; + Gui->getCursorCoords(cursorX,cursorY,cursorZ); + if(cursorX == -30000) + { + c->con.printerr("The cursor is not active.\n"); + c->Resume(); + return CR_FAILURE; + } + int32_t blockX = cursorX / 16, blockY = cursorY / 16; + int32_t tileX = cursorX % 16, tileY = cursorY % 16; + df_block *b = Mapz->getBlock(blockX,blockY,cursorZ); + vector spatters; + Mapz->SortBlockEvents(blockX, blockY, cursorZ, 0,0, &spatters); + for(int i = 0; i < spatters.size(); i++) + { + spatters[i]->intensity[tileX][tileY] = 0; + } + c->Resume(); + return CR_OK; +} + DFhackCExport command_result clean (Core * c, vector & parameters) { bool help = false;