From c859076a3fd663f8ff004dd78d212eaed20a16a4 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Fri, 7 Feb 2020 20:49:56 +0100 Subject: [PATCH 1/4] Adjusted to int-> enum defs, fixed bug --- plugins/embark-assistant/survey.cpp | 54 ++++++++++++++++++----------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/plugins/embark-assistant/survey.cpp b/plugins/embark-assistant/survey.cpp index a2fb648f2..94e4bd832 100644 --- a/plugins/embark-assistant/survey.cpp +++ b/plugins/embark-assistant/survey.cpp @@ -1909,12 +1909,12 @@ uint8_t embark_assist::survey::translate_ew_edge(embark_assist::defs::world_tile df::world_region_type east_region_type; if (own_edge) { - effective_edge = world_data->region_details[0]->edges.biome_x[i][k]; + effective_edge = world_data->region_details[0]->edges.biome_y[i][k]; east_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i, k); west_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i - 1, k); } else { - effective_edge = world_data->region_details[0]->edges.biome_x[i + 1][k]; + effective_edge = world_data->region_details[0]->edges.biome_y[i + 1][k]; west_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i, k); east_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i + 1, k); } @@ -1995,14 +1995,18 @@ void embark_assist::survey::survey_region_sites(embark_assist::defs::site_lists break; case df::world_site_type::Monument: - if (site->subtype_info->lair_type != -1 || - site->subtype_info->is_monument == 0) { // Not Tomb, which is visible already - } - else if (site->subtype_info->lair_type == -1) { - site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'V' }); // Vault - } - else { + switch (site->subtype_info->monument_type) { + case df::monument_type::NONE: + case df::monument_type::TOMB: + break; // NONE shouldn't appear, and Tombs are visible already + + case df::monument_type::VAULT: + site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'V' }); + break; + + default: site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'M' }); // Any other Monument type. Pyramid? + break; } break; @@ -2011,19 +2015,27 @@ void embark_assist::survey::survey_region_sites(embark_assist::defs::site_lists break; case df::world_site_type::LairShrine: - if (site->subtype_info->lair_type == 0 || - site->subtype_info->lair_type == 1 || - site->subtype_info->lair_type == 4) { // Only Rocs seen. Mountain lair? - site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'l' }); // Lair - } - else if (site->subtype_info->lair_type == 2) { - site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'L' }); // Labyrinth - } - else if (site->subtype_info->lair_type == 3) { - site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'S' }); // Shrine - } - else { + switch (site->subtype_info->lair_type) { + case df::lair_type::NONE: + break; + + case df::lair_type::SIMPLE_MOUND: + case df::lair_type::SIMPLE_BURROW: + case df::lair_type::WILDERNESS_LOCATION: + site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'l' }); + break; + + case df::lair_type::LABYRINTH: + site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'L' }); + break; + + case df::lair_type::SHRINE: + site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, 'S' }); + break; + + default: site_list->push_back({ (uint8_t)site->rgn_min_x , (uint8_t)site->rgn_min_y, '?' }); // Can these exist? + break; } break; From 31d984e9348f23287f89b50ec661bdb542400f4d Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Tue, 5 May 2020 10:21:56 +0200 Subject: [PATCH 2/4] Fixed 2 incursion handling bugs --- docs/changelog.txt | 1 + plugins/embark-assistant/survey.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 1aa7f916e..5b83825e1 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -42,6 +42,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes - Fixed a segfault when attempting to start a headless session with a graphical PRINT_MODE setting - `labormanager`: fixed handling of new jobs in 0.47 +- `embark-assistant`: fixed a couple of incursion handling bugs. ## Ruby - Updated ``item_find`` and ``building_find`` to use centralized logic that works on more screens diff --git a/plugins/embark-assistant/survey.cpp b/plugins/embark-assistant/survey.cpp index 79c66e4df..20dd9d539 100644 --- a/plugins/embark-assistant/survey.cpp +++ b/plugins/embark-assistant/survey.cpp @@ -2424,7 +2424,7 @@ void embark_assist::survey::survey_embark(embark_assist::defs::mid_level_tiles * } else { process_embark_incursion_mid_level_tile - (translate_ns_edge(survey_results, + (translate_ew_edge(survey_results, true, x, y, @@ -2481,7 +2481,7 @@ void embark_assist::survey::survey_embark(embark_assist::defs::mid_level_tiles * } else { process_embark_incursion_mid_level_tile - (translate_ns_edge(survey_results, + (translate_ew_edge(survey_results, false, x, y, From 4a48c356a9b5c2a283a5ba19d068a488ae94861a Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Tue, 2 Jun 2020 15:58:46 +0200 Subject: [PATCH 3/4] fixed bug with incursion handling along world tile edges --- plugins/embark-assistant/defs.h | 2 ++ plugins/embark-assistant/survey.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/plugins/embark-assistant/defs.h b/plugins/embark-assistant/defs.h index 29c5a063c..13494b91e 100644 --- a/plugins/embark-assistant/defs.h +++ b/plugins/embark-assistant/defs.h @@ -119,6 +119,8 @@ namespace embark_assist { df::world_region_type region_type[16][16]; // Required for incursion override detection. We could store only the // edges, but storing it for every tile allows for a unified fetching // logic. + int8_t north_row_biome_x[16]; // "biome_x" data cached for the northern row for access from the north. + int8_t west_column_biome_y[16]; // "biome_y" data cached for the western row for access from the west. }; struct geo_datum { diff --git a/plugins/embark-assistant/survey.cpp b/plugins/embark-assistant/survey.cpp index 20dd9d539..01ed9ba31 100644 --- a/plugins/embark-assistant/survey.cpp +++ b/plugins/embark-assistant/survey.cpp @@ -1470,6 +1470,8 @@ void embark_assist::survey::survey_mid_level_tile(embark_assist::defs::geo_data 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++) { @@ -1919,7 +1921,17 @@ uint8_t embark_assist::survey::translate_ns_edge(embark_assist::defs::world_tile north_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i, k - 1); } else { - effective_edge = world_data->region_details[0]->edges.biome_x[i][k + 1]; + if (k < 15) { // We're still within the same world tile + effective_edge = world_data->region_details[0]->edges.biome_x[i][k + 1]; + } + else { // Getting the data from the world tile to the south + if (y + 1 == world_data->world_height) { + return 4; // There's nothing to the south, so we fall back on our own tile. + } + + effective_edge = survey_results->at(x).at(y + 1).north_row_biome_x[i]; + } + north_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i, k); south_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i, k + 1); } @@ -1993,7 +2005,16 @@ uint8_t embark_assist::survey::translate_ew_edge(embark_assist::defs::world_tile west_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i - 1, k); } else { - effective_edge = world_data->region_details[0]->edges.biome_y[i + 1][k]; + if (i < 15) { // We're still within the same world tile + effective_edge = world_data->region_details[0]->edges.biome_y[i + 1][k]; + } + else { // Getting the data from the world tile to the east + if (x + 1 == world_data->world_width) { + return 4; // There's nothing to the east, so we fall back on our own tile. + } + + effective_edge = survey_results->at(x + 1).at(y).west_column_biome_y[k]; + } west_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i, k); east_region_type = embark_assist::survey::region_type_of(survey_results, x, y, i + 1, k); } From d5a491e85238931786e737c82854d0bc53bc8f6a Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sun, 7 Jun 2020 08:38:12 +0200 Subject: [PATCH 4/4] fixed parameter bugs --- plugins/embark-assistant/survey.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/embark-assistant/survey.cpp b/plugins/embark-assistant/survey.cpp index 01ed9ba31..2d5dca04d 100644 --- a/plugins/embark-assistant/survey.cpp +++ b/plugins/embark-assistant/survey.cpp @@ -1603,7 +1603,7 @@ df::world_region_type embark_assist::survey::region_type_of(embark_assist::defs: int16_t effective_y = y; int8_t effective_i = i; int8_t effective_k = k; - adjust_coordinates(&effective_x, &effective_y, &effective_i, &effective_i); + adjust_coordinates(&effective_x, &effective_y, &effective_i, &effective_k); if (effective_x < 0 || effective_x >= world_data->world_width || @@ -1659,7 +1659,7 @@ uint8_t embark_assist::survey::translate_corner(embark_assist::defs::world_tile effective_k = k + 1; } - adjust_coordinates(&effective_x, &effective_y, &effective_i, &effective_i); + adjust_coordinates(&effective_x, &effective_y, &effective_i, &effective_k); if (effective_x == world_data->world_width) { if (effective_y == world_data->world_height) { // Only the SE corner of the SE most tile of the world can reference this.