From 78596cad83b00a1fb9db33c87c84fae0a225707d Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Apr 2013 10:19:09 +0200 Subject: [PATCH 1/8] Fix enchantment points value --- apps/openmw/mwclass/armor.cpp | 4 ++-- apps/openmw/mwclass/armor.hpp | 2 +- apps/openmw/mwclass/book.cpp | 4 ++-- apps/openmw/mwclass/book.hpp | 2 +- apps/openmw/mwclass/clothing.cpp | 4 ++-- apps/openmw/mwclass/clothing.hpp | 2 +- apps/openmw/mwclass/weapon.cpp | 4 ++-- apps/openmw/mwclass/weapon.hpp | 2 +- apps/openmw/mwgui/enchantingdialog.cpp | 5 +++-- apps/openmw/mwmechanics/enchanting.cpp | 4 ++-- apps/openmw/mwmechanics/enchanting.hpp | 4 ++-- apps/openmw/mwworld/class.cpp | 2 +- apps/openmw/mwworld/class.hpp | 2 +- components/esm/loadweap.hpp | 2 +- 14 files changed, 22 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 8a8f72c888..fa0d47107f 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -375,12 +375,12 @@ namespace MWClass return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell); } - short Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const + float Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const { MWWorld::LiveCellRef *ref = ptr.get(); - return ref->mBase->mData.mEnchant; + return ref->mBase->mData.mEnchant/10.f; } bool Armor::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index 9b8e9dd149..964ba71469 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -77,7 +77,7 @@ namespace MWClass virtual std::string getModel(const MWWorld::Ptr &ptr) const; - virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; + virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; }; diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index b658295f85..472d17da9c 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -176,12 +176,12 @@ namespace MWClass return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell); } - short Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const + float Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const { MWWorld::LiveCellRef *ref = ptr.get(); - return ref->mBase->mData.mEnchant; + return ref->mBase->mData.mEnchant/10.f; } bool Book::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 3f083f5525..3d728e5064 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -58,7 +58,7 @@ namespace MWClass virtual std::string getModel(const MWWorld::Ptr &ptr) const; - virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; + virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; }; diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 3072f852d5..599efa51a9 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -295,12 +295,12 @@ namespace MWClass return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell); } - short Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const + float Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const { MWWorld::LiveCellRef *ref = ptr.get(); - return ref->mBase->mData.mEnchant; + return ref->mBase->mData.mEnchant/10.f; } bool Clothing::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index a6de0cb4f0..db4b7a2e9f 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -71,7 +71,7 @@ namespace MWClass virtual std::string getModel(const MWWorld::Ptr &ptr) const; - virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; + virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; }; diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 6c6b3daa61..306a2d671e 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -428,12 +428,12 @@ namespace MWClass return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell); } - short Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const + float Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const { MWWorld::LiveCellRef *ref = ptr.get(); - return ref->mBase->mData.mEnchant; + return ref->mBase->mData.mEnchant/10.f; } bool Weapon::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index 05b1aee22b..ba444ba05a 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -79,7 +79,7 @@ namespace MWClass virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; - virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; + virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const; }; } diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index 2ae98f358f..6f7cfbf403 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -57,8 +57,9 @@ namespace MWGui void EnchantingDialog::updateLabels() { - mEnchantmentPoints->setCaption(boost::lexical_cast(mEnchanting.getEnchantCost()) - + " / " + boost::lexical_cast(mEnchanting.getMaxEnchantValue())); + std::stringstream enchantCost; + enchantCost << std::setprecision(1) << std::fixed << mEnchanting.getEnchantCost(); + mEnchantmentPoints->setCaption(enchantCost.str() + " / " + boost::lexical_cast(mEnchanting.getMaxEnchantValue())); mCharge->setCaption(boost::lexical_cast(mEnchanting.getGemCharge())); diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index a38cb0037b..ded75f03a9 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -134,7 +134,7 @@ namespace MWMechanics } } - int Enchanting::getEnchantCost() const + float Enchanting::getEnchantCost() const { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); float cost = 0; @@ -193,7 +193,7 @@ namespace MWMechanics return soul->mData.mSoul; } - int Enchanting::getMaxEnchantValue() const + float Enchanting::getMaxEnchantValue() const { if (itemEmpty()) return 0; diff --git a/apps/openmw/mwmechanics/enchanting.hpp b/apps/openmw/mwmechanics/enchanting.hpp index d8a6342ac9..2831f9ddb6 100644 --- a/apps/openmw/mwmechanics/enchanting.hpp +++ b/apps/openmw/mwmechanics/enchanting.hpp @@ -35,9 +35,9 @@ namespace MWMechanics bool create(); //Return true if created, false if failed. void nextEnchantType(); //Set enchant type to next possible type (for mOldItemPtr object) int getEnchantType() const; - int getEnchantCost() const; + float getEnchantCost() const; int getEnchantPrice() const; - int getMaxEnchantValue() const; + float getMaxEnchantValue() const; int getGemCharge() const; float getEnchantChance() const; bool soulEmpty() const; //Return true if empty diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 451f0c5c10..03a55c7f05 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -132,7 +132,7 @@ namespace MWWorld return 0; } - short Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const + float Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const { throw std::runtime_error ("class does not support enchanting"); } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index b901950e31..e203fedc3a 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -231,7 +231,7 @@ namespace MWWorld ///< @return the enchantment ID if the object is enchanted, otherwise an empty string /// (default implementation: return empty string) - virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const; + virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const; ///< @return the number of enchantment points available for possible enchanting virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const; diff --git a/components/esm/loadweap.hpp b/components/esm/loadweap.hpp index e482d3b109..384af125dc 100644 --- a/components/esm/loadweap.hpp +++ b/components/esm/loadweap.hpp @@ -48,7 +48,7 @@ struct Weapon short mType; short mHealth; float mSpeed, mReach; - short mEnchant; // Enchantment points + short mEnchant; // Enchantment points. The real value is mEnchant/10.f unsigned char mChop[2], mSlash[2], mThrust[2]; // Min and max int mFlags; }; // 32 bytes From 9648804af5d27da19f77c3880fe82a9c2ba69e4d Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Apr 2013 10:20:38 +0200 Subject: [PATCH 2/8] Fix terrain material leak, this should in theory allow the terrain to free its temporary resources --- apps/openmw/mwrender/terrainmaterial.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/terrainmaterial.cpp b/apps/openmw/mwrender/terrainmaterial.cpp index dd74254be6..b9c055acdf 100644 --- a/apps/openmw/mwrender/terrainmaterial.cpp +++ b/apps/openmw/mwrender/terrainmaterial.cpp @@ -54,9 +54,10 @@ namespace MWRender TerrainMaterial::Profile::~Profile() { + if (mMaterial) + sh::Factory::getInstance().destroyMaterialInstance(mMaterial->getName()); } - Ogre::MaterialPtr TerrainMaterial::Profile::generate(const Ogre::Terrain* terrain) { const Ogre::String& matName = terrain->getMaterialName(); From 867c7db01401e3f987689b61479af2ffb45864cf Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Apr 2013 11:00:15 +0200 Subject: [PATCH 3/8] Fix wrong door sounds --- apps/openmw/mwbase/world.hpp | 2 ++ apps/openmw/mwclass/door.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 7 +++++++ apps/openmw/mwworld/worldimp.hpp | 8 +++++--- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 42821e3617..1b8d813fd1 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -326,6 +326,8 @@ namespace MWBase virtual void setupPlayer(bool newGame) = 0; virtual void renderPlayer() = 0; + virtual bool getOpenOrCloseDoor(const MWWorld::Ptr& door) = 0; + ///< if activated, should this door be opened or closed? virtual void activateDoor(const MWWorld::Ptr& door) = 0; ///< activate (open or close) an non-teleport door diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 5b061e090b..91d38b8eff 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -141,7 +141,7 @@ namespace MWClass { // animated door boost::shared_ptr action(new MWWorld::ActionDoor(ptr)); - if (ptr.getRefData().getLocalRotation().rot[2] == 0) + if (MWBase::Environment::get().getWorld()->getOpenOrCloseDoor(ptr)) action->setSound(openSound); else action->setSound(closeSound); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index f1fd020df2..736c52a386 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1548,4 +1548,11 @@ namespace MWWorld mDoorStates[door] = 0; // close } } + + bool World::getOpenOrCloseDoor(const Ptr &door) + { + if (mDoorStates.find(door) != mDoorStates.end()) + return !mDoorStates[door]; // if currently opening or closing, then do the opposite + return door.getRefData().getLocalRotation().rot[2] == 0; + } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 172ae406cd..8ea43cb256 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -113,6 +113,9 @@ namespace MWWorld void addContainerScripts(const Ptr& reference, Ptr::CellStore* cell); void PCDropped (const Ptr& item); + virtual void processDoors(float duration); + ///< Run physics simulation and modify \a world accordingly. + public: World (OEngine::Render::OgreRenderer& renderer, @@ -272,9 +275,6 @@ namespace MWWorld virtual void doPhysics(const PtrMovementList &actors, float duration); ///< Run physics simulation and modify \a world accordingly. - virtual void processDoors(float duration); - ///< Run physics simulation and modify \a world accordingly. - virtual bool toggleCollisionMode(); ///< Toggle collision mode for player. If disabled player object should ignore /// collisions and gravity. @@ -374,6 +374,8 @@ namespace MWWorld virtual void setupPlayer(bool newGame); virtual void renderPlayer(); + virtual bool getOpenOrCloseDoor(const MWWorld::Ptr& door); + ///< if activated, should this door be opened or closed? virtual void activateDoor(const MWWorld::Ptr& door); ///< activate (open or close) an non-teleport door From 5ff098b8fb9ff8865851d9b693c7e693a4f05c4d Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Apr 2013 11:55:30 +0200 Subject: [PATCH 4/8] Fix quick keys being triggered when in UI mode --- apps/openmw/mwinput/inputmanagerimp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 6a34161e08..882edadcee 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -679,7 +679,8 @@ namespace MWInput void InputManager::quickKey (int index) { - mWindows.activateQuickKey (index); + if (!mWindows.isGuiMode()) + mWindows.activateQuickKey (index); } void InputManager::showQuickKeysMenu() From 6c5ea1ea7ae3a53f2cfb3335e206d547326f5da4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Apr 2013 12:05:10 +0200 Subject: [PATCH 5/8] Fix incorrect weapon health meter for fully repaired weapons, fix exception when equipping lockpicks or probes --- apps/openmw/mwclass/lockpick.cpp | 8 ++++++++ apps/openmw/mwclass/lockpick.hpp | 3 +++ apps/openmw/mwclass/probe.cpp | 8 ++++++++ apps/openmw/mwclass/probe.hpp | 3 +++ apps/openmw/mwgui/windowmanagerimp.cpp | 6 ++++-- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index bfbf107565..52a22d28e9 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -181,4 +181,12 @@ namespace MWClass { return npcServices & ESM::NPC::Picks; } + + int Lockpick::getItemMaxHealth (const MWWorld::Ptr& ptr) const + { + MWWorld::LiveCellRef *ref = + ptr.get(); + + return ref->mBase->mData.mUses; + } } diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index edd884a3e0..df794debd5 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -59,6 +59,9 @@ namespace MWClass virtual std::string getModel(const MWWorld::Ptr &ptr) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; + + virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; + ///< Return item max health or throw an exception, if class does not have item health }; } diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 4ec6a8340b..1c14c894d5 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -180,4 +180,12 @@ namespace MWClass { return npcServices & ESM::NPC::Probes; } + + int Probe::getItemMaxHealth (const MWWorld::Ptr& ptr) const + { + MWWorld::LiveCellRef *ref = + ptr.get(); + + return ref->mBase->mData.mUses; + } } diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 75ebaa01cb..70390c85cd 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -59,6 +59,9 @@ namespace MWClass virtual std::string getModel(const MWWorld::Ptr &ptr) const; virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; + + virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const; + ///< Return item max health or throw an exception, if class does not have item health }; } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 2171beaffb..36e53ca090 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -918,14 +918,16 @@ namespace MWGui const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get() .find(MWWorld::Class::get(item).getEnchantment(item)); - int chargePercent = item.getCellRef().mEnchantmentCharge / static_cast(ench->mData.mCharge) * 100; + int chargePercent = (item.getCellRef().mEnchantmentCharge == -1) ? 100 + : (item.getCellRef().mEnchantmentCharge / static_cast(ench->mData.mCharge) * 100); mHud->setSelectedEnchantItem(item, chargePercent); mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item)); } void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item) { - int durabilityPercent = item.getCellRef().mCharge / static_cast(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100; + int durabilityPercent = (item.getCellRef().mCharge == -1) ? 100 + : (item.getCellRef().mCharge / static_cast(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100); mHud->setSelectedWeapon(item, durabilityPercent); mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item)); } From d5c7a26041d825e1cbd675831a8bfe32fd25bcdb Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Apr 2013 12:32:24 +0200 Subject: [PATCH 6/8] Fix broken loose file resources when using Ogre 1.9 --- components/bsa/bsa_archive.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index c97ca4562a..7d3df15908 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -313,21 +313,26 @@ public: void destroyInstance( Archive* arch) { delete arch; } }; -class DirArchiveFactory : public FileSystemArchiveFactory +class DirArchiveFactory : public ArchiveFactory { public: - const String& getType() const - { - static String name = "Dir"; - return name; - } + const String& getType() const + { + static String name = "Dir"; + return name; + } - Archive *createInstance( const String& name ) - { - return new DirArchive(name); - } + Archive *createInstance( const String& name ) + { + return new DirArchive(name); + } - void destroyInstance( Archive* arch) { delete arch; } + virtual Archive* createInstance(const String& name, bool readOnly) + { + return new DirArchive(name); + } + + void destroyInstance( Archive* arch) { delete arch; } }; From 6222b3f52a5aaea6802ccd0de7e436db4d919a15 Mon Sep 17 00:00:00 2001 From: Glorf Date: Mon, 29 Apr 2013 17:19:20 +0200 Subject: [PATCH 7/8] Bugfix #744 --- apps/openmw/mwgui/windowmanagerimp.cpp | 7 +++++++ apps/openmw/mwgui/windowmanagerimp.hpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 2171beaffb..fcd784decd 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1110,6 +1110,13 @@ namespace MWGui { mLoadingScreen->loadingDone (); } + bool WindowManager::getRestEnabled() + { + //Enable rest dialogue if character creation finished + if(mRestAllowed==false && MWBase::Environment::get().getWorld()->getGlobalVariable ("chargenstate").mFloat==-1) + mRestAllowed=true; + return mRestAllowed; + } bool WindowManager::getPlayerSleeping () { diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 652ad870f3..acac77bf31 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -220,7 +220,7 @@ namespace MWGui virtual void loadingDone(); virtual void enableRest() { mRestAllowed = true; } - virtual bool getRestEnabled() { return mRestAllowed; } + virtual bool getRestEnabled(); virtual bool getPlayerSleeping(); virtual void wakeUpPlayer(); From 74de8b83b60de56d39b300b383ec3b090571abcd Mon Sep 17 00:00:00 2001 From: Glorf Date: Mon, 29 Apr 2013 17:56:16 +0200 Subject: [PATCH 8/8] Enabled collision when new game --- apps/openmw/engine.cpp | 2 +- apps/openmw/mwbase/world.hpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 11 +++++++---- apps/openmw/mwworld/worldimp.hpp | 4 +++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 4472b205f7..39e1137ca0 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -368,7 +368,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) mEnvironment.setWorld( new MWWorld::World (*mOgre, mFileCollections, mMaster, mPlugins, mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoder, mFallbackMap, mActivationDistanceOverride)); - MWBase::Environment::get().getWorld()->setupPlayer(mNewGame); + MWBase::Environment::get().getWorld()->setupPlayer(); //Load translation data mTranslationDataStorage.setEncoder(mEncoder); diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 42821e3617..072dc75148 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -323,7 +323,7 @@ namespace MWBase virtual void changeVanityModeScale(float factor) = 0; virtual bool vanityRotateCamera(float * rot) = 0; - virtual void setupPlayer(bool newGame) = 0; + virtual void setupPlayer() = 0; virtual void renderPlayer() = 0; virtual void activateDoor(const MWWorld::Ptr& door) = 0; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 6fc7324e51..9902233227 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -163,7 +163,8 @@ namespace MWWorld ToUTF8::Utf8Encoder* encoder, const std::map& fallbackMap, int mActivationDistanceOverride) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), mSky (true), mCells (mStore, mEsm), - mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride),mFallback(fallbackMap) + mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride), + mFallback(fallbackMap), mNewGame(newGame) { mPhysics = new PhysicsSystem(renderer); mPhysEngine = mPhysics->getEngine(); @@ -214,7 +215,7 @@ namespace MWWorld // global variables mGlobalVariables = new Globals (mStore); - if (newGame) + if (mNewGame) { // set new game mark mGlobalVariables->setInt ("chargenstate", 1); @@ -1465,12 +1466,12 @@ namespace MWWorld return mRendering->vanityRotateCamera(rot); } - void World::setupPlayer(bool newGame) + void World::setupPlayer() { const ESM::NPC* player = mStore.get().find ("player"); mPlayer = new MWWorld::Player (player, *this); mRendering->attachCameraTo(mPlayer->getPlayer()); - if (newGame) + if (mNewGame) { MWWorld::Class::get(mPlayer->getPlayer()).getContainerStore(mPlayer->getPlayer()).fill(player->mInventory, "", mStore); MWWorld::Class::get(mPlayer->getPlayer()).getInventoryStore(mPlayer->getPlayer()).autoEquip (mPlayer->getPlayer()); @@ -1481,6 +1482,8 @@ namespace MWWorld { mRendering->renderPlayer(mPlayer->getPlayer()); mPhysics->addActor(mPlayer->getPlayer()); + if (mNewGame) + toggleCollisionMode(); } void World::setupExternalRendering (MWRender::ExternalRendering& rendering) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 172ae406cd..19106c901b 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -85,6 +85,8 @@ namespace MWWorld float mFaced2Distance; int mNumFacing; + bool mNewGame; + std::map mDoorStates; ///< only holds doors that are currently moving. 0 means closing, 1 opening @@ -371,7 +373,7 @@ namespace MWWorld virtual bool vanityRotateCamera(float * rot); - virtual void setupPlayer(bool newGame); + virtual void setupPlayer(); virtual void renderPlayer(); virtual void activateDoor(const MWWorld::Ptr& door);