From 9dfd775bf23cf6421408d017f3e3dbd4c0b9611e Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 13 Aug 2018 08:30:50 +0400 Subject: [PATCH 1/2] Implement GetPCTraveling console command --- apps/openmw/mwbase/world.hpp | 3 +++ apps/openmw/mwgui/travelwindow.cpp | 4 ++++ apps/openmw/mwscript/miscextensions.cpp | 3 +-- apps/openmw/mwworld/worldimp.cpp | 17 ++++++++++++++++- apps/openmw/mwworld/worldimp.hpp | 4 ++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index a88616625..ee1227e0c 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -566,6 +566,9 @@ namespace MWBase virtual bool isPlayerInJail() const = 0; + virtual void setPlayerTraveling(bool traveling) = 0; + virtual bool isPlayerTraveling() const = 0; + virtual void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) = 0; /// Return terrain height at \a worldPos position. diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 7a4a9293c..cf4fb1b5e 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -154,6 +154,10 @@ namespace MWGui if (playerGoldsetPlayerTraveling(true); + if (!mPtr.getCell()->isExterior()) // Interior cell -> mages guild transport MWBase::Environment::get().getWindowManager()->playSound("mysticism cast"); diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 30d0c6fee..7da1a4833 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -1155,8 +1155,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime &runtime) { - /// \todo implement traveling check - runtime.push (0); + runtime.push (MWBase::Environment::get().getWorld()->isPlayerTraveling()); } }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index f4c2a75f3..41ed74000 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -153,7 +153,8 @@ namespace MWWorld mGodMode(false), mScriptsEnabled(true), mContentFiles (contentFiles), mUserDataPath(userDataPath), mActivationDistanceOverride (activationDistanceOverride), mStartupScript(startupScript), mStartCell (startCell), mDistanceToFacedObject(-1), mTeleportEnabled(true), - mLevitationEnabled(true), mGoToJail(false), mDaysInPrison(0), mSpellPreloadTimer(0.f) + mLevitationEnabled(true), mGoToJail(false), mDaysInPrison(0), + mPlayerTraveling(false), mSpellPreloadTimer(0.f) { mPhysics.reset(new MWPhysics::PhysicsSystem(resourceSystem, rootNode)); mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, &mFallback, resourcePath)); @@ -311,6 +312,7 @@ namespace MWWorld mGoToJail = false; mTeleportEnabled = true; mLevitationEnabled = true; + mPlayerTraveling = false; fillGlobalVariables(); } @@ -1639,6 +1641,9 @@ namespace MWWorld void World::update (float duration, bool paused) { + // Reset "traveling" flag - there was a frame to detect traveling. + mPlayerTraveling = false; + if (mGoToJail && !paused) goToJail(); @@ -3312,6 +3317,16 @@ namespace MWWorld return MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_Jail); } + void World::setPlayerTraveling(bool traveling) + { + mPlayerTraveling = traveling; + } + + bool World::isPlayerTraveling() const + { + return mPlayerTraveling; + } + float World::getTerrainHeightAt(const osg::Vec3f& worldPos) const { return mRendering->getTerrainHeightAt(worldPos); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index a2616995a..102683768 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -168,6 +168,7 @@ namespace MWWorld bool mLevitationEnabled; bool mGoToJail; int mDaysInPrison; + bool mPlayerTraveling; float mSpellPreloadTimer; @@ -672,6 +673,9 @@ namespace MWWorld bool isPlayerInJail() const override; + void setPlayerTraveling(bool traveling); + bool isPlayerTraveling() const; + /// Return terrain height at \a worldPos position. float getTerrainHeightAt(const osg::Vec3f& worldPos) const override; From 4003fa12962fa0c48a8b2780b340b8068fd552cb Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 13 Aug 2018 11:10:01 +0400 Subject: [PATCH 2/2] Keep jailing state for one frame after leaving jail (bug #3788) --- CHANGELOG.md | 1 + apps/openmw/mwworld/worldimp.cpp | 19 ++++++++++++------- apps/openmw/mwworld/worldimp.hpp | 5 +++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 775f0545d..f08d05d9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Bug #3486: [Mod] NPC Commands does not work Bug #3591: Angled hit distance too low Bug #3629: DB assassin attack never triggers creature spawning + Bug #3788: GetPCInJail and GetPCTraveling do not work as in vanilla Bug #3876: Landscape texture painting is misaligned Bug #3897: Have Goodbye give all choices the effects of Goodbye Bug #3911: [macOS] Typing in the "Content List name" dialog box produces double characters diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 41ed74000..874478b71 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -154,7 +154,7 @@ namespace MWWorld mActivationDistanceOverride (activationDistanceOverride), mStartupScript(startupScript), mStartCell (startCell), mDistanceToFacedObject(-1), mTeleportEnabled(true), mLevitationEnabled(true), mGoToJail(false), mDaysInPrison(0), - mPlayerTraveling(false), mSpellPreloadTimer(0.f) + mPlayerTraveling(false), mPlayerInJail(false), mSpellPreloadTimer(0.f) { mPhysics.reset(new MWPhysics::PhysicsSystem(resourceSystem, rootNode)); mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, &mFallback, resourcePath)); @@ -313,6 +313,7 @@ namespace MWWorld mTeleportEnabled = true; mLevitationEnabled = true; mPlayerTraveling = false; + mPlayerInJail = false; fillGlobalVariables(); } @@ -1641,11 +1642,17 @@ namespace MWWorld void World::update (float duration, bool paused) { + if (mGoToJail && !paused) + goToJail(); + // Reset "traveling" flag - there was a frame to detect traveling. mPlayerTraveling = false; - if (mGoToJail && !paused) - goToJail(); + // The same thing for "in jail" flag: reset it if: + // 1. Player was in jail + // 2. Jailing window was closed + if (mPlayerInJail && !mGoToJail && !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_Jail)) + mPlayerInJail = false; updateWeather(duration, paused); @@ -3286,6 +3293,7 @@ namespace MWWorld { // Reset bounty and forget the crime now, but don't change cell yet (the player should be able to read the dialog text first) mGoToJail = true; + mPlayerInJail = true; MWWorld::Ptr player = getPlayerPtr(); @@ -3311,10 +3319,7 @@ namespace MWWorld bool World::isPlayerInJail() const { - if (mGoToJail) - return true; - - return MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_Jail); + return mPlayerInJail; } void World::setPlayerTraveling(bool traveling) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 102683768..2352fd31c 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -169,6 +169,7 @@ namespace MWWorld bool mGoToJail; int mDaysInPrison; bool mPlayerTraveling; + bool mPlayerInJail; float mSpellPreloadTimer; @@ -673,8 +674,8 @@ namespace MWWorld bool isPlayerInJail() const override; - void setPlayerTraveling(bool traveling); - bool isPlayerTraveling() const; + void setPlayerTraveling(bool traveling) override; + bool isPlayerTraveling() const override; /// Return terrain height at \a worldPos position. float getTerrainHeightAt(const osg::Vec3f& worldPos) const override;