|
|
|
@ -747,12 +747,12 @@ void MapExtras::BlockInfo::prepare(Block *mblock)
|
|
|
|
|
|
|
|
|
|
// tree_info contains vertical slices of the tree. This ensures there's a slice for our Z-level.
|
|
|
|
|
df::plant_tree_info * info = pp->tree_info;
|
|
|
|
|
if(!((pp->pos.z-1 <= block->map_pos.z) && ((pp->pos.z+info->z_dim) > block->map_pos.z)))
|
|
|
|
|
if(!((pp->pos.z-1 <= block->map_pos.z) && ((pp->pos.z+info->body_height) > block->map_pos.z)))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Parse through a single horizontal slice of the tree.
|
|
|
|
|
for(int xx = 0; xx < info->x_dim;xx++)
|
|
|
|
|
for(int yy = 0; yy < info->y_dim;yy++)
|
|
|
|
|
for(int xx = 0; xx < info->dim_x;xx++)
|
|
|
|
|
for(int yy = 0; yy < info->dim_y;yy++)
|
|
|
|
|
{
|
|
|
|
|
// Any non-zero value here other than blocked means there's some sort of branch here.
|
|
|
|
|
// If the block is at or above the plant's base level, we use the body array
|
|
|
|
@ -760,14 +760,15 @@ void MapExtras::BlockInfo::prepare(Block *mblock)
|
|
|
|
|
// TODO: verify that the tree bounds intersect the block.
|
|
|
|
|
df::plant_tree_tile tile;
|
|
|
|
|
int z_diff = block->map_pos.z-pp->pos.z;
|
|
|
|
|
if(z_diff >= 0)
|
|
|
|
|
tile = info->body[z_diff][xx+(yy*info->x_dim)];
|
|
|
|
|
else tile = info->roots[0][xx+(yy*info->x_dim)];
|
|
|
|
|
if ((z_diff >= 0) && (z_diff < info->body_height))
|
|
|
|
|
tile = info->body[z_diff][xx+(yy*info->dim_x)];
|
|
|
|
|
else if ((z_diff < 0) && (z_diff >= -info->roots_depth))
|
|
|
|
|
tile = info->roots[0][xx+(yy*info->dim_x)];
|
|
|
|
|
if(tile.whole && !(tile.bits.blocked))
|
|
|
|
|
{
|
|
|
|
|
df::coord pos=pp->pos;
|
|
|
|
|
pos.x = pos.x - (info->x_dim/2) + xx;
|
|
|
|
|
pos.y = pos.y - (info->y_dim/2) + yy;
|
|
|
|
|
pos.x = pos.x - (info->dim_x/2) + xx;
|
|
|
|
|
pos.y = pos.y - (info->dim_y/2) + yy;
|
|
|
|
|
pos.z = block->map_pos.z;
|
|
|
|
|
plants[pos] = pp;
|
|
|
|
|
}
|
|
|
|
|