adjust code to new tree root type

develop
Myk Taylor 2023-04-11 10:14:28 -07:00
parent 5ade6c8282
commit 460b1e8eaf
No known key found for this signature in database
3 changed files with 19 additions and 12 deletions

@ -60,6 +60,7 @@ using namespace std;
#include "df/flow_info.h" #include "df/flow_info.h"
#include "df/job.h" #include "df/job.h"
#include "df/plant.h" #include "df/plant.h"
#include "df/plant_root_tile.h"
#include "df/plant_tree_info.h" #include "df/plant_tree_info.h"
#include "df/plant_tree_tile.h" #include "df/plant_tree_tile.h"
#include "df/region_map_entry.h" #include "df/region_map_entry.h"
@ -805,14 +806,16 @@ void MapExtras::BlockInfo::prepare(Block *mblock)
// If the block is at or above the plant's base level, we use the body array // If the block is at or above the plant's base level, we use the body array
// otherwise we use the roots. // otherwise we use the roots.
// TODO: verify that the tree bounds intersect the block. // TODO: verify that the tree bounds intersect the block.
df::plant_tree_tile tile; bool has_tree_tile = false;
int z_diff = block->map_pos.z - pp->pos.z; int z_diff = block->map_pos.z - pp->pos.z;
if (z_diff >= 0) if (z_diff >= 0) {
tile = info->body[z_diff][xx + (yy*info->dim_x)]; df::plant_tree_tile tile = info->body[z_diff][xx + (yy * info->dim_x)];
else has_tree_tile = tile.whole && !(tile.bits.blocked);
tile = info->roots[-1 - z_diff][xx + (yy*info->dim_x)]; } else {
if (tile.whole && !(tile.bits.blocked)) df::plant_root_tile tile = info->roots[-1 - z_diff][xx + (yy * info->dim_x)];
{ has_tree_tile = tile.whole && !(tile.bits.blocked);
}
if (has_tree_tile) {
df::coord pos = pp->pos; df::coord pos = pp->pos;
pos.x = pos.x - (info->dim_x / 2) + xx; pos.x = pos.x - (info->dim_x / 2) + xx;
pos.y = pos.y - (info->dim_y / 2) + yy; pos.y = pos.y - (info->dim_y / 2) + yy;

@ -57,6 +57,7 @@ using namespace std;
#include "df/flow_info.h" #include "df/flow_info.h"
#include "df/map_block_column.h" #include "df/map_block_column.h"
#include "df/plant.h" #include "df/plant.h"
#include "df/plant_root_tile.h"
#include "df/plant_tree_info.h" #include "df/plant_tree_info.h"
#include "df/plant_tree_tile.h" #include "df/plant_tree_tile.h"
#include "df/region_map_entry.h" #include "df/region_map_entry.h"

@ -76,7 +76,9 @@
#include "df/ocean_wave.h" #include "df/ocean_wave.h"
#include "df/physical_attribute_type.h" #include "df/physical_attribute_type.h"
#include "df/plant.h" #include "df/plant.h"
#include "df/plant_tree_tile.h"
#include "df/plant_raw_flags.h" #include "df/plant_raw_flags.h"
#include "df/plant_root_tile.h"
#include "df/projectile.h" #include "df/projectile.h"
#include "df/proj_itemst.h" #include "df/proj_itemst.h"
#include "df/proj_unitst.h" #include "df/proj_unitst.h"
@ -971,17 +973,18 @@ void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
|| yyy >= 16 || yyy >= 16
) )
continue; continue;
df::plant_tree_tile tile;
if (-localPos.z < 0) if (-localPos.z < 0)
{ {
tile = tree_info->roots[-1 + localPos.z][xx + (yy*tree_info->dim_x)]; df::plant_root_tile tile = tree_info->roots[-1 + localPos.z][xx + (yy * tree_info->dim_x)];
if (!tile.whole || tile.bits.blocked)
continue;
} }
else else
{ {
tile = tree_info->body[-localPos.z][xx + (yy*tree_info->dim_x)]; df::plant_tree_tile tile = tree_info->body[-localPos.z][xx + (yy * tree_info->dim_x)];
if (!tile.whole || tile.bits.blocked)
continue;
} }
if (!tile.whole || tile.bits.blocked)
continue;
if (tree_info->body_height <= 1) if (tree_info->body_height <= 1)
trunk_percent[xxx][yyy] = 0; trunk_percent[xxx][yyy] = 0;
else else