Merge branch 'develop' into myk_dreamfort

develop
myk002 2021-02-13 07:15:11 -08:00
commit 81d0a276b2
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
7 changed files with 214 additions and 228 deletions

@ -185,7 +185,7 @@ endif()
# set up versioning. # set up versioning.
set(DF_VERSION "0.47.05") set(DF_VERSION "0.47.05")
set(DFHACK_RELEASE "alpha0") set(DFHACK_RELEASE "beta1")
set(DFHACK_PRERELEASE TRUE) set(DFHACK_PRERELEASE TRUE)
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")

@ -35,7 +35,13 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements ## Misc Improvements
- `quickfort`: Dreamfort blueprint set improvements: `significant <http://www.bay12forums.com/smf/index.php?topic=176889.msg8239017#msg8239017>`_ refinements across the entire blueprint set. Dreamfort is now much faster, much more efficient, and much easier to use. The `checklist <https://docs.google.com/spreadsheets/d/13PVZ2h3Mm3x_G1OXQvwKd7oIR2lK4A1Ahf6Om1kFigw/edit#gid=1459509569>`__ now includes a mini-walkthrough for quick reference. The spreadsheet now also includes `embark profile suggestions <https://docs.google.com/spreadsheets/d/13PVZ2h3Mm3x_G1OXQvwKd7oIR2lK4A1Ahf6Om1kFigw/edit#gid=149144025>`__ - `quickfort`: Dreamfort blueprint set improvements: `significant <http://www.bay12forums.com/smf/index.php?topic=176889.msg8239017#msg8239017>`_ refinements across the entire blueprint set. Dreamfort is now much faster, much more efficient, and much easier to use. The `checklist <https://docs.google.com/spreadsheets/d/13PVZ2h3Mm3x_G1OXQvwKd7oIR2lK4A1Ahf6Om1kFigw/edit#gid=1459509569>`__ now includes a mini-walkthrough for quick reference. The spreadsheet now also includes `embark profile suggestions <https://docs.google.com/spreadsheets/d/13PVZ2h3Mm3x_G1OXQvwKd7oIR2lK4A1Ahf6Om1kFigw/edit#gid=149144025>`__
- `quickfort`: added aliases for configuring masterwork and artifact core quality for all stockpile categories that have them - `quickfort`: added aliases for configuring masterwork and artifact core quality for all stockpile categories that have them; made it possible to take from multiple stockpiles in the ``quantumstop`` alias
# 0.47.05-beta1
## Fixes
- `embark-assistant`: fixed bug in soil depth determination for ocean tiles
- `orders`: don't crash when importing orders with malformed JSON
# 0.47.04-r5 # 0.47.04-r5

@ -1 +1 @@
Subproject commit b7222848dbfd4391d8acafc926303bc4f6253d24 Subproject commit f45c7324de5ab6b18b3a3348a542cd125352ca0c

