From b728f8de6473409295a551507d16c20109413121 Mon Sep 17 00:00:00 2001
From: erorcun <erorcunerorcun@hotmail.com.tr>
Date: Sun, 24 Jan 2021 19:08:07 +0300
Subject: [PATCH] Fix out of bound binding orders

---
 src/core/ControllerConfig.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp
index fcc4503a..64663b81 100644
--- a/src/core/ControllerConfig.cpp
+++ b/src/core/ControllerConfig.cpp
@@ -2755,9 +2755,10 @@ wchar *CControllerConfigManager::GetButtonComboText(e_ControllerAction action)
 void CControllerConfigManager::SetControllerKeyAssociatedWithAction(e_ControllerAction action, int32 key, eControllerType type)
 {
 	ResetSettingOrder(action);
+	int numOfSettings = GetNumOfSettingsForAction(action);
 	
 	m_aSettings[action][type].m_Key = key;
-	m_aSettings[action][type].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1;
+	m_aSettings[action][type].m_ContSetOrder = numOfSettings + 1;
 }
 
 int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerAction action)
@@ -2767,8 +2768,10 @@ int32 CControllerConfigManager::GetMouseButtonAssociatedWithAction(e_ControllerA
 
 void CControllerConfigManager::SetMouseButtonAssociatedWithAction(e_ControllerAction action, int32 button)
 {
+	int numOfSettings = GetNumOfSettingsForAction(action);
+	
 	m_aSettings[action][MOUSE].m_Key = button;
-	m_aSettings[action][MOUSE].m_ContSetOrder = GetNumOfSettingsForAction(action) + 1;
+	m_aSettings[action][MOUSE].m_ContSetOrder = numOfSettings + 1;
 }
 
 void CControllerConfigManager::ResetSettingOrder(e_ControllerAction action)