From 928bcb6d95d29be41b52872df9e0ee83aa4ad238 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sun, 15 Nov 2015 11:15:05 -0500 Subject: [PATCH] military search: Don't try to pass selection in empty list to DF Fixes #748 --- plugins/search.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/search.cpp b/plugins/search.cpp index 6d12e922c..f5b10f156 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -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; }