From 34ea9ea8134d1145087a6039d021bce69b7cfff2 Mon Sep 17 00:00:00 2001
From: Capostrophic <alexdobrohotov@yandex.ru>
Date: Wed, 17 Apr 2019 17:51:18 +0300
Subject: [PATCH] Add an option to restore MCP-like movement behavior

---
 apps/launcher/advancedpage.cpp        |  2 ++
 apps/openmw/mwmechanics/character.cpp |  2 +-
 files/settings-default.cfg            |  3 +++
 files/ui/advancedpage.ui              | 10 ++++++++++
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp
index f098dcaa21..a8ff9a0ed1 100644
--- a/apps/launcher/advancedpage.cpp
+++ b/apps/launcher/advancedpage.cpp
@@ -81,6 +81,7 @@ bool Launcher::AdvancedPage::loadSettings()
         unarmedFactorsStrengthComboBox->setCurrentIndex(unarmedFactorsStrengthIndex);
     loadSettingBool(requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game");
     loadSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game");
+    loadSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game");
 
     // Input Settings
     loadSettingBool(allowThirdPersonZoomCheckBox, "allow third person zoom", "Input");
@@ -141,6 +142,7 @@ void Launcher::AdvancedPage::saveSettings()
         mEngineSettings.setInt("strength influences hand to hand", "Game", unarmedFactorsStrengthIndex);
     saveSettingBool(requireAppropriateAmmunitionCheckBox, "only appropriate ammunition bypasses resistance", "Game");
     saveSettingBool(magicItemAnimationsCheckBox, "use magic item animations", "Game");
+    saveSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game");
 
     // Input Settings
     saveSettingBool(allowThirdPersonZoomCheckBox, "allow third person zoom", "Input");
diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp
index c8a99174b5..8a6101cd59 100644
--- a/apps/openmw/mwmechanics/character.cpp
+++ b/apps/openmw/mwmechanics/character.cpp
@@ -2372,7 +2372,7 @@ void CharacterController::update(float duration, bool animationOnly)
     moved.x() *= scale;
     moved.y() *= scale;
 
-    if(mPtr.getClass().isNpc())
+    if (mPtr.getClass().isNpc() && !Settings::Manager::getBool("normalise race speed", "Game"))
     {
         const ESM::NPC* npc = mPtr.get<ESM::NPC>()->mBase;
         const ESM::Race* race = world->getStore().get<ESM::Race>().find(npc->mRace);
diff --git a/files/settings-default.cfg b/files/settings-default.cfg
index 71260c37b8..217f11d136 100644
--- a/files/settings-default.cfg
+++ b/files/settings-default.cfg
@@ -261,6 +261,9 @@ only appropriate ammunition bypasses resistance = false
 # Use casting animations for magic items, just as for spells
 use magic item animations = false
 
+# Don't use race weight in NPC movement speed calculations
+normalise race speed = false
+
 [General]
 
 # Anisotropy reduces distortion in textures at low angles (e.g. 0 to 16).
diff --git a/files/ui/advancedpage.ui b/files/ui/advancedpage.ui
index 4aaffe936c..f7575cd2b8 100644
--- a/files/ui/advancedpage.ui
+++ b/files/ui/advancedpage.ui
@@ -159,6 +159,16 @@
             </property>
            </widget>
           </item>
+          <item>
+           <widget class="QCheckBox" name="normaliseRaceSpeedCheckBox">
+            <property name="toolTip">
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Don't use race weight in NPC movement speed calculations.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+            </property>
+            <property name="text">
+             <string>Normalise race speed</string>
+            </property>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>