From e54ba2c5d14aa3f7b812b2d5523095e126e6f0ee Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 11 Sep 2014 19:19:38 +0200 Subject: [PATCH 01/15] Fix broken dialogue Function_HealthPercent --- apps/openmw/mwdialogue/filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 2d75576f01..2888a6e08b 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -249,7 +249,7 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c float ratio = mActor.getClass().getCreatureStats (mActor).getHealth().getCurrent() / mActor.getClass().getCreatureStats (mActor).getHealth().getModified(); - return select.selectCompare (ratio); + return select.selectCompare (static_cast(ratio*100)); } default: From 04c79d5f1ec1175afc32e6f762d2fa4e4c632189 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 11 Sep 2014 19:20:04 +0200 Subject: [PATCH 02/15] Fix case issue when setting companion's profit on the script --- apps/openmw/mwgui/companionwindow.cpp | 2 +- apps/openmw/mwscript/locals.hpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/companionwindow.cpp b/apps/openmw/mwgui/companionwindow.cpp index 4ea2a44c70..7b6644c6b9 100644 --- a/apps/openmw/mwgui/companionwindow.cpp +++ b/apps/openmw/mwgui/companionwindow.cpp @@ -148,7 +148,7 @@ void CompanionWindow::onMessageBoxButtonClicked(int button) if (button == 0) { mPtr.getRefData().getLocals().setVarByInt(mPtr.getClass().getScript(mPtr), - "minimumProfit", mPtr.getClass().getNpcStats(mPtr).getProfit()); + "minimumprofit", mPtr.getClass().getNpcStats(mPtr).getProfit()); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Companion); MWBase::Environment::get().getDialogueManager()->startDialogue (mPtr); diff --git a/apps/openmw/mwscript/locals.hpp b/apps/openmw/mwscript/locals.hpp index 1e8c6e12a4..9fa4214acc 100644 --- a/apps/openmw/mwscript/locals.hpp +++ b/apps/openmw/mwscript/locals.hpp @@ -24,8 +24,11 @@ namespace MWScript bool isEmpty() const; void configure (const ESM::Script& script); + /// @note var needs to be in lowercase bool setVarByInt(const std::string& script, const std::string& var, int val); - int getIntVar (const std::string& script, const std::string& var); ///< if var does not exist, returns 0 + int getIntVar (const std::string& script, const std::string& var); + ///< if var does not exist, returns 0 + /// @note var needs to be in lowercase void write (ESM::Locals& locals, const std::string& script) const; From dc1e8d4e2234c29463b7fc7fd40926b055680850 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 12 Sep 2014 20:28:08 +0200 Subject: [PATCH 03/15] Don't trigger any mouse button bindings while in the settings menu --- apps/openmw/mwinput/inputmanagerimp.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 2a0acf4167..ed8fbf33f6 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -554,9 +554,10 @@ namespace MWInput } setPlayerControlsEnabled(!guiMode); - mInputBinder->mousePressed (arg, id); - + // Don't trigger any mouse bindings while in settings menu, otherwise rebinding controls becomes impossible + if (MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_Settings) + mInputBinder->mousePressed (arg, id); } void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) From 319f4e0547d7376affd986e193450693236485a2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 13 Sep 2014 20:39:32 +0200 Subject: [PATCH 04/15] Bind to scancodes instead of keycodes --- apps/openmw/mwinput/inputmanagerimp.cpp | 82 +++++++++---------- apps/openmw/mwinput/inputmanagerimp.hpp | 2 +- extern/oics/ICSInputControlSystem.cpp | 17 ++-- extern/oics/ICSInputControlSystem.h | 13 ++- .../oics/ICSInputControlSystem_keyboard.cpp | 24 +++--- 5 files changed, 68 insertions(+), 70 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index ed8fbf33f6..86b01cdc4e 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -503,7 +503,7 @@ namespace MWInput // (which is somewhat reasonable, and hopefully true for all SDL platforms) OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); if (mInputBinder->getKeyBinding(mInputBinder->getControl(A_Console), ICS::Control::INCREASE) - == arg.keysym.sym + == arg.keysym.scancode && MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console) SDL_StopTextInput(); @@ -870,41 +870,41 @@ namespace MWInput { // using hardcoded key defaults is inevitable, if we want the configuration files to stay valid // across different versions of OpenMW (in the case where another input action is added) - std::map defaultKeyBindings; + std::map defaultKeyBindings; //Gets the Keyvalue from the Scancode; gives the button in the same place reguardless of keyboard format - defaultKeyBindings[A_Activate] = SDL_GetKeyFromScancode(SDL_SCANCODE_SPACE); - defaultKeyBindings[A_MoveBackward] = SDL_GetKeyFromScancode(SDL_SCANCODE_S); - defaultKeyBindings[A_MoveForward] = SDL_GetKeyFromScancode(SDL_SCANCODE_W); - defaultKeyBindings[A_MoveLeft] = SDL_GetKeyFromScancode(SDL_SCANCODE_A); - defaultKeyBindings[A_MoveRight] = SDL_GetKeyFromScancode(SDL_SCANCODE_D); - defaultKeyBindings[A_ToggleWeapon] = SDL_GetKeyFromScancode(SDL_SCANCODE_F); - defaultKeyBindings[A_ToggleSpell] = SDL_GetKeyFromScancode(SDL_SCANCODE_R); - defaultKeyBindings[A_QuickKeysMenu] = SDL_GetKeyFromScancode(SDL_SCANCODE_F1); - defaultKeyBindings[A_Console] = SDL_GetKeyFromScancode(SDL_SCANCODE_GRAVE); - defaultKeyBindings[A_Run] = SDL_GetKeyFromScancode(SDL_SCANCODE_LSHIFT); - defaultKeyBindings[A_Sneak] = SDL_GetKeyFromScancode(SDL_SCANCODE_LCTRL); - defaultKeyBindings[A_AutoMove] = SDL_GetKeyFromScancode(SDL_SCANCODE_Q); - defaultKeyBindings[A_Jump] = SDL_GetKeyFromScancode(SDL_SCANCODE_E); - defaultKeyBindings[A_Journal] = SDL_GetKeyFromScancode(SDL_SCANCODE_J); - defaultKeyBindings[A_Rest] = SDL_GetKeyFromScancode(SDL_SCANCODE_T); - defaultKeyBindings[A_GameMenu] = SDL_GetKeyFromScancode(SDL_SCANCODE_ESCAPE); - defaultKeyBindings[A_TogglePOV] = SDL_GetKeyFromScancode(SDL_SCANCODE_TAB); - defaultKeyBindings[A_QuickKey1] = SDL_GetKeyFromScancode(SDL_SCANCODE_1); - defaultKeyBindings[A_QuickKey2] = SDL_GetKeyFromScancode(SDL_SCANCODE_2); - defaultKeyBindings[A_QuickKey3] = SDL_GetKeyFromScancode(SDL_SCANCODE_3); - defaultKeyBindings[A_QuickKey4] = SDL_GetKeyFromScancode(SDL_SCANCODE_4); - defaultKeyBindings[A_QuickKey5] = SDL_GetKeyFromScancode(SDL_SCANCODE_5); - defaultKeyBindings[A_QuickKey6] = SDL_GetKeyFromScancode(SDL_SCANCODE_6); - defaultKeyBindings[A_QuickKey7] = SDL_GetKeyFromScancode(SDL_SCANCODE_7); - defaultKeyBindings[A_QuickKey8] = SDL_GetKeyFromScancode(SDL_SCANCODE_8); - defaultKeyBindings[A_QuickKey9] = SDL_GetKeyFromScancode(SDL_SCANCODE_9); - defaultKeyBindings[A_QuickKey10] = SDL_GetKeyFromScancode(SDL_SCANCODE_0); - defaultKeyBindings[A_Screenshot] = SDL_GetKeyFromScancode(SDL_SCANCODE_F12); - defaultKeyBindings[A_ToggleHUD] = SDL_GetKeyFromScancode(SDL_SCANCODE_F11); - defaultKeyBindings[A_AlwaysRun] = SDL_GetKeyFromScancode(SDL_SCANCODE_CAPSLOCK); - defaultKeyBindings[A_QuickSave] = SDL_GetKeyFromScancode(SDL_SCANCODE_F5); - defaultKeyBindings[A_QuickLoad] = SDL_GetKeyFromScancode(SDL_SCANCODE_F9); + defaultKeyBindings[A_Activate] = SDL_SCANCODE_SPACE; + defaultKeyBindings[A_MoveBackward] = SDL_SCANCODE_S; + defaultKeyBindings[A_MoveForward] = SDL_SCANCODE_W; + defaultKeyBindings[A_MoveLeft] = SDL_SCANCODE_A; + defaultKeyBindings[A_MoveRight] = SDL_SCANCODE_D; + defaultKeyBindings[A_ToggleWeapon] = SDL_SCANCODE_F; + defaultKeyBindings[A_ToggleSpell] = SDL_SCANCODE_R; + defaultKeyBindings[A_QuickKeysMenu] = SDL_SCANCODE_F1; + defaultKeyBindings[A_Console] = SDL_SCANCODE_GRAVE; + defaultKeyBindings[A_Run] = SDL_SCANCODE_LSHIFT; + defaultKeyBindings[A_Sneak] = SDL_SCANCODE_LCTRL; + defaultKeyBindings[A_AutoMove] = SDL_SCANCODE_Q; + defaultKeyBindings[A_Jump] = SDL_SCANCODE_E; + defaultKeyBindings[A_Journal] = SDL_SCANCODE_J; + defaultKeyBindings[A_Rest] = SDL_SCANCODE_T; + defaultKeyBindings[A_GameMenu] = SDL_SCANCODE_ESCAPE; + defaultKeyBindings[A_TogglePOV] = SDL_SCANCODE_TAB; + defaultKeyBindings[A_QuickKey1] = SDL_SCANCODE_1; + defaultKeyBindings[A_QuickKey2] = SDL_SCANCODE_2; + defaultKeyBindings[A_QuickKey3] = SDL_SCANCODE_3; + defaultKeyBindings[A_QuickKey4] = SDL_SCANCODE_4; + defaultKeyBindings[A_QuickKey5] = SDL_SCANCODE_5; + defaultKeyBindings[A_QuickKey6] = SDL_SCANCODE_6; + defaultKeyBindings[A_QuickKey7] = SDL_SCANCODE_7; + defaultKeyBindings[A_QuickKey8] = SDL_SCANCODE_8; + defaultKeyBindings[A_QuickKey9] = SDL_SCANCODE_9; + defaultKeyBindings[A_QuickKey10] = SDL_SCANCODE_0; + defaultKeyBindings[A_Screenshot] = SDL_SCANCODE_F12; + defaultKeyBindings[A_ToggleHUD] = SDL_SCANCODE_F11; + defaultKeyBindings[A_AlwaysRun] = SDL_SCANCODE_CAPSLOCK; + defaultKeyBindings[A_QuickSave] = SDL_SCANCODE_F5; + defaultKeyBindings[A_QuickLoad] = SDL_SCANCODE_F9; std::map defaultMouseButtonBindings; defaultMouseButtonBindings[A_Inventory] = SDL_BUTTON_RIGHT; @@ -926,14 +926,14 @@ namespace MWInput } if (!controlExists || force || - ( mInputBinder->getKeyBinding (control, ICS::Control::INCREASE) == SDLK_UNKNOWN + ( mInputBinder->getKeyBinding (control, ICS::Control::INCREASE) == SDL_SCANCODE_UNKNOWN && mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS )) { clearAllBindings (control); if (defaultKeyBindings.find(i) != defaultKeyBindings.end()) - mInputBinder->addKeyBinding(control, static_cast(defaultKeyBindings[i]), ICS::Control::INCREASE); + mInputBinder->addKeyBinding(control, defaultKeyBindings[i], ICS::Control::INCREASE); else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end()) mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE); } @@ -992,8 +992,8 @@ namespace MWInput ICS::Control* c = mInputBinder->getChannel (action)->getAttachedControls ().front().control; - if (mInputBinder->getKeyBinding (c, ICS::Control::INCREASE) != SDLK_UNKNOWN) - return mInputBinder->keyCodeToString (mInputBinder->getKeyBinding (c, ICS::Control::INCREASE)); + if (mInputBinder->getKeyBinding (c, ICS::Control::INCREASE) != SDL_SCANCODE_UNKNOWN) + return mInputBinder->scancodeToString (mInputBinder->getKeyBinding (c, ICS::Control::INCREASE)); else if (mInputBinder->getMouseButtonBinding (c, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS) return "#{sMouse} " + boost::lexical_cast(mInputBinder->getMouseButtonBinding (c, ICS::Control::INCREASE)); else @@ -1054,10 +1054,10 @@ namespace MWInput } void InputManager::keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control - , SDL_Keycode key, ICS::Control::ControlChangingDirection direction) + , SDL_Scancode key, ICS::Control::ControlChangingDirection direction) { //Disallow binding escape key - if(key==SDLK_ESCAPE) + if(key==SDL_SCANCODE_ESCAPE) return; clearAllBindings(control); @@ -1108,7 +1108,7 @@ namespace MWInput void InputManager::clearAllBindings (ICS::Control* control) { // right now we don't really need multiple bindings for the same action, so remove all others first - if (mInputBinder->getKeyBinding (control, ICS::Control::INCREASE) != SDLK_UNKNOWN) + if (mInputBinder->getKeyBinding (control, ICS::Control::INCREASE) != SDL_SCANCODE_UNKNOWN) mInputBinder->removeKeyBinding (mInputBinder->getKeyBinding (control, ICS::Control::INCREASE)); if (mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS) mInputBinder->removeMouseButtonBinding (mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE)); diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 6bf1ad6b00..a94b61c8ba 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -108,7 +108,7 @@ namespace MWInput , ICS::InputControlSystem::NamedAxis axis, ICS::Control::ControlChangingDirection direction); virtual void keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control - , SDL_Keycode key, ICS::Control::ControlChangingDirection direction); + , SDL_Scancode key, ICS::Control::ControlChangingDirection direction); virtual void mouseButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control , unsigned int button, ICS::Control::ControlChangingDirection direction); diff --git a/extern/oics/ICSInputControlSystem.cpp b/extern/oics/ICSInputControlSystem.cpp index 27006e9871..e493cdf26c 100644 --- a/extern/oics/ICSInputControlSystem.cpp +++ b/extern/oics/ICSInputControlSystem.cpp @@ -424,7 +424,7 @@ namespace ICS control.SetAttribute( "axisBindable", "false" ); } - if(getKeyBinding(*o, Control/*::ControlChangingDirection*/::INCREASE) != SDLK_UNKNOWN) + if(getKeyBinding(*o, Control/*::ControlChangingDirection*/::INCREASE) != SDL_SCANCODE_UNKNOWN) { TiXmlElement keyBinder( "KeyBinder" ); @@ -434,7 +434,7 @@ namespace ICS control.InsertEndChild(keyBinder); } - if(getKeyBinding(*o, Control/*::ControlChangingDirection*/::DECREASE) != SDLK_UNKNOWN) + if(getKeyBinding(*o, Control/*::ControlChangingDirection*/::DECREASE) != SDL_SCANCODE_UNKNOWN) { TiXmlElement keyBinder( "KeyBinder" ); @@ -801,14 +801,13 @@ namespace ICS mDetectingBindingControl = NULL; } - std::string InputControlSystem::keyCodeToString(SDL_Keycode key) + std::string InputControlSystem::scancodeToString(SDL_Scancode key) { - return std::string(SDL_GetKeyName(key)); - } - - SDL_Keycode InputControlSystem::stringToKeyCode(std::string key) - { - return SDL_GetKeyFromName(key.c_str()); + SDL_Keycode code = SDL_GetKeyFromScancode(key); + if (code == SDLK_UNKNOWN) + return std::string(SDL_GetScancodeName(key)); + else + return std::string(SDL_GetKeyName(code)); } void InputControlSystem::adjustMouseRegion(Uint16 width, Uint16 height) diff --git a/extern/oics/ICSInputControlSystem.h b/extern/oics/ICSInputControlSystem.h index 1e9c78e602..f874abaf8d 100644 --- a/extern/oics/ICSInputControlSystem.h +++ b/extern/oics/ICSInputControlSystem.h @@ -118,14 +118,14 @@ namespace ICS //TODO: does this have an SDL equivalent? //bool sliderMoved(const OIS::JoyStickEvent &evt, int index); - void addKeyBinding(Control* control, SDL_Keycode key, Control::ControlChangingDirection direction); + void addKeyBinding(Control* control, SDL_Scancode key, Control::ControlChangingDirection direction); void addMouseAxisBinding(Control* control, NamedAxis axis, Control::ControlChangingDirection direction); void addMouseButtonBinding(Control* control, unsigned int button, Control::ControlChangingDirection direction); void addJoystickAxisBinding(Control* control, int deviceId, int axis, Control::ControlChangingDirection direction); void addJoystickButtonBinding(Control* control, int deviceId, unsigned int button, Control::ControlChangingDirection direction); void addJoystickPOVBinding(Control* control, int deviceId, int index, POVAxis axis, Control::ControlChangingDirection direction); void addJoystickSliderBinding(Control* control, int deviceId, int index, Control::ControlChangingDirection direction); - void removeKeyBinding(SDL_Keycode key); + void removeKeyBinding(SDL_Scancode key); void removeMouseAxisBinding(NamedAxis axis); void removeMouseButtonBinding(unsigned int button); void removeJoystickAxisBinding(int deviceId, int axis); @@ -133,7 +133,7 @@ namespace ICS void removeJoystickPOVBinding(int deviceId, int index, POVAxis axis); void removeJoystickSliderBinding(int deviceId, int index); - SDL_Keycode getKeyBinding(Control* control, ICS::Control::ControlChangingDirection direction); + SDL_Scancode getKeyBinding(Control* control, ICS::Control::ControlChangingDirection direction); NamedAxis getMouseAxisBinding(Control* control, ICS::Control::ControlChangingDirection direction); unsigned int getMouseButtonBinding(Control* control, ICS::Control::ControlChangingDirection direction); int getJoystickAxisBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction); @@ -141,8 +141,7 @@ namespace ICS POVBindingPair getJoystickPOVBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction); int getJoystickSliderBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction); - std::string keyCodeToString(SDL_Keycode key); - SDL_Keycode stringToKeyCode(std::string key); + std::string scancodeToString(SDL_Scancode key); void enableDetectingBindingState(Control* control, Control::ControlChangingDirection direction); void cancelDetectingBindingState(); @@ -186,7 +185,7 @@ namespace ICS std::string mFileName; - typedef std::map ControlsKeyBinderMapType; // + typedef std::map ControlsKeyBinderMapType; // typedef std::map ControlsAxisBinderMapType; // typedef std::map ControlsButtonBinderMapType; // typedef std::map ControlsPOVBinderMapType; // @@ -233,7 +232,7 @@ namespace ICS { public: virtual void keyBindingDetected(InputControlSystem* ICS, Control* control - , SDL_Keycode key, Control::ControlChangingDirection direction); + , SDL_Scancode key, Control::ControlChangingDirection direction); virtual void mouseAxisBindingDetected(InputControlSystem* ICS, Control* control , InputControlSystem::NamedAxis axis, Control::ControlChangingDirection direction); diff --git a/extern/oics/ICSInputControlSystem_keyboard.cpp b/extern/oics/ICSInputControlSystem_keyboard.cpp index 8e7415b5b1..fbfa9af52a 100644 --- a/extern/oics/ICSInputControlSystem_keyboard.cpp +++ b/extern/oics/ICSInputControlSystem_keyboard.cpp @@ -43,16 +43,16 @@ namespace ICS dir = Control::DECREASE; } - addKeyBinding(mControls.back(), FromString(xmlKeyBinder->Attribute("key")), dir); + addKeyBinding(mControls.back(), SDL_Scancode(FromString(xmlKeyBinder->Attribute("key"))), dir); xmlKeyBinder = xmlKeyBinder->NextSiblingElement("KeyBinder"); } } - void InputControlSystem::addKeyBinding(Control* control, SDL_Keycode key, Control::ControlChangingDirection direction) + void InputControlSystem::addKeyBinding(Control* control, SDL_Scancode key, Control::ControlChangingDirection direction) { ICS_LOG("\tAdding KeyBinder [key=" - + keyCodeToString(key) + ", direction=" + + scancodeToString(key) + ", direction=" + ToString(direction) + "]"); ControlKeyBinderItem controlKeyBinderItem; @@ -61,7 +61,7 @@ namespace ICS mControlsKeyBinderMap[ key ] = controlKeyBinderItem; } - void InputControlSystem::removeKeyBinding(SDL_Keycode key) + void InputControlSystem::removeKeyBinding(SDL_Scancode key) { ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.find(key); if(it != mControlsKeyBinderMap.end()) @@ -70,7 +70,7 @@ namespace ICS } } - SDL_Keycode InputControlSystem::getKeyBinding(Control* control + SDL_Scancode InputControlSystem::getKeyBinding(Control* control , ICS::Control::ControlChangingDirection direction) { ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.begin(); @@ -83,7 +83,7 @@ namespace ICS it++; } - return SDLK_UNKNOWN; + return SDL_SCANCODE_UNKNOWN; } void InputControlSystem::keyPressed(const SDL_KeyboardEvent &evt) { @@ -91,7 +91,7 @@ namespace ICS { if(!mDetectingBindingControl) { - ControlsKeyBinderMapType::const_iterator it = mControlsKeyBinderMap.find(evt.keysym.sym); + ControlsKeyBinderMapType::const_iterator it = mControlsKeyBinderMap.find(evt.keysym.scancode); if(it != mControlsKeyBinderMap.end()) { it->second.control->setIgnoreAutoReverse(false); @@ -115,7 +115,7 @@ namespace ICS else if(mDetectingBindingListener) { mDetectingBindingListener->keyBindingDetected(this, - mDetectingBindingControl, evt.keysym.sym, mDetectingBindingDirection); + mDetectingBindingControl, evt.keysym.scancode, mDetectingBindingDirection); } } } @@ -124,7 +124,7 @@ namespace ICS { if(mActive) { - ControlsKeyBinderMapType::const_iterator it = mControlsKeyBinderMap.find(evt.keysym.sym); + ControlsKeyBinderMapType::const_iterator it = mControlsKeyBinderMap.find(evt.keysym.scancode); if(it != mControlsKeyBinderMap.end()) { it->second.control->setChangingDirection(Control::STOP); @@ -133,14 +133,14 @@ namespace ICS } void DetectingBindingListener::keyBindingDetected(InputControlSystem* ICS, Control* control - , SDL_Keycode key, Control::ControlChangingDirection direction) + , SDL_Scancode key, Control::ControlChangingDirection direction) { // if the key is used by another control, remove it ICS->removeKeyBinding(key); // if the control has a key assigned, remove it - SDL_Keycode oldKey = ICS->getKeyBinding(control, direction); - if(oldKey != SDLK_UNKNOWN) + SDL_Scancode oldKey = ICS->getKeyBinding(control, direction); + if(oldKey != SDL_SCANCODE_UNKNOWN) { ICS->removeKeyBinding(oldKey); } From 86257641436eab26832b6e6e961220d545923849 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 13 Sep 2014 20:50:49 +0200 Subject: [PATCH 05/15] Give 100% of health back when Resurrecting an actor (Fixes #1877) --- apps/openmw/mwmechanics/creaturestats.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 7a2ece6cad..2c3f867f93 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -270,11 +270,7 @@ namespace MWMechanics { if (mDead) { - if (mDynamic[0].getCurrent()<1) - { - mDynamic[0].setModified(mDynamic[0].getModified(), 1); - mDynamic[0].setCurrent(1); - } + mDynamic[0].setCurrent(mDynamic[0].getModified()); if (mDynamic[0].getCurrent()>=1) mDead = false; } From a42e60970bdebb10a4c3841e5b9145ad8b42499c Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 13 Sep 2014 20:55:57 +0200 Subject: [PATCH 06/15] Revert "delete death events on adding an actor to the scene" If we go to a different cell in the exact frame of an actor's death, the death event would be lost permanently. This reverts commit fd2c07a6f47b26469d01d05b7a284aa87f9caef2. Conflicts: apps/openmw/mwmechanics/actors.cpp --- apps/openmw/mwmechanics/actors.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 31a0856605..88e89a774c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1044,9 +1044,6 @@ namespace MWMechanics void Actors::addActor (const MWWorld::Ptr& ptr, bool updateImmediately) { - // erase previous death events since we are currently only tracking them while in an active cell - ptr.getClass().getCreatureStats(ptr).clearHasDied(); - removeActor(ptr); MWRender::Animation *anim = MWBase::Environment::get().getWorld()->getAnimation(ptr); From 99c276baa964ad6e17ab303a65a4524535cd9c1a Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 13 Sep 2014 21:23:44 +0200 Subject: [PATCH 07/15] Set weapon Magical flag when enchanting a weapon --- apps/openmw/mwclass/weapon.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index f958302cf3..d2f88efef3 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -378,6 +378,7 @@ namespace MWClass newItem.mName=newName; newItem.mData.mEnchant=enchCharge; newItem.mEnchant=enchId; + newItem.mData.mFlags |= ESM::Weapon::Magical; const ESM::Weapon *record = MWBase::Environment::get().getWorld()->createRecord (newItem); return record->mId; } From 0c273568f2512916038e2ccb50a06f42be9ff0ef Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 13 Sep 2014 21:45:03 +0200 Subject: [PATCH 08/15] Increment version number for input configuration Old files are broken by keycode->scancode switch (319f4e0547d7376affd986e193450693236485a2) --- apps/openmw/engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 1247ceda12..8bedd09641 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -367,7 +367,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) // Create input and UI first to set up a bootstrapping environment for // showing a loading screen and keeping the window responsive while doing so - std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v1.xml").string(); + std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v2.xml").string(); bool keybinderUserExists = boost::filesystem::exists(keybinderUser); MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, mGrab); mEnvironment.setInputManager (input); From 4426b03fa45aab63872dddb2ba5d95c9329c6f53 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 13 Sep 2014 22:21:37 +0200 Subject: [PATCH 09/15] Remove some garbage --- apps/openmw/engine.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 8bedd09641..c02cc60d3f 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -339,8 +339,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) // This has to be added BEFORE MyGUI is initialized, as it needs // to find core.xml here. - //addResourcesDirectory(mResDir); - addResourcesDirectory(mCfgMgr.getCachePath ().string()); addResourcesDirectory(mResDir / "mygui"); From 4b27950879b73608f69398488247786984e734e0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 14 Sep 2014 07:04:02 +0200 Subject: [PATCH 10/15] Don't apply race height to NPC collision shape (Fixes #1487) --- apps/openmw/mwworld/physicssystem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 1b46f52066..51aae2bc36 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -719,7 +719,10 @@ namespace MWWorld } if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) - act->setScale(node->getScale().x); + { + // NOTE: Ignoring Npc::adjustScale (race height) on purpose. This is a bug in MW and must be replicated for compatibility reasons + act->setScale(ptr.getCellRef().getScale()); + } } bool PhysicsSystem::toggleCollisionMode() From 002b41ba51a19f59c4b15293be22d4ca95a625ea Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 14 Sep 2014 08:33:41 +0200 Subject: [PATCH 11/15] Make changeWeather work when the player isn't in a cell yet (workaround for modTESTchargen_v2_5) --- apps/openmw/mwworld/weather.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 675a3e86e6..613fd712fd 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -702,9 +702,13 @@ void WeatherManager::changeWeather(const std::string& region, const unsigned int mRegionOverrides[Misc::StringUtils::lowerCase(region)] = weather; - std::string playerRegion = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell()->mRegion; - if (Misc::StringUtils::ciEqual(region, playerRegion)) - setWeather(weather); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); + if (player.isInCell()) + { + std::string playerRegion = player.getCell()->getCell()->mRegion; + if (Misc::StringUtils::ciEqual(region, playerRegion)) + setWeather(weather); + } } void WeatherManager::modRegion(const std::string ®ionid, const std::vector &chances) From 413bad2dc68a13410d21aee962f00ae2f2ed596d Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 14 Sep 2014 09:40:34 +0200 Subject: [PATCH 12/15] Fix a MyGUI warning --- files/mygui/openmw_windows.skin.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/files/mygui/openmw_windows.skin.xml b/files/mygui/openmw_windows.skin.xml index a7092416f0..49dcb89f91 100644 --- a/files/mygui/openmw_windows.skin.xml +++ b/files/mygui/openmw_windows.skin.xml @@ -836,10 +836,6 @@ - - - - From c5fa0768f1e7ebd6b3ce88ce8fb0e446e16d98d0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 14 Sep 2014 10:23:23 +0200 Subject: [PATCH 13/15] Fix broken minimum track size for scrollbars --- files/mygui/openmw_list.skin.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 291e3a8cc7..491ceb0339 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -5,7 +5,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -79,7 +79,8 @@ - + + From 1270dada3455fe0d981f1ef683c1407ab1fc22dd Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 14 Sep 2014 10:35:57 +0200 Subject: [PATCH 14/15] Don't set Attacked flag when the actor is already in combat with the attacker (Fixes #1909) --- apps/openmw/mwclass/creature.cpp | 3 ++- apps/openmw/mwclass/npc.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 139f390f88..c31ab2a2ad 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -329,7 +329,8 @@ namespace MWClass { // NOTE: 'object' and/or 'attacker' may be empty. - getCreatureStats(ptr).setAttacked(true); + if (!attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat(attacker)) + getCreatureStats(ptr).setAttacked(true); // Self defense if ((canWalk(ptr) || canFly(ptr) || canSwim(ptr)) // No retaliation for totally static creatures diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 8915f66543..b6d4181083 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -640,10 +640,12 @@ namespace MWClass bool wasDead = getCreatureStats(ptr).isDead(); - getCreatureStats(ptr).setAttacked(true); + if (!attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat(attacker)) + { + getCreatureStats(ptr).setAttacked(true); - if (!attacker.isEmpty()) MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker); + } if(!successful) { From 233e221de29f6bce6f3e9b5281c39034703a9269 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 14 Sep 2014 10:49:33 +0200 Subject: [PATCH 15/15] Terminate AI packages when target is disabled or deleted (Fixes #1910) --- apps/openmw/mwmechanics/aiactivate.cpp | 5 ++++- apps/openmw/mwmechanics/aicombat.cpp | 4 +++- apps/openmw/mwmechanics/aifollow.cpp | 4 +++- apps/openmw/mwmechanics/aipursue.cpp | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/aiactivate.cpp b/apps/openmw/mwmechanics/aiactivate.cpp index 7310b27abd..54bcd67b5a 100644 --- a/apps/openmw/mwmechanics/aiactivate.cpp +++ b/apps/openmw/mwmechanics/aiactivate.cpp @@ -28,7 +28,10 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration) actor.getClass().getCreatureStats(actor).setDrawState(DrawState_Nothing); - if(target == MWWorld::Ptr()) + if(target == MWWorld::Ptr() || + !target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered + // with the MechanicsManager + ) return true; //Target doesn't exist //Set the target desition from the actor diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index d484071bf6..c55cea587e 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -180,7 +180,9 @@ namespace MWMechanics if (target.isEmpty()) return false; - if(target.getClass().getCreatureStats(target).isDead()) + if(!target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered + // with the MechanicsManager + || target.getClass().getCreatureStats(target).isDead()) return true; const MWWorld::Class& actorClass = actor.getClass(); diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index f830d09d5b..a10f97e781 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -45,7 +45,9 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration) { MWWorld::Ptr target = getTarget(); - if (target.isEmpty()) + if (target.isEmpty() || !target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered + // with the MechanicsManager + ) return true; //Target doesn't exist // Only the player can be actively followed. AiFollow packages with targets other than the player diff --git a/apps/openmw/mwmechanics/aipursue.cpp b/apps/openmw/mwmechanics/aipursue.cpp index c41c639ea1..3ef0e8e963 100644 --- a/apps/openmw/mwmechanics/aipursue.cpp +++ b/apps/openmw/mwmechanics/aipursue.cpp @@ -38,7 +38,9 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, float duration) ESM::Position pos = actor.getRefData().getPosition(); //position of the actor const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId); //The target to follow - if(target == MWWorld::Ptr()) + if(target == MWWorld::Ptr() || !target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered + // with the MechanicsManager + ) return true; //Target doesn't exist if(target.getClass().getCreatureStats(target).isDead())