@ -14,13 +14,9 @@
#include "df/builtin_mats.h" #include "df/builtin_mats.h"
#include "df/coord2d.h" #include "df/coord2d.h"
#include "df/creature_interaction_effect.h" #include "df/creature_interaction_effect.h"
#include "df/creature_interaction_effect_display_symbolst.h"
#include "df/creature_interaction_effect_type.h" #include "df/creature_interaction_effect_type.h"
#include "df/entity_raw.h" #include "df/entity_raw.h"
#include "df/feature_init.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/feature_type.h"
#include "df/historical_entity.h" #include "df/historical_entity.h"
#include "df/historical_entity_type.h" #include "df/historical_entity_type.h"
@ -29,17 +25,13 @@
#include "df/interaction.h" #include "df/interaction.h"
#include "df/interaction_effect.h" #include "df/interaction_effect.h"
#include "df/interaction_effect_type.h" #include "df/interaction_effect_type.h"
#include "df/interaction_effect_animatest.h"
#include "df/interaction_instance.h" #include "df/interaction_instance.h"
#include "df/interaction_source.h" #include "df/interaction_source.h"
#include "df/interaction_source_regionst.h"
#include "df/interaction_source_type.h" #include "df/interaction_source_type.h"
#include "df/interaction_target.h" #include "df/interaction_target.h"
#include "df/interaction_target_corpsest.h"
#include "df/interaction_target_materialst.h" #include "df/interaction_target_materialst.h"
#include "df/material_common.h" #include "df/material_common.h"
#include "df/reaction.h" #include "df/reaction.h"
#include "df/reaction_product.h"
#include "df/reaction_product_itemst.h" #include "df/reaction_product_itemst.h"
#include "df/reaction_product_type.h" #include "df/reaction_product_type.h"
#include "df/region_map_entry.h" #include "df/region_map_entry.h"
@ -55,7 +47,6 @@
#include "df/world_region_details.h" #include "df/world_region_details.h"
#include "df/world_region_feature.h" #include "df/world_region_feature.h"
#include "df/world_region_type.h" #include "df/world_region_type.h"
#include "df/world_river.h"
#include "df/world_site.h" #include "df/world_site.h"
#include "df/world_site_type.h" #include "df/world_site_type.h"
#include "df/world_underground_region.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 embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data *geo_summary, void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data *geo_summary,
embark_assist::defs::world_tile_data *survey_results, embark_assist::defs::world_tile_data *survey_results,
embark_assist::defs::mid_level_tiles *mlt) { embark_assist::defs::mid_level_tiles *mlt) {
@ -909,13 +915,12 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); auto screen = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
int16_t x = screen->location.region_pos.x; int16_t x = screen->location.region_pos.x;
int16_t y = screen->location.region_pos.y; 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 max_soil_depth;
int8_t offset; int8_t offset;
int16_t elevation; int16_t elevation;
int16_t last_bottom; int16_t last_bottom;
int16_t top_z; 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 min_z = 0; // Initialized to silence warning about potential usage of uninitialized data.
int16_t bottom_z; int16_t bottom_z;
df::coord2d adjusted; df::coord2d adjusted;
@ -930,9 +935,9 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
bool aquifer; bool aquifer;
for (uint16_t i = 0; i < state->max_inorganic; i++) { for (uint16_t i = 0; i < state->max_inorganic; i++) {
tile->metals[i] = 0; tile.metals[i] = 0;
tile->economics[i] = 0; tile.economics[i] = 0;
tile->minerals[i] = 0; tile.minerals[i] = 0;
} }
for (uint8_t i = 0; i < 16; i++) { for (uint8_t i = 0; i < 16; i++) {
@ -943,10 +948,11 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
} }
} }
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 i = 0; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) { 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; max_soil_depth = -1;
offset = details->biome[i][k]; offset = details->biome[i][k];
@ -954,68 +960,68 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
if (adjusted.x != x || adjusted.y != y) if (adjusted.x != x || adjusted.y != y)
{ {
mlt->at(i).at(k).biome_offset = offset; mid_level_tile.biome_offset = offset;
} }
else 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] = tile.biome_index[mid_level_tile.biome_offset] = region_map_entry.region_id;
world_data->region_map[adjusted.x][adjusted.y].region_id;
mlt->at(i).at(k).savagery_level = world_data->region_map[adjusted.x][adjusted.y].savagery / 33; mid_level_tile.savagery_level = region_map_entry.savagery / 33;
if (mlt->at(i).at(k).savagery_level == 3) { if (mid_level_tile.savagery_level == 3) {
mlt->at(i).at(k).savagery_level = 2; mid_level_tile.savagery_level = 2;
} }
mlt->at(i).at(k).evilness_level = world_data->region_map[adjusted.x][adjusted.y].evilness / 33; mid_level_tile.evilness_level = region_map_entry.evilness / 33;
if (mlt->at(i).at(k).evilness_level == 3) { if (mid_level_tile.evilness_level == 3) {
mlt->at(i).at(k).evilness_level = 2; mid_level_tile.evilness_level = 2;
} }
elevation = details->elevation[i][k]; 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 // Special biome adjustments
if (!world_data->region_map[adjusted.x][adjusted.y].flags.is_set(region_map_entry_flags::is_lake)) { if (!region_map_entry.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.elevation >= 150) { // Mountain
max_soil_depth = 0; 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) { if (elevation == 99) {
elevation = 98; elevation = 98;
} }
if ((world_data->geo_biomes[world_data->region_map[x][y].geo_index]->unk1 == 4 || if ((world_geo_biome->unk1 == 4 ||
world_data->geo_biomes[world_data->region_map[x][y].geo_index]->unk1 == 5) && world_geo_biome->unk1 == 5) &&
details->unk12e8 < 500) { details->unk12e8 < 500) {
max_soil_depth = 0; max_soil_depth = 0;
} }
} }
} }
base_z = elevation - 1;
features = details->features[i][k]; features = details->features[i][k];
mlt->at(i).at(k).adamantine_level = -1; mid_level_tile.adamantine_level = -1;
mlt->at(i).at(k).magma_level = -1; mid_level_tile.magma_level = -1;
end_check_l = static_cast<uint16_t>(features.size()); end_check_l = static_cast<uint16_t>(features.size());
for (size_t l = 0; l < end_check_l; l++) { for (size_t l = 0; l < end_check_l; l++) {
auto feature = features[l]; auto feature = features[l];
if (feature->feature_idx != -1) { 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: 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; break;
case df::feature_type::magma_pool: 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; break;
case df::feature_type::volcano: case df::feature_type::volcano:
mlt->at(i).at(k).magma_level = 3; mid_level_tile.magma_level = 3;
break; break;
default: default:
@ -1026,8 +1032,6 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
feature->min_z != -30000) { feature->min_z != -30000) {
auto layer = world_data->underground_regions[feature->layer]; 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) { if (layer->type == df::world_underground_region::MagmaSea) {
min_z = feature->min_z; // The features are individual per region tile min_z = feature->min_z; // The features are individual per region tile
} }
@ -1040,56 +1044,57 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
max_soil_depth = std::max((154 - elevation) / 5, 1); 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 - auto geo_datum = geo_summary->at(region_map_entry.geo_index);
std::min((int)geo_summary->at(world_data->region_map[adjusted.x][adjusted.y].geo_index).soil_size, (int)max_soil_depth); soil_erosion = geo_datum.soil_size -
std::min((int)geo_datum.soil_size, (int)max_soil_depth);
int16_t layer_shift[16]; int16_t layer_shift[16];
int16_t cur_shift = elevation + soil_erosion - 1; int16_t cur_shift = elevation + soil_erosion - 1;
aquifer = false; aquifer = false;
mlt->at(i).at(k).aquifer = embark_assist::defs::Clear_Aquifer_Bits; mid_level_tile.aquifer = embark_assist::defs::Clear_Aquifer_Bits;
mlt->at(i).at(k).clay = false; mid_level_tile.clay = false;
mlt->at(i).at(k).sand = false; mid_level_tile.sand = false;
mlt->at(i).at(k).flux = false; mid_level_tile.flux = false;
mlt->at(i).at(k).coal = false; mid_level_tile.coal = false;
if (max_soil_depth == 0) { if (max_soil_depth == 0) {
mlt->at(i).at(k).soil_depth = 0; mid_level_tile.soil_depth = 0;
} }
else { 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; mid_level_tile.offset = offset;
mlt->at(i).at(k).elevation = details->elevation[i][k]; mid_level_tile.elevation = details->elevation[i][k];
mlt->at(i).at(k).river_size = embark_assist::defs::river_sizes::None; mid_level_tile.river_size = embark_assist::defs::river_sizes::None;
mlt->at(i).at(k).river_elevation = 100; mid_level_tile.river_elevation = 100;
if (details->rivers_vertical.active[i][k] != 0) { 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); mid_level_tile.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_elevation = details->rivers_vertical.elevation[i][k];
} }
else if (details->rivers_horizontal.active[i][k] != 0) { 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); mid_level_tile.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_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)) { 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) { if (tile.min_region_soil > mid_level_tile.soil_depth) {
tile->min_region_soil = mlt->at(i).at(k).soil_depth; tile.min_region_soil = mid_level_tile.soil_depth;
} }
if (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 = mlt->at(i).at(k).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; if (end_check_l > 16) end_check_l = 16;
for (uint16_t l = 0; l < end_check_l; l++) { 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; layer_shift[l] = cur_shift;
if (layer->type == df::geo_layer_type::SOIL || if (layer->type == df::geo_layer_type::SOIL ||
@ -1113,7 +1118,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. // 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++) { 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; top_z = last_bottom - 1;
bottom_z = std::max((int)layer->bottom_height + layer_shift[l], (int)min_z); bottom_z = std::max((int)layer->bottom_height + layer_shift[l], (int)min_z);
@ -1124,38 +1129,38 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
if (top_z >= bottom_z) { if (top_z >= bottom_z) {
last_bottom = 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++) { 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 || if (layer->type == df::geo_layer_type::SOIL ||
layer->type == df::geo_layer_type::SOIL_SAND) { layer->type == df::geo_layer_type::SOIL_SAND) {
if (world->raws.inorganics[layer->mat_index]->flags.is_set(df::inorganic_flags::SOIL_SAND)) { if (inorganic_layer->flags.is_set(df::inorganic_flags::SOIL_SAND)) {
mlt->at(i).at(k).sand = true; mid_level_tile.sand = true;
} }
} }
if (world->raws.inorganics[layer->mat_index]->economic_uses.size() > 0) { if (inorganic_layer->economic_uses.size() > 0) {
mlt->at(i).at(k).economics[layer->mat_index] = true; 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++) { for (uint16_t m = 0; m < end_check_m; m++) {
if (world->raws.inorganics[layer->mat_index]->economic_uses[m] == state->clay_reaction) { if (inorganic_layer->economic_uses[m] == state->clay_reaction) {
mlt->at(i).at(k).clay = true; mid_level_tile.clay = true;
} }
else if (inorganic_layer->economic_uses[m] == state->flux_reaction) {
else if (world->raws.inorganics[layer->mat_index]->economic_uses[m] == state->flux_reaction) { mid_level_tile.flux = true;
mlt->at(i).at(k).flux = true;
} }
} }
for (uint16_t m = 0; m < state->coals.size(); m++) { for (uint16_t m = 0; m < state->coals.size(); m++) {
if (layer->mat_index == state->coals[m]) { if (layer->mat_index == state->coals[m]) {
mlt->at(i).at(k).coal = true; mid_level_tile.coal = true;
break; break;
} }
} }
@ -1164,31 +1169,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()); end_check_m = static_cast<uint16_t>(layer->vein_mat.size());
for (uint16_t m = 0; m < end_check_m; m++) { 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++) { 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) { if (inorganic_vein->economic_uses.size() > 0) {
mlt->at(i).at(k).economics[layer->vein_mat[m]] = true; 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++) { for (uint16_t n = 0; n < end_check_n; n++) {
if (world->raws.inorganics[layer->vein_mat[m]]->economic_uses[n] == state->clay_reaction) { if (inorganic_vein->economic_uses[n] == state->clay_reaction) {
mlt->at(i).at(k).clay = true; mid_level_tile.clay = true;
} }
else if (world->raws.inorganics[layer->vein_mat[m]]->economic_uses[n] == state->flux_reaction) { else if (inorganic_vein->economic_uses[n] == state->flux_reaction) {
mlt->at(i).at(k).flux = true; mid_level_tile.flux = true;
} }
} }
for (uint16_t n = 0; n < state->coals.size(); n++) { for (uint16_t n = 0; n < state->coals.size(); n++) {
if (layer->vein_mat[m] == state->coals[n]) { if (vein_mat_index == state->coals[n]) {
mlt->at(i).at(k).coal = true; mid_level_tile.coal = true;
break; break;
} }
} }
@ -1196,23 +1203,23 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
} }
if (bottom_z <= elevation - 3 && 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; aquifer = true;
} }
} }
} }
if (!aquifer) { 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) { else if (region_map_entry.drainage % 20 == 7) {
mlt->at(i).at(k).aquifer = embark_assist::defs::Heavy_Aquifer_Bit; mid_level_tile.aquifer = embark_assist::defs::Heavy_Aquifer_Bit;
} }
else { 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, mid_level_tile.trees = tree_level_of(world_data->regions[region_map_entry.region_id]->type,
world_data->region_map[adjusted.x][adjusted.y].vegetation); region_map_entry.vegetation);
} }
} }
@ -1228,14 +1235,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 i = 1; i < 16; i++) {
for (uint8_t k = 0; k < 15; k++) { 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 && if (details->rivers_horizontal.active[i][k] != 0 &&
details->rivers_vertical.active[i - 1][k + 1] != 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 western_neighbour.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; western_neighbour.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_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) { if (western_neighbour.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; western_neighbour.river_elevation = mlt->at(i - 1).at(k + 1).river_elevation;
} }
} }
} }
@ -1243,78 +1251,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 i = 0; i < 16; i++) {
for (uint8_t k = 1; k < 16; k++) { 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 && if (details->rivers_vertical.active[i][k] != 0 &&
mlt->at(i).at(k - 1).river_size == embark_assist::defs::river_sizes::None) { northern_neighbour.river_size == embark_assist::defs::river_sizes::None) {
mlt->at(i).at(k - 1).river_size = mlt->at(i).at(k).river_size; northern_neighbour.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_elevation = mlt->at(i).at(k).river_elevation;
} }
} }
} }
for (uint8_t i = 1; i < 16; i++) { for (uint8_t i = 1; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) { 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 && if (details->rivers_horizontal.active[i][k] != 0 &&
mlt->at(i - 1).at(k).river_size == embark_assist::defs::river_sizes::None) { western_neighbour.river_size == embark_assist::defs::river_sizes::None) {
mlt->at(i - 1).at(k).river_size = mlt->at(i).at(k).river_size; western_neighbour.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_elevation = mlt->at(i).at(k).river_elevation;
} }
} }
} }
survey_results->at(x).at(y).aquifer = embark_assist::defs::Clear_Aquifer_Bits; tile.aquifer = embark_assist::defs::Clear_Aquifer_Bits;
survey_results->at(x).at(y).clay_count = 0; tile.clay_count = 0;
survey_results->at(x).at(y).sand_count = 0; tile.sand_count = 0;
survey_results->at(x).at(y).flux_count = 0; tile.flux_count = 0;
survey_results->at(x).at(y).coal_count = 0; tile.coal_count = 0;
survey_results->at(x).at(y).min_region_soil = 10; tile.min_region_soil = 10;
survey_results->at(x).at(y).max_region_soil = 0; tile.max_region_soil = 0;
survey_results->at(x).at(y).savagery_count[0] = 0; tile.savagery_count[0] = 0;
survey_results->at(x).at(y).savagery_count[1] = 0; tile.savagery_count[1] = 0;
survey_results->at(x).at(y).savagery_count[2] = 0; tile.savagery_count[2] = 0;
survey_results->at(x).at(y).evilness_count[0] = 0; tile.evilness_count[0] = 0;
survey_results->at(x).at(y).evilness_count[1] = 0; tile.evilness_count[1] = 0;
survey_results->at(x).at(y).evilness_count[2] = 0; tile.evilness_count[2] = 0;
for (uint8_t i = 0; i < 16; i++) { for (uint8_t i = 0; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) { for (uint8_t k = 0; k < 16; k++) {
survey_results->at(x).at(y).aquifer |= mlt->at(i).at(k).aquifer; const embark_assist::defs::mid_level_tile &mid_level_tile = mlt->at(i).at(k);
if (mlt->at(i).at(k).clay) { survey_results->at(x).at(y).clay_count++; } tile.aquifer |= mid_level_tile.aquifer;
if (mlt->at(i).at(k).sand) { survey_results->at(x).at(y).sand_count++; } if (mid_level_tile.clay) { tile.clay_count++; }
if (mlt->at(i).at(k).flux) { survey_results->at(x).at(y).flux_count++; } if (mid_level_tile.sand) { tile.sand_count++; }
if (mlt->at(i).at(k).coal) { survey_results->at(x).at(y).coal_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) { if (mid_level_tile.soil_depth < tile.min_region_soil) {
survey_results->at(x).at(y).min_region_soil = mlt->at(i).at(k).soil_depth; 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) { if (mid_level_tile.soil_depth > tile.max_region_soil) {
survey_results->at(x).at(y).max_region_soil = mlt->at(i).at(k).soil_depth; tile.max_region_soil = mid_level_tile.soil_depth;
} }
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) {
if (survey_results->at(x).at(y).min_river_size == embark_assist::defs::river_sizes::None || if (tile.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) { mid_level_tile.river_size < tile.min_river_size) {
survey_results->at(x).at(y).min_river_size = mlt->at(i).at(k).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) { if (tile.max_river_size < mid_level_tile.river_size) {
survey_results->at(x).at(y).max_river_size = mlt->at(i).at(k).river_size; tile.max_river_size = mid_level_tile.river_size;
} }
if (i < 15 && if (i < 15) {
mlt->at(i + 1).at(k).river_size != embark_assist::defs::river_sizes::None && const embark_assist::defs::mid_level_tile &eastern_neighbour = mlt->at(i + 1).at(k);
abs (mlt->at(i).at(k).river_elevation - mlt->at(i + 1).at(k).river_elevation) > if (eastern_neighbour.river_size != embark_assist::defs::river_sizes::None &&
survey_results->at(x).at(y).max_waterfall) { abs(mid_level_tile.river_elevation - eastern_neighbour.river_elevation) > tile.max_waterfall) {
survey_results->at(x).at(y).max_waterfall = tile.max_waterfall = abs(mid_level_tile.river_elevation - eastern_neighbour.river_elevation);
abs(mlt->at(i).at(k).river_elevation - mlt->at(i + 1).at(k).river_elevation); }
} }
if (k < 15 && if (k < 15) {
mlt->at(i).at(k + 1).river_size != embark_assist::defs::river_sizes::None && const embark_assist::defs::mid_level_tile &southern_neighbour = mlt->at(i).at(k + 1);
abs(mlt->at(i).at(k).river_elevation - mlt->at(i).at(k + 1).river_elevation) > if (southern_neighbour.river_size != embark_assist::defs::river_sizes::None &&
survey_results->at(x).at(y).max_waterfall) { abs(mid_level_tile.river_elevation - southern_neighbour.river_elevation) > tile.max_waterfall) {
survey_results->at(x).at(y).max_waterfall = tile.max_waterfall = abs(mid_level_tile.river_elevation - southern_neighbour.river_elevation);
abs(mlt->at(i).at(k).river_elevation - mlt->at(i).at(k + 1).river_elevation); }
} }
} }
@ -1324,23 +1335,23 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
// reanimating handled separately // reanimating handled separately
// thralling 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 (tile.min_tree_level > mid_level_tile.trees) tile.min_tree_level = mid_level_tile.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.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]++; tile.savagery_count[mid_level_tile.savagery_level]++;
survey_results->at(x).at(y).evilness_count[mlt->at(i).at(k).evilness_level]++; tile.evilness_count[mid_level_tile.evilness_level]++;
for (uint16_t l = 0; l < state->max_inorganic; l++) { 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 (mid_level_tile.metals[l]) { tile.metals[l] = true; }
if (mlt->at(i).at(k).economics[l]) { survey_results->at(x).at(y).economics[l] = true; } if (mid_level_tile.economics[l]) { tile.economics[l] = true; }
if (mlt->at(i).at(k).minerals[l]) { survey_results->at(x).at(y).minerals[l] = true; } if (mid_level_tile.minerals[l]) { tile.minerals[l] = true; }
} }
} }
} }
for (uint8_t i = 1; i < 10; i++) { for (uint8_t i = 1; i < 10; i++) {
if (survey_results->at(x).at(y).biome_index[i] == -1) { if (tile.biome_index[i] == -1) {
survey_results->at(x).at(y).biome[i] = -1; tile.biome[i] = -1;
} }
} }
@ -1351,8 +1362,8 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
for (uint8_t i = 1; i < 10; i++) for (uint8_t i = 1; i < 10; i++)
{ {
if (survey_results->at(x).at(y).biome[i] != -1) { if (tile.biome[i] != -1) {
biomes[survey_results->at(x).at(y).biome[i]] = true; biomes[tile.biome[i]] = true;
} }
} }
int count = 0; int count = 0;
@ -1360,83 +1371,43 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data
if (biomes[i]) count++; if (biomes[i]) count++;
} }
tile->biome_count = count; tile.biome_count = count;
for (uint8_t i = 0; i < 16; i++) { for (uint8_t i = 0; i < 16; i++) {
tile->north_row[i].aquifer = mlt->at(i).at(0).aquifer; copy_incursion_values(tile.north_row[i], mlt->at(i).at(0));
tile->south_row[i].aquifer = mlt->at(i).at(15).aquifer; copy_incursion_values(tile.south_row[i], mlt->at(i).at(15));
tile->west_column[i].aquifer = mlt->at(0).at(i).aquifer; copy_incursion_values(tile.west_column[i], mlt->at(0).at(i));
tile->east_column[i].aquifer = mlt->at(15).at(i).aquifer; copy_incursion_values(tile.east_column[i], mlt->at(15).at(i));
tile->north_row[i].clay= mlt->at(i).at(0).clay; tile.north_corner_selection[i] = world_data->region_details[0]->edges.biome_corner[i][0];
tile->south_row[i].clay = mlt->at(i).at(15).clay; tile.west_corner_selection[i] = world_data->region_details[0]->edges.biome_corner[0][i];
tile->west_column[i].clay = mlt->at(0).at(i).clay; tile.north_row_biome_x[i] = world_data->region_details[0]->edges.biome_x[i][0];
tile->east_column[i].clay = mlt->at(15).at(i).clay; tile.west_column_biome_y[i] = world_data->region_details[0]->edges.biome_y[0][i];
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];
} }
for (uint8_t i = 0; i < 16; i++) { for (uint8_t i = 0; i < 16; i++) {
for (uint8_t k = 0; k < 16; k++) { 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 // 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++) { for (uint16_t i = 0; i < world->entities.all.size(); i++) {
if (world->entities.all[i]->flags.bits.neighbor) { if (world->entities.all[i]->flags.bits.neighbor) {
if (world->entities.all[i]->type == df::historical_entity_type::SiteGovernment) { if (world->entities.all[i]->type == df::historical_entity_type::SiteGovernment) {
tile->necro_neighbors++; tile.necro_neighbors++;
} }
else 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;
} }
//================================================================================= //=================================================================================

@ -426,29 +426,38 @@ static command_result orders_import_command(color_ostream & out, const std::stri
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
} }
const std::string filename("dfhack-config/orders/" + name + ".json");
Json::Value orders; Json::Value orders;
{ {
std::ifstream file("dfhack-config/orders/" + name + ".json"); std::ifstream file(filename);
if (!file.good()) if (!file.good())
{ {
out << COLOR_LIGHTRED << "Cannot find orders file." << std::endl; out << COLOR_LIGHTRED << "Cannot find orders file: " << filename << std::endl;
return CR_FAILURE; return CR_FAILURE;
} }
file >> orders; try
{
file >> orders;
}
catch (const std::exception & e)
{
out << COLOR_LIGHTRED << "Error reading orders file: " << filename << ": " << e.what() << std::endl;
return CR_FAILURE;
}
if (!file.good()) if (!file.good())
{ {
out << COLOR_LIGHTRED << "Error reading orders file." << std::endl; out << COLOR_LIGHTRED << "Error reading orders file: " << filename << std::endl;
return CR_FAILURE; return CR_FAILURE;
} }
} }
if (orders.type() != Json::arrayValue) if (orders.type() != Json::arrayValue)
{ {
out << COLOR_LIGHTRED << "Invalid orders file: expected array" << std::endl; out << COLOR_LIGHTRED << "Invalid orders file: " << filename << ": expected array" << std::endl;
return CR_FAILURE; return CR_FAILURE;
} }

@ -80,15 +80,15 @@ public:
if (found) { if (found) {
// Entice the bookkeeper to spend less time update records. // Entice the bookkeeper to spend less time update records.
ui->bookkeeper_precision += ui->bookkeeper_precision >> 3; ui->nobles.bookkeeper_precision += ui->nobles.bookkeeper_precision >> 3;
if (!bookkeeping) { if (!bookkeeping) {
command_method("start_bookkeeping", out); command_method("start_bookkeeping", out);
bookkeeping = true; bookkeeping = true;
} }
} else { } else {
// Entice the bookkeeper to update records more often. // Entice the bookkeeper to update records more often.
ui->bookkeeper_precision -= ui->bookkeeper_precision >> 5; ui->nobles.bookkeeper_precision -= ui->nobles.bookkeeper_precision >> 5;
ui->bookkeeper_cooldown -= ui->bookkeeper_cooldown >> 2; ui->nobles.bookkeeper_cooldown -= ui->nobles.bookkeeper_cooldown >> 2;
if (bookkeeping) { if (bookkeeping) {
command_method("finish_bookkeeping", out); command_method("finish_bookkeeping", out);
bookkeeping = false; bookkeeping = false;

@ -1 +1 @@
Subproject commit 86788f5bf975da2506c61372ebfbe36ca47ed57c Subproject commit 3cb5415e0044c80297bfbbae0722e22c86f72d33