1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Initialize variable without reading itself

This commit is contained in:
elsid 2020-05-01 17:10:06 +02:00
parent eeb13ad8a3
commit 6d8debe009
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40
2 changed files with 12 additions and 5 deletions

View File

@ -266,16 +266,22 @@ void HeadAnimationTime::setBlinkStop(float value)
// ---------------------------------------------------- // ----------------------------------------------------
NpcAnimation::NpcType NpcAnimation::getNpcType() NpcAnimation::NpcType NpcAnimation::getNpcType() const
{ {
const MWWorld::Class &cls = mPtr.getClass(); const MWWorld::Class &cls = mPtr.getClass();
// Dead vampires should typically stay vampires. // Dead vampires should typically stay vampires.
if (mNpcType == Type_Vampire && cls.getNpcStats(mPtr).isDead() && !cls.getNpcStats(mPtr).isWerewolf()) if (mNpcType == Type_Vampire && cls.getNpcStats(mPtr).isDead() && !cls.getNpcStats(mPtr).isWerewolf())
return mNpcType; return mNpcType;
return getNpcType(mPtr);
}
NpcAnimation::NpcType NpcAnimation::getNpcType(const MWWorld::Ptr& ptr)
{
const MWWorld::Class &cls = ptr.getClass();
NpcAnimation::NpcType curType = Type_Normal; 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; curType = Type_Vampire;
if (cls.getNpcStats(mPtr).isWerewolf()) if (cls.getNpcStats(ptr).isWerewolf())
curType = Type_Werewolf; curType = Type_Werewolf;
return curType; return curType;
@ -326,7 +332,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> par
mViewMode(viewMode), mViewMode(viewMode),
mShowWeapons(false), mShowWeapons(false),
mShowCarriedLeft(true), mShowCarriedLeft(true),
mNpcType(getNpcType()), mNpcType(getNpcType(ptr)),
mFirstPersonFieldOfView(firstPersonFieldOfView), mFirstPersonFieldOfView(firstPersonFieldOfView),
mSoundsDisabled(disableSounds), mSoundsDisabled(disableSounds),
mAccurateAiming(false), mAccurateAiming(false),

View File

@ -74,7 +74,7 @@ private:
void updateNpcBase(); void updateNpcBase();
NpcType getNpcType(); NpcType getNpcType() const;
PartHolderPtr insertBoundedPart(const std::string &model, const std::string &bonename, PartHolderPtr insertBoundedPart(const std::string &model, const std::string &bonename,
const std::string &bonefilter, bool enchantedGlow, osg::Vec4f* glowColor=nullptr); const std::string &bonefilter, bool enchantedGlow, osg::Vec4f* glowColor=nullptr);
@ -94,6 +94,7 @@ private:
static bool isFirstPersonPart(const ESM::BodyPart* bodypart); static bool isFirstPersonPart(const ESM::BodyPart* bodypart);
static bool isFemalePart(const ESM::BodyPart* bodypart); static bool isFemalePart(const ESM::BodyPart* bodypart);
static NpcType getNpcType(const MWWorld::Ptr& ptr);
protected: protected:
virtual void addControllers(); virtual void addControllers();