From 571d6151f0983e488feafb3cd6c9c74bbd038082 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 18 Feb 2016 15:50:43 +0300 Subject: Add some extra checks and logging while sorting keys. --- src/input/inputactionsortfunctor.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/input/inputactionsortfunctor.h') diff --git a/src/input/inputactionsortfunctor.h b/src/input/inputactionsortfunctor.h index 6a3a72245..6884f9c11 100644 --- a/src/input/inputactionsortfunctor.h +++ b/src/input/inputactionsortfunctor.h @@ -21,6 +21,8 @@ #ifndef INPUT_INPUTACTIONSORTFUNCTOR_H #define INPUT_INPUTACTIONSORTFUNCTOR_H +#include "logger.h" + #include "input/inputactiondata.h" #include "localconsts.h" @@ -31,8 +33,19 @@ class InputActionSortFunctor final bool operator() (const InputActionT key1, const InputActionT key2) const { - return keys[CAST_SIZE(key1)].priority - >= keys[CAST_SIZE(key2)].priority; + const size_t k1 = CAST_SIZE(key1); + const size_t k2 = CAST_SIZE(key2); + if (k1 >= CAST_SIZE(InputAction::TOTAL)) + { + logger->log("broken key1: %ld", static_cast(k1)); + return false; + } + if (k2 >= CAST_SIZE(InputAction::TOTAL)) + { + logger->log("broken key2: %ld", static_cast(k2)); + return false; + } + return keys[k1].priority >= keys[k2].priority; } const InputActionData *keys A_NONNULLPOINTER; -- cgit v1.2.3-60-g2f50