From 460b1e8eaf05f5dafad745ccc5776a66f47de431 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Tue, 11 Apr 2023 10:14:28 -0700 Subject: [PATCH] adjust code to new tree root type --- library/modules/MapCache.cpp | 17 ++++++++++------- library/modules/Maps.cpp | 1 + .../remotefortressreader.cpp | 13 ++++++++----- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/library/modules/MapCache.cpp b/library/modules/MapCache.cpp index b88a078b1..c329220c9 100644 --- a/library/modules/MapCache.cpp +++ b/library/modules/MapCache.cpp @@ -60,6 +60,7 @@ using namespace std; #include "df/flow_info.h" #include "df/job.h" #include "df/plant.h" +#include "df/plant_root_tile.h" #include "df/plant_tree_info.h" #include "df/plant_tree_tile.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 // otherwise we use the roots. // 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; - if (z_diff >= 0) - tile = info->body[z_diff][xx + (yy*info->dim_x)]; - else - tile = info->roots[-1 - z_diff][xx + (yy*info->dim_x)]; - if (tile.whole && !(tile.bits.blocked)) - { + if (z_diff >= 0) { + df::plant_tree_tile tile = info->body[z_diff][xx + (yy * info->dim_x)]; + has_tree_tile = tile.whole && !(tile.bits.blocked); + } else { + 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; pos.x = pos.x - (info->dim_x / 2) + xx; pos.y = pos.y - (info->dim_y / 2) + yy; diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp index ddcd6078f..2e831075d 100644 --- a/library/modules/Maps.cpp +++ b/library/modules/Maps.cpp @@ -57,6 +57,7 @@ using namespace std; #include "df/flow_info.h" #include "df/map_block_column.h" #include "df/plant.h" +#include "df/plant_root_tile.h" #include "df/plant_tree_info.h" #include "df/plant_tree_tile.h" #include "df/region_map_entry.h" diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index f33044877..061cf2698 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -76,7 +76,9 @@ #include "df/ocean_wave.h" #include "df/physical_attribute_type.h" #include "df/plant.h" +#include "df/plant_tree_tile.h" #include "df/plant_raw_flags.h" +#include "df/plant_root_tile.h" #include "df/projectile.h" #include "df/proj_itemst.h" #include "df/proj_unitst.h" @@ -971,17 +973,18 @@ void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc || yyy >= 16 ) continue; - df::plant_tree_tile tile; 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 { - 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) trunk_percent[xxx][yyy] = 0; else