From 7d39c5450ca099e2b61e0380c338241e2b7bdf39 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Sun, 5 Nov 2017 21:40:35 +0100 Subject: [PATCH 1/9] Fixed escaping @ in boost program options filter --- components/files/escape.cpp | 3 ++- components/files/escape.hpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/files/escape.cpp b/components/files/escape.cpp index f28870c70..3c3d04d51 100644 --- a/components/files/escape.cpp +++ b/components/files/escape.cpp @@ -27,7 +27,8 @@ namespace Files std::string EscapeHashString::processString(const std::string & str) { std::string temp = boost::replace_all_copy(str, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sHashIdentifier, "#"); - boost::replace_all(temp, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sEscapeIdentifier, std::string((char)escape_hash_filter::sEscape, 1)); + auto format = std::string(1, (char)escape_hash_filter::sEscape); + boost::replace_all(temp, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sEscapeIdentifier, format); return temp; } diff --git a/components/files/escape.hpp b/components/files/escape.hpp index 2017c2ed2..64410f3ab 100644 --- a/components/files/escape.hpp +++ b/components/files/escape.hpp @@ -78,6 +78,12 @@ namespace Files mFinishLine = true; } } + else if (character == sEscape) + { + mNext.push(sEscape); + mNext.push(sEscapeIdentifier); + record = false; + } else if (mPrevious == sEscape) { mNext.push(sEscape); From af3e1f92ec71df8b3a10f638f9a7d6b18fa474d6 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Tue, 7 Nov 2017 22:16:59 +0100 Subject: [PATCH 2/9] Added StringUtil::replaceAll() --- components/misc/stringops.hpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp index 9acd81710..12c222036 100644 --- a/components/misc/stringops.hpp +++ b/components/misc/stringops.hpp @@ -2,6 +2,7 @@ #define MISC_STRINGOPS_H #include +#include #include #include @@ -138,6 +139,35 @@ public: return notFound; } + + /** @brief Replaces all occurrences of a string in another string. + * + * @param str The string to operate on. + * @param what The string to replace. + * @param with The replacement string. + * @param what_len The length of the string to replace. + * @param with_len The length of the replacement string. + * + * @return A reference to the string passed in @p str. + */ + static std::string &replaceAll(std::string &str, const char *what, const char *with, + std::size_t what_len=std::string::npos, std::size_t with_len=std::string::npos) + { + if (what_len == std::string::npos) + what_len = strlen(what); + + if (with_len == std::string::npos) + with_len = strlen(with); + + std::size_t found; + std::size_t offset = 0; + while((found = str.find(what, offset, what_len)) != std::string::npos) + { + str.replace(found, what_len, with, with_len); + offset = found + with_len; + } + return str; + } }; } From 70d578d050ea9e26cf14064ee0e2bb62a051ceae Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Tue, 7 Nov 2017 23:10:58 +0100 Subject: [PATCH 3/9] Removed escape_hash_filter::mPrevious, removed usage of boost::replace_all --- components/files/escape.cpp | 15 ++++++++++----- components/files/escape.hpp | 11 ----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/components/files/escape.cpp b/components/files/escape.cpp index 3c3d04d51..93ae9b885 100644 --- a/components/files/escape.cpp +++ b/components/files/escape.cpp @@ -1,6 +1,6 @@ #include "escape.hpp" -#include +#include namespace Files { @@ -8,7 +8,7 @@ namespace Files const int escape_hash_filter::sEscapeIdentifier = 'a'; const int escape_hash_filter::sHashIdentifier = 'h'; - escape_hash_filter::escape_hash_filter() : mNext(), mPrevious(), mSeenNonWhitespace(false), mFinishLine(false) + escape_hash_filter::escape_hash_filter() : mSeenNonWhitespace(false), mFinishLine(false) { } @@ -26,9 +26,14 @@ namespace Files std::string EscapeHashString::processString(const std::string & str) { - std::string temp = boost::replace_all_copy(str, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sHashIdentifier, "#"); - auto format = std::string(1, (char)escape_hash_filter::sEscape); - boost::replace_all(temp, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sEscapeIdentifier, format); + std::string temp = str; + + static const char hash[] = { escape_hash_filter::sEscape, escape_hash_filter::sHashIdentifier }; + Misc::StringUtils::replaceAll(temp, hash, "#", 2, 1); + + static const char escape[] = { escape_hash_filter::sEscape, escape_hash_filter::sEscapeIdentifier }; + Misc::StringUtils::replaceAll(temp, escape, "@", 2, 1); + return temp; } diff --git a/components/files/escape.hpp b/components/files/escape.hpp index 64410f3ab..d01bd8d98 100644 --- a/components/files/escape.hpp +++ b/components/files/escape.hpp @@ -30,7 +30,6 @@ namespace Files private: std::queue mNext; - int mPrevious; bool mSeenNonWhitespace; bool mFinishLine; @@ -42,11 +41,9 @@ namespace Files if (mNext.empty()) { int character = boost::iostreams::get(src); - bool record = true; if (character == boost::iostreams::WOULD_BLOCK) { mNext.push(character); - record = false; } else if (character == EOF) { @@ -79,12 +76,6 @@ namespace Files } } else if (character == sEscape) - { - mNext.push(sEscape); - mNext.push(sEscapeIdentifier); - record = false; - } - else if (mPrevious == sEscape) { mNext.push(sEscape); mNext.push(sEscapeIdentifier); @@ -95,8 +86,6 @@ namespace Files } if (!mSeenNonWhitespace && !isspace(character)) mSeenNonWhitespace = true; - if (record) - mPrevious = character; } int retval = mNext.front(); mNext.pop(); From 43b5c2e36bc19db88f391f6a40429be4cf25c3a0 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Tue, 7 Nov 2017 23:20:10 +0100 Subject: [PATCH 4/9] Fixed parameter naming --- components/misc/stringops.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp index 12c222036..9f4931d72 100644 --- a/components/misc/stringops.hpp +++ b/components/misc/stringops.hpp @@ -145,26 +145,26 @@ public: * @param str The string to operate on. * @param what The string to replace. * @param with The replacement string. - * @param what_len The length of the string to replace. - * @param with_len The length of the replacement string. + * @param whatLen The length of the string to replace. + * @param withLen The length of the replacement string. * * @return A reference to the string passed in @p str. */ static std::string &replaceAll(std::string &str, const char *what, const char *with, - std::size_t what_len=std::string::npos, std::size_t with_len=std::string::npos) + std::size_t whatLen=std::string::npos, std::size_t withLen=std::string::npos) { - if (what_len == std::string::npos) - what_len = strlen(what); + if (whatLen == std::string::npos) + whatLen = strlen(what); - if (with_len == std::string::npos) - with_len = strlen(with); + if (withLen == std::string::npos) + withLen = strlen(with); std::size_t found; std::size_t offset = 0; - while((found = str.find(what, offset, what_len)) != std::string::npos) + while((found = str.find(what, offset, whatLen)) != std::string::npos) { - str.replace(found, what_len, with, with_len); - offset = found + with_len; + str.replace(found, whatLen, with, withLen); + offset = found + withLen; } return str; } From b9baee51d556f5e4555fb227292a850cd8b51525 Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Fri, 10 Nov 2017 21:47:14 +0100 Subject: [PATCH 5/9] Fix overlapping widgets in trade window layout (Fixes #4205) --- files/mygui/openmw_trade_window.layout | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/files/mygui/openmw_trade_window.layout b/files/mygui/openmw_trade_window.layout index d1f31c475..ebfe9b30f 100644 --- a/files/mygui/openmw_trade_window.layout +++ b/files/mygui/openmw_trade_window.layout @@ -53,18 +53,17 @@ - - - - - + + + + - + - + From 1afbf99f74c8a5b4c0aedad91ff20f3d3529fee4 Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Fri, 10 Nov 2017 21:48:11 +0100 Subject: [PATCH 6/9] Make movement keys not function in text input mode --- apps/openmw/mwinput/inputmanagerimp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index a5bb93b6c..5aa795c10 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -176,6 +176,8 @@ namespace MWInput void InputManager::handleGuiArrowKey(int action) { + if (SDL_IsTextInputActive()) + return; MyGUI::KeyCode key; switch (action) { From b06512a60d9f020cdd8d9f44fe6ef76f216eb9dd Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Fri, 10 Nov 2017 22:02:43 +0100 Subject: [PATCH 7/9] Fix error message that referred to the wrong file (Bug #4159) --- apps/openmw/mwrender/animation.cpp | 6 +++--- apps/openmw/mwrender/animation.hpp | 7 ++++--- apps/openmw/mwrender/creatureanimation.cpp | 8 ++++---- apps/openmw/mwrender/npcanimation.cpp | 12 ++++++------ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 90b69de8e..a1aa24871 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -536,7 +536,7 @@ namespace MWRender return mKeyframes->mTextKeys; } - void Animation::addAnimSource(const std::string &model) + void Animation::addAnimSource(const std::string &model, const std::string& baseModel) { std::string kfname = model; Misc::StringUtils::lowerCaseInPlace(kfname); @@ -565,7 +565,7 @@ namespace MWRender NodeMap::const_iterator found = nodeMap.find(bonename); if (found == nodeMap.end()) { - std::cerr << "Warning: addAnimSource: can't find bone '" + bonename << "' in " << model << " (referenced by " << kfname << ")" << std::endl; + std::cerr << "Warning: addAnimSource: can't find bone '" + bonename << "' in " << baseModel << " (referenced by " << kfname << ")" << std::endl; continue; } @@ -1668,7 +1668,7 @@ namespace MWRender { setObjectRoot(model, false, false, false); if (animated) - addAnimSource(model); + addAnimSource(model, model); if (!ptr.getClass().getEnchantment(ptr).empty()) addGlow(mObjectRoot, getEnchantmentColor(ptr)); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 5aec80f5d..8ac78babc 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -309,11 +309,12 @@ protected: */ void setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly, bool isCreature); - /** Adds the keyframe controllers in the specified model as a new animation source. Note that the .nif - * file extension will be replaced with .kf. + /** Adds the keyframe controllers in the specified model as a new animation source. * @note Later added animation sources have the highest priority when it comes to finding a particular animation. + * @param model The file to add the keyframes for. Note that the .nif file extension will be replaced with .kf. + * @param baseModel The filename of the mObjectRoot, only used for error messages. */ - void addAnimSource(const std::string &model); + void addAnimSource(const std::string &model, const std::string& baseModel); /** Adds an additional light to the given node using the specified ESM record. */ void addExtraLight(osg::ref_ptr parent, const ESM::Light *light); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 735c0b66d..827b576c3 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -33,8 +33,8 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr, setObjectRoot(model, false, false, true); if((ref->mBase->mFlags&ESM::Creature::Bipedal)) - addAnimSource("meshes\\xbase_anim.nif"); - addAnimSource(model); + addAnimSource("meshes\\xbase_anim.nif", model); + addAnimSource(model, model); } } @@ -51,8 +51,8 @@ CreatureWeaponAnimation::CreatureWeaponAnimation(const MWWorld::Ptr &ptr, const setObjectRoot(model, true, false, true); if((ref->mBase->mFlags&ESM::Creature::Bipedal)) - addAnimSource("meshes\\xbase_anim.nif"); - addAnimSource(model); + addAnimSource("meshes\\xbase_anim.nif", model); + addAnimSource(model, model); mPtr.getClass().getInventoryStore(mPtr).setInvListener(this, mPtr); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index ece57c273..08e376f08 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -482,25 +482,25 @@ void NpcAnimation::updateNpcBase() { const std::string base = "meshes\\xbase_anim.nif"; if (smodel != base) - addAnimSource(base); + addAnimSource(base, smodel); - addAnimSource(smodel); + addAnimSource(smodel, smodel); if(!isWerewolf) { if(mNpc->mModel.length() > 0) - addAnimSource(Misc::ResourceHelpers::correctActorModelPath("meshes\\" + mNpc->mModel, mResourceSystem->getVFS())); + addAnimSource(Misc::ResourceHelpers::correctActorModelPath("meshes\\" + mNpc->mModel, mResourceSystem->getVFS()), smodel); if(Misc::StringUtils::lowerCase(mNpc->mRace).find("argonian") != std::string::npos) - addAnimSource("meshes\\xargonian_swimkna.nif"); + addAnimSource("meshes\\xargonian_swimkna.nif", smodel); } } else { const std::string base = "meshes\\xbase_anim.1st.nif"; if (smodel != base) - addAnimSource(base); + addAnimSource(base, smodel); - addAnimSource(smodel); + addAnimSource(smodel, smodel); mObjectRoot->setNodeMask(Mask_FirstPerson); mObjectRoot->addCullCallback(new OverrideFieldOfViewCallback(mFirstPersonFieldOfView)); From a5adc5b018fa76a39e5a3a41aba4f5fcc8ab049d Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Fri, 10 Nov 2017 22:09:24 +0100 Subject: [PATCH 8/9] Add NPC base skeleton files to the optimizer blacklist (Fixes #4159) --- components/resource/scenemanager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 9c5a2a14e..03b850fac 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -432,13 +432,18 @@ namespace Resource bool canOptimize(const std::string& filename) { - // xmesh.nif can not be optimized because there are keyframes added in post size_t slashpos = filename.find_last_of("\\/"); if (slashpos != std::string::npos && slashpos+1 < filename.size()) { std::string basename = filename.substr(slashpos+1); + // xmesh.nif can not be optimized because there are keyframes added in post if (!basename.empty() && basename[0] == 'x') return false; + + // NPC skeleton files can not be optimized because of keyframes added in post + // (most of them are usually named like 'xbase_anim.nif' anyway, but not all of them :( ) + if (basename.compare(0, 9, "base_anim") == 0 || basename.compare(0, 4, "skin") == 0) + return false; } // For spell VFX, DummyXX nodes must remain intact. Not adding those to reservedNames to avoid being overly cautious - instead, decide on filename From f1aeb416ece36dbc37cd41138cc37bf6517cc5f4 Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Fri, 10 Nov 2017 22:54:04 +0000 Subject: [PATCH 9/9] Disable Activate key when textinput is active (Bug #4151) --- apps/openmw/mwinput/inputmanagerimp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 5aa795c10..9ef5033f0 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -1113,7 +1113,10 @@ namespace MWInput void InputManager::activate() { if (MWBase::Environment::get().getWindowManager()->isGuiMode()) - MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Return, 0); + { + if (!SDL_IsTextInputActive()) + MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Return, 0); + } else if (mControlSwitch["playercontrols"]) mPlayer->activate(); }