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(); diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 21a0606a9..3c336557f 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -142,6 +142,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) @@ -346,13 +358,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/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; iresetReference(); mConsole->resetReference(); + mInventoryWindow->clear(); + mSelectedSpell.clear(); mCustomMarkers.clear(); diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index ea43a8cd7..c1adb89e9 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -818,6 +818,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/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index e88e5e537..d14a8f49c 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -531,8 +531,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)) @@ -547,7 +546,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/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); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 3cbce9f93..09090f50a 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -338,12 +338,16 @@ namespace MWMechanics winMgr->setValue(fbar, stats.getFatigue()); } - if(stats.getTimeToStartDrowning() != mWatchedTimeToStartDrowning) + float timeToDrown = stats.getTimeToStartDrowning(); + + if(timeToDrown != 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) + + 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 e9ca8f474..003055316 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); 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) { 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; 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()) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 351243a84..e7ea093f0 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -580,13 +580,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);