|
|
@ -23,26 +23,22 @@ struct farm_select_hook : df::viewscreen_dwarfmodest {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Adapted from autofarm
|
|
|
|
// Adapted from autofarm
|
|
|
|
using namespace df::enums::plant_raw_flags;
|
|
|
|
using namespace df::enums::plant_raw_flags;
|
|
|
|
// Discovered?
|
|
|
|
// Possible to plant?
|
|
|
|
if (ui->tasks.discovered_plants[crop_id])
|
|
|
|
df::plant_raw* raws = world->raws.plants.all[crop_id];
|
|
|
|
|
|
|
|
if (raws->flags.is_set(SEED) && raws->flags.is_set((df::plant_raw_flags)season))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Possible to plant?
|
|
|
|
// Right depth?
|
|
|
|
df::plant_raw* raws = world->raws.plants.all[crop_id];
|
|
|
|
DFCoord cursor (farm_plot->centerx, farm_plot->centery, farm_plot->z);
|
|
|
|
if (raws->flags.is_set(SEED) && raws->flags.is_set((df::plant_raw_flags)season))
|
|
|
|
MapExtras::MapCache mc;
|
|
|
|
|
|
|
|
MapExtras::Block * b = mc.BlockAt(cursor / 16);
|
|
|
|
|
|
|
|
if (!b || !b->is_valid())
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &block = *b->getRaw();
|
|
|
|
|
|
|
|
df::tile_designation &des =
|
|
|
|
|
|
|
|
block.designation[farm_plot->centerx % 16][farm_plot->centery % 16];
|
|
|
|
|
|
|
|
if ((raws->underground_depth_min == 0 || raws->underground_depth_max == 0) != des.bits.subterranean)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Right depth?
|
|
|
|
return true;
|
|
|
|
DFCoord cursor (farm_plot->centerx, farm_plot->centery, farm_plot->z);
|
|
|
|
|
|
|
|
MapExtras::MapCache mc;
|
|
|
|
|
|
|
|
MapExtras::Block * b = mc.BlockAt(cursor / 16);
|
|
|
|
|
|
|
|
if (!b || !b->is_valid())
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &block = *b->getRaw();
|
|
|
|
|
|
|
|
df::tile_designation &des =
|
|
|
|
|
|
|
|
block.designation[farm_plot->centerx % 16][farm_plot->centery % 16];
|
|
|
|
|
|
|
|
if ((raws->underground_depth_min == 0 || raws->underground_depth_max == 0) != des.bits.subterranean)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|