Skip to content

Commit

Permalink
Merge remote-tracking branch 'PatrikLundell/embark-assistant' into de…
Browse files Browse the repository at this point in the history
…velop

Also move changelog entries to misc improvements per DFHack#1383
  • Loading branch information
lethosor committed Dec 27, 2018
2 parents 58fd98c + ef57295 commit 3e2c898
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 55 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:

## Misc Improvements
- `devel/export-dt-ini`: added viewscreen offsets for DT 40.1.2
- `embark-assistant`:
- added match indicator display on the right ("World") map
- changed 'c'ancel to abort find if it's under way and clear results if not, allowing use of partial surveys.
- added Coal as a search criterion, as well as a coal indication as current embark selection info.
- `labormanager`: now takes nature value into account when assigning jobs

## Internals
Expand Down
5 changes: 5 additions & 0 deletions plugins/embark-assistant/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace embark_assist {
bool clay = false;
bool sand = false;
bool flux = false;
bool coal = false;
int8_t soil_depth;
int8_t offset;
int16_t elevation;
Expand All @@ -51,6 +52,7 @@ namespace embark_assist {
uint16_t clay_count = 0;
uint16_t sand_count = 0;
uint16_t flux_count = 0;
uint16_t coal_count = 0;
uint8_t min_region_soil = 10;
uint8_t max_region_soil = 0;
bool waterfall = false;
Expand Down Expand Up @@ -90,6 +92,7 @@ namespace embark_assist {
bool clay_absent = true;
bool sand_absent = true;
bool flux_absent = true;
bool coal_absent = true;
std::vector<bool> possible_metals;
std::vector<bool> possible_economics;
std::vector<bool> possible_minerals;
Expand All @@ -113,6 +116,7 @@ namespace embark_assist {
bool clay;
bool sand;
bool flux;
bool coal;
std::vector<uint16_t> metals;
std::vector<uint16_t> economics;
std::vector<uint16_t> minerals;
Expand Down Expand Up @@ -253,6 +257,7 @@ namespace embark_assist {
present_absent_ranges clay;
present_absent_ranges sand;
present_absent_ranges flux;
present_absent_ranges coal;
soil_ranges soil_min;
all_present_ranges soil_min_everywhere;
soil_ranges soil_max;
Expand Down
2 changes: 1 addition & 1 deletion plugins/embark-assistant/embark-assistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" the embark rectangle as well as normally undisplayed sites in the\n"
" current embark region. It also has a site selection tool with more\n"
" options than DF's vanilla search tool. For detailed help invoke the\n"
" in game info screen. Requires 46 lines to display properly.\n"
" in game info screen. Prefers 46 lines to display properly.\n"
));
return CR_OK;
}
Expand Down
11 changes: 11 additions & 0 deletions plugins/embark-assistant/finder_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace embark_assist {
clay,
sand,
flux,
coal,
soil_min,
soil_min_everywhere,
soil_max,
Expand Down Expand Up @@ -508,6 +509,7 @@ namespace embark_assist {
case fields::clay:
case fields::sand:
case fields::flux:
case fields::coal:
{
embark_assist::defs::present_absent_ranges k = embark_assist::defs::present_absent_ranges::NA;
while (true) {
Expand Down Expand Up @@ -993,6 +995,10 @@ namespace embark_assist {
state->finder_list.push_back({ "Flux", static_cast<int8_t>(i) });
break;

case fields::coal:
state->finder_list.push_back({ "Coal", static_cast<int8_t>(i) });
break;

case fields::soil_min:
state->finder_list.push_back({ "Min Soil", static_cast<int8_t>(i) });
break;
Expand Down Expand Up @@ -1228,6 +1234,11 @@ namespace embark_assist {
static_cast<embark_assist::defs::present_absent_ranges>(state->ui[static_cast<uint8_t>(i)]->current_value);
break;

case fields::coal:
finder.coal =
static_cast<embark_assist::defs::present_absent_ranges>(state->ui[static_cast<uint8_t>(i)]->current_value);
break;

case fields::soil_min:
finder.soil_min =
static_cast<embark_assist::defs::soil_ranges>(state->ui[static_cast<uint8_t>(i)]->current_value);
Expand Down
15 changes: 7 additions & 8 deletions plugins/embark-assistant/help_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ namespace embark_assist{
help_text.push_back("Main screen control keys used by the Embark Assistant:");
help_text.push_back("i: Info/Help. Brings up this display.");
help_text.push_back("f: Brings up the Find Embark screen. See the Find page for more information.");
help_text.push_back("c: Clears the results of a Find operation, and also cancels an operation if");
help_text.push_back(" one is under way.");
help_text.push_back("c: Clears the results of a Find operation, or cancels an operation if one is");
help_text.push_back(" under way (at which time a second 'c' clears it).");
help_text.push_back("q: Quits the Embark Assistant and brings you back to the vanilla DF interface.");
help_text.push_back(" It can be noted that the Embark Assistant automatically cancels itself");
help_text.push_back(" when DF leaves the embark screen either through <ESC>Abort Game or by");
Expand Down Expand Up @@ -171,8 +171,8 @@ namespace embark_assist{
help_text.push_back("A list of all economic minerals present in the embark. Both clays and flux");
help_text.push_back("stones are economic, so they show up here as well.");
help_text.push_back("In addition to the above, the Find functionality can also produce blinking");
help_text.push_back("overlays over the region map and the middle world map to indicate where");
help_text.push_back("matching embarks are found. The region display marks the top left corner of");
help_text.push_back("overlays over the Local, Region, and World maps to indicate where");
help_text.push_back("matching embarks are found. The Local display marks the top left corner of");
help_text.push_back("a matching embark rectangle as a matching tile.");

break;
Expand Down Expand Up @@ -257,14 +257,13 @@ namespace embark_assist{
help_text.push_back("- The geo information is gathered by code which is essentially a");
help_text.push_back(" copy of parts of prospector's code adapted for this plugin.");
help_text.push_back("- Clay determination is made by finding the reaction MAKE_CLAY_BRICKS.");
help_text.push_back(" Flux determination is made by finding the reaction PIG_IRON_MAKING.");
help_text.push_back("- Right world map overlay not implemented as author has failed to");
help_text.push_back(" emulate the sizing logic exactly.");
help_text.push_back("- Flux determination is made by finding the reaction PIG_IRON_MAKING.");
help_text.push_back("- Coal is detected by finding COAL producing reactions on minerals.");
help_text.push_back("- There's currently a DF bug (#0010267) that causes adamantine spires");
help_text.push_back(" reaching caverns that have been removed at world gen to fail to be");
help_text.push_back(" generated at all. It's likely this bug also affects magma pools.");
help_text.push_back(" This plugin does not address this but scripts can correct it.");
help_text.push_back("Version 0.5 2018-07-13");
help_text.push_back("Version 0.8 2018-12-04");

break;
}
Expand Down
48 changes: 46 additions & 2 deletions plugins/embark-assistant/matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace embark_assist {
bool clay_found = false;
bool sand_found = false;
bool flux_found = false;
bool coal_found = false;
uint8_t max_soil = 0;
bool uneven = false;
int16_t min_temperature = survey_results->at(x).at(y).min_temperature[mlt->at(start_x).at(start_y).biome_offset];
Expand Down Expand Up @@ -174,6 +175,12 @@ namespace embark_assist {
flux_found = true;
}

// Coal
if (mlt->at(i).at(k).coal) {
if (finder->coal == embark_assist::defs::present_absent_ranges::Absent) return false;
coal_found = true;
}

// Min Soil
if (finder->soil_min != embark_assist::defs::soil_ranges::NA &&
mlt->at(i).at(k).soil_depth < static_cast<uint16_t>(finder->soil_min) &&
Expand Down Expand Up @@ -335,6 +342,9 @@ namespace embark_assist {
// Flux
if (finder->flux == embark_assist::defs::present_absent_ranges::Present && !flux_found) return false;

// Coal
if (finder->coal == embark_assist::defs::present_absent_ranges::Present && !coal_found) return false;

// Min Soil
if (finder->soil_min != embark_assist::defs::soil_ranges::NA &&
finder->soil_min_everywhere == embark_assist::defs::all_present_ranges::Present &&
Expand Down Expand Up @@ -571,6 +581,7 @@ namespace embark_assist {
case embark_assist::defs::present_absent_ranges::Present:
if (tile->clay_count == 0) return false;
break;

case embark_assist::defs::present_absent_ranges::Absent:
if (tile->clay_count > 256 - embark_size) return false;
break;
Expand All @@ -584,6 +595,7 @@ namespace embark_assist {
case embark_assist::defs::present_absent_ranges::Present:
if (tile->sand_count == 0) return false;
break;

case embark_assist::defs::present_absent_ranges::Absent:
if (tile->sand_count > 256 - embark_size) return false;
break;
Expand All @@ -597,11 +609,26 @@ namespace embark_assist {
case embark_assist::defs::present_absent_ranges::Present:
if (tile->flux_count == 0) return false;
break;

case embark_assist::defs::present_absent_ranges::Absent:
if (tile->flux_count > 256 - embark_size) return false;
break;
}

// Coal
switch (finder->coal) {
case embark_assist::defs::present_absent_ranges::NA:
break; // No restriction

case embark_assist::defs::present_absent_ranges::Present:
if (tile->coal_count == 0) return false;
break;

case embark_assist::defs::present_absent_ranges::Absent:
if (tile->coal_count > 256 - embark_size) return false;
break;
}

// Soil Min
switch (finder->soil_min) {
case embark_assist::defs::soil_ranges::NA:
Expand Down Expand Up @@ -1027,6 +1054,7 @@ namespace embark_assist {
case embark_assist::defs::present_absent_ranges::Present:
if (tile->clay_count == 0) return false;
break;

case embark_assist::defs::present_absent_ranges::Absent:
if (tile->clay_count == 256) return false;
break;
Expand All @@ -1040,6 +1068,7 @@ namespace embark_assist {
case embark_assist::defs::present_absent_ranges::Present:
if (tile->sand_count == 0) return false;
break;

case embark_assist::defs::present_absent_ranges::Absent:
if (tile->sand_count == 256) return false;
break;
Expand All @@ -1053,11 +1082,26 @@ namespace embark_assist {
case embark_assist::defs::present_absent_ranges::Present:
if (tile->flux_count == 0) return false;
break;

case embark_assist::defs::present_absent_ranges::Absent:
if (tile->flux_count == 256) return false;
break;
}

// Coal
switch (finder->coal) {
case embark_assist::defs::present_absent_ranges::NA:
break; // No restriction

case embark_assist::defs::present_absent_ranges::Present:
if (tile->coal_count == 0) return false;
break;

case embark_assist::defs::present_absent_ranges::Absent:
if (tile->coal_count == 256) return false;
break;
}

// Soil Min
switch (finder->soil_min) {
case embark_assist::defs::soil_ranges::NA:
Expand Down Expand Up @@ -1518,11 +1562,11 @@ uint16_t embark_assist::matcher::find(embark_assist::defs::match_iterators *iter
preliminary_matches = preliminary_world_match(survey_results, &iterator->finder, match_results);

if (preliminary_matches == 0) {
out.printerr("matcher::find: Preliminarily matching world tiles: %i\n", preliminary_matches);
out.printerr("matcher::find: Preliminarily matching World Tiles: %i\n", preliminary_matches);
return 0;
}
else {
out.print("matcher::find: Preliminarily matching world tiles: %i\n", preliminary_matches);
out.print("matcher::find: Preliminarily matching World Tiles: %i\n", preliminary_matches);
}

while (screen->location.region_pos.x != 0 || screen->location.region_pos.y != 0) {
Expand Down
Loading

0 comments on commit 3e2c898

Please sign in to comment.