From 3476bd7d042a5ddf4abddc6283d31db8d1e87add Mon Sep 17 00:00:00 2001 From: uramer Date: Sun, 1 Mar 2020 14:22:00 +0100 Subject: [PATCH] [Client] Play sounds at fixed position if the object is in current cell --- apps/openmw/mwmp/ObjectList.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmp/ObjectList.cpp b/apps/openmw/mwmp/ObjectList.cpp index 1acea696b..28bf7bdc4 100644 --- a/apps/openmw/mwmp/ObjectList.cpp +++ b/apps/openmw/mwmp/ObjectList.cpp @@ -792,9 +792,21 @@ void ObjectList::playObjectSounds(MWWorld::CellStore* cellStore) if (ptrFound) { LOG_APPEND(TimedLog::LOG_VERBOSE, "- Playing sound %s on %s", baseObject.soundId.c_str(), objectDescription.c_str()); + bool playAtPosition = false; + if (ptrFound.isInCell()) { + ESM::CellId localCell = Main::get().getLocalPlayer()->cell.getCellId(); + ESM::CellId soundCell = ptrFound.getCell()->getCell()->getCellId(); + playAtPosition = localCell == soundCell; + } - MWBase::Environment::get().getSoundManager()->playSound3D(ptrFound, baseObject.soundId, - baseObject.volume, baseObject.pitch, MWSound::Type::Sfx, MWSound::PlayMode::Normal, 0); + if (playAtPosition) { + MWBase::Environment::get().getSoundManager()->playSound3D(ptrFound.getRefData().getPosition().asVec3(), + baseObject.soundId, baseObject.volume, baseObject.pitch, MWSound::Type::Sfx, MWSound::PlayMode::Normal, 0); + } + else { + MWBase::Environment::get().getSoundManager()->playSound3D(ptrFound, + baseObject.soundId, baseObject.volume, baseObject.pitch, MWSound::Type::Sfx, MWSound::PlayMode::Normal, 0); + } } } }