Merge remote-tracking branch 'lethosor/fix-k-search-crash' into develop

develop
lethosor 2021-01-29 20:08:08 -05:00
commit 845993ba59
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 13 additions and 7 deletions

@ -37,6 +37,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `embark-assistant`: fixed order of factors when calculating min temperature
- `embark-assistant`: improved performance of surveying
- `quickfort`: creating zones no longer causes eventual crashes
- `search`: fixed crash when searching the ``k`` sidebar and navigating to another tile with certain keys, like ``<`` or ``>``
## Misc Improvements
- `buildingplan`: set global settings from the ``DFHack#`` prompt: e.g. ``buildingplan set boulders false``

@ -115,7 +115,9 @@ static string get_unit_description(df::unit *unit)
return desc;
}
static bool cursor_key_pressed (std::set<df::interface_key> *input)
static bool cursor_key_pressed (std::set<df::interface_key> *input, bool in_entry_mode)
{
if (in_entry_mode)
{
// give text input (e.g. "2") priority over cursor keys
for (auto it = input->begin(); it != input->end(); ++it)
@ -123,6 +125,7 @@ static bool cursor_key_pressed (std::set<df::interface_key> *input)
if (Screen::keyToChar(*it) != -1)
return false;
}
}
return
input->count(df::interface_key::CURSOR_UP) ||
input->count(df::interface_key::CURSOR_DOWN) ||
@ -249,7 +252,7 @@ public:
// ENTER or ESC: leave typing mode
end_entry_mode();
}
else if (cursor_key_pressed(input))
else if (cursor_key_pressed(input, entry_mode))
{
// Arrow key pressed. Leave entry mode and allow screen to process key
end_entry_mode();
@ -1953,7 +1956,9 @@ public:
end_entry_mode();
return false;
}
if (cursor_key_pressed(input))
bool hotkey_pressed =
input->lower_bound(interface_key::D_HOTKEY1) != input->upper_bound(interface_key::D_HOTKEY16);
if (cursor_key_pressed(input, in_entry_mode()) || hotkey_pressed)
{
end_entry_mode();
clear_search();