|
|
@ -85,6 +85,9 @@ int dig(DFHack::API& DF,
|
|
|
|
|
|
|
|
|
|
|
|
cout << "============================" << endl;
|
|
|
|
cout << "============================" << endl;
|
|
|
|
cout << "source is " << x_source << " " << y_source << " " << z_source << endl;
|
|
|
|
cout << "source is " << x_source << " " << y_source << " " << z_source << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int debugmaxx = 0;
|
|
|
|
|
|
|
|
int debugmaxy = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// walk the map
|
|
|
|
// walk the map
|
|
|
|
for(uint32_t x = 0; x < x_max; x++)
|
|
|
|
for(uint32_t x = 0; x < x_max; x++)
|
|
|
@ -118,18 +121,26 @@ int dig(DFHack::API& DF,
|
|
|
|
//designations[i].bits.dig = DFHack::designation_default;
|
|
|
|
//designations[i].bits.dig = DFHack::designation_default;
|
|
|
|
//++count;
|
|
|
|
//++count;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int world_x = (x*16)+lx;
|
|
|
|
|
|
|
|
int world_y = (y*16)+ly;
|
|
|
|
|
|
|
|
|
|
|
|
DigTarget dt;
|
|
|
|
DigTarget dt;
|
|
|
|
dt.x = x+lx;
|
|
|
|
dt.x = world_x;
|
|
|
|
dt.y = y+ly;
|
|
|
|
dt.y = world_y;
|
|
|
|
dt.z = z;
|
|
|
|
dt.z = z;
|
|
|
|
dt.source_distance = manhattan_distance(
|
|
|
|
dt.source_distance = manhattan_distance(
|
|
|
|
x_source, y_source, z_source,
|
|
|
|
x_source, y_source, z_source,
|
|
|
|
//x, y, z, i);
|
|
|
|
//x, y, z, i);
|
|
|
|
x+lx, y+ly, z);
|
|
|
|
world_x, world_y, z);
|
|
|
|
candidates.push_back(dt);
|
|
|
|
candidates.push_back(dt);
|
|
|
|
|
|
|
|
|
|
|
|
cout << "target found at " << x+lx << " " << y+ly << " " << z;
|
|
|
|
cout << "target found at " << world_x << " " << world_y << " " << z;
|
|
|
|
cout << ", " << dt.source_distance << " tiles to source" << endl;
|
|
|
|
cout << ", " << dt.source_distance << " tiles to source" << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (world_x > debugmaxx)
|
|
|
|
|
|
|
|
debugmaxx = world_x;
|
|
|
|
|
|
|
|
if (world_y > debugmaxy)
|
|
|
|
|
|
|
|
debugmaxy = world_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // local y
|
|
|
|
} // local y
|
|
|
|
} // local x
|
|
|
|
} // local x
|
|
|
@ -155,22 +166,24 @@ int dig(DFHack::API& DF,
|
|
|
|
// mark the tiles for actual digging
|
|
|
|
// mark the tiles for actual digging
|
|
|
|
for (vector<DigTarget>::iterator i = candidates.begin(); i != candidates.end(); ++i)
|
|
|
|
for (vector<DigTarget>::iterator i = candidates.begin(); i != candidates.end(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int world_x = (*i).x/16;
|
|
|
|
int grid_x = (*i).x/16;
|
|
|
|
int world_y = (*i).y/16;
|
|
|
|
int grid_y = (*i).y/16;
|
|
|
|
int world_z = (*i).z;
|
|
|
|
int z = (*i).z;
|
|
|
|
|
|
|
|
|
|
|
|
int local_x = (*i).x-world_x;
|
|
|
|
int local_x = (*i).x-grid_x;
|
|
|
|
int local_y = (*i).y-world_y;
|
|
|
|
int local_y = (*i).y-grid_y;
|
|
|
|
|
|
|
|
|
|
|
|
cout << "designating at " << world_x+local_x << " " << world_y+local_y << " " << (*i).z;
|
|
|
|
cout << "designating at " << grid_x+local_x << " " << grid_y+local_y << " " << (*i).z;
|
|
|
|
cout << ", " << (*i).source_distance << " tiles to source" << endl;
|
|
|
|
cout << ", " << (*i).source_distance << " tiles to source" << endl;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO this could probably be made much better, theres a big chance the trees are on the same grid
|
|
|
|
// TODO this could probably be made much better, theres a big chance the trees are on the same grid
|
|
|
|
DF.ReadDesignations(world_x, world_y, world_z, (uint32_t *) designations);
|
|
|
|
DF.ReadDesignations(grid_x, grid_y, z, (uint32_t *) designations);
|
|
|
|
designations[local_x][local_y].bits.dig = DFHack::designation_default;
|
|
|
|
designations[local_x][local_y].bits.dig = DFHack::designation_default;
|
|
|
|
DF.WriteDesignations(world_x, world_y, world_z, (uint32_t *) designations);
|
|
|
|
DF.WriteDesignations(grid_x, grid_y, z, (uint32_t *) designations);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cout << debugmaxx << " " << debugmaxy << endl;
|
|
|
|
|
|
|
|
|
|
|
|
return num;
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|