|
|
@ -19,6 +19,8 @@ using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using std::string;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using df::global::world;
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result df_grow (Core * c, vector <string> & parameters);
|
|
|
|
DFhackCExport command_result df_grow (Core * c, vector <string> & parameters);
|
|
|
|
DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters);
|
|
|
|
DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters);
|
|
|
|
DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameters);
|
|
|
|
DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameters);
|
|
|
@ -109,19 +111,13 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
|
|
|
|
uint32_t x_max, y_max, z_max;
|
|
|
|
uint32_t x_max, y_max, z_max;
|
|
|
|
Maps::getSize(x_max, y_max, z_max);
|
|
|
|
Maps::getSize(x_max, y_max, z_max);
|
|
|
|
MapExtras::MapCache map;
|
|
|
|
MapExtras::MapCache map;
|
|
|
|
DFHack::Vegetation *veg = c->getVegetation();
|
|
|
|
|
|
|
|
if (!veg->all_plants)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cerr << "Unable to read vegetation!" << std::endl;
|
|
|
|
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(shrubs || trees)
|
|
|
|
if(shrubs || trees)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int destroyed = 0;
|
|
|
|
int destroyed = 0;
|
|
|
|
for(size_t i = 0 ; i < veg->all_plants->size(); i++)
|
|
|
|
for(size_t i = 0 ; i < world->plants.all.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DFHack::df_plant *p = veg->all_plants->at(i);
|
|
|
|
df::plant *p = world->plants.all[i];
|
|
|
|
if(shrubs && p->is_shrub || trees && !p->is_shrub)
|
|
|
|
if(shrubs && p->flags.bits.is_shrub || trees && !p->flags.bits.is_shrub)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (what == do_immolate)
|
|
|
|
if (what == do_immolate)
|
|
|
|
p->is_burning = true;
|
|
|
|
p->is_burning = true;
|
|
|
@ -136,14 +132,14 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
|
|
|
|
int32_t x,y,z;
|
|
|
|
int32_t x,y,z;
|
|
|
|
if(Gui->getCursorCoords(x,y,z))
|
|
|
|
if(Gui->getCursorCoords(x,y,z))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vector<DFHack::df_plant *> * alltrees;
|
|
|
|
vector<df::plant *> * alltrees;
|
|
|
|
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))
|
|
|
|
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool didit = false;
|
|
|
|
bool didit = false;
|
|
|
|
for(size_t i = 0 ; i < alltrees->size(); i++)
|
|
|
|
for(size_t i = 0 ; i < alltrees->size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DFHack::df_plant * tree = alltrees->at(i);
|
|
|
|
df::plant * tree = alltrees->at(i);
|
|
|
|
if(tree->x == x && tree->y == y && tree->z == z)
|
|
|
|
if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(what == do_immolate)
|
|
|
|
if(what == do_immolate)
|
|
|
|
tree->is_burning = true;
|
|
|
|
tree->is_burning = true;
|
|
|
@ -166,7 +162,6 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Cleanup
|
|
|
|
// Cleanup
|
|
|
|
veg->Finish();
|
|
|
|
|
|
|
|
c->Resume();
|
|
|
|
c->Resume();
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -218,24 +213,17 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
|
|
|
|
return CR_FAILURE;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MapExtras::MapCache map;
|
|
|
|
MapExtras::MapCache map;
|
|
|
|
DFHack::Vegetation *veg = c->getVegetation();
|
|
|
|
|
|
|
|
if (!veg->all_plants)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
con.printerr("Unable to read vegetation!\n");
|
|
|
|
|
|
|
|
c->Resume();
|
|
|
|
|
|
|
|
return CR_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DFHack::Gui *Gui = c->getGui();
|
|
|
|
DFHack::Gui *Gui = c->getGui();
|
|
|
|
int32_t x,y,z;
|
|
|
|
int32_t x,y,z;
|
|
|
|
if(Gui->getCursorCoords(x,y,z))
|
|
|
|
if(Gui->getCursorCoords(x,y,z))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vector<DFHack::df_plant *> * alltrees;
|
|
|
|
vector<df::plant *> * alltrees;
|
|
|
|
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))
|
|
|
|
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(size_t i = 0 ; i < alltrees->size(); i++)
|
|
|
|
for(size_t i = 0 ; i < alltrees->size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DFHack::df_plant * tree = alltrees->at(i);
|
|
|
|
df::plant * tree = alltrees->at(i);
|
|
|
|
if(tree->x == x && tree->y == y && tree->z == z)
|
|
|
|
if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(DFHack::tileShape(map.tiletypeAt(DFHack::DFCoord(x,y,z))) == DFHack::SAPLING_OK)
|
|
|
|
if(DFHack::tileShape(map.tiletypeAt(DFHack::DFCoord(x,y,z))) == DFHack::SAPLING_OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -249,11 +237,11 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int grown = 0;
|
|
|
|
int grown = 0;
|
|
|
|
for(size_t i = 0 ; i < veg->all_plants->size(); i++)
|
|
|
|
for(size_t i = 0 ; i < world->plants.all.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DFHack::df_plant *p = veg->all_plants->at(i);
|
|
|
|
df::plant *p = world->plants.all[i];
|
|
|
|
uint16_t ttype = map.tiletypeAt(DFHack::DFCoord(p->x,p->y,p->z));
|
|
|
|
uint16_t ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z));
|
|
|
|
if(!p->is_shrub && DFHack::tileShape(ttype) == DFHack::SAPLING_OK)
|
|
|
|
if(!p->flags.bits.is_shrub && DFHack::tileShape(ttype) == DFHack::SAPLING_OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p->grow_counter = DFHack::sapling_to_tree_threshold;
|
|
|
|
p->grow_counter = DFHack::sapling_to_tree_threshold;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -261,7 +249,6 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
// Cleanup
|
|
|
|
veg->Finish();
|
|
|
|
|
|
|
|
c->Resume();
|
|
|
|
c->Resume();
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|