diff --git a/CHANGELOG.md b/CHANGELOG.md index 46f44ea06f..42565e87d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Bug #3894: Hostile spell effects not detected/present on first frame of OnPCHitMe Bug #4202: Open .omwaddon files without needing toopen openmw-cs first Bug #4240: Ash storm origin coordinates and hand shielding animation behavior are incorrect + Bug #4270: Closing doors while they are obstructed desyncs closing sfx Bug #4276: Resizing character window differs from vanilla Bug #4329: Removed birthsign abilities are restored after reloading the save Bug #4341: Error message about missing GDB is too vague diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 3ea994683c..07680e76f3 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1632,11 +1632,14 @@ namespace MWWorld bool reached = (targetRot == maxRot && state != MWWorld::DoorState::Idle) || targetRot == minRot; /// \todo should use convexSweepTest here + bool collisionWithActor = false; std::vector collisions = mPhysics->getCollisions(door, MWPhysics::CollisionType_Door, MWPhysics::CollisionType_Actor); for (MWWorld::Ptr& ptr : collisions) { if (ptr.getClass().isActor()) { + collisionWithActor = true; + // Collided with actor, ask actor to try to avoid door if(ptr != getPlayerPtr() ) { @@ -1651,6 +1654,25 @@ namespace MWWorld } } + // Cancel door closing sound if collision with actor is detected + if (collisionWithActor) + { + const ESM::Door* ref = door.get()->mBase; + + if (state == MWWorld::DoorState::Opening) + { + const std::string& openSound = ref->mOpenSound; + if (!openSound.empty() && MWBase::Environment::get().getSoundManager()->getSoundPlaying(door, openSound)) + MWBase::Environment::get().getSoundManager()->stopSound3D(door, openSound); + } + else if (state == MWWorld::DoorState::Closing) + { + const std::string& closeSound = ref->mCloseSound; + if (!closeSound.empty() && MWBase::Environment::get().getSoundManager()->getSoundPlaying(door, closeSound)) + MWBase::Environment::get().getSoundManager()->stopSound3D(door, closeSound); + } + } + // the rotation order we want to use mWorldScene->updateObjectRotation(door, false); return reached;