mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
Merged pull request #1979
This commit is contained in:
commit
2c8bbde7ef
3 changed files with 34 additions and 17 deletions
|
@ -144,6 +144,7 @@
|
||||||
Bug #4677: Crash in ESM reader when NPC record has DNAM record without DODT one
|
Bug #4677: Crash in ESM reader when NPC record has DNAM record without DODT one
|
||||||
Bug #4678: Crash in ESP parser when SCVR has no variable names
|
Bug #4678: Crash in ESP parser when SCVR has no variable names
|
||||||
Bug #4685: Missing sound causes an exception inside Say command
|
Bug #4685: Missing sound causes an exception inside Say command
|
||||||
|
Bug #4689: Default creature soundgen entries are not used
|
||||||
Feature #912: Editor: Add missing icons to UniversalId tables
|
Feature #912: Editor: Add missing icons to UniversalId tables
|
||||||
Feature #1221: Editor: Creature/NPC rendering
|
Feature #1221: Editor: Creature/NPC rendering
|
||||||
Feature #1617: Editor: Enchantment effect record verifier
|
Feature #1617: Editor: Enchantment effect record verifier
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace MWClass
|
||||||
|
|
||||||
std::string Activator::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
std::string Activator::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||||
{
|
{
|
||||||
std::string model = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise
|
const std::string model = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
std::string creatureId;
|
std::string creatureId;
|
||||||
|
|
||||||
|
@ -151,21 +151,35 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (creatureId.empty())
|
|
||||||
return std::string();
|
|
||||||
|
|
||||||
int type = getSndGenTypeFromName(name);
|
int type = getSndGenTypeFromName(name);
|
||||||
std::vector<const ESM::SoundGenerator*> sounds;
|
|
||||||
|
|
||||||
for (auto sound = store.get<ESM::SoundGenerator>().begin(); sound != store.get<ESM::SoundGenerator>().end(); ++sound)
|
std::vector<const ESM::SoundGenerator*> fallbacksounds;
|
||||||
if (type == sound->mType && !sound->mCreature.empty() && (Misc::StringUtils::ciEqual(creatureId, sound->mCreature)))
|
if (!creatureId.empty())
|
||||||
sounds.push_back(&*sound);
|
{
|
||||||
|
std::vector<const ESM::SoundGenerator*> sounds;
|
||||||
|
for (auto sound = store.get<ESM::SoundGenerator>().begin(); sound != store.get<ESM::SoundGenerator>().end(); ++sound)
|
||||||
|
{
|
||||||
|
if (type == sound->mType && !sound->mCreature.empty() && (Misc::StringUtils::ciEqual(creatureId, sound->mCreature)))
|
||||||
|
sounds.push_back(&*sound);
|
||||||
|
if (type == sound->mType && sound->mCreature.empty())
|
||||||
|
fallbacksounds.push_back(&*sound);
|
||||||
|
}
|
||||||
|
|
||||||
if (!sounds.empty())
|
if (!sounds.empty())
|
||||||
return sounds[Misc::Rng::rollDice(sounds.size())]->mSound;
|
return sounds[Misc::Rng::rollDice(sounds.size())]->mSound;
|
||||||
|
if (!fallbacksounds.empty())
|
||||||
|
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size())]->mSound;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The activator doesn't have a corresponding creature ID, but we can try to use the defaults
|
||||||
|
for (auto sound = store.get<ESM::SoundGenerator>().begin(); sound != store.get<ESM::SoundGenerator>().end(); ++sound)
|
||||||
|
if (type == sound->mType && sound->mCreature.empty())
|
||||||
|
fallbacksounds.push_back(&*sound);
|
||||||
|
|
||||||
if (type == ESM::SoundGenerator::Land)
|
if (!fallbacksounds.empty())
|
||||||
return "Body Fall Large";
|
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size())]->mSound;
|
||||||
|
}
|
||||||
|
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,25 +632,27 @@ namespace MWClass
|
||||||
if(type >= 0)
|
if(type >= 0)
|
||||||
{
|
{
|
||||||
std::vector<const ESM::SoundGenerator*> sounds;
|
std::vector<const ESM::SoundGenerator*> sounds;
|
||||||
|
std::vector<const ESM::SoundGenerator*> fallbacksounds;
|
||||||
|
|
||||||
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()) ? ptr.getCellRef().getRefId() : ref->mBase->mOriginal;
|
const std::string& ourId = (ref->mBase->mOriginal.empty()) ? ptr.getCellRef().getRefId() : 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(ourId, sound->mCreature)))
|
if (type == sound->mType && !sound->mCreature.empty() && (Misc::StringUtils::ciEqual(ourId, sound->mCreature)))
|
||||||
sounds.push_back(&*sound);
|
sounds.push_back(&*sound);
|
||||||
|
if (type == sound->mType && sound->mCreature.empty())
|
||||||
|
fallbacksounds.push_back(&*sound);
|
||||||
++sound;
|
++sound;
|
||||||
}
|
}
|
||||||
if(!sounds.empty())
|
if (!sounds.empty())
|
||||||
return sounds[Misc::Rng::rollDice(sounds.size())]->mSound;
|
return sounds[Misc::Rng::rollDice(sounds.size())]->mSound;
|
||||||
|
if (!fallbacksounds.empty())
|
||||||
|
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size())]->mSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == ESM::SoundGenerator::Land)
|
|
||||||
return "Body Fall Large";
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue