military search: Don't try to pass selection in empty list to DF

Fixes #748
develop
lethosor 2015-11-15 11:15:05 -05:00
parent 875ecf7827
commit 928bcb6d95
1 changed files with 6 additions and 3 deletions

@ -1327,12 +1327,15 @@ public:
{
// About to make an assignment, so restore original list (it will be changed by the game)
int32_t *cursor = get_viewscreen_cursor();
df::unit *selected_unit = get_primary_list()->at(*cursor);
auto list = get_primary_list();
if (*cursor >= list->size())
return false;
df::unit *selected_unit = list->at(*cursor);
clear_search();
for (*cursor = 0; *cursor < get_primary_list()->size(); (*cursor)++)
for (*cursor = 0; *cursor < list->size(); (*cursor)++)
{
if (get_primary_list()->at(*cursor) == selected_unit)
if (list->at(*cursor) == selected_unit)
break;
}