Merge branch 'develop' into ea_improve_survey_performance_keep_mlts_on_heap

develop
bseiller 2021-02-09 08:42:42 +01:00
commit 6ffbf401c4
4 changed files with 192 additions and 218 deletions

@ -33,6 +33,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future
## Fixes
- `embark-assistant`: fixed bug in soil depth determination for ocean tiles
# 0.47.04-r5
## Fixes

@ -1 +1 @@
Subproject commit b7222848dbfd4391d8acafc926303bc4f6253d24
Subproject commit 51f96f9edc52f8916d550f5f833e2959df68bfba

@ -14,13 +14,9 @@
#include "df/builtin_mats.h"
#include "df/coord2d.h"
#include "df/creature_interaction_effect.h"
#include "df/creature_interaction_effect_display_symbolst.h"
#include "df/creature_interaction_effect_type.h"
#include "df/entity_raw.h"
#include "df/feature_init.h"
#include "df/feature_init_deep_special_tubest.h"
#include "df/feature_init_magma_poolst.h"
#include "df/feature_init_volcanost.h"
#include "df/feature_type.h"
#include "df/historical_entity.h"
#include "df/historical_entity_type.h"
@ -29,17 +25,13 @@
#include "df/interaction.h"
#include "df/interaction_effect.h"
#include "df/interaction_effect_type.h"
#include "df/interaction_effect_animatest.h"
#include "df/interaction_instance.h"
#include "df/interaction_source.h"
#include "df/interaction_source_regionst.h"
#include "df/interaction_source_type.h"
#include "df/interaction_target.h"
#include "df/interaction_target_corpsest.h"
#include "df/interaction_target_materialst.h"
#include "df/material_common.h"
#include "df/reaction.h"
#include "df/reaction_product.h"
#include "df/reaction_product_itemst.h"
#include "df/reaction_product_type.h"
#include "df/region_map_entry.h"
@ -55,7 +47,6 @@
#include "df/world_region_details.h"
#include "df/world_region_feature.h"
#include "df/world_region_type.h"
#include "df/world_river.h"
#include "df/world_site.h"
#include "df/world_site_type.h"
#include "df/world_underground_region.h"
@ -902,6 +893,21 @@ void embark_assist::survey::high_level_world_survey(embark_assist::defs::geo_dat
//=================================================================================
void inline copy_incursion_values(embark_assist::defs::mid_level_tile_incursion_base &target,
const embark_assist::defs::mid_level_tile_incursion_base &source) {
target.aquifer = source.aquifer;
target.clay = source.clay;
target.sand = source.sand;
target.soil_depth = source.soil_depth;
target.elevation = source.elevation;
target.biome_offset = source.biome_offset;
target.trees = source.trees;
target.savagery_level = source.savagery_level;
target.evilness_level = source.evilness_level;
}
//=================================================================================
void reset_mlt_inorganics(embark_assist::defs::mid_level_tiles &mlts) {
const uint16_t size = mlts[0][0].metals.size();
for (uint8_t i = 0; i < 16; i++) {
@ -925,13 +931,12 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
int16_t x = screen->location.region_pos.x;
int16_t y = screen->location.region_pos.y;
embark_assist::defs::region_tile_datum *tile = &survey_results->at(x).at(y);
embark_assist::defs::region_tile_datum &tile = survey_results->at(x).at(y);
int8_t max_soil_depth;
int8_t offset;
int16_t elevation;
int16_t last_bottom;
int16_t top_z;
int16_t base_z;
int16_t min_z = 0; // Initialized to silence warning about potential usage of uninitialized data.
int16_t bottom_z;
df::coord2d adjusted;
@ -946,17 +951,18 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
bool aquifer;
for (uint16_t i = 0; i < state->max_inorganic; i++) {
tile->metals[i] = 0;
tile->economics[i] = 0;
tile->minerals[i] = 0;
tile.metals[i] = 0;
tile.economics[i] = 0;
tile.minerals[i] = 0;
}
reset_mlt_inorganics(*mlt);
for (uint8_t i = 1; i < 10; i++) survey_results->at(x).at(y).biome_index[i] = -1;
for (uint8_t i = 1; i < 10; i++) tile.biome_index[i] = -1;
for (uint8_t i = 0; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) {
embark_assist::defs::mid_level_tile &mid_level_tile = mlt->at(i).at(k);
max_soil_depth = -1;
offset = details->biome[i][k];
@ -964,68 +970,68 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
if (adjusted.x != x || adjusted.y != y)
{
mlt->at(i).at(k).biome_offset = offset;
mid_level_tile.biome_offset = offset;
}
else
{
mlt->at(i).at(k).biome_offset = 5;
mid_level_tile.biome_offset = 5;
}
const df::region_map_entry &region_map_entry = world_data->region_map[adjusted.x][adjusted.y];
survey_results->at(x).at(y).biome_index[mlt->at(i).at(k).biome_offset] =
world_data->region_map[adjusted.x][adjusted.y].region_id;
tile.biome_index[mid_level_tile.biome_offset] = region_map_entry.region_id;
mlt->at(i).at(k).savagery_level = world_data->region_map[adjusted.x][adjusted.y].savagery / 33;
if (mlt->at(i).at(k).savagery_level == 3) {
mlt->at(i).at(k).savagery_level = 2;
mid_level_tile.savagery_level = region_map_entry.savagery / 33;
if (mid_level_tile.savagery_level == 3) {
mid_level_tile.savagery_level = 2;
}
mlt->at(i).at(k).evilness_level = world_data->region_map[adjusted.x][adjusted.y].evilness / 33;
if (mlt->at(i).at(k).evilness_level == 3) {
mlt->at(i).at(k).evilness_level = 2;
mid_level_tile.evilness_level = region_map_entry.evilness / 33;
if (mid_level_tile.evilness_level == 3) {
mid_level_tile.evilness_level = 2;
}
elevation = details->elevation[i][k];
const df::world_geo_biome* world_geo_biome = world_data->geo_biomes[region_map_entry.geo_index];
// Special biome adjustments
if (!world_data->region_map[adjusted.x][adjusted.y].flags.is_set(region_map_entry_flags::is_lake)) {
if (world_data->region_map[adjusted.x][adjusted.y].elevation >= 150) { // Mountain
if (!region_map_entry.flags.is_set(region_map_entry_flags::is_lake)) {
if (region_map_entry.elevation >= 150) { // Mountain
max_soil_depth = 0;
}
else if (world_data->region_map[adjusted.x][adjusted.y].elevation < 100) { // Ocean
else if (region_map_entry.elevation < 100) { // Ocean
if (elevation == 99) {
elevation = 98;
}
if ((world_data->geo_biomes[world_data->region_map[x][y].geo_index]->unk1 == 4 ||
world_data->geo_biomes[world_data->region_map[x][y].geo_index]->unk1 == 5) &&
if ((world_geo_biome->unk1 == 4 ||
world_geo_biome->unk1 == 5) &&
details->unk12e8 < 500) {
max_soil_depth = 0;
}
}
}
base_z = elevation - 1;
features = details->features[i][k];
mlt->at(i).at(k).adamantine_level = -1;
mlt->at(i).at(k).magma_level = -1;
mid_level_tile.adamantine_level = -1;
mid_level_tile.magma_level = -1;
end_check_l = static_cast<uint16_t>(features.size());
for (size_t l = 0; l < end_check_l; l++) {
auto feature = features[l];
if (feature->feature_idx != -1) {
switch (world_data->feature_map[x / 16][y / 16].features->feature_init[x % 16][y % 16][feature->feature_idx]->getType())
auto feature_init = world_data->feature_map[x / 16][y / 16].features->feature_init[x % 16][y % 16][feature->feature_idx];
switch (feature_init->getType())
{
case df::feature_type::deep_special_tube:
mlt->at(i).at(k).adamantine_level = world_data->feature_map[x / 16][y / 16].features->feature_init[x % 16][y % 16][feature->feature_idx]->start_depth;
mid_level_tile.adamantine_level = feature_init->start_depth;
break;
case df::feature_type::magma_pool:
mlt->at(i).at(k).magma_level = 2 - world_data->feature_map[x / 16][y / 16].features->feature_init[x % 16][y % 16][feature->feature_idx]->start_depth;
mid_level_tile.magma_level = 2 - feature_init->start_depth;
break;
case df::feature_type::volcano:
mlt->at(i).at(k).magma_level = 3;
mid_level_tile.magma_level = 3;
break;
default:
@ -1036,8 +1042,6 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
feature->min_z != -30000) {
auto layer = world_data->underground_regions[feature->layer];
base_z = std::min((int)base_z, (int)feature->min_z);
if (layer->type == df::world_underground_region::MagmaSea) {
min_z = feature->min_z; // The features are individual per region tile
}
@ -1050,56 +1054,57 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
max_soil_depth = std::max((154 - elevation) / 5, 1);
}
soil_erosion = geo_summary->at(world_data->region_map[adjusted.x][adjusted.y].geo_index).soil_size -
std::min((int)geo_summary->at(world_data->region_map[adjusted.x][adjusted.y].geo_index).soil_size, (int)max_soil_depth);
auto geo_datum = geo_summary->at(region_map_entry.geo_index);
soil_erosion = geo_datum.soil_size -
std::min((int)geo_datum.soil_size, (int)max_soil_depth);
int16_t layer_shift[16];
int16_t cur_shift = elevation + soil_erosion - 1;
aquifer = false;
mlt->at(i).at(k).aquifer = embark_assist::defs::Clear_Aquifer_Bits;
mlt->at(i).at(k).clay = false;
mlt->at(i).at(k).sand = false;
mlt->at(i).at(k).flux = false;
mlt->at(i).at(k).coal = false;
mid_level_tile.aquifer = embark_assist::defs::Clear_Aquifer_Bits;
mid_level_tile.clay = false;
mid_level_tile.sand = false;
mid_level_tile.flux = false;
mid_level_tile.coal = false;
if (max_soil_depth == 0) {
mlt->at(i).at(k).soil_depth = 0;
mid_level_tile.soil_depth = 0;
}
else {
mlt->at(i).at(k).soil_depth = geo_summary->at(world_data->region_map[adjusted.x][adjusted.y].geo_index).soil_size - soil_erosion;
mid_level_tile.soil_depth = geo_datum.soil_size - soil_erosion;
}
mlt->at(i).at(k).offset = offset;
mlt->at(i).at(k).elevation = details->elevation[i][k];
mlt->at(i).at(k).river_size = embark_assist::defs::river_sizes::None;
mlt->at(i).at(k).river_elevation = 100;
mid_level_tile.offset = offset;
mid_level_tile.elevation = details->elevation[i][k];
mid_level_tile.river_size = embark_assist::defs::river_sizes::None;
mid_level_tile.river_elevation = 100;
if (details->rivers_vertical.active[i][k] != 0) {
mlt->at(i).at(k).river_size = river_size_of (details->rivers_vertical.x_max[i][k] - details->rivers_vertical.x_min[i][k] + 1);
mlt->at(i).at(k).river_elevation = details->rivers_vertical.elevation[i][k];
mid_level_tile.river_size = river_size_of (details->rivers_vertical.x_max[i][k] - details->rivers_vertical.x_min[i][k] + 1);
mid_level_tile.river_elevation = details->rivers_vertical.elevation[i][k];
}
else if (details->rivers_horizontal.active[i][k] != 0) {
mlt->at(i).at(k).river_size = river_size_of (details->rivers_horizontal.y_max[i][k] - details->rivers_horizontal.y_min[i][k] + 1);
mlt->at(i).at(k).river_elevation = details->rivers_horizontal.elevation[i][k];
mid_level_tile.river_size = river_size_of (details->rivers_horizontal.y_max[i][k] - details->rivers_horizontal.y_min[i][k] + 1);
mid_level_tile.river_elevation = details->rivers_horizontal.elevation[i][k];
}
if (mlt->at(i).at(k).river_size != embark_assist::defs::river_sizes::None &&
if (mid_level_tile.river_size != embark_assist::defs::river_sizes::None &&
world_tile->flags.is_set(df::region_map_entry_flags::is_brook)) {
mlt->at(i).at(k).river_size = embark_assist::defs::river_sizes::Brook;
mid_level_tile.river_size = embark_assist::defs::river_sizes::Brook;
}
if (tile->min_region_soil > mlt->at(i).at(k).soil_depth) {
tile->min_region_soil = mlt->at(i).at(k).soil_depth;
if (tile.min_region_soil > mid_level_tile.soil_depth) {
tile.min_region_soil = mid_level_tile.soil_depth;
}
if (tile->max_region_soil < mlt->at(i).at(k).soil_depth) {
tile->max_region_soil = mlt->at(i).at(k).soil_depth;
if (tile.max_region_soil < mid_level_tile.soil_depth) {
tile.max_region_soil = mid_level_tile.soil_depth;
}
end_check_l = static_cast<uint16_t>(world_data->geo_biomes[world_data->region_map[adjusted.x][adjusted.y].geo_index]->layers.size());
end_check_l = static_cast<uint16_t>(world_geo_biome->layers.size());
if (end_check_l > 16) end_check_l = 16;
for (uint16_t l = 0; l < end_check_l; l++) {
auto layer = world_data->geo_biomes[world_data->region_map[adjusted.x][adjusted.y].geo_index]->layers[l];
auto layer = world_geo_biome->layers[l];
layer_shift[l] = cur_shift;
if (layer->type == df::geo_layer_type::SOIL ||
@ -1123,7 +1128,7 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
// Don't have to set up the end_check as we can reuse the one above.
for (uint16_t l = 0; l < end_check_l; l++) {
auto layer = world_data->geo_biomes[world_data->region_map[adjusted.x][adjusted.y].geo_index]->layers[l];
auto layer = world_geo_biome->layers[l];
top_z = last_bottom - 1;
bottom_z = std::max((int)layer->bottom_height + layer_shift[l], (int)min_z);
@ -1134,38 +1139,38 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
if (top_z >= bottom_z) {
last_bottom = bottom_z;
mlt->at(i).at(k).minerals[layer->mat_index] = true;
mid_level_tile.minerals[layer->mat_index] = true;
end_check_m = static_cast<uint16_t>(world->raws.inorganics[layer->mat_index]->metal_ore.mat_index.size());
const df::inorganic_raw* inorganic_layer = world->raws.inorganics[layer->mat_index];
end_check_m = static_cast<uint16_t>(inorganic_layer->metal_ore.mat_index.size());
for (uint16_t m = 0; m < end_check_m; m++) {
mlt->at(i).at(k).metals[world->raws.inorganics[layer->mat_index]->metal_ore.mat_index[m]] = true;
mid_level_tile.metals[inorganic_layer->metal_ore.mat_index[m]] = true;
}
if (layer->type == df::geo_layer_type::SOIL ||
layer->type == df::geo_layer_type::SOIL_SAND) {
if (world->raws.inorganics[layer->mat_index]->flags.is_set(df::inorganic_flags::SOIL_SAND)) {
mlt->at(i).at(k).sand = true;
if (inorganic_layer->flags.is_set(df::inorganic_flags::SOIL_SAND)) {
mid_level_tile.sand = true;
}
}
if (world->raws.inorganics[layer->mat_index]->economic_uses.size() > 0) {
mlt->at(i).at(k).economics[layer->mat_index] = true;
if (inorganic_layer->economic_uses.size() > 0) {
mid_level_tile.economics[layer->mat_index] = true;
end_check_m = static_cast<uint16_t>(world->raws.inorganics[layer->mat_index]->economic_uses.size());
end_check_m = static_cast<uint16_t>(inorganic_layer->economic_uses.size());
for (uint16_t m = 0; m < end_check_m; m++) {
if (world->raws.inorganics[layer->mat_index]->economic_uses[m] == state->clay_reaction) {
mlt->at(i).at(k).clay = true;
if (inorganic_layer->economic_uses[m] == state->clay_reaction) {
mid_level_tile.clay = true;
}
else if (world->raws.inorganics[layer->mat_index]->economic_uses[m] == state->flux_reaction) {
mlt->at(i).at(k).flux = true;
else if (inorganic_layer->economic_uses[m] == state->flux_reaction) {
mid_level_tile.flux = true;
}
}
for (uint16_t m = 0; m < state->coals.size(); m++) {
if (layer->mat_index == state->coals[m]) {
mlt->at(i).at(k).coal = true;
mid_level_tile.coal = true;
break;
}
}
@ -1174,31 +1179,33 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
end_check_m = static_cast<uint16_t>(layer->vein_mat.size());
for (uint16_t m = 0; m < end_check_m; m++) {
mlt->at(i).at(k).minerals[layer->vein_mat[m]] = true;
const int vein_mat_index = layer->vein_mat[m];
mid_level_tile.minerals[vein_mat_index] = true;
end_check_n = static_cast<uint16_t>(world->raws.inorganics[layer->vein_mat[m]]->metal_ore.mat_index.size());
const df::inorganic_raw* inorganic_vein = world->raws.inorganics[vein_mat_index];
end_check_n = static_cast<uint16_t>(inorganic_vein->metal_ore.mat_index.size());
for (uint16_t n = 0; n < end_check_n; n++) {
mlt->at(i).at(k).metals[world->raws.inorganics[layer->vein_mat[m]]->metal_ore.mat_index[n]] = true;
mid_level_tile.metals[inorganic_vein->metal_ore.mat_index[n]] = true;
}
if (world->raws.inorganics[layer->vein_mat[m]]->economic_uses.size() > 0) {
mlt->at(i).at(k).economics[layer->vein_mat[m]] = true;
if (inorganic_vein->economic_uses.size() > 0) {
mid_level_tile.economics[vein_mat_index] = true;
end_check_n = static_cast<uint16_t>(world->raws.inorganics[layer->vein_mat[m]]->economic_uses.size());
end_check_n = static_cast<uint16_t>(inorganic_vein->economic_uses.size());
for (uint16_t n = 0; n < end_check_n; n++) {
if (world->raws.inorganics[layer->vein_mat[m]]->economic_uses[n] == state->clay_reaction) {
mlt->at(i).at(k).clay = true;
if (inorganic_vein->economic_uses[n] == state->clay_reaction) {
mid_level_tile.clay = true;
}
else if (world->raws.inorganics[layer->vein_mat[m]]->economic_uses[n] == state->flux_reaction) {
mlt->at(i).at(k).flux = true;
else if (inorganic_vein->economic_uses[n] == state->flux_reaction) {
mid_level_tile.flux = true;
}
}
for (uint16_t n = 0; n < state->coals.size(); n++) {
if (layer->vein_mat[m] == state->coals[n]) {
mlt->at(i).at(k).coal = true;
if (vein_mat_index == state->coals[n]) {
mid_level_tile.coal = true;
break;
}
}
@ -1206,23 +1213,23 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
}
if (bottom_z <= elevation - 3 &&
world->raws.inorganics[layer->mat_index]->flags.is_set(df::inorganic_flags::AQUIFER)) {
inorganic_layer->flags.is_set(df::inorganic_flags::AQUIFER)) {
aquifer = true;
}
}
}
if (!aquifer) {
mlt->at(i).at(k).aquifer = embark_assist::defs::None_Aquifer_Bit;
mid_level_tile.aquifer = embark_assist::defs::None_Aquifer_Bit;
}
else if (world_data->region_map[adjusted.x][adjusted.y].drainage % 20 == 7) {
mlt->at(i).at(k).aquifer = embark_assist::defs::Heavy_Aquifer_Bit;
else if (region_map_entry.drainage % 20 == 7) {
mid_level_tile.aquifer = embark_assist::defs::Heavy_Aquifer_Bit;
}
else {
mlt->at(i).at(k).aquifer = embark_assist::defs::Light_Aquifer_Bit;
mid_level_tile.aquifer = embark_assist::defs::Light_Aquifer_Bit;
}
mlt->at(i).at(k).trees = tree_level_of(world_data->regions[world_data->region_map[adjusted.x][adjusted.y].region_id]->type,
world_data->region_map[adjusted.x][adjusted.y].vegetation);
mid_level_tile.trees = tree_level_of(world_data->regions[region_map_entry.region_id]->type,
region_map_entry.vegetation);
}
}
@ -1238,14 +1245,15 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
//
for (uint8_t i = 1; i < 16; i++) {
for (uint8_t k = 0; k < 15; k++) {
auto western_neighbour = mlt->at(i - 1).at(k);
if (details->rivers_horizontal.active[i][k] != 0 &&
details->rivers_vertical.active[i - 1][k + 1] != 0 &&
mlt->at(i - 1).at(k).river_size == embark_assist::defs::river_sizes::None) { // Probably never true
mlt->at(i - 1).at(k).river_size = mlt->at(i).at(k).river_size;
mlt->at(i - 1).at(k).river_elevation = mlt->at(i).at(k).river_elevation;
western_neighbour.river_size == embark_assist::defs::river_sizes::None) { // Probably never true
western_neighbour.river_size = mlt->at(i).at(k).river_size;
western_neighbour.river_elevation = mlt->at(i).at(k).river_elevation;
if (mlt->at(i - 1).at(k).river_elevation > mlt->at(i - 1).at(k + 1).river_elevation) {
mlt->at(i - 1).at(k).river_elevation = mlt->at(i - 1).at(k + 1).river_elevation;
if (western_neighbour.river_elevation > mlt->at(i - 1).at(k + 1).river_elevation) {
western_neighbour.river_elevation = mlt->at(i - 1).at(k + 1).river_elevation;
}
}
}
@ -1253,78 +1261,81 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
for (uint8_t i = 0; i < 16; i++) {
for (uint8_t k = 1; k < 16; k++) {
auto northern_neighbour = mlt->at(i).at(k - 1);
if (details->rivers_vertical.active[i][k] != 0 &&
mlt->at(i).at(k - 1).river_size == embark_assist::defs::river_sizes::None) {
mlt->at(i).at(k - 1).river_size = mlt->at(i).at(k).river_size;
mlt->at(i).at(k - 1).river_elevation = mlt->at(i).at(k).river_elevation;
northern_neighbour.river_size == embark_assist::defs::river_sizes::None) {
northern_neighbour.river_size = mlt->at(i).at(k).river_size;
northern_neighbour.river_elevation = mlt->at(i).at(k).river_elevation;
}
}
}
for (uint8_t i = 1; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) {
auto western_neighbour = mlt->at(i - 1).at(k);
if (details->rivers_horizontal.active[i][k] != 0 &&
mlt->at(i - 1).at(k).river_size == embark_assist::defs::river_sizes::None) {
mlt->at(i - 1).at(k).river_size = mlt->at(i).at(k).river_size;
mlt->at(i - 1).at(k).river_elevation = mlt->at(i).at(k).river_elevation;
western_neighbour.river_size == embark_assist::defs::river_sizes::None) {
western_neighbour.river_size = mlt->at(i).at(k).river_size;
western_neighbour.river_elevation = mlt->at(i).at(k).river_elevation;
}
}
}
survey_results->at(x).at(y).aquifer = embark_assist::defs::Clear_Aquifer_Bits;
survey_results->at(x).at(y).clay_count = 0;
survey_results->at(x).at(y).sand_count = 0;
survey_results->at(x).at(y).flux_count = 0;
survey_results->at(x).at(y).coal_count = 0;
survey_results->at(x).at(y).min_region_soil = 10;
survey_results->at(x).at(y).max_region_soil = 0;
survey_results->at(x).at(y).savagery_count[0] = 0;
survey_results->at(x).at(y).savagery_count[1] = 0;
survey_results->at(x).at(y).savagery_count[2] = 0;
survey_results->at(x).at(y).evilness_count[0] = 0;
survey_results->at(x).at(y).evilness_count[1] = 0;
survey_results->at(x).at(y).evilness_count[2] = 0;
tile.aquifer = embark_assist::defs::Clear_Aquifer_Bits;
tile.clay_count = 0;
tile.sand_count = 0;
tile.flux_count = 0;
tile.coal_count = 0;
tile.min_region_soil = 10;
tile.max_region_soil = 0;
tile.savagery_count[0] = 0;
tile.savagery_count[1] = 0;
tile.savagery_count[2] = 0;
tile.evilness_count[0] = 0;
tile.evilness_count[1] = 0;
tile.evilness_count[2] = 0;
for (uint8_t i = 0; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) {
survey_results->at(x).at(y).aquifer |= mlt->at(i).at(k).aquifer;
if (mlt->at(i).at(k).clay) { survey_results->at(x).at(y).clay_count++; }
if (mlt->at(i).at(k).sand) { survey_results->at(x).at(y).sand_count++; }
if (mlt->at(i).at(k).flux) { survey_results->at(x).at(y).flux_count++; }
if (mlt->at(i).at(k).coal) { survey_results->at(x).at(y).coal_count++; }
const embark_assist::defs::mid_level_tile &mid_level_tile = mlt->at(i).at(k);
tile.aquifer |= mid_level_tile.aquifer;
if (mid_level_tile.clay) { tile.clay_count++; }
if (mid_level_tile.sand) { tile.sand_count++; }
if (mid_level_tile.flux) { tile.flux_count++; }
if (mid_level_tile.coal) { tile.coal_count++; }
if (mlt->at(i).at(k).soil_depth < survey_results->at(x).at(y).min_region_soil) {
survey_results->at(x).at(y).min_region_soil = mlt->at(i).at(k).soil_depth;
if (mid_level_tile.soil_depth < tile.min_region_soil) {
tile.min_region_soil = mid_level_tile.soil_depth;
}
if (mlt->at(i).at(k).soil_depth > survey_results->at(x).at(y).max_region_soil) {
survey_results->at(x).at(y).max_region_soil = mlt->at(i).at(k).soil_depth;
if (mid_level_tile.soil_depth > tile.max_region_soil) {
tile.max_region_soil = mid_level_tile.soil_depth;
}
if (mlt->at(i).at(k).river_size != embark_assist::defs::river_sizes::None) {
if (survey_results->at(x).at(y).min_river_size == embark_assist::defs::river_sizes::None ||
mlt->at(i).at(k).river_size < survey_results->at(x).at(y).min_river_size) {
survey_results->at(x).at(y).min_river_size = mlt->at(i).at(k).river_size;
if (mid_level_tile.river_size != embark_assist::defs::river_sizes::None) {
if (tile.min_river_size == embark_assist::defs::river_sizes::None ||
mid_level_tile.river_size < tile.min_river_size) {
tile.min_river_size = mid_level_tile.river_size;
}
if (survey_results->at(x).at(y).max_river_size < mlt->at(i).at(k).river_size) {
survey_results->at(x).at(y).max_river_size = mlt->at(i).at(k).river_size;
if (tile.max_river_size < mid_level_tile.river_size) {
tile.max_river_size = mid_level_tile.river_size;
}
if (i < 15 &&
mlt->at(i + 1).at(k).river_size != embark_assist::defs::river_sizes::None &&
abs (mlt->at(i).at(k).river_elevation - mlt->at(i + 1).at(k).river_elevation) >
survey_results->at(x).at(y).max_waterfall) {
survey_results->at(x).at(y).max_waterfall =
abs(mlt->at(i).at(k).river_elevation - mlt->at(i + 1).at(k).river_elevation);
if (i < 15) {
const embark_assist::defs::mid_level_tile &eastern_neighbour = mlt->at(i + 1).at(k);
if (eastern_neighbour.river_size != embark_assist::defs::river_sizes::None &&
abs(mid_level_tile.river_elevation - eastern_neighbour.river_elevation) > tile.max_waterfall) {
tile.max_waterfall = abs(mid_level_tile.river_elevation - eastern_neighbour.river_elevation);
}
}
if (k < 15 &&
mlt->at(i).at(k + 1).river_size != embark_assist::defs::river_sizes::None &&
abs(mlt->at(i).at(k).river_elevation - mlt->at(i).at(k + 1).river_elevation) >
survey_results->at(x).at(y).max_waterfall) {
survey_results->at(x).at(y).max_waterfall =
abs(mlt->at(i).at(k).river_elevation - mlt->at(i).at(k + 1).river_elevation);
if (k < 15) {
const embark_assist::defs::mid_level_tile &southern_neighbour = mlt->at(i).at(k + 1);
if (southern_neighbour.river_size != embark_assist::defs::river_sizes::None &&
abs(mid_level_tile.river_elevation - southern_neighbour.river_elevation) > tile.max_waterfall) {
tile.max_waterfall = abs(mid_level_tile.river_elevation - southern_neighbour.river_elevation);
}
}
}
@ -1334,23 +1345,23 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
// reanimating handled separately
// thralling handled separately
if (survey_results->at(x).at(y).min_tree_level > mlt->at(i).at(k).trees) survey_results->at(x).at(y).min_tree_level = mlt->at(i).at(k).trees;
if (survey_results->at(x).at(y).max_tree_level < mlt->at(i).at(k).trees) survey_results->at(x).at(y).max_tree_level = mlt->at(i).at(k).trees;
if (tile.min_tree_level > mid_level_tile.trees) tile.min_tree_level = mid_level_tile.trees;
if (tile.max_tree_level < mid_level_tile.trees) tile.max_tree_level = mid_level_tile.trees;
survey_results->at(x).at(y).savagery_count[mlt->at(i).at(k).savagery_level]++;
survey_results->at(x).at(y).evilness_count[mlt->at(i).at(k).evilness_level]++;
tile.savagery_count[mid_level_tile.savagery_level]++;
tile.evilness_count[mid_level_tile.evilness_level]++;
for (uint16_t l = 0; l < state->max_inorganic; l++) {
if (mlt->at(i).at(k).metals[l]) { survey_results->at(x).at(y).metals[l] = true; }
if (mlt->at(i).at(k).economics[l]) { survey_results->at(x).at(y).economics[l] = true; }
if (mlt->at(i).at(k).minerals[l]) { survey_results->at(x).at(y).minerals[l] = true; }
if (mid_level_tile.metals[l]) { tile.metals[l] = true; }
if (mid_level_tile.economics[l]) { tile.economics[l] = true; }
if (mid_level_tile.minerals[l]) { tile.minerals[l] = true; }
}
}
}
for (uint8_t i = 1; i < 10; i++) {
if (survey_results->at(x).at(y).biome_index[i] == -1) {
survey_results->at(x).at(y).biome[i] = -1;
if (tile.biome_index[i] == -1) {
tile.biome[i] = -1;
}
}
@ -1361,8 +1372,8 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
for (uint8_t i = 1; i < 10; i++)
{
if (survey_results->at(x).at(y).biome[i] != -1) {
biomes[survey_results->at(x).at(y).biome[i]] = true;
if (tile.biome[i] != -1) {
biomes[tile.biome[i]] = true;
}
}
int count = 0;
@ -1370,83 +1381,43 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
if (biomes[i]) count++;
}
tile->biome_count = count;
tile.biome_count = count;
for (uint8_t i = 0; i < 16; i++) {
tile->north_row[i].aquifer = mlt->at(i).at(0).aquifer;
tile->south_row[i].aquifer = mlt->at(i).at(15).aquifer;
tile->west_column[i].aquifer = mlt->at(0).at(i).aquifer;
tile->east_column[i].aquifer = mlt->at(15).at(i).aquifer;
tile->north_row[i].clay= mlt->at(i).at(0).clay;
tile->south_row[i].clay = mlt->at(i).at(15).clay;
tile->west_column[i].clay = mlt->at(0).at(i).clay;
tile->east_column[i].clay = mlt->at(15).at(i).clay;
tile->north_row[i].sand = mlt->at(i).at(0).sand;
tile->south_row[i].sand = mlt->at(i).at(15).sand;
tile->west_column[i].sand = mlt->at(0).at(i).sand;
tile->east_column[i].sand = mlt->at(15).at(i).sand;
tile->north_row[i].soil_depth = mlt->at(i).at(0).soil_depth;
tile->south_row[i].soil_depth = mlt->at(i).at(15).soil_depth;
tile->west_column[i].soil_depth = mlt->at(0).at(i).soil_depth;
tile->east_column[i].soil_depth = mlt->at(15).at(i).soil_depth;
tile->north_row[i].elevation = mlt->at(i).at(0).elevation;
tile->south_row[i].elevation = mlt->at(i).at(15).elevation;
tile->west_column[i].elevation = mlt->at(0).at(i).elevation;
tile->east_column[i].elevation = mlt->at(15).at(i).elevation;
tile->north_row[i].biome_offset = mlt->at(i).at(0).biome_offset;
tile->south_row[i].biome_offset = mlt->at(i).at(15).biome_offset;
tile->west_column[i].biome_offset = mlt->at(0).at(i).biome_offset;
tile->east_column[i].biome_offset = mlt->at(15).at(i).biome_offset;
tile->north_row[i].trees = mlt->at(i).at(0).trees;
tile->south_row[i].trees = mlt->at(i).at(15).trees;
tile->west_column[i].trees = mlt->at(0).at(i).trees;
tile->east_column[i].trees = mlt->at(15).at(i).trees;
tile->north_row[i].savagery_level = mlt->at(i).at(0).savagery_level;
tile->south_row[i].savagery_level = mlt->at(i).at(15).savagery_level;
tile->west_column[i].savagery_level = mlt->at(0).at(i).savagery_level;
tile->east_column[i].savagery_level = mlt->at(15).at(i).savagery_level;
tile->north_row[i].evilness_level = mlt->at(i).at(0).evilness_level;
tile->south_row[i].evilness_level = mlt->at(i).at(15).evilness_level;
tile->west_column[i].evilness_level = mlt->at(0).at(i).evilness_level;
tile->east_column[i].evilness_level = mlt->at(15).at(i).evilness_level;
tile->north_corner_selection[i] = world_data->region_details[0]->edges.biome_corner[i][0];
tile->west_corner_selection[i] = world_data->region_details[0]->edges.biome_corner[0][i];
tile->north_row_biome_x[i] = world_data->region_details[0]->edges.biome_x[i][0];
tile->west_column_biome_y[i] = world_data->region_details[0]->edges.biome_y[0][i];
copy_incursion_values(tile.north_row[i], mlt->at(i).at(0));
copy_incursion_values(tile.south_row[i], mlt->at(i).at(15));
copy_incursion_values(tile.west_column[i], mlt->at(0).at(i));
copy_incursion_values(tile.east_column[i], mlt->at(15).at(i));
tile.north_corner_selection[i] = world_data->region_details[0]->edges.biome_corner[i][0];
tile.west_corner_selection[i] = world_data->region_details[0]->edges.biome_corner[0][i];
tile.north_row_biome_x[i] = world_data->region_details[0]->edges.biome_x[i][0];
tile.west_column_biome_y[i] = world_data->region_details[0]->edges.biome_y[0][i];
}
for (uint8_t i = 0; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) {
tile->region_type[i][k] = world_data->regions[tile->biome_index[mlt->at(i).at(k).biome_offset]]->type;
tile.region_type[i][k] = world_data->regions[tile.biome_index[mlt->at(i).at(k).biome_offset]]->type;
}
}
// Focus has to be at the world tile to get neighbor info
//
if (!tile->surveyed) {
if (!tile.surveyed) {
for (uint16_t i = 0; i < world->entities.all.size(); i++) {
if (world->entities.all[i]->flags.bits.neighbor) {
if (world->entities.all[i]->type == df::historical_entity_type::SiteGovernment) {
tile->necro_neighbors++;
tile.necro_neighbors++;
}
else
{
tile->neighbors.push_back(world->entities.all[i]->entity_raw->index);
tile.neighbors.push_back(world->entities.all[i]->entity_raw->index);
}
}
}
}
tile->surveyed = true;
tile.surveyed = true;
}
//=================================================================================

@ -1 +1 @@
Subproject commit 86788f5bf975da2506c61372ebfbe36ca47ed57c
Subproject commit 515c75d22d18e0d64e0e3d56ec32f16b209eeac6