mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 18:39:42 +00:00
Merge pull request #2819 from elsid/fix_ub
Fix UB in NpcAnimation::mNpcType initialization
This commit is contained in:
commit
7ba8176862
2 changed files with 12 additions and 5 deletions
|
@ -266,16 +266,22 @@ void HeadAnimationTime::setBlinkStop(float value)
|
|||
|
||||
// ----------------------------------------------------
|
||||
|
||||
NpcAnimation::NpcType NpcAnimation::getNpcType()
|
||||
NpcAnimation::NpcType NpcAnimation::getNpcType() const
|
||||
{
|
||||
const MWWorld::Class &cls = mPtr.getClass();
|
||||
// Dead vampires should typically stay vampires.
|
||||
if (mNpcType == Type_Vampire && cls.getNpcStats(mPtr).isDead() && !cls.getNpcStats(mPtr).isWerewolf())
|
||||
return mNpcType;
|
||||
return getNpcType(mPtr);
|
||||
}
|
||||
|
||||
NpcAnimation::NpcType NpcAnimation::getNpcType(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
const MWWorld::Class &cls = ptr.getClass();
|
||||
NpcAnimation::NpcType curType = Type_Normal;
|
||||
if (cls.getCreatureStats(mPtr).getMagicEffects().get(ESM::MagicEffect::Vampirism).getMagnitude() > 0)
|
||||
if (cls.getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::Vampirism).getMagnitude() > 0)
|
||||
curType = Type_Vampire;
|
||||
if (cls.getNpcStats(mPtr).isWerewolf())
|
||||
if (cls.getNpcStats(ptr).isWerewolf())
|
||||
curType = Type_Werewolf;
|
||||
|
||||
return curType;
|
||||
|
@ -326,7 +332,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> par
|
|||
mViewMode(viewMode),
|
||||
mShowWeapons(false),
|
||||
mShowCarriedLeft(true),
|
||||
mNpcType(getNpcType()),
|
||||
mNpcType(getNpcType(ptr)),
|
||||
mFirstPersonFieldOfView(firstPersonFieldOfView),
|
||||
mSoundsDisabled(disableSounds),
|
||||
mAccurateAiming(false),
|
||||
|
|
|
@ -74,7 +74,7 @@ private:
|
|||
|
||||
void updateNpcBase();
|
||||
|
||||
NpcType getNpcType();
|
||||
NpcType getNpcType() const;
|
||||
|
||||
PartHolderPtr insertBoundedPart(const std::string &model, const std::string &bonename,
|
||||
const std::string &bonefilter, bool enchantedGlow, osg::Vec4f* glowColor=nullptr);
|
||||
|
@ -94,6 +94,7 @@ private:
|
|||
|
||||
static bool isFirstPersonPart(const ESM::BodyPart* bodypart);
|
||||
static bool isFemalePart(const ESM::BodyPart* bodypart);
|
||||
static NpcType getNpcType(const MWWorld::Ptr& ptr);
|
||||
|
||||
protected:
|
||||
virtual void addControllers();
|
||||
|
|
Loading…
Reference in a new issue