From c4d38bb42df4c734b20c2567ab5b79808bf8728b Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 16 Feb 2016 19:17:04 +0100 Subject: [PATCH] Fix clang analyzer warnings --- apps/opencs/model/prefs/state.hpp | 2 +- apps/opencs/model/world/refidadapterimp.cpp | 18 +++++++++--------- apps/openmw/mwgui/settingswindow.cpp | 7 ------- apps/openmw/mwmechanics/actors.cpp | 2 +- apps/openmw/mwmechanics/aiescort.cpp | 2 +- apps/openmw/mwmechanics/aiescort.hpp | 2 +- apps/openmw/mwmechanics/aifollow.cpp | 2 +- apps/openmw/mwmechanics/aifollow.hpp | 4 ++-- apps/openmw/mwmechanics/aipackage.cpp | 2 +- apps/openmw/mwmechanics/aipackage.hpp | 2 +- apps/openmw/mwmechanics/aisequence.cpp | 8 +++----- .../openmw/mwmechanics/mechanicsmanagerimp.cpp | 2 +- apps/openmw/mwmechanics/spellcasting.cpp | 7 ------- components/resource/scenemanager.cpp | 18 +++++++++--------- components/sceneutil/lightutil.hpp | 2 +- components/vfs/bsaarchive.hpp | 2 +- 16 files changed, 33 insertions(+), 49 deletions(-) diff --git a/apps/opencs/model/prefs/state.hpp b/apps/opencs/model/prefs/state.hpp index bcd76c671..fffadee5e 100644 --- a/apps/opencs/model/prefs/state.hpp +++ b/apps/opencs/model/prefs/state.hpp @@ -1,4 +1,4 @@ -#ifndef CSV_PREFS_STATE_H +#ifndef CSM_PREFS_STATE_H #define CSM_PREFS_STATE_H #include diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index 039624c84..7885bf595 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -108,7 +108,7 @@ void CSMWorld::IngredEffectRefIdAdapter::setNestedTable (const RefIdColumn* colu ESM::Ingredient ingredient = record.get(); ingredient.mData = - static_cast >&>(nestedTable).mNestedTable.at(0); + static_cast >&>(nestedTable).mNestedTable.at(0); record.setModified (ingredient); } @@ -120,11 +120,11 @@ CSMWorld::NestedTableWrapperBase* CSMWorld::IngredEffectRefIdAdapter::nestedTabl static_cast&> (data.getRecord (RefIdData::LocalIndex (index, mType))); // return the whole struct - std::vector wrap; + std::vector wrap; wrap.push_back(record.get().mData); // deleted by dtor of NestedTableStoring - return new NestedTableWrapper >(wrap); + return new NestedTableWrapper >(wrap); } QVariant CSMWorld::IngredEffectRefIdAdapter::getNestedData (const RefIdColumn *column, @@ -1129,7 +1129,7 @@ void CSMWorld::CreatureAttributesRefIdAdapter::setNestedTable (const RefIdColumn // store the whole struct creature.mData = - static_cast > &>(nestedTable).mNestedTable.at(0); + static_cast > &>(nestedTable).mNestedTable.at(0); record.setModified (creature); } @@ -1141,10 +1141,10 @@ CSMWorld::NestedTableWrapperBase* CSMWorld::CreatureAttributesRefIdAdapter::nest static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Creature))); // return the whole struct - std::vector wrap; + std::vector wrap; wrap.push_back(record.get().mData); // deleted by dtor of NestedTableStoring - return new NestedTableWrapper >(wrap); + return new NestedTableWrapper >(wrap); } QVariant CSMWorld::CreatureAttributesRefIdAdapter::getNestedData (const RefIdColumn *column, @@ -1235,7 +1235,7 @@ void CSMWorld::CreatureAttackRefIdAdapter::setNestedTable (const RefIdColumn* co // store the whole struct creature.mData = - static_cast > &>(nestedTable).mNestedTable.at(0); + static_cast > &>(nestedTable).mNestedTable.at(0); record.setModified (creature); } @@ -1247,10 +1247,10 @@ CSMWorld::NestedTableWrapperBase* CSMWorld::CreatureAttackRefIdAdapter::nestedTa static_cast&> (data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Creature))); // return the whole struct - std::vector wrap; + std::vector wrap; wrap.push_back(record.get().mData); // deleted by dtor of NestedTableStoring - return new NestedTableWrapper >(wrap); + return new NestedTableWrapper >(wrap); } QVariant CSMWorld::CreatureAttackRefIdAdapter::getNestedData (const RefIdColumn *column, diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 86ecd9dfb..b410204e9 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -27,13 +27,6 @@ namespace { - std::string fpsLevelToStr(int level) - { - if (level == 0) - return "#{sOff}"; - else //if (level == 1) - return "#{sOn}"; - } std::string textureMipmappingToStr(const std::string& val) { diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 70aab95df..4a689d964 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1377,7 +1377,7 @@ namespace MWMechanics { if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow) { - MWWorld::Ptr followTarget = static_cast(*it)->getTarget(); + MWWorld::Ptr followTarget = (*it)->getTarget(); if (followTarget.isEmpty()) continue; if (followTarget == actor) diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index fffab8d77..1fc6c52a4 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -119,7 +119,7 @@ namespace MWMechanics return TypeIdEscort; } - MWWorld::Ptr AiEscort::getTarget() + MWWorld::Ptr AiEscort::getTarget() const { return MWBase::Environment::get().getWorld()->getPtr(mActorId, false); } diff --git a/apps/openmw/mwmechanics/aiescort.hpp b/apps/openmw/mwmechanics/aiescort.hpp index cdb0f7936..677cf6f43 100644 --- a/apps/openmw/mwmechanics/aiescort.hpp +++ b/apps/openmw/mwmechanics/aiescort.hpp @@ -37,7 +37,7 @@ namespace MWMechanics virtual int getTypeId() const; - MWWorld::Ptr getTarget(); + MWWorld::Ptr getTarget() const; virtual bool sideWithTarget() const { return true; } void writeState(ESM::AiSequence::AiSequence &sequence) const; diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index 1430d42f2..02daec19e 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -200,7 +200,7 @@ void AiFollow::writeState(ESM::AiSequence::AiSequence &sequence) const sequence.mPackages.push_back(package); } -MWWorld::Ptr AiFollow::getTarget() +MWWorld::Ptr AiFollow::getTarget() const { if (mActorId == -2) return MWWorld::Ptr(); diff --git a/apps/openmw/mwmechanics/aifollow.hpp b/apps/openmw/mwmechanics/aifollow.hpp index 017ea7122..0f955879a 100644 --- a/apps/openmw/mwmechanics/aifollow.hpp +++ b/apps/openmw/mwmechanics/aifollow.hpp @@ -31,7 +31,7 @@ namespace MWMechanics AiFollow(const ESM::AiSequence::AiFollow* follow); - MWWorld::Ptr getTarget(); + MWWorld::Ptr getTarget() const; virtual bool sideWithTarget() const { return true; } virtual bool followTargetThroughDoors() const { return true; } @@ -60,7 +60,7 @@ namespace MWMechanics float mY; float mZ; std::string mActorRefId; - int mActorId; + mutable int mActorId; std::string mCellId; bool mActive; // have we spotted the target? int mFollowIndex; diff --git a/apps/openmw/mwmechanics/aipackage.cpp b/apps/openmw/mwmechanics/aipackage.cpp index 58ba7dfe8..863fe05ef 100644 --- a/apps/openmw/mwmechanics/aipackage.cpp +++ b/apps/openmw/mwmechanics/aipackage.cpp @@ -20,7 +20,7 @@ MWMechanics::AiPackage::~AiPackage() {} -MWWorld::Ptr MWMechanics::AiPackage::getTarget() +MWWorld::Ptr MWMechanics::AiPackage::getTarget() const { return MWWorld::Ptr(); } diff --git a/apps/openmw/mwmechanics/aipackage.hpp b/apps/openmw/mwmechanics/aipackage.hpp index 72bb4487c..f938a34a1 100644 --- a/apps/openmw/mwmechanics/aipackage.hpp +++ b/apps/openmw/mwmechanics/aipackage.hpp @@ -72,7 +72,7 @@ namespace MWMechanics virtual void fastForward(const MWWorld::Ptr& actor, AiState& state) {} /// Get the target actor the AI is targeted at (not applicable to all AI packages, default return empty Ptr) - virtual MWWorld::Ptr getTarget(); + virtual MWWorld::Ptr getTarget() const; /// Return true if having this AiPackage makes the actor side with the target in fights (default false) virtual bool sideWithTarget() const; diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index 71733d613..5cfc1264a 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -68,9 +68,8 @@ bool AiSequence::getCombatTarget(MWWorld::Ptr &targetActor) const { if (getTypeId() != AiPackage::TypeIdCombat) return false; - const AiCombat *combat = static_cast(mPackages.front()); - targetActor = combat->getTarget(); + targetActor = mPackages.front()->getTarget(); return !targetActor.isEmpty(); } @@ -114,8 +113,7 @@ bool AiSequence::isInCombat(const MWWorld::Ptr &actor) const { if ((*it)->getTypeId() == AiPackage::TypeIdCombat) { - const AiCombat *combat = static_cast(*it); - if (combat->getTarget() == actor) + if ((*it)->getTarget() == actor) return true; } } @@ -255,7 +253,7 @@ void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor) for (std::list::const_iterator iter (mPackages.begin()); iter!=mPackages.end(); ++iter) { if((*iter)->getTypeId() == AiPackage::TypeIdCombat && package.getTypeId() == AiPackage::TypeIdCombat - && static_cast(*iter)->getTarget() == static_cast(&package)->getTarget()) + && (*iter)->getTarget() == (&package)->getTarget()) { return; // already in combat with this actor } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 84da270eb..7fbc3a853 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1330,7 +1330,7 @@ namespace MWMechanics { if ((*it)->getTypeId() == AiPackage::TypeIdCombat) { - MWWorld::Ptr target = static_cast(*it)->getTarget(); + MWWorld::Ptr target = (*it)->getTarget(); if (!target.isEmpty() && target.getClass().isNpc()) isFightingNpc = true; } diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 4c5138835..736d2a616 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -62,13 +62,6 @@ namespace } } - void applyDynamicStatsEffect(int attribute, const MWWorld::Ptr& target, float magnitude) - { - MWMechanics::DynamicStat value = target.getClass().getCreatureStats(target).getDynamic(attribute); - value.setCurrent(value.getCurrent()+magnitude, attribute == 2); - target.getClass().getCreatureStats(target).setDynamic(attribute, value); - } - } namespace MWMechanics diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 85a4afa30..ffe8dd881 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -139,16 +139,16 @@ namespace Resource virtual void apply(osg::Node& node) { if (osgFX::Effect* effect = dynamic_cast(&node)) - apply(*effect); + applyEffect(*effect); osg::StateSet* stateset = node.getStateSet(); if (stateset) - apply(stateset); + applyStateSet(stateset); traverse(node); } - void apply(osgFX::Effect& effect) + void applyEffect(osgFX::Effect& effect) { for (int i =0; igetNumPasses(); ++pass) { if (tech->getPassStateSet(pass)) - apply(tech->getPassStateSet(pass)); + applyStateSet(tech->getPassStateSet(pass)); } } } @@ -165,29 +165,29 @@ namespace Resource { osg::StateSet* stateset = geode.getStateSet(); if (stateset) - apply(stateset); + applyStateSet(stateset); for (unsigned int i=0; igetStateSet(); if (stateset) - apply(stateset); + applyStateSet(stateset); } } - void apply(osg::StateSet* stateset) + void applyStateSet(osg::StateSet* stateset) { const osg::StateSet::TextureAttributeList& texAttributes = stateset->getTextureAttributeList(); for(unsigned int unit=0;unitgetTextureAttribute(unit, osg::StateAttribute::TEXTURE); if (texture) - apply(texture); + applyStateAttribute(texture); } } - void apply(osg::StateAttribute* attr) + void applyStateAttribute(osg::StateAttribute* attr) { osg::Texture* tex = attr->asTexture(); if (tex) diff --git a/components/sceneutil/lightutil.hpp b/components/sceneutil/lightutil.hpp index 810ffa318..d6c970340 100644 --- a/components/sceneutil/lightutil.hpp +++ b/components/sceneutil/lightutil.hpp @@ -8,7 +8,7 @@ namespace osg namespace ESM { - class Light; + struct Light; } namespace SceneUtil diff --git a/components/vfs/bsaarchive.hpp b/components/vfs/bsaarchive.hpp index 25ad60e0a..a6e274037 100644 --- a/components/vfs/bsaarchive.hpp +++ b/components/vfs/bsaarchive.hpp @@ -34,4 +34,4 @@ namespace VFS } -#endif \ No newline at end of file +#endif