From 92e45507d8bba9321163e3bfd3099cd92ac9de20 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 3 Mar 2018 14:16:21 +0400 Subject: [PATCH 1/6] Weapon sheathing support, including quivers and scabbards (feature #4673) --- CHANGELOG.md | 2 +- apps/openmw/mwclass/creature.cpp | 2 +- apps/openmw/mwrender/actoranimation.cpp | 346 +++++++++++++++- apps/openmw/mwrender/actoranimation.hpp | 19 + apps/openmw/mwrender/animation.cpp | 2 - apps/openmw/mwrender/creatureanimation.cpp | 15 + apps/openmw/mwrender/creatureanimation.hpp | 2 + apps/openmw/mwrender/npcanimation.cpp | 29 +- apps/openmw/mwrender/npcanimation.hpp | 1 + apps/openmw/mwworld/containerstore.cpp | 6 +- apps/openmw/mwworld/containerstore.hpp | 5 +- apps/openmw/mwworld/inventorystore.cpp | 384 +++++++++++------- apps/openmw/mwworld/inventorystore.hpp | 9 +- components/resource/scenemanager.cpp | 3 +- .../reference/modding/settings/game.rst | 13 +- files/settings-default.cfg | 3 + 16 files changed, 673 insertions(+), 168 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d50c96ef49..22c426d517 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,9 @@ Feature #2229: Improve pathfinding AI Feature #3442: Default values for fallbacks from ini file + Feature #4673: Weapon sheathing Task #4686: Upgrade media decoder to a more current FFmpeg API - 0.45.0 ------ diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 8a6f7d23d6..c89ea8b7f0 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -166,7 +166,7 @@ namespace MWClass getContainerStore(ptr).fill(ref->mBase->mInventory, ptr.getCellRef().getRefId()); if (hasInventory) - getInventoryStore(ptr).autoEquipShield(ptr); + getInventoryStore(ptr).autoEquip(ptr); } } diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index e6aff8d19e..e4cf283944 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -1,5 +1,4 @@ #include "actoranimation.hpp" - #include #include @@ -9,11 +8,22 @@ #include #include +#include +#include + +#include #include #include +#include #include +#include + +#include + +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwworld/ptr.hpp" @@ -43,6 +53,8 @@ ActorAnimation::ActorAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr // Make sure we cleaned object from effects, just in cast if we re-use node removeEffects(); + + mWeaponSheathing = Settings::Manager::getBool("weapon sheathing", "Game"); } ActorAnimation::~ActorAnimation() @@ -51,6 +63,302 @@ ActorAnimation::~ActorAnimation() { mInsert->removeChild(iter->second); } + + mScabbard.reset(); +} + +PartHolderPtr ActorAnimation::getWeaponPart(const std::string& model, const std::string& bonename, bool enchantedGlow, osg::Vec4f* glowColor) +{ + osg::Group* parent = getBoneByName(bonename); + if (!parent) + return nullptr; + + osg::ref_ptr instance = mResourceSystem->getSceneManager()->getInstance(model, parent); + + const NodeMap& nodeMap = getNodeMap(); + NodeMap::const_iterator found = nodeMap.find(Misc::StringUtils::lowerCase(bonename)); + if (found == nodeMap.end()) + return PartHolderPtr(); + + if (enchantedGlow) + addGlow(instance, *glowColor); + + return PartHolderPtr(new PartHolder(instance)); +} + +osg::Group* ActorAnimation::getBoneByName(std::string boneName) +{ + if (!mObjectRoot) + return nullptr; + + SceneUtil::FindByNameVisitor findVisitor (boneName); + mObjectRoot->accept(findVisitor); + + return findVisitor.mFoundNode; +} + +std::string ActorAnimation::getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon) +{ + std::string boneName; + if(weapon.isEmpty()) + return boneName; + + const std::string &type = weapon.getClass().getTypeName(); + if(type == typeid(ESM::Weapon).name()) + { + const MWWorld::LiveCellRef *ref = weapon.get(); + ESM::Weapon::Type weaponType = (ESM::Weapon::Type)ref->mBase->mData.mType; + return getHolsteredWeaponBoneName(weaponType); + } + + return boneName; +} + +std::string ActorAnimation::getHolsteredWeaponBoneName(const unsigned int weaponType) +{ + std::string boneName; + + switch(weaponType) + { + case ESM::Weapon::ShortBladeOneHand: + boneName = "Bip01 ShortBladeOneHand"; + break; + case ESM::Weapon::LongBladeOneHand: + boneName = "Bip01 LongBladeOneHand"; + break; + case ESM::Weapon::BluntOneHand: + boneName = "Bip01 BluntOneHand"; + break; + case ESM::Weapon::AxeOneHand: + boneName = "Bip01 LongBladeOneHand"; + break; + case ESM::Weapon::LongBladeTwoHand: + boneName = "Bip01 LongBladeTwoClose"; + break; + case ESM::Weapon::BluntTwoClose: + boneName = "Bip01 BluntTwoClose"; + break; + case ESM::Weapon::AxeTwoHand: + boneName = "Bip01 AxeTwoClose"; + break; + case ESM::Weapon::BluntTwoWide: + boneName = "Bip01 BluntTwoWide"; + break; + case ESM::Weapon::SpearTwoWide: + boneName = "Bip01 SpearTwoWide"; + break; + case ESM::Weapon::MarksmanBow: + boneName = "Bip01 MarksmanBow"; + break; + case ESM::Weapon::MarksmanCrossbow: + boneName = "Bip01 MarksmanCrossbow"; + break; + case ESM::Weapon::MarksmanThrown: + boneName = "Bip01 MarksmanThrown"; + break; + default: + break; + } + + return boneName; +} + +void ActorAnimation::injectWeaponBones() +{ + if (!mResourceSystem->getVFS()->exists("meshes\\xbase_anim_sh.nif")) + { + mWeaponSheathing = false; + return; + } + + osg::ref_ptr sheathSkeleton = mResourceSystem->getSceneManager()->getInstance("meshes\\xbase_anim_sh.nif"); + + for (unsigned int type=0; type<=ESM::Weapon::MarksmanThrown; ++type) + { + const std::string holsteredBoneName = getHolsteredWeaponBoneName(type); + + SceneUtil::FindByNameVisitor findVisitor (holsteredBoneName); + sheathSkeleton->accept(findVisitor); + osg::ref_ptr sheathNode = findVisitor.mFoundNode; + + if (sheathNode && sheathNode.get()->getNumParents()) + { + osg::Group* sheathParent = getBoneByName(sheathNode.get()->getParent(0)->getName()); + + if (sheathParent) + { + sheathNode.get()->getParent(0)->removeChild(sheathNode); + sheathParent->addChild(sheathNode); + } + } + } +} + +// To make sure we do not run morph controllers for weapons, i.e. bows +class EmptyCallback : public osg::NodeCallback +{ + public: + + virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) + { + } +}; + +void ActorAnimation::updateHolsteredWeapon(bool showHolsteredWeapons) +{ + if (!mWeaponSheathing) + return; + + if (!mPtr.getClass().hasInventoryStore(mPtr)) + return; + + mScabbard.reset(); + + const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr); + MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); + if (weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name()) + return; + + // Since throwing weapons stack themselves, do not show such weapon itself + if (weapon->get()->mBase->mData.mType == ESM::Weapon::MarksmanThrown) + showHolsteredWeapons = false; + + std::string mesh = weapon->getClass().getModel(*weapon); + std::string scabbardName = mesh; + + std::string boneName = getHolsteredWeaponBoneName(*weapon); + if (mesh.empty() || boneName.empty()) + return; + + // If the scabbard is not found, use a weapon mesh as fallback + scabbardName = scabbardName.replace(scabbardName.size()-4, 4, "_sh.nif"); + bool isEnchanted = !weapon->getClass().getEnchantment(*weapon).empty(); + if(!mResourceSystem->getVFS()->exists(scabbardName)) + { + if (showHolsteredWeapons) + { + osg::Vec4f glowColor = getEnchantmentColor(*weapon); + mScabbard = getWeaponPart(mesh, boneName, isEnchanted, &glowColor); + if (mScabbard) + mScabbard->getNode()->setUpdateCallback(new EmptyCallback); + } + + return; + } + + mScabbard = getWeaponPart(scabbardName, boneName); + + osg::Group* weaponNode = getBoneByName("Bip01 Weapon"); + if (!weaponNode) + return; + + // When we draw weapon, hide the Weapon node from sheath model. + // Otherwise add the enchanted glow to it. + if (!showHolsteredWeapons) + { + weaponNode->setNodeMask(0); + } + else + { + // If mesh author declared empty weapon node, use transformation from this node, but use the common weapon mesh. + // This approach allows to tweak weapon position without need to store the whole weapon mesh in the _sh file. + if (!weaponNode->getNumChildren()) + { + osg::ref_ptr fallbackNode = mResourceSystem->getSceneManager()->getInstance(mesh, weaponNode); + fallbackNode->setUpdateCallback(new EmptyCallback); + } + + if (isEnchanted) + { + osg::Vec4f glowColor = getEnchantmentColor(*weapon); + addGlow(weaponNode, glowColor); + } + } +} + +void ActorAnimation::updateQuiver() +{ + if (!mWeaponSheathing) + return; + + if (!mPtr.getClass().hasInventoryStore(mPtr)) + return; + + const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr); + MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); + if(weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name()) + return; + + std::string mesh = weapon->getClass().getModel(*weapon); + std::string boneName = getHolsteredWeaponBoneName(*weapon); + if (mesh.empty() || boneName.empty()) + return; + + osg::Group* ammoNode = getBoneByName("Bip01 Ammo"); + if (!ammoNode) + return; + + // Special case for throwing weapons - they do not use ammo, but they stack themselves + bool suitableAmmo = false; + MWWorld::ConstContainerStoreIterator ammo = weapon; + unsigned int ammoCount = 0; + if (weapon->get()->mBase->mData.mType == ESM::Weapon::MarksmanThrown) + { + ammoCount = ammo->getRefData().getCount(); + osg::Group* throwingWeaponNode = getBoneByName("Weapon Bone"); + if (throwingWeaponNode && throwingWeaponNode->getNumChildren()) + ammoCount--; + + suitableAmmo = true; + } + else + { + ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition); + if (ammo == inv.end()) + return; + + ammoCount = ammo->getRefData().getCount(); + bool arrowAttached = isArrowAttached(); + if (arrowAttached) + ammoCount--; + + if (weapon->get()->mBase->mData.mType == ESM::Weapon::MarksmanCrossbow) + suitableAmmo = ammo->get()->mBase->mData.mType == ESM::Weapon::Bolt; + else if (weapon->get()->mBase->mData.mType == ESM::Weapon::MarksmanBow) + suitableAmmo = ammo->get()->mBase->mData.mType == ESM::Weapon::Arrow; + } + + if (ammoNode && suitableAmmo) + { + // We should not show more ammo than equipped and more than quiver mesh has + ammoCount = std::min(ammoCount, ammoNode->getNumChildren()); + + // Remove existing ammo nodes + for (unsigned int i=0; igetNumChildren(); ++i) + { + osg::ref_ptr arrowNode = ammoNode->getChild(i)->asGroup(); + if (!arrowNode->getNumChildren()) + continue; + + osg::ref_ptr arrowChildNode = arrowNode->getChild(0); + arrowNode->removeChild(arrowChildNode); + } + + // Add new ones + osg::Vec4f glowColor = getEnchantmentColor(*ammo); + std::string model = ammo->getClass().getModel(*ammo); + for (unsigned int i=0; i arrowNode = ammoNode->getChild(i)->asGroup(); + osg::ref_ptr arrow = mResourceSystem->getSceneManager()->getInstance(model, arrowNode); + if (!ammo->getClass().getEnchantment(*ammo).empty()) + addGlow(arrow, glowColor); + } + } + + // recreate shaders for invisible actors, otherwise new nodes will be visible + if (mAlpha != 1.f) + mResourceSystem->getSceneManager()->recreateShaders(mObjectRoot); } void ActorAnimation::itemAdded(const MWWorld::ConstPtr& item, int /*count*/) @@ -63,6 +371,24 @@ void ActorAnimation::itemAdded(const MWWorld::ConstPtr& item, int /*count*/) addHiddenItemLight(item, light); } } + + if (!mPtr.getClass().hasInventoryStore(mPtr)) + return; + + // If the count of equipped ammo or throwing weapon was changed, we should update quiver + const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr); + MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); + if(weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name()) + return; + + MWWorld::ConstContainerStoreIterator ammo = inv.end(); + if (weapon->get()->mBase->mData.mType == ESM::Weapon::MarksmanThrown) + ammo = weapon; + else + ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition); + + if(ammo != inv.end() && item.getCellRef().getRefId() == ammo->getCellRef().getRefId()) + updateQuiver(); } void ActorAnimation::itemRemoved(const MWWorld::ConstPtr& item, int /*count*/) @@ -78,6 +404,24 @@ void ActorAnimation::itemRemoved(const MWWorld::ConstPtr& item, int /*count*/) } } } + + if (!mPtr.getClass().hasInventoryStore(mPtr)) + return; + + // If the count of equipped ammo or throwing weapon was changed, we should update quiver + const MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr); + MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); + if(weapon == inv.end() || weapon->getTypeName() != typeid(ESM::Weapon).name()) + return; + + MWWorld::ConstContainerStoreIterator ammo = inv.end(); + if (weapon->get()->mBase->mData.mType == ESM::Weapon::MarksmanThrown) + ammo = weapon; + else + ammo = inv.getSlot(MWWorld::InventoryStore::Slot_Ammunition); + + if(ammo != inv.end() && item.getCellRef().getRefId() == ammo->getCellRef().getRefId()) + updateQuiver(); } void ActorAnimation::addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM::Light* esmLight) diff --git a/apps/openmw/mwrender/actoranimation.hpp b/apps/openmw/mwrender/actoranimation.hpp index c00f057183..7a8acd3a83 100644 --- a/apps/openmw/mwrender/actoranimation.hpp +++ b/apps/openmw/mwrender/actoranimation.hpp @@ -6,6 +6,7 @@ #include #include "../mwworld/containerstore.hpp" +#include "../mwworld/inventorystore.hpp" #include "animation.hpp" @@ -36,6 +37,24 @@ class ActorAnimation : public Animation, public MWWorld::ContainerStoreListener virtual void itemAdded(const MWWorld::ConstPtr& item, int count); virtual void itemRemoved(const MWWorld::ConstPtr& item, int count); + virtual bool isArrowAttached() const { return false; } + + protected: + bool mWeaponSheathing; + osg::Group* getBoneByName(std::string boneName); + virtual void updateHolsteredWeapon(bool showHolsteredWeapons); + virtual void injectWeaponBones(); + virtual void updateQuiver(); + virtual std::string getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon); + virtual std::string getHolsteredWeaponBoneName(const unsigned int weaponType); + virtual PartHolderPtr getWeaponPart(const std::string& model, const std::string& bonename, bool enchantedGlow, osg::Vec4f* glowColor); + virtual PartHolderPtr getWeaponPart(const std::string& model, const std::string& bonename) + { + osg::Vec4f stubColor = osg::Vec4f(0,0,0,0); + return getWeaponPart(model, bonename, false, &stubColor); + }; + + PartHolderPtr mScabbard; private: void addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM::Light* esmLight); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index bf293bd557..7730b9104f 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1748,8 +1748,6 @@ namespace MWRender } else { - osg::StateSet* stateset (new osg::StateSet); - osg::BlendFunc* blendfunc (new osg::BlendFunc); stateset->setAttributeAndModes(blendfunc, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index a262d00211..aeee69ab08 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -49,7 +49,12 @@ CreatureWeaponAnimation::CreatureWeaponAnimation(const MWWorld::Ptr &ptr, const setObjectRoot(model, true, false, true); if((ref->mBase->mFlags&ESM::Creature::Bipedal)) + { + if (mWeaponSheathing) + injectWeaponBones(); + addAnimSource("meshes\\xbase_anim.nif", model); + } addAnimSource(model, model); mPtr.getClass().getInventoryStore(mPtr).setInvListener(this, mPtr); @@ -84,6 +89,9 @@ void CreatureWeaponAnimation::updateParts() mWeapon.reset(); mShield.reset(); + updateHolsteredWeapon(!mShowWeapons); + updateQuiver(); + if (mShowWeapons) updatePart(mWeapon, MWWorld::InventoryStore::Slot_CarriedRight); if (mShowCarriedLeft) @@ -157,14 +165,21 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot) } } +bool CreatureWeaponAnimation::isArrowAttached() const +{ + return mAmmunition != nullptr; +} + void CreatureWeaponAnimation::attachArrow() { WeaponAnimation::attachArrow(mPtr); + updateQuiver(); } void CreatureWeaponAnimation::releaseArrow(float attackStrength) { WeaponAnimation::releaseArrow(mPtr, attackStrength); + updateQuiver(); } osg::Group *CreatureWeaponAnimation::getArrowBone() diff --git a/apps/openmw/mwrender/creatureanimation.hpp b/apps/openmw/mwrender/creatureanimation.hpp index ff959a551e..d0fd5bdb4f 100644 --- a/apps/openmw/mwrender/creatureanimation.hpp +++ b/apps/openmw/mwrender/creatureanimation.hpp @@ -54,6 +54,8 @@ namespace MWRender /// to indicate the facing orientation of the character. virtual void setPitchFactor(float factor) { mPitchFactor = factor; } + protected: + virtual bool isArrowAttached() const; private: PartHolderPtr mWeapon; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index c7669f5e90..f21f248841 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include // TextKeyMapHolder #include "../mwworld/esmstore.hpp" @@ -308,6 +310,12 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode) if(mViewMode == viewMode) return; + // Disable weapon sheathing in the 1st-person mode + if (viewMode == VM_FirstPerson) + mWeaponSheathing = false; + else + mWeaponSheathing = Settings::Manager::getBool("weapon sheathing", "Game"); + mViewMode = viewMode; rebuild(); @@ -389,6 +397,7 @@ void NpcAnimation::setRenderBin() void NpcAnimation::rebuild() { + mScabbard.reset(); updateNpcBase(); MWBase::Environment::get().getMechanicsManager()->forceStateUpdate(mPtr); @@ -460,6 +469,11 @@ void NpcAnimation::updateNpcBase() setObjectRoot(smodel, true, true, false); + if (mWeaponSheathing) + injectWeaponBones(); + + updateParts(); + if(!is1stPerson) { const std::string base = "meshes\\xbase_anim.nif"; @@ -488,8 +502,6 @@ void NpcAnimation::updateNpcBase() mObjectRoot->addCullCallback(new OverrideFieldOfViewCallback(mFirstPersonFieldOfView)); } - updateParts(); - mWeaponAnimationTime->updateStartTime(); } @@ -899,7 +911,8 @@ void NpcAnimation::showWeapons(bool showWeapon) attachArrow(); } } - if (mAlpha != 1.f) + // Note: we will need to recreate shaders later if we use weapon sheathing anyway, so there is no point to update them here + if (mAlpha != 1.f && !mWeaponSheathing) mResourceSystem->getSceneManager()->recreateShaders(mObjectRoot); } else @@ -909,6 +922,9 @@ void NpcAnimation::showWeapons(bool showWeapon) if (mPtr == MWMechanics::getPlayer()) MWBase::Environment::get().getWorld()->getPlayer().setAttackingOrSpell(false); } + + updateHolsteredWeapon(!mShowWeapons); + updateQuiver(); } void NpcAnimation::showCarriedLeft(bool show) @@ -936,11 +952,13 @@ void NpcAnimation::showCarriedLeft(bool show) void NpcAnimation::attachArrow() { WeaponAnimation::attachArrow(mPtr); + updateQuiver(); } void NpcAnimation::releaseArrow(float attackStrength) { WeaponAnimation::releaseArrow(mPtr, attackStrength); + updateQuiver(); } osg::Group* NpcAnimation::getArrowBone() @@ -1185,4 +1203,9 @@ void NpcAnimation::setAccurateAiming(bool enabled) mAccurateAiming = enabled; } +bool NpcAnimation::isArrowAttached() const +{ + return mAmmunition != nullptr; +} + } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 335ca5d5a3..1fbdd863cd 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -95,6 +95,7 @@ private: protected: virtual void addControllers(); + virtual bool isArrowAttached() const; public: /** diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 6a24ae4f01..ee30899018 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -330,7 +330,8 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr item.getRefData().getLocals().setVarByInt(script, "onpcadd", 1); } - if (mListener) + // we should not fire event for InventoryStore yet - it has some custom logic + if (mListener && !actorPtr.getClass().hasInventoryStore(actorPtr)) mListener->itemAdded(item, count); return it; @@ -439,7 +440,8 @@ int MWWorld::ContainerStore::remove(const Ptr& item, int count, const Ptr& actor flagAsModified(); - if (mListener) + // we should not fire event for InventoryStore yet - it has some custom logic + if (mListener && !actor.getClass().hasInventoryStore(actor)) mListener->itemRemoved(item, count - toRemove); // number of removed items diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index b67eb65527..4564d2fa3c 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -68,6 +68,9 @@ namespace MWWorld static const std::string sGoldId; + protected: + ContainerStoreListener* mListener; + private: MWWorld::CellRefList potions; @@ -87,8 +90,6 @@ namespace MWWorld ///< Stores result of levelled item spawns. <(refId, spawningGroup), count> /// This is used to restock levelled items(s) if the old item was sold. - ContainerStoreListener* mListener; - mutable float mCachedWeight; mutable bool mWeightUpToDate; ContainerStoreIterator addImp (const Ptr& ptr, int count); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 647ae261ba..6fe1d0c733 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -99,7 +99,8 @@ void MWWorld::InventoryStore::readEquipmentState(const MWWorld::ContainerStoreIt } MWWorld::InventoryStore::InventoryStore() - : mListener(nullptr) + : ContainerStore() + , mInventoryListener(nullptr) , mUpdatesEnabled (true) , mFirstAutoEquip(true) , mSelectedEnchantItem(end()) @@ -111,7 +112,7 @@ MWWorld::InventoryStore::InventoryStore() MWWorld::InventoryStore::InventoryStore (const InventoryStore& store) : ContainerStore (store) , mMagicEffects(store.mMagicEffects) - , mListener(store.mListener) + , mInventoryListener(store.mInventoryListener) , mUpdatesEnabled(store.mUpdatesEnabled) , mFirstAutoEquip(store.mFirstAutoEquip) , mPermanentMagicEffectMagnitudes(store.mPermanentMagicEffectMagnitudes) @@ -124,6 +125,7 @@ MWWorld::InventoryStore::InventoryStore (const InventoryStore& store) MWWorld::InventoryStore& MWWorld::InventoryStore::operator= (const InventoryStore& store) { mListener = store.mListener; + mInventoryListener = store.mInventoryListener; mMagicEffects = store.mMagicEffects; mFirstAutoEquip = store.mFirstAutoEquip; mPermanentMagicEffectMagnitudes = store.mPermanentMagicEffectMagnitudes; @@ -147,6 +149,9 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add(const Ptr& itemPtr, autoEquip(actorPtr); } + if (mListener) + mListener->itemAdded(itemPtr, count); + return retVal; } @@ -246,25 +251,195 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::findSlot (int slot) con return mSlots[slot]; } -void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) +void MWWorld::InventoryStore::autoEquipWeapon (const MWWorld::Ptr& actor, TSlots& slots_) { + if (!actor.getClass().isNpc()) + { + // In original game creatures do not autoequip weapon, but we need it for weapon sheathing. + // The only case when the difference is noticable - when this creature sells weapon. + // So just disable weapon autoequipping for creatures which sells weapon. + int services = actor.getClass().getServices(actor); + bool sellsWeapon = services & (ESM::NPC::Weapon|ESM::NPC::MagicItems); + if (sellsWeapon) + return; + } + + static const ESM::Skill::SkillEnum weaponSkills[] = + { + ESM::Skill::LongBlade, + ESM::Skill::Axe, + ESM::Skill::Spear, + ESM::Skill::ShortBlade, + ESM::Skill::Marksman, + ESM::Skill::BluntWeapon + }; + const size_t weaponSkillsLength = sizeof(weaponSkills) / sizeof(weaponSkills[0]); + + bool weaponSkillVisited[weaponSkillsLength] = { false }; + + // give arrows/bolt with max damage by default + int arrowMax = 0; + int boltMax = 0; + ContainerStoreIterator arrow(end()); + ContainerStoreIterator bolt(end()); + + // rate ammo + for (ContainerStoreIterator iter(begin(ContainerStore::Type_Weapon)); iter!=end(); ++iter) + { + const ESM::Weapon* esmWeapon = iter->get()->mBase; + + if (esmWeapon->mData.mType == ESM::Weapon::Arrow) + { + if (esmWeapon->mData.mChop[1] >= arrowMax) + { + arrowMax = esmWeapon->mData.mChop[1]; + arrow = iter; + } + } + else if (esmWeapon->mData.mType == ESM::Weapon::Bolt) + { + if (esmWeapon->mData.mChop[1] >= boltMax) + { + boltMax = esmWeapon->mData.mChop[1]; + bolt = iter; + } + } + } + + // rate weapon + for (int i = 0; i < static_cast(weaponSkillsLength); ++i) + { + int max = 0; + int maxWeaponSkill = -1; + + for (int j = 0; j < static_cast(weaponSkillsLength); ++j) + { + int skillValue = actor.getClass().getSkill(actor, static_cast(weaponSkills[j])); + if (skillValue > max && !weaponSkillVisited[j]) + { + max = skillValue; + maxWeaponSkill = j; + } + } + + if (maxWeaponSkill == -1) + break; + + max = 0; + ContainerStoreIterator weapon(end()); + + for (ContainerStoreIterator iter(begin(ContainerStore::Type_Weapon)); iter!=end(); ++iter) + { + if (!canActorAutoEquip(actor, *iter)) + continue; + + const ESM::Weapon* esmWeapon = iter->get()->mBase; + + if (esmWeapon->mData.mType == ESM::Weapon::Arrow || esmWeapon->mData.mType == ESM::Weapon::Bolt) + continue; + + if (iter->getClass().getEquipmentSkill(*iter) == weaponSkills[maxWeaponSkill]) + { + if (esmWeapon->mData.mChop[1] >= max) + { + max = esmWeapon->mData.mChop[1]; + weapon = iter; + } + + if (esmWeapon->mData.mSlash[1] >= max) + { + max = esmWeapon->mData.mSlash[1]; + weapon = iter; + } + + if (esmWeapon->mData.mThrust[1] >= max) + { + max = esmWeapon->mData.mThrust[1]; + weapon = iter; + } + } + } + + bool isBow = false; + bool isCrossbow = false; + if (weapon != end()) + { + const MWWorld::LiveCellRef *ref = weapon->get(); + ESM::Weapon::Type type = (ESM::Weapon::Type)ref->mBase->mData.mType; + + if (type == ESM::Weapon::MarksmanBow) + isBow = true; + else if (type == ESM::Weapon::MarksmanCrossbow) + isCrossbow = true; + } + + if (weapon != end() && weapon->getClass().canBeEquipped(*weapon, actor).first) + { + // Do not equip ranged weapons, if there is no suitable ammo + bool hasAmmo = true; + if (isBow == true) + { + if (arrow == end()) + hasAmmo = false; + else + slots_[Slot_Ammunition] = arrow; + } + if (isCrossbow == true) + { + if (bolt == end()) + hasAmmo = false; + else + slots_[Slot_Ammunition] = bolt; + } + + if (hasAmmo) + { + std::pair, bool> itemsSlots = weapon->getClass().getEquipmentSlots (*weapon); + + if (!itemsSlots.first.empty()) + { + if (!itemsSlots.second) + { + if (weapon->getRefData().getCount() > 1) + { + unstack(*weapon, actor); + } + } + + int slot = itemsSlots.first.front(); + slots_[slot] = weapon; + + if (!isBow && !isCrossbow) + slots_[Slot_Ammunition] = end(); + } + + break; + } + } + + weaponSkillVisited[maxWeaponSkill] = true; + } +} + +void MWWorld::InventoryStore::autoEquipArmor (const MWWorld::Ptr& actor, TSlots& slots_) +{ + // Only NPCs can wear armor for now. + // For creatures we equip only shields. + if (!actor.getClass().isNpc()) + { + autoEquipShield(actor, slots_); + return; + } + const MWBase::World *world = MWBase::Environment::get().getWorld(); const MWWorld::Store &store = world->getStore().get(); static float fUnarmoredBase1 = store.find("fUnarmoredBase1")->mValue.getFloat(); static float fUnarmoredBase2 = store.find("fUnarmoredBase2")->mValue.getFloat(); - int unarmoredSkill = actor.getClass().getSkill(actor, ESM::Skill::Unarmored); + int unarmoredSkill = actor.getClass().getSkill(actor, ESM::Skill::Unarmored); float unarmoredRating = (fUnarmoredBase1 * unarmoredSkill) * (fUnarmoredBase2 * unarmoredSkill); - TSlots slots_; - initSlots (slots_); - - // Disable model update during auto-equip - mUpdatesEnabled = false; - - // Autoequip clothing, armor and weapons. - // Equipping lights is handled in Actors::updateEquippedLight based on environment light. for (ContainerStoreIterator iter (begin(ContainerStore::Type_Clothing | ContainerStore::Type_Armor)); iter!=end(); ++iter) { Ptr test = *iter; @@ -289,12 +464,12 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) std::pair, bool> itemsSlots = iter->getClass().getEquipmentSlots (*iter); - // checking if current item poited by iter can be equipped + // checking if current item pointed by iter can be equipped for (std::vector::const_iterator iter2 (itemsSlots.first.begin()); iter2!=itemsSlots.first.end(); ++iter2) { // if true then it means slot is equipped already - // check if slot may require swapping if current item is more valueable + // check if slot may require swapping if current item is more valuable if (slots_.at (*iter2)!=end()) { Ptr old = *slots_.at (*iter2); @@ -362,98 +537,48 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) break; } } +} - static const ESM::Skill::SkillEnum weaponSkills[] = +void MWWorld::InventoryStore::autoEquipShield(const MWWorld::Ptr& actor, TSlots& slots_) +{ + for (ContainerStoreIterator iter(begin(ContainerStore::Type_Armor)); iter != end(); ++iter) { - ESM::Skill::LongBlade, - ESM::Skill::Axe, - ESM::Skill::Spear, - ESM::Skill::ShortBlade, - ESM::Skill::Marksman, - ESM::Skill::BluntWeapon - }; - const size_t weaponSkillsLength = sizeof(weaponSkills) / sizeof(weaponSkills[0]); - - bool weaponSkillVisited[weaponSkillsLength] = { false }; - - for (int i = 0; i < static_cast(weaponSkillsLength); ++i) - { - int max = 0; - int maxWeaponSkill = -1; - - for (int j = 0; j < static_cast(weaponSkillsLength); ++j) + if (iter->get()->mBase->mData.mType != ESM::Armor::Shield) + continue; + if (iter->getClass().canBeEquipped(*iter, actor).first != 1) + continue; + if (iter->getClass().getItemHealth(*iter) <= 0) + continue; + std::pair, bool> shieldSlots = + iter->getClass().getEquipmentSlots(*iter); + if (shieldSlots.first.empty()) + continue; + int slot = shieldSlots.first[0]; + const ContainerStoreIterator& shield = mSlots[slot]; + if (shield != end() + && shield.getType() == Type_Armor && shield->get()->mBase->mData.mType == ESM::Armor::Shield) { - int skillValue = actor.getClass().getSkill(actor, static_cast(weaponSkills[j])); - - if (skillValue > max && !weaponSkillVisited[j]) - { - max = skillValue; - maxWeaponSkill = j; - } - } - - if (maxWeaponSkill == -1) - break; - - max = 0; - ContainerStoreIterator weapon(end()); - - for (ContainerStoreIterator iter(begin(ContainerStore::Type_Weapon)); iter!=end(); ++iter) - { - if (!canActorAutoEquip(actor, *iter)) + if (shield->getClass().getItemHealth(*shield) >= iter->getClass().getItemHealth(*iter)) continue; - - const ESM::Weapon* esmWeapon = iter->get()->mBase; - - if (esmWeapon->mData.mType == ESM::Weapon::Arrow || esmWeapon->mData.mType == ESM::Weapon::Bolt) - continue; - - if (iter->getClass().getEquipmentSkill(*iter) == weaponSkills[maxWeaponSkill]) - { - if (esmWeapon->mData.mChop[1] >= max) - { - max = esmWeapon->mData.mChop[1]; - weapon = iter; - } - - if (esmWeapon->mData.mSlash[1] >= max) - { - max = esmWeapon->mData.mSlash[1]; - weapon = iter; - } - - if (esmWeapon->mData.mThrust[1] >= max) - { - max = esmWeapon->mData.mThrust[1]; - weapon = iter; - } - } } - - if (weapon != end() && weapon->getClass().canBeEquipped(*weapon, actor).first) - { - std::pair, bool> itemsSlots = - weapon->getClass().getEquipmentSlots (*weapon); - - if (!itemsSlots.first.empty()) - { - if (!itemsSlots.second) - { - if (weapon->getRefData().getCount() > 1) - { - unstack(*weapon, actor); - } - } - - int slot = itemsSlots.first.front(); - slots_[slot] = weapon; - } - - break; - } - - weaponSkillVisited[maxWeaponSkill] = true; + slots_[slot] = iter; } +} + +void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) +{ + TSlots slots_; + initSlots (slots_); + + // Disable model update during auto-equip + mUpdatesEnabled = false; + + // Autoequip clothing, armor and weapons. + // Equipping lights is handled in Actors::updateEquippedLight based on environment light. + // Note: creatures do not use the armor mitigation and can equip only shields + // Use a custom logic for them - select shield based on its health instead of armor rating (since it useless for creatures) + autoEquipWeapon(actor, slots_); + autoEquipArmor(actor, slots_); bool changed = false; @@ -476,50 +601,6 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) } } -void MWWorld::InventoryStore::autoEquipShield(const MWWorld::Ptr& actor) -{ - bool updated = false; - - mUpdatesEnabled = false; - for (ContainerStoreIterator iter(begin(ContainerStore::Type_Armor)); iter != end(); ++iter) - { - if (iter->get()->mBase->mData.mType != ESM::Armor::Shield) - continue; - - if (iter->getClass().canBeEquipped(*iter, actor).first != 1) - continue; - - if (iter->getClass().getItemHealth(*iter) <= 0) - continue; - - std::pair, bool> shieldSlots = - iter->getClass().getEquipmentSlots(*iter); - - if (shieldSlots.first.empty()) - continue; - - int slot = shieldSlots.first[0]; - const ContainerStoreIterator& shield = mSlots[slot]; - - if (shield != end() - && shield.getType() == Type_Armor && shield->get()->mBase->mData.mType == ESM::Armor::Shield) - { - if (shield->getClass().getItemHealth(*shield) >= iter->getClass().getItemHealth(*iter)) - continue; - } - - equip(slot, iter, actor); - updated = true; - } - mUpdatesEnabled = true; - - if (updated) - { - fireEquipmentChangedEvent(actor); - updateMagicEffects(actor); - } -} - const MWMechanics::MagicEffects& MWWorld::InventoryStore::getMagicEffects() const { return mMagicEffects; @@ -532,7 +613,7 @@ void MWWorld::InventoryStore::updateMagicEffects(const Ptr& actor) return; // Delay update until the listener is set up - if (!mListener) + if (!mInventoryListener) return; mMagicEffects = MWMechanics::MagicEffects(); @@ -603,7 +684,7 @@ void MWWorld::InventoryStore::updateMagicEffects(const Ptr& actor) // During first auto equip, we don't play any sounds. // Basically we don't want sounds when the actor is first loaded, // the items should appear as if they'd always been equipped. - mListener->permanentEffectAdded(magicEffect, !mFirstAutoEquip); + mInventoryListener->permanentEffectAdded(magicEffect, !mFirstAutoEquip); } if (magnitude) @@ -737,6 +818,9 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor mSelectedEnchantItem = end(); } + if (mListener) + mListener->itemRemoved(item, retCount); + return retCount; } @@ -822,12 +906,12 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipItemQuantity(con MWWorld::InventoryStoreListener* MWWorld::InventoryStore::getInvListener() { - return mListener; + return mInventoryListener; } void MWWorld::InventoryStore::setInvListener(InventoryStoreListener *listener, const Ptr& actor) { - mListener = listener; + mInventoryListener = listener; updateMagicEffects(actor); } @@ -835,8 +919,8 @@ void MWWorld::InventoryStore::fireEquipmentChangedEvent(const Ptr& actor) { if (!mUpdatesEnabled) return; - if (mListener) - mListener->equipmentChanged(); + if (mInventoryListener) + mInventoryListener->equipmentChanged(); // if player, update inventory window /* diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index 49991c1646..e99a99bfa0 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -69,7 +69,7 @@ namespace MWWorld MWMechanics::MagicEffects mMagicEffects; - InventoryStoreListener* mListener; + InventoryStoreListener* mInventoryListener; // Enables updates of magic effects and actor model whenever items are equipped or unequipped. // This is disabled during autoequip to avoid excessive updates @@ -94,6 +94,10 @@ namespace MWWorld TSlots mSlots; + void autoEquipWeapon(const MWWorld::Ptr& actor, TSlots& slots_); + void autoEquipArmor(const MWWorld::Ptr& actor, TSlots& slots_); + void autoEquipShield(const MWWorld::Ptr& actor, TSlots& slots_); + // selected magic item (for using enchantments of type "Cast once" or "Cast when used") ContainerStoreIterator mSelectedEnchantItem; @@ -164,9 +168,6 @@ namespace MWWorld void autoEquip (const MWWorld::Ptr& actor); ///< Auto equip items according to stats and item value. - void autoEquipShield(const MWWorld::Ptr& actor); - ///< Auto-equip the shield with most health. - const MWMechanics::MagicEffects& getMagicEffects() const; ///< Return magic effects from worn items. diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 8edb3d7657..328a10cd1b 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -396,7 +396,8 @@ namespace Resource { const char* reserved[] = {"Head", "Neck", "Chest", "Groin", "Right Hand", "Left Hand", "Right Wrist", "Left Wrist", "Shield Bone", "Right Forearm", "Left Forearm", "Right Upper Arm", "Left Upper Arm", "Right Foot", "Left Foot", "Right Ankle", "Left Ankle", "Right Knee", "Left Knee", "Right Upper Leg", "Left Upper Leg", "Right Clavicle", - "Left Clavicle", "Weapon Bone", "Tail", "Bip01", "Root Bone", "BoneOffset", "AttachLight", "ArrowBone", "Camera"}; + "Left Clavicle", "Weapon Bone", "Tail", "Bip01", "Root Bone", "BoneOffset", "AttachLight", "Arrow", "Camera"}; + reservedNames = std::vector(reserved, reserved + sizeof(reserved)/sizeof(reserved[0])); for (unsigned int i=0; i Date: Mon, 5 Nov 2018 16:37:47 +0100 Subject: [PATCH 2/6] bump /extern/recastnavigation to commit 3087e805b02d5eb8fff7851234fa2b3f71290eba; fixes clang warning about missing delete: https://github.com/recastnavigation/recastnavigation/issues/359 --- extern/recastnavigation/.id | 2 +- extern/recastnavigation/Recast/Include/RecastAlloc.h | 1 + extern/recastnavigation/RecastDemo/premake5.lua | 5 ++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extern/recastnavigation/.id b/extern/recastnavigation/.id index c4937ac232..4ff8c7be69 100644 --- a/extern/recastnavigation/.id +++ b/extern/recastnavigation/.id @@ -1 +1 @@ -7bfd9a1d4caccf61e0485b2b05b29966348a8b39 +3087e805b02d5eb8fff7851234fa2b3f71290eba diff --git a/extern/recastnavigation/Recast/Include/RecastAlloc.h b/extern/recastnavigation/Recast/Include/RecastAlloc.h index 3e78496d1b..e436af9a01 100644 --- a/extern/recastnavigation/Recast/Include/RecastAlloc.h +++ b/extern/recastnavigation/Recast/Include/RecastAlloc.h @@ -66,6 +66,7 @@ void rcFree(void* ptr); /// and STL. struct rcNewTag {}; inline void* operator new(size_t, const rcNewTag&, void* p) { return p; } +inline void operator delete(void*, const rcNewTag&, void*) {} /// Signed to avoid warnnings when comparing to int loop indexes, and common error with comparing to zero. /// MSVC2010 has a bug where ssize_t is unsigned (!!!). diff --git a/extern/recastnavigation/RecastDemo/premake5.lua b/extern/recastnavigation/RecastDemo/premake5.lua index 8545c6d7c8..d2a6343f1b 100644 --- a/extern/recastnavigation/RecastDemo/premake5.lua +++ b/extern/recastnavigation/RecastDemo/premake5.lua @@ -41,8 +41,7 @@ solution "recastnavigation" -- warnings "Extra" uses /W4 which is too aggressive for us, so use W3 instead. -- Disable: -- * C4351: new behavior for array initialization - -- * C4291: no matching operator delete found; we don't use exceptions, so doesn't matter - buildoptions { "/W3", "/wd4351", "/wd4291" } + buildoptions { "/W3", "/wd4351" } filter "platforms:Win32" architecture "x32" @@ -170,7 +169,7 @@ project "RecastDemo" } postbuildcommands { -- Copy the SDL2 dll to the Bin folder. - '{COPY} "%{wks.location}../../Contrib/SDL/lib/%{cfg.architecture:gsub("x86_64", "x64")}/SDL2.dll" "%{cfg.targetdir}"' + '{COPY} "%{path.getabsolute("Contrib/SDL/lib/" .. cfg.architecture:gsub("x86_64", "x64") .. "/SDL2.dll")}" "%{cfg.targetdir}"' } -- mac includes and libs From fcb2cde1dd0834b855f455ddf609506215acd1c7 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Wed, 7 Nov 2018 17:47:05 +0300 Subject: [PATCH 3/6] Tweak the default chargen and level up messages --- files/openmw.cfg | 80 ++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/files/openmw.cfg b/files/openmw.cfg index 9c51df3899..f2972aef48 100644 --- a/files/openmw.cfg +++ b/files/openmw.cfg @@ -117,69 +117,69 @@ fallback=FontColor_color_negative,200,60,30 fallback=FontColor_color_count,223,201,159 # leveling -fallback=Level_Up_Level2,You've just realized that there is more to the life than you thought, the last few days have opened your eyes. An uncertain future awaits you. -fallback=Level_Up_Level3,Hard work and determination have served you well, keep this up and you'll be bound for great things. -fallback=Level_Up_Level4,It's as clear as day to you now, all that time you pissed away in your youth. This... this is life and all the experience you've gained giving you the tools you need to succeed in life. -fallback=Level_Up_Level5,Things seem to be working out for you, the world is opening up as you become more capable. -fallback=Level_Up_Level6,There is so much more to learn but with every push you gain more knowledge, only increasing your thirst for it. -fallback=Level_Up_Level7,You've dug deep within yourself, thinking you'll finally be who you thought you would be... but there is more and you keep digging. +fallback=Level_Up_Level2,The last few days have opened your eyes: you realize now that there is more to the life than you thought. An uncertain future awaits you. +fallback=Level_Up_Level3,You finally come to understand that great doings start from hard work and determination. +fallback=Level_Up_Level4,After reminiscing upon all that time you lost in your youth, it's as clear as day to you now: this - this is the life, and all the experience you gain gives you the tools you need to succeed in it. +fallback=Level_Up_Level5,Things seem to be working out for you. As you become more capable, the world is opening up. +fallback=Level_Up_Level6,With every push you did to gain knowledge, and yet your thirst for it increased, you realize there is so much more to learn still. +fallback=Level_Up_Level7,You dig deep within yourself, trying to finally become the one who you thought you would be... but there's much to keep digging through. fallback=Level_Up_Level8,Success doesn't come easily, but you make it appear that way to others. -fallback=Level_Up_Level9,Everything is becoming second nature to you but also just a bit more dangerous. -fallback=Level_Up_Level10,Nothing in life is easy or it wouldn't be worth the blood, sweat and tears. +fallback=Level_Up_Level9,Everything may slowly become a second nature to you, but it also can turn just a bit more dangerous. +fallback=Level_Up_Level10,Nothing in life is easy, or it wouldn't have been worth the blood, sweat and tears. fallback=Level_Up_Level11,Working smarter, not harder is something even a barbarian could benefit from. -fallback=Level_Up_Level12,Some would call you crazy for keeping at it, but you know better. It'll all pay off, it already has. -fallback=Level_Up_Level13,One nights sleep was all the difference between between something being difficult and then it being easy. -fallback=Level_Up_Level14,Waking up today was the best day ever for you, you await more days like these in your future. -fallback=Level_Up_Level15,Ouch! You lean back feeling your whole body for what seems the first time. You'll be more mindful in the future, you only have by one life. -fallback=Level_Up_Level16,Trusting your instincts have gotten you this far, but you'll need to be smarter to keep from being dead. +fallback=Level_Up_Level12,Perhaps some would call you delusional for keeping at it, but you know better. Your dilegence has already paid off, after all. +fallback=Level_Up_Level13,One night's sleep is all the difference between something being difficult and something being easy. +fallback=Level_Up_Level14,After waking up, you wonder: could today be the best day in your life? You never know. +fallback=Level_Up_Level15,Ouch! You lean back feeling your whole body for what seems the first time. You'll be more mindful in the future -- you can only live once. +fallback=Level_Up_Level16,Trusting your instincts has gotten you this far, but now it's clear to you that you need to be smarter to survive. fallback=Level_Up_Level17,You're forging your spirit in the crucible that is experience. Be ever vigilant. -fallback=Level_Up_Level18,The frustrations of the day before melt away as you wake up, today is a new day. -fallback=Level_Up_Level19,Today isn't yesterday, you feel it deep inside but you know that there is still more to this life. -fallback=Level_Up_Level20,Luck has never been a factor in your success, just look at the scars on your body and the trails you've endured. -fallback=Level_Up_Default,Through sheer force of will, you push onwards and upwards. The toil of your persistence has paid off. +fallback=Level_Up_Level18,The frustrations of the day before vanish as you wake up. Today is a new day. +fallback=Level_Up_Level19,Today isn't yesterday, you feel that deep inside. You know that there is still more to this life. +fallback=Level_Up_Level20,Luck has never been a factor in your success -- that's obvious from the scars on your body and from the number of trails you've endured. +fallback=Level_Up_Default,Through sheer force of will, you push onwards and upwards. The toil of your persistence is paying off. # character creation -fallback=Question_1_Question,Before you lies some kind of creation you never seen before, it's hind leg caught in a hunter's trap. You can tell that its leg is broken. +fallback=Question_1_Question,Before you lies a creature you have never seen before. Its hind leg is caught in a hunter's trap, and you can tell that the leg is broken. What will you do? fallback=Question_1_AnswerOne,Pull out you knife for a short and merciful kill. fallback=Question_1_AnswerTwo,Reach into your herbal pouch to find something to ease its suffering before putting it to sleep. -fallback=Question_1_AnswerThree,Leave it alone but take the time to observe and learn from this new creation +fallback=Question_1_AnswerThree,Leave the leg alone, but take the time to observe and learn from this odd creature. fallback=Question_1_Sound,Voice\CharGen\QA1.mp3 -fallback=Question_2_Question,Your mother has given everyone a list of choice, pick one. -fallback=Question_2_AnswerOne,The fence posts need replacing, help your father? -fallback=Question_2_AnswerTwo,Tonight's supper needs a few herbs, head out into the forest to collect them? -fallback=Question_2_AnswerThree,Fish aren't going find their way into the kitchen without your help. Go fishing? +fallback=Question_2_Question,Your mother suggests you to help with work around your family household. Do you decide to... +fallback=Question_2_AnswerOne,Help your father with fence post replacement? +fallback=Question_2_AnswerTwo,Collect a few herbs in the forest for tonight's supper? +fallback=Question_2_AnswerThree,Help the fish to find their way into the kitchen? fallback=Question_2_Sound,Voice\CharGen\QA2.mp3 -fallback=Question_3_Question,One of your brother teases you mercilessly in front of everyone about embarrassing details you would rather be forgotten. -fallback=Question_3_AnswerOne,Give him a black-eye and dare him to keep it up? -fallback=Question_3_AnswerTwo,Beat him to the punch and play it up, if you can control the negative then he can't embarrass you? -fallback=Question_3_AnswerThree,Wait until he sleeps, put his hand in a bowl of water and call everyone around the next day to see the results? +fallback=Question_3_Question,Your brother teases you mercilessly in front of everyone with embarrassing details you would rather have forgotten. +fallback=Question_3_AnswerOne,Give him a black-eye and dare him to keep it up. +fallback=Question_3_AnswerTwo,Beat him to the punch and play it up -- if you can control the negative, then he can't embarrass you. +fallback=Question_3_AnswerThree,Wait until he sleeps, put his hand in a bowl of water and call everyone around the next day to see the results. fallback=Question_3_Sound,Voice\CharGen\QA3.mp3 -fallback=Question_4_Question,Rumor has it that the King's security console has a new tool at their disposal for sniffing out the truth, people able to read minds. -fallback=Question_4_AnswerOne,You recoil at the thought of someone being able to read your thoughts. It's not that you think something that you'll ever act on it? -fallback=Question_4_AnswerTwo,For those who have done nothing, there is nothing to fear. This is just yet another tool for sniffing out thieves, murderers and plots against the crown? -fallback=Question_4_AnswerThree,While you loath the idea of someone reading your mind, you accept that it does have its uses if tempered by law and common sense. You wouldn't believe the mind of a madman for example? +fallback=Question_4_Question,Rumor has it that the King's security console has a new tool at their disposal for sniffing out the truth, which could be used for reading minds. +fallback=Question_4_AnswerOne,You recoil at the thought of someone being able to read your thoughts. It's not that you think something that you'll ever act on it. +fallback=Question_4_AnswerTwo,For those who have done nothing, there is nothing to fear. This is just yet another utility for catching thieves, murderers and plots against the crown. +fallback=Question_4_AnswerThree,While you loath the idea of someone reading your mind, you accept that it does have its uses if tempered by law and common sense. You wouldn't believe the mind of a madman. fallback=Question_4_Sound,Voice\CharGen\QA4.mp3 -fallback=Question_5_Question,You're off to market for supplies. You notice that one of the merchants had given you too much back in change. -fallback=Question_5_AnswerOne,How dreadful, what if it was you. You head back to the merchant? -fallback=Question_5_AnswerTwo,Happy days indeed, you put that extra money towards the needs of your family? -fallback=Question_5_AnswerThree,You win some and you lose some. In this case you won and they lost, the oversight is the merchant's problem, not yours? +fallback=Question_5_Question,You are returning home from the market after acquiring supplies, and notice that one of the merchants had given you too much back in change. +fallback=Question_5_AnswerOne,How dreadful, what if it was you? You head back to the merchant. +fallback=Question_5_AnswerTwo,Happy days indeed. Put that extra money towards the needs of your family? +fallback=Question_5_AnswerThree,You win some and you lose some. In this case you have won and they have lost, and the oversight is the merchant's problem, not yours, right? fallback=Question_5_Sound,Voice\CharGen\QA5.mp3 fallback=Question_6_Question,While at market, a noble yells out to the city watch about a theft. As you turn around a man bumps into you and drops a sack, startled he darts into the crowd. fallback=Question_6_AnswerOne,You pick up the sack and head over to the noble to return his property? fallback=Question_6_AnswerTwo,Just walk away, the last thing you need is someone thinking you had anything to do with it? -fallback=Question_6_AnswerThree,Finders, keepers... you whistle as you walk away? +fallback=Question_6_AnswerThree,Finders, keepers... you whistle as you walk away with the bag hidden? fallback=Question_6_Sound,Voice\CharGen\QA6.mp3 fallback=Question_7_Question,If it's one thing you hate, it's cleaning out the stalls. It has to be done before sunset before the critters return. On your way there an old friend greets you and offers to help if you promise to help them in the future. fallback=Question_7_AnswerOne,You thank him for the offer but would rather get it over with and not make promises you can't keep? fallback=Question_7_AnswerTwo,You reason that two pairs of hands are better than one regardless of the task? -fallback=Question_7_AnswerThree,Sounds great, anything is better than cleaning the stalls. +fallback=Question_7_AnswerThree,You say that it sounds great and anything is better than cleaning the stalls? fallback=Question_7_Sound,Voice\CharGen\QA7.mp3 -fallback=Question_8_Question,You just climbed down ladder from working on the roof. You're mother thanks you for the hard work but just at the moment you notice the hammer about to fall down on her head. +fallback=Question_8_Question,You just climbed down the ladder after working on the roof. Your mother thanks you for the hard work but just at the moment you notice that a hammer is about to fall down on her head. fallback=Question_8_AnswerOne,You lunge at your mother, pushing her out the way while the hammer falls on top of you? -fallback=Question_8_AnswerTwo,Use the ladder to intercept the hammer before it lands on her? +fallback=Question_8_AnswerTwo,Try to use the ladder to intercept the hammer before it lands on her? fallback=Question_8_AnswerThree,Warn her to take a step back? fallback=Question_8_Sound,Voice\CharGen\QA8.mp3 -fallback=Question_9_Question,It's the end of the week and you just got your wages for your hard work. You decide to take the quick way back home, darting into a alley only to be confronted by ruffians who demand that you empty your pockets. +fallback=Question_9_Question,It's the end of the week, and you have just got your wages for your hard work. You decide to take the quick way back home, darting into a alley only to be confronted by ruffians who demand that you empty your pockets. fallback=Question_9_AnswerOne,You tell them to go pack sand, planting your feet and raising your fists? fallback=Question_9_AnswerTwo,Acting dejected, you turn your wages over. You know that you can count on your friends to help you track these brigands down and recover what's yours? fallback=Question_9_AnswerThree,Tossing the sack into the air, you charge the leader who's attention is squarely focused on the coins in flight? From 8fd71fe4ad8e8a6aaa8d1e71abfb3db16e9fd0bd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 4 Nov 2018 12:42:34 +0100 Subject: [PATCH 4/6] fix rain delay when exiting water When the particle system updates its internal state noting that it's been culled, it stops emitting any further particles. Prevent it from having that knowledge. v2: Fix off-by-one-frame error following review by @AnyOldName3 --- CHANGELOG.md | 1 + apps/openmw/mwrender/sky.cpp | 19 +++++++++++++++++-- apps/openmw/mwrender/sky.hpp | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d50c96ef49..7880bb2a5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ 0.46.0 ------ + Bug #4540: Rain delay when exiting water Feature #2229: Improve pathfinding AI Feature #3442: Default values for fallbacks from ini file Task #4686: Upgrade media decoder to a more current FFmpeg API diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index d6a0b9f019..0ea0905a61 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -401,11 +401,15 @@ public: { } - virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) + bool isUnderwater() { osg::Vec3f eyePoint = mCameraRelativeTransform->getLastEyePoint(); + return mEnabled && eyePoint.z() < mWaterLevel; + } - if (mEnabled && eyePoint.z() < mWaterLevel) + virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) + { + if (isUnderwater()) return; traverse(node, nv); @@ -1575,6 +1579,8 @@ void SkyManager::update(float duration) mRainIntensityUniform->set((float) mWeatherAlpha); } + switchUnderwaterRain(); + if (mIsStorm) { osg::Quat quat; @@ -1626,6 +1632,15 @@ void SkyManager::updateRainParameters() } } +void SkyManager::switchUnderwaterRain() +{ + if (!mRainParticleSystem) + return; + + bool freeze = mUnderwaterSwitch->isUnderwater(); + mRainParticleSystem->setFrozen(freeze); +} + void SkyManager::setWeather(const WeatherResult& weather) { if (!mCreated) return; diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index a9345cdb41..e70f165213 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -180,6 +180,7 @@ namespace MWRender void createRain(); void destroyRain(); + void switchUnderwaterRain(); void updateRainParameters(); Resource::SceneManager* mSceneManager; From ad368346718eb163159468abce09e7b4ee932838 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 8 Nov 2018 12:44:48 +0400 Subject: [PATCH 5/6] Fix some compiler warnings --- apps/opencs/model/world/infoselectwrapper.cpp | 1 - apps/wizard/existinginstallationpage.cpp | 8 +++++--- components/contentselector/model/contentmodel.cpp | 2 +- components/myguiplatform/myguirendermanager.cpp | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/world/infoselectwrapper.cpp b/apps/opencs/model/world/infoselectwrapper.cpp index 3bc9bf4d2f..3200d39fcc 100644 --- a/apps/opencs/model/world/infoselectwrapper.cpp +++ b/apps/opencs/model/world/infoselectwrapper.cpp @@ -520,7 +520,6 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getConditionFloatRange const float FloatMax = std::numeric_limits::infinity(); const float FloatMin = -std::numeric_limits::infinity(); const float Epsilon = std::numeric_limits::epsilon(); - const std::pair InvalidRange(FloatMax, FloatMin); float value = mConstSelect.mValue.getFloat(); diff --git a/apps/wizard/existinginstallationpage.cpp b/apps/wizard/existinginstallationpage.cpp index 3ec98a9353..4c05f5500e 100644 --- a/apps/wizard/existinginstallationpage.cpp +++ b/apps/wizard/existinginstallationpage.cpp @@ -31,11 +31,13 @@ void Wizard::ExistingInstallationPage::initializePage() // Hide the default item if there are installations to choose from installationsList->item(0)->setHidden(!paths.isEmpty()); - foreach (const QString &path, paths) { - QListWidgetItem *item = new QListWidgetItem(path); - + foreach (const QString &path, paths) + { if (installationsList->findItems(path, Qt::MatchExactly).isEmpty()) + { + QListWidgetItem *item = new QListWidgetItem(path); installationsList->addItem(item); + } } connect(installationsList, SIGNAL(currentTextChanged(QString)), diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 41407ec885..39e91d5a39 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -168,7 +168,7 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int case Qt::DisplayRole: { if (column >=0 && column <=EsmFile::FileProperty_GameFile) - return file->fileProperty(static_cast(column)); + return file->fileProperty(static_cast(column)); return QVariant(); } diff --git a/components/myguiplatform/myguirendermanager.cpp b/components/myguiplatform/myguirendermanager.cpp index 845d0c4849..4781ef3fc5 100644 --- a/components/myguiplatform/myguirendermanager.cpp +++ b/components/myguiplatform/myguirendermanager.cpp @@ -134,9 +134,9 @@ public: { state->bindVertexBufferObject(bufferobject); - glVertexPointer(3, GL_FLOAT, sizeof(MyGUI::Vertex), (char*)nullptr); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MyGUI::Vertex), (char*)nullptr + 12); - glTexCoordPointer(2, GL_FLOAT, sizeof(MyGUI::Vertex), (char*)nullptr + 16); + glVertexPointer(3, GL_FLOAT, sizeof(MyGUI::Vertex), static_cast(0)); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MyGUI::Vertex), static_cast(0) + 12); + glTexCoordPointer(2, GL_FLOAT, sizeof(MyGUI::Vertex), static_cast(0) + 16); } else { From 9ae077c0332ded59c95a50348524df336b029eb7 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Thu, 8 Nov 2018 17:38:09 +0100 Subject: [PATCH 6/6] use c++11 std::align from (#2026) * use c++11 std::align from * for Ubuntu, use gcc5 instead of 4.8 * use travis to set gcc to 5 eval and sudo * use eval in .travis.yml * use gcc-8 * replace precise with trusty llvm toolchain, because we have been using trusty for awhile now * push things to matrix, so we can support multiple releases if we want * we should not be allowing for failures, we are ready to start trusting clang and its analyzer * scan-build was pushed to another package * use gcc-8 still but wrap in scan-build * travis.yml cleanup, have output of scripts go to stdout, make search for substring a regex use double [] fix missing , use bash to use regex black spaces matter * set human readable names for our various builds, split out our static analysis between openmw and openmw-cs * test if not set, then set otherwise ignore * use quotes * do not eval it, set it in travis env * no more && * what does clang7 have to say? * use sourceline for now * use clang-7 instead of clang-7.0 * yes, llvm-toolchain-trusty-7 not llvm-toolchain-trusty-7.0 * for static analysis, openmw is compiled and checked on its own while openmw-cs is build with all the rest. this might change in the future. and actually do it the other way around --- .travis.yml | 54 +++++++++++++------ CI/before_install.linux.sh | 7 +-- CI/before_script.linux.sh | 20 +++++-- .../detournavigator/recastallocutils.hpp | 11 ---- .../detournavigator/recasttempallocator.hpp | 2 +- 5 files changed, 59 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 781f498e2e..6d8970b67b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,4 @@ -os: - - linux - - osx -osx_image: xcode9.4 language: cpp -sudo: required -dist: trusty branches: only: - master @@ -20,16 +14,16 @@ addons: sources: - sourceline: 'ppa:openmw/openmw' - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.6 + - llvm-toolchain-trusty-7 packages: [ # Dev - cmake, clang-3.6, libunshield-dev, libtinyxml-dev, + cmake, clang-7, clang-tools-7, gcc-8, g++-8, # Boost libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev, # FFmpeg libavcodec-dev, libavformat-dev, libavutil-dev, libswscale-dev, - # Audio & Video - libsdl2-dev, libqt4-dev, libopenal-dev, + # Audio, Video and Misc. deps + libsdl2-dev, libqt4-dev, libopenal-dev, libunshield-dev, libtinyxml-dev, # The other ones from OpenMW ppa libbullet-dev, libswresample-dev, libopenscenegraph-3.4-dev, libmygui-dev ] @@ -44,18 +38,44 @@ addons: branch_pattern: coverity_scan matrix: include: - - os: linux + - name: OpenMW (all) on MacOS xcode9.4 + os: osx + osx_image: xcode9.4 + - name: OpenMW (all) on Ubuntu Trusty GCC-8 + os: linux + dist: trusty + sudo: required env: - ANALYZE="scan-build-3.6 --use-cc clang-3.6 --use-c++ clang++-3.6 " + - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" + - name: OpenMW (openmw) on Ubuntu Trusty Clang-7 with Static Analysis + os: linux + dist: trusty + sudo: required + env: + - MATRIX_EVAL="CC=clang-7 && CXX=clang++-7" + - ANALYZE="scan-build-7 --use-cc clang-7 --use-c++ clang++-7" + - BUILD_OPENMW_CS="OFF" compiler: clang - allow_failures: - - env: ANALYZE="scan-build-3.6 --use-cc clang-3.6 --use-c++ clang++-3.6 " + - name: OpenMW (openmw-cs) on Ubuntu Trusty Clang-7 with Static Analysis + os: linux + dist: trusty + sudo: required + env: + - MATRIX_EVAL="CC=clang-7 && CXX=clang++-7" + - ANALYZE="scan-build-7 --use-cc clang-7 --use-c++ clang++-7" + - BUILD_OPENMW="OFF" + compiler: clang +# allow_failures: +# - name: OpenMW (openmw) on Ubuntu Trusty Clang-7 with Static Analysis -before_install: ./CI/before_install.${TRAVIS_OS_NAME}.sh -before_script: ./CI/before_script.${TRAVIS_OS_NAME}.sh +before_install: + - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then eval "${MATRIX_EVAL}"; fi + - ./CI/before_install.${TRAVIS_OS_NAME}.sh +before_script: + - ./CI/before_script.${TRAVIS_OS_NAME}.sh script: - cd ./build - - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then ${ANALYZE}make -j3; fi + - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then ${ANALYZE} make -j3; fi - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "osx" ]; then make package; fi - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./openmw_test_suite; fi - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ]; then cd .. && ./CI/check_tabs.sh; fi diff --git a/CI/before_install.linux.sh b/CI/before_install.linux.sh index 1ec88fb9e9..fd4e4829c9 100755 --- a/CI/before_install.linux.sh +++ b/CI/before_install.linux.sh @@ -1,3 +1,4 @@ -#!/bin/sh -e -sudo ln -s /usr/bin/clang-3.6 /usr/local/bin/clang -sudo ln -s /usr/bin/clang++-3.6 /usr/local/bin/clang++ +#!/bin/bash -ex + +sudo ln -sf /usr/bin/clang-7 /usr/local/bin/clang +sudo ln -sf /usr/bin/clang++-7 /usr/local/bin/clang++ diff --git a/CI/before_script.linux.sh b/CI/before_script.linux.sh index dd879989a8..c8c4f8f85d 100755 --- a/CI/before_script.linux.sh +++ b/CI/before_script.linux.sh @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/bash -ex free -m @@ -8,8 +8,22 @@ GOOGLETEST_DIR="$(pwd)/googletest/build" mkdir build cd build export CODE_COVERAGE=1 -if [ "${CC}" = "clang" ]; then export CODE_COVERAGE=0; fi -${ANALYZE}cmake \ + +if [[ "${CC}" =~ "clang" ]]; then export CODE_COVERAGE=0; fi +if [[ -z "${BUILD_OPENMW}" ]]; then export BUILD_OPENMW=ON; fi +if [[ -z "${BUILD_OPENMW_CS}" ]]; then export BUILD_OPENMW_CS=ON; fi + +${ANALYZE} cmake \ + -DBUILD_OPENMW=${BUILD_OPENMW} \ + -DBUILD_OPENCS=${BUILD_OPENMW_CS} \ + -DBUILD_LAUNCHER=${BUILD_OPENMW_CS} \ + -DBUILD_BSATOOL=${BUILD_OPENMW_CS} \ + -DBUILD_ESMTOOL=${BUILD_OPENMW_CS} \ + -DBUILD_MWINIIMPORTER=${BUILD_OPENMW_CS} \ + -DBUILD_ESSIMPORTER=${BUILD_OPENMW_CS} \ + -DBUILD_WIZARD=${BUILD_OPENMW_CS} \ + -DBUILD_NIFTEST=${BUILD_OPENMW_CS} \ + -DBUILD_MYGUI_PLUGIN=${BUILD_OPENMW_CS} \ -DBUILD_WITH_CODE_COVERAGE=${CODE_COVERAGE} \ -DBUILD_UNITTESTS=1 \ -DCMAKE_INSTALL_PREFIX=/usr \ diff --git a/components/detournavigator/recastallocutils.hpp b/components/detournavigator/recastallocutils.hpp index 7b083d139e..69a5cfa8b5 100644 --- a/components/detournavigator/recastallocutils.hpp +++ b/components/detournavigator/recastallocutils.hpp @@ -86,17 +86,6 @@ namespace DetourNavigator return static_cast(ptr) + 1; } - // TODO: use std::align - inline void* align(std::size_t align, std::size_t size, void*& ptr, std::size_t& space) noexcept - { - const auto intptr = reinterpret_cast(ptr); - const auto aligned = (intptr - 1u + align) & - align; - const auto diff = aligned - intptr; - if ((size + diff) > space) - return nullptr; - space -= diff; - return ptr = reinterpret_cast(aligned); - } } #endif diff --git a/components/detournavigator/recasttempallocator.hpp b/components/detournavigator/recasttempallocator.hpp index e369b4224e..fbf9fd62c1 100644 --- a/components/detournavigator/recasttempallocator.hpp +++ b/components/detournavigator/recasttempallocator.hpp @@ -21,7 +21,7 @@ namespace DetourNavigator std::size_t space = mStack.size() - getUsedSize(); void* top = mTop; const auto itemSize = 2 * sizeof(std::size_t) + size; - if (rcUnlikely(!align(sizeof(std::size_t), itemSize, top, space))) + if (rcUnlikely(!std::align(sizeof(std::size_t), itemSize, top, space))) return nullptr; setTempPtrBufferType(top, BufferType_temp); setTempPtrPrev(top, mPrev);