Update getplants to use Designations module

Fixes #531
Fixes #1014
Fixes #1018
develop
lethosor 2017-05-06 00:11:07 -04:00
parent 55931703ac
commit 3dc2c2259b
1 changed files with 10 additions and 13 deletions

@ -1,5 +1,7 @@
// (un)designate matching plants for gathering/cutting // (un)designate matching plants for gathering/cutting
#include <set>
#include "Core.h" #include "Core.h"
#include "Console.h" #include "Console.h"
#include "Export.h" #include "Export.h"
@ -7,18 +9,19 @@
#include "DataDefs.h" #include "DataDefs.h"
#include "TileTypes.h" #include "TileTypes.h"
#include "df/world.h"
#include "df/map_block.h" #include "df/map_block.h"
#include "df/tile_dig_designation.h"
#include "df/plant_raw.h"
#include "df/plant.h" #include "df/plant.h"
#include "df/plant_raw.h"
#include "df/tile_dig_designation.h"
#include "df/world.h"
#include "modules/Designations.h"
#include "modules/Maps.h" #include "modules/Maps.h"
#include <set>
using std::string; using std::string;
using std::vector; using std::vector;
using std::set; using std::set;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
@ -129,20 +132,14 @@ command_result df_getplants (color_ostream &out, vector <string> & parameters)
continue; continue;
if (cur->designation[x][y].bits.hidden) if (cur->designation[x][y].bits.hidden)
continue; continue;
if (deselect && cur->designation[x][y].bits.dig == tile_dig_designation::Default) if (deselect && Designations::unmarkPlant(plant))
{ {
cur->designation[x][y].bits.dig = tile_dig_designation::No;
dirty = true;
++count; ++count;
} }
if (!deselect && cur->designation[x][y].bits.dig == tile_dig_designation::No) if (!deselect && Designations::markPlant(plant))
{ {
cur->designation[x][y].bits.dig = tile_dig_designation::Default;
dirty = true;
++count; ++count;
} }
if (dirty)
cur->flags.bits.designated = true;
} }
if (count) if (count)
out.print("Updated %d plant designations.\n", count); out.print("Updated %d plant designations.\n", count);
@ -171,4 +168,4 @@ DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCom
DFhackCExport command_result plugin_shutdown ( color_ostream &out ) DFhackCExport command_result plugin_shutdown ( color_ostream &out )
{ {
return CR_OK; return CR_OK;
} }