From fb0c4700a4a99573279fc2fbd9c0f852b54f8743 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 14 Apr 2017 23:19:48 +0400 Subject: [PATCH 01/10] Save a proto gender in racemenu --- apps/openmw/mwgui/race.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 184ce0775..c4a27f7ed 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -146,6 +146,7 @@ namespace MWGui const ESM::NPC& proto = mPreview->getPrototype(); setRaceId(proto.mRace); + setGender(proto.isMale() ? GM_Male : GM_Female); recountParts(); for (unsigned int i=0; i Date: Fri, 14 Apr 2017 23:21:20 +0400 Subject: [PATCH 02/10] Reviewmenu: read name, race, class and birthsign from player stats (fixes bug #2628) --- apps/openmw/mwgui/charactercreation.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 9464daaf6..b2c9f1038 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -13,6 +13,7 @@ #include "../mwworld/class.hpp" #include "../mwworld/esmstore.hpp" +#include "../mwworld/player.hpp" #include "textinput.hpp" #include "race.hpp" @@ -230,10 +231,19 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog); mReviewDialog = 0; mReviewDialog = new ReviewDialog(); - mReviewDialog->setPlayerName(mPlayerName); - mReviewDialog->setRace(mPlayerRaceId); - mReviewDialog->setClass(mPlayerClass); - mReviewDialog->setBirthSign(mPlayerBirthSignId); + + MWBase::World *world = MWBase::Environment::get().getWorld(); + + const ESM::NPC *playerNpc = world->getPlayerPtr().get()->mBase; + + const MWWorld::Player player = world->getPlayer(); + + const ESM::Class *playerClass = world->getStore().get().find(playerNpc->mClass); + + mReviewDialog->setPlayerName(playerNpc->mName); + mReviewDialog->setRace(playerNpc->mRace); + mReviewDialog->setClass(*playerClass); + mReviewDialog->setBirthSign(player.getBirthSign()); { MWWorld::Ptr player = MWMechanics::getPlayer(); From c3fd327bb29452cd5cc2b977ee79ebc83edc20f4 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 16 Apr 2017 22:15:25 +0400 Subject: [PATCH 03/10] Fixed drowning widget initialization --- apps/openmw/mwmechanics/actors.cpp | 6 ++++++ apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 14 +++++++++----- apps/openmw/mwmechanics/npcstats.cpp | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 88fee8ef1..1ae0e36a9 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -803,6 +803,12 @@ namespace MWMechanics CharacterController* ctrl = it->second->getCharacterController(); NpcStats &stats = ptr.getClass().getNpcStats(ptr); + + // When npc stats are just initialized, mTimeToStartDrowning == -1 and we should get value from GMST + static const int fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get().find("fHoldBreathTime")->getFloat(); + if (stats.getTimeToStartDrowning() == -1.f) + stats.setTimeToStartDrowning(fHoldBreathTime); + MWBase::World *world = MWBase::Environment::get().getWorld(); bool knockedOutUnderwater = (ctrl->isKnockedOut() && world->isUnderwater(ptr.getCell(), osg::Vec3f(ptr.getRefData().getPosition().asVec3()))); if((world->isSubmerged(ptr) || knockedOutUnderwater) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 34269d793..6145e7a29 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -328,12 +328,16 @@ namespace MWMechanics winMgr->setValue(fbar, stats.getFatigue()); } - if(stats.getTimeToStartDrowning() != mWatchedTimeToStartDrowning) - { - const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get() + static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get() .find("fHoldBreathTime")->getFloat(); - mWatchedTimeToStartDrowning = stats.getTimeToStartDrowning(); - if(stats.getTimeToStartDrowning() >= fHoldBreathTime) + + float timeToDrown = stats.getTimeToStartDrowning(); + + if(timeToDrown != mWatchedTimeToStartDrowning) + { + mWatchedTimeToStartDrowning = timeToDrown; + + if(timeToDrown >= fHoldBreathTime || timeToDrown == -1.0) // -1.0 is a special value during initialization winMgr->setDrowningBarVisibility(false); else { diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 0b016e69d..41f2a9b51 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -30,7 +30,7 @@ MWMechanics::NpcStats::NpcStats() , mBounty(0) , mWerewolfKills (0) , mLevelProgress(0) -, mTimeToStartDrowning(20.0) +, mTimeToStartDrowning(-1.0) // set breath to special value, it will be replaced during actor update , mIsWerewolf(false) { mSkillIncreases.resize (ESM::Attribute::Length, 0); From 3c4c47d1e604a1c18a990a658229e1b4b4ab3109 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 19 Apr 2017 15:52:15 +0400 Subject: [PATCH 04/10] Reduced scope of fHoldBreathTime variable --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 6145e7a29..930049ba0 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -328,13 +328,13 @@ namespace MWMechanics winMgr->setValue(fbar, stats.getFatigue()); } - static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get() - .find("fHoldBreathTime")->getFloat(); - float timeToDrown = stats.getTimeToStartDrowning(); if(timeToDrown != mWatchedTimeToStartDrowning) { + static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get() + .find("fHoldBreathTime")->getFloat(); + mWatchedTimeToStartDrowning = timeToDrown; if(timeToDrown >= fHoldBreathTime || timeToDrown == -1.0) // -1.0 is a special value during initialization From c65587558492f0cdd699fea5249149228602a858 Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 20 Apr 2017 00:28:27 +0900 Subject: [PATCH 05/10] Change mWaterEnabled from float to bool --- apps/openmw/mwphysics/physicssystem.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 3312f10a0..81385d675 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -211,7 +211,7 @@ namespace MWPhysics float mTimeAccum; float mWaterHeight; - float mWaterEnabled; + bool mWaterEnabled; std::auto_ptr mWaterCollisionObject; std::auto_ptr mWaterCollisionShape; From 5a00b239accf24367860e2217918c861ce9532de Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 20 Apr 2017 00:35:27 +0900 Subject: [PATCH 06/10] Reduce scope of variables --- apps/openmw/mwmechanics/aicombat.cpp | 6 ++++-- apps/openmw/mwrender/animation.cpp | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 17005f235..d111eb127 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -500,8 +500,7 @@ namespace MWMechanics { // get the range of the target's weapon float rangeAttackOfTarget = 0.f; - bool isRangedCombat = false; - MWWorld::Ptr targetWeapon = MWWorld::Ptr(); + MWWorld::Ptr targetWeapon = MWWorld::Ptr(); const MWWorld::Class& targetClass = target.getClass(); if (targetClass.hasInventoryStore(target)) @@ -516,7 +515,10 @@ namespace MWMechanics boost::shared_ptr targetWeaponAction (new ActionWeapon(targetWeapon)); if (targetWeaponAction.get()) + { + bool isRangedCombat = false; rangeAttackOfTarget = targetWeaponAction->getCombatRange(isRangedCombat); + } // apply sideway movement (kind of dodging) with some probability // if actor is within range of target's weapon diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index ba4307c89..fe20ac437 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1058,11 +1058,9 @@ namespace MWRender float timepassed = duration * state.mSpeedMult; while(state.mPlaying) { - float targetTime; - if (!state.shouldLoop()) { - targetTime = state.getTime() + timepassed; + float targetTime = state.getTime() + timepassed; if(textkey == textkeys.end() || textkey->first > targetTime) { if(mAccumCtrl && state.mTime == mAnimationTimePtr[0]->getTimePtr()) From f299f26720004e2e7b3f8ed0ebb65d29ea60ced4 Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 20 Apr 2017 00:42:53 +0900 Subject: [PATCH 07/10] Remove unused variable --- apps/openmw/mwworld/scene.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index e27c0b585..2467af646 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -538,13 +538,9 @@ namespace MWWorld std::cout << "Changing to interior\n"; // unload - int current = 0; CellStoreCollection::iterator active = mActiveCells.begin(); while (active!=mActiveCells.end()) - { unloadCell (active++); - ++current; - } int refsToLoad = cell->count(); loadingListener->setProgressRange(refsToLoad); From 30081393a6fd2e40825b9836e2d086fbeb1ab91d Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 19 Apr 2017 18:28:49 +0200 Subject: [PATCH 08/10] Add InventoryWindow::clear() as part of world cleanup --- apps/openmw/mwgui/inventorywindow.cpp | 25 ++++++++++++++++++------- apps/openmw/mwgui/inventorywindow.hpp | 2 ++ apps/openmw/mwgui/windowmanagerimp.cpp | 2 ++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 21b90991c..b5a1b50d0 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -136,6 +136,18 @@ namespace MWGui dirtyPreview(); updatePreviewSize(); + + updateEncumbranceBar(); + mItemView->update(); + notifyContentChanged(); + } + + void InventoryWindow::clear() + { + mPtr = MWWorld::Ptr(); + mTradeModel = NULL; + mSortModel = NULL; + mItemView->setModel(NULL); } void InventoryWindow::setGuiMode(GuiMode mode) @@ -340,13 +352,12 @@ namespace MWGui void InventoryWindow::open() { - mPtr = MWMechanics::getPlayer(); - - updateEncumbranceBar(); - - mItemView->update(); - - notifyContentChanged(); + if (!mPtr.isEmpty()) + { + updateEncumbranceBar(); + mItemView->update(); + notifyContentChanged(); + } adjustPanes(); } diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 651bda590..11091c428 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -60,6 +60,8 @@ namespace MWGui void updatePlayer(); + void clear(); + void useItem(const MWWorld::Ptr& ptr); void setGuiMode(GuiMode mode); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 16d1a9c6d..9238e5cfd 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1696,6 +1696,8 @@ namespace MWGui mCompanionWindow->resetReference(); mConsole->resetReference(); + mInventoryWindow->clear(); + mSelectedSpell.clear(); mCustomMarkers.clear(); From 60a2625b897cc5d56ab8c7b8b98bef93166efb2e Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 20 Apr 2017 01:32:36 +0900 Subject: [PATCH 09/10] Add parentheses to clarify calculations --- apps/openmw/mwmechanics/alchemy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 783bbf573..e6e3b4c4e 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -171,10 +171,10 @@ void MWMechanics::Alchemy::updateEffects() if (fPotionT1DurMult<=0) throw std::runtime_error ("invalid gmst: fPotionT1DurMult"); - float magnitude = magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude ? - 1 : (x / fPotionT1MagMul) / magicEffect->mData.mBaseCost; - float duration = magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration ? - 1 : (x / fPotionT1DurMult) / magicEffect->mData.mBaseCost; + float magnitude = (magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude) ? + 1.0f : (x / fPotionT1MagMul) / magicEffect->mData.mBaseCost; + float duration = (magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration) ? + 1.0f : (x / fPotionT1DurMult) / magicEffect->mData.mBaseCost; if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) applyTools (magicEffect->mData.mFlags, magnitude); From e87d2aa1af635f47e4870605312a9ec693cacffd Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 20 Apr 2017 01:47:30 +0900 Subject: [PATCH 10/10] Remove unused function --- apps/openmw/mwphysics/physicssystem.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 5e79e2a09..40805a4b1 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -230,13 +230,6 @@ namespace MWPhysics return direction - project(direction, planeNormal); } - static inline osg::Vec3f reflect(const osg::Vec3& velocity, const osg::Vec3f& normal) - { - return velocity - (normal * (normal * velocity)) * 2; - // ^ dot product - } - - public: static osg::Vec3f traceDown(const MWWorld::Ptr &ptr, const osg::Vec3f& position, Actor* actor, btCollisionWorld* collisionWorld, float maxHeight) {