From 87c84e6fcdc04f1935ba8f10cddf32b5a95a09c4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 5 Aug 2010 13:29:49 +0200 Subject: [PATCH] limited activation range according to GMST settings --- apps/openmw/engine.cpp | 10 ++++------ apps/openmw/mwworld/world.cpp | 11 +++++++++++ apps/openmw/mwworld/world.hpp | 5 +++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 8734ffaada..3c6eb6f16a 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -74,22 +74,20 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) if (focusFrameCounter++ == focusUpdateFrame) { - std::pair handle = mEnvironment.mWorld->getMWScene()->getFacedHandle(); + std::string handle = mEnvironment.mWorld->getFacedHandle(); std::string name; - if (!handle.first.empty()) + if (!handle.empty()) { - // TODO compare handle.second with max activation range (from a GMST) - - MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle.first); + MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); if (!ptr.isEmpty()) name = MWWorld::Class::get (ptr).getName (ptr); } if (!name.empty()) - std::cout << "Object: " << name << ", distance: " << handle.second << std::endl; + std::cout << "Object: " << name << std::endl; focusFrameCounter = 0; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 73a9d6ad30..94a6758c75 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -600,4 +600,15 @@ namespace MWWorld { mCellChanged = false; } + + std::string World::getFacedHandle() + { + std::pair result = mScene.getFacedHandle(); + + if (result.first.empty() || + result.second>getStore().gameSettings.find ("iMaxActivateDist")->i) + return ""; + + return result.first; + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 354c3603c3..d201616983 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -83,8 +83,6 @@ namespace MWWorld ~World(); - MWRender::MWScene* getMWScene() { return &mScene; } - MWRender::PlayerPos& getPlayerPos(); ESMS::ESMStore& getStore(); @@ -133,6 +131,9 @@ namespace MWWorld ///< works only for interior cells currently. void markCellAsUnchanged(); + + std::string getFacedHandle(); + ///< Return handle of the object the player is looking at }; }