From b0d9e94004b0704e16ab649ba4b8c60752422c70 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 17 Jun 2017 11:42:04 +0000 Subject: [PATCH] Remove an old hack from my menu system that upon closer inspection is no longer needed. git-svn-id: https://svn.eduke32.com/eduke32@6186 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/menus.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index f8929c543..b25e42153 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -3836,7 +3836,13 @@ static vec2_t Menu_TextSize(int32_t x, int32_t y, const MenuFont_t *font, const static int32_t Menu_FindOptionBinarySearch(MenuOption_t *object, const int32_t query, size_t searchstart, size_t searchend) { const size_t thissearch = (searchstart + searchend) / 2; - const int32_t difference = ((object->options->optionValues == NULL && query < 0) ? object->options->numOptions-1 : query) - ((object->options->optionValues == NULL) ? (int32_t) thissearch : object->options->optionValues[thissearch]); + const bool isIdentityMap = object->options->optionValues == NULL; + + const int32_t destination = isIdentityMap ? (int32_t) thissearch : object->options->optionValues[thissearch]; + + const int32_t difference = query - destination; + + Bassert(!isIdentityMap || query >= 0); if (difference == 0) return thissearch;