SoundGen fix: use Original Creature field only if non-empty

moveref
scrawl 10 years ago
parent 88a2e4c043
commit 192626c6f5

@ -679,14 +679,15 @@ namespace MWClass
if(type >= 0) if(type >= 0)
{ {
std::vector<const ESM::SoundGenerator*> sounds; std::vector<const ESM::SoundGenerator*> sounds;
sounds.reserve(8);
MWWorld::LiveCellRef<ESM::Creature>* ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature>* ref = ptr.get<ESM::Creature>();
const std::string& ourId = (ref->mBase->mOriginal.empty()) ? getId(ptr) : ref->mBase->mOriginal;
MWWorld::Store<ESM::SoundGenerator>::iterator sound = store.begin(); MWWorld::Store<ESM::SoundGenerator>::iterator sound = store.begin();
while(sound != store.end()) while(sound != store.end())
{ {
if (type == sound->mType && !sound->mCreature.empty() && Misc::StringUtils::ciEqual(ref->mBase->mOriginal, sound->mCreature)) if (type == sound->mType && !sound->mCreature.empty() && (Misc::StringUtils::ciEqual(ourId, sound->mCreature)))
sounds.push_back(&*sound); sounds.push_back(&*sound);
++sound; ++sound;
} }

Loading…
Cancel
Save