MCPcopy Create free account
hub / github.com/DFHack/dfhack / CopyBlock

Function CopyBlock

plugins/remotefortressreader/remotefortressreader.cpp:930–1035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

928}
929
930void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos)
931{
932
933 MapExtras::Block * block = MC->BlockAtTile(DfBlock->map_pos);
934
935 int trunk_percent[16][16];
936 int tree_x[16][16];
937 int tree_y[16][16];
938 int tree_z[16][16];
939 for (int xx = 0; xx < 16; xx++)
940 for (int yy = 0; yy < 16; yy++)
941 {
942 trunk_percent[xx][yy] = 255;
943 tree_x[xx][yy] = -3000;
944 tree_y[xx][yy] = -3000;
945 tree_z[xx][yy] = -3000;
946 }
947
948#if DF_VERSION_INT > 34011
949 df::map_block_column * column = df::global::world->map.column_index[(DfBlock->map_pos.x / 48) * 3][(DfBlock->map_pos.y / 48) * 3];
950 for (size_t i = 0; i < column->plants.size(); i++)
951 {
952 df::plant* plant = column->plants[i];
953 if (plant->tree_info == NULL)
954 continue;
955 df::plant_tree_info * tree_info = plant->tree_info;
956 if (
957 plant->pos.z - tree_info->roots_depth > DfBlock->map_pos.z
958 || (plant->pos.z + tree_info->body_height) <= DfBlock->map_pos.z
959 || (plant->pos.x - tree_info->dim_x / 2) > (DfBlock->map_pos.x + 16)
960 || (plant->pos.x + tree_info->dim_x / 2) < (DfBlock->map_pos.x)
961 || (plant->pos.y - tree_info->dim_y / 2) > (DfBlock->map_pos.y + 16)
962 || (plant->pos.y + tree_info->dim_y / 2) < (DfBlock->map_pos.y)
963 )
964 continue;
965 DFCoord localPos = plant->pos - DfBlock->map_pos;
966 for (int xx = 0; xx < tree_info->dim_x; xx++)
967 for (int yy = 0; yy < tree_info->dim_y; yy++)
968 {
969 int xxx = localPos.x - (tree_info->dim_x / 2) + xx;
970 int yyy = localPos.y - (tree_info->dim_y / 2) + yy;
971 if (xxx < 0
972 || yyy < 0
973 || xxx >= 16
974 || yyy >= 16
975 )
976 continue;
977 if (-localPos.z < 0)
978 {
979 df::plant_root_tile tile = tree_info->roots[-1 + localPos.z][xx + (yy * tree_info->dim_x)];
980 if (!tile.whole || tile.bits.blocked)
981 continue;
982 }
983 else
984 {
985 df::plant_tree_tile tile = tree_info->body[-localPos.z][xx + (yy * tree_info->dim_x)];
986 if (!tile.whole || tile.bits.blocked)
987 continue;

Callers 1

GetBlockListFunction · 0.85

Calls 5

tileMaterialFunction · 0.85
CopyMatFunction · 0.85
add_tilesMethod · 0.80
findFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected