mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 05:53:50 +00:00
Update the Ptr in SoundManager for references moved to a different cell. Fixes looping sounds not stopping after a moved object was already deleted.
This commit is contained in:
parent
5dd3cfa09a
commit
ba5300b071
4 changed files with 14 additions and 0 deletions
|
@ -147,6 +147,8 @@ namespace MWBase
|
|||
virtual void update(float duration) = 0;
|
||||
|
||||
virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up) = 0;
|
||||
|
||||
virtual void updatePtr (const MWWorld::Ptr& old, const MWWorld::Ptr& updated) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -640,6 +640,15 @@ namespace MWSound
|
|||
mListenerUp = up;
|
||||
}
|
||||
|
||||
void SoundManager::updatePtr(const MWWorld::Ptr &old, const MWWorld::Ptr &updated)
|
||||
{
|
||||
for (SoundMap::iterator snditer = mActiveSounds.begin(); snditer != mActiveSounds.end(); ++snditer)
|
||||
{
|
||||
if (snditer->second.first == old)
|
||||
snditer->second.first = updated;
|
||||
}
|
||||
}
|
||||
|
||||
// Default readAll implementation, for decoders that can't do anything
|
||||
// better
|
||||
void Sound_Decoder::readAll(std::vector<char> &output)
|
||||
|
|
|
@ -148,6 +148,8 @@ namespace MWSound
|
|||
virtual void update(float duration);
|
||||
|
||||
virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up);
|
||||
|
||||
virtual void updatePtr (const MWWorld::Ptr& old, const MWWorld::Ptr& updated);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -905,6 +905,7 @@ namespace MWWorld
|
|||
MWWorld::Class::get(ptr).copyToCell(ptr, newCell, pos);
|
||||
|
||||
mRendering->updateObjectCell(ptr, copy);
|
||||
MWBase::Environment::get().getSoundManager()->updatePtr (ptr, copy);
|
||||
|
||||
MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager();
|
||||
mechMgr->updateCell(ptr, copy);
|
||||
|
|
Loading…
Reference in a new issue