From 2a65aaf5abf30d0e3db94ef51d96d478cfc41603 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 16 Jun 2018 14:21:28 +0400 Subject: [PATCH 1/2] Forbid actors to use teleporting doors (bug #2562) --- CHANGELOG.md | 1 + apps/openmw/mwclass/door.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26e1feb27..f5b48d6e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Bug #1990: Sunrise/sunset not set correct Bug #2222: Fatigue's effect on selling price is backwards Bug #2326: After a bound item expires the last equipped item of that type is not automatically re-equipped + Bug #2562: Forcing AI to activate a teleport door sometimes causes a crash Bug #2835: Player able to slowly move when overencumbered Bug #2971: Compiler did not reject lines with naked expressions beginning with x.y Bug #3374: Touch spells not hitting kwama foragers diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index eba87a47b..6846d3280 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -121,14 +121,23 @@ namespace MWClass bool hasKey = false; std::string keyName; + // FIXME: If NPC activate teleporting door, it can lead to crash due to iterator invalidation in the Actors update. + // Make such activation a no-op for now, how in vanilla game. + if (actor != MWMechanics::getPlayer() && ptr.getCellRef().getTeleport()) + { + std::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + action->setSound(lockedSound); + return action; + } + // make door glow if player activates it with telekinesis - if (actor == MWBase::Environment::get().getWorld()->getPlayerPtr() && - MWBase::Environment::get().getWorld()->getDistanceToFacedObject() > + if (actor == MWMechanics::getPlayer() && + MWBase::Environment::get().getWorld()->getDistanceToFacedObject() > MWBase::Environment::get().getWorld()->getMaxActivationDistance()) { MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); int index = ESM::MagicEffect::effectStringToId("sEffectTelekinesis"); const ESM::MagicEffect *effect = store.get().find(index); From 3cc6da1db2aaa0c584091527fd0decc26f0715fb Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Sun, 17 Jun 2018 10:13:03 +0200 Subject: [PATCH 2/2] Update door.cpp typo fix --- apps/openmw/mwclass/door.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 6846d3280..a6aacfa12 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -122,7 +122,7 @@ namespace MWClass std::string keyName; // FIXME: If NPC activate teleporting door, it can lead to crash due to iterator invalidation in the Actors update. - // Make such activation a no-op for now, how in vanilla game. + // Make such activation a no-op for now, like how it is in the vanilla game. if (actor != MWMechanics::getPlayer() && ptr.getCellRef().getTeleport()) { std::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr));