From 56105df3999cee7a86c4338d105358875967225a Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Sun, 10 Nov 2019 19:06:03 +0200
Subject: SL-6109 Better key and table localization support and fix for
 key-replacing

---
 indra/llcommon/llkeybind.cpp | 31 ++++++-------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

(limited to 'indra/llcommon')

diff --git a/indra/llcommon/llkeybind.cpp b/indra/llcommon/llkeybind.cpp
index 46a3230240..ecfc289cb3 100644
--- a/indra/llcommon/llkeybind.cpp
+++ b/indra/llcommon/llkeybind.cpp
@@ -340,43 +340,24 @@ bool LLKeyBind::addKeyData(const LLKeyData& data)
 
 void LLKeyBind::replaceKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore, U32 index)
 {
-    if (mouse != CLICK_NONE || key != KEY_NONE )
-    {
-        // if both click and key are none, we are inserting a placeholder, we don't want to reset anything
-        // otherwise reset identical key
-        for (data_vector_t::iterator iter = mData.begin(); iter != mData.end(); iter++)
-        {
-            if (iter->mKey == key
-                && iter->mMouse == mouse
-                && iter->mIgnoreMasks == ignore
-                && (iter->mIgnoreMasks || iter->mMask == mask))
-            {
-                iter->reset();
-                break;
-            }
-        }
-    }
-    if (mData.size() > index)
-    {
-        mData[index] = LLKeyData(mouse, key, mask, ignore);
-    }
-    else
-    {
-        mData.push_back(LLKeyData(mouse, key, mask, ignore));
-    }
+    replaceKeyData(LLKeyData(mouse, key, mask, ignore), index);
 }
 
 void LLKeyBind::replaceKeyData(const LLKeyData& data, U32 index)
 {
     if (!data.isEmpty())
     {
+        // if both click and key are none (isEmpty()), we are inserting a placeholder, we don't want to reset anything
+        // otherwise reset identical key
         for (data_vector_t::iterator iter = mData.begin(); iter != mData.end(); iter++)
         {
             if (iter->mKey == data.mKey
                 && iter->mMouse == data.mMouse
                 && iter->mIgnoreMasks == data.mIgnoreMasks
-                && (iter->mIgnoreMasks || iter->mMask == data.mMask))
+                && iter->mMask == data.mMask)
             {
+                // Replacing only fully equal combinations even in case 'ignore' is set
+                // Reason: Simplicity and user might decide to do a 'move' command as W and Shift+Ctrl+W, and 'run' as Shift+W
                 iter->reset();
                 break;
             }
-- 
cgit v1.2.3