From af1fe64408ac85d635acc11d157ab8f9548c9d6a Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Tue, 7 Mar 2017 19:00:09 +0100 Subject: [PATCH] GetSoundPlaying called on an equipped item now also looks for sounds played by the equipping actor (Fixes #3781) --- apps/openmw/mwscript/soundextensions.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index a9896d203..516c58b26 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -12,6 +12,9 @@ #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwworld/inventorystore.hpp" +#include "../mwworld/class.hpp" + #include "interpretercontext.hpp" #include "ref.hpp" @@ -183,8 +186,22 @@ namespace MWScript int index = runtime[0].mInteger; runtime.pop(); - runtime.push (MWBase::Environment::get().getSoundManager()->getSoundPlaying ( - ptr, runtime.getStringLiteral (index))); + bool ret = MWBase::Environment::get().getSoundManager()->getSoundPlaying ( + ptr, runtime.getStringLiteral (index)); + + // GetSoundPlaying called on an equipped item should also look for sounds played by the equipping actor. + if (!ret && ptr.getContainerStore()) + { + MWWorld::Ptr cont = MWBase::Environment::get().getWorld()->findContainer(ptr); + + if (!cont.isEmpty() && cont.getClass().hasInventoryStore(cont) && cont.getClass().getInventoryStore(cont).isEquipped(ptr)) + { + ret = MWBase::Environment::get().getSoundManager()->getSoundPlaying ( + cont, runtime.getStringLiteral (index)); + } + } + + runtime.push(ret); } };