Merge pull request #1092 from Allofich/warnings

Fix shadowing warnings
coverity_scan^2
scrawl 8 years ago committed by GitHub
commit 73b6c34a23

@ -39,9 +39,9 @@ void test(const MWWorld::Ptr& actor, int &compiled, int &total, const Compiler::
{ {
std::vector<const ESM::DialInfo*> infos = filter.listAll(*it); std::vector<const ESM::DialInfo*> infos = filter.listAll(*it);
for (std::vector<const ESM::DialInfo*>::iterator it = infos.begin(); it != infos.end(); ++it) for (std::vector<const ESM::DialInfo*>::iterator iter = infos.begin(); iter != infos.end(); ++iter)
{ {
const ESM::DialInfo* info = *it; const ESM::DialInfo* info = *iter;
if (!info->mResultScript.empty()) if (!info->mResultScript.empty())
{ {
bool success = true; bool success = true;

@ -225,7 +225,7 @@ namespace MWGui
mSpellItems.push_back(label); mSpellItems.push_back(label);
coord.top += lineHeight; coord.top += lineHeight;
std::vector<std::string>::const_iterator end = categories[category].spells.end(); end = categories[category].spells.end();
for (std::vector<std::string>::const_iterator it = categories[category].spells.begin(); it != end; ++it) for (std::vector<std::string>::const_iterator it = categories[category].spells.begin(); it != end; ++it)
{ {
const std::string &spellId = *it; const std::string &spellId = *it;

@ -559,8 +559,8 @@ namespace MWGui
std::vector<std::string> destNotes; std::vector<std::string> destNotes;
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(marker.dest); CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(marker.dest);
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second; ++it) for (CustomMarkerCollection::ContainerType::const_iterator iter = markers.first; iter != markers.second; ++iter)
destNotes.push_back(it->second.mNote); destNotes.push_back(iter->second.mNote);
MarkerUserData data (mLocalMapRender); MarkerUserData data (mLocalMapRender);
data.notes = destNotes; data.notes = destNotes;

@ -476,16 +476,16 @@ namespace MWGui
MWWorld::Ptr player = MWMechanics::getPlayer(); MWWorld::Ptr player = MWMechanics::getPlayer();
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
MWWorld::Ptr item; MWWorld::Ptr item;
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) for (MWWorld::ContainerStoreIterator iter = store.begin(); iter != store.end(); ++iter)
{ {
if (Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), id)) if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), id))
{ {
if (item.isEmpty() || if (item.isEmpty() ||
// Prefer the stack with the lowest remaining uses // Prefer the stack with the lowest remaining uses
!item.getClass().hasItemHealth(*it) || !item.getClass().hasItemHealth(*iter) ||
it->getClass().getItemHealth(*it) < item.getClass().getItemHealth(item)) iter->getClass().getItemHealth(*iter) < item.getClass().getItemHealth(item))
{ {
item = *it; item = *iter;
} }
} }
} }

@ -362,10 +362,10 @@ namespace MWGui
std::sort(items.begin(), items.end(), sortRaces); std::sort(items.begin(), items.end(), sortRaces);
int index = 0; int index = 0;
for (std::vector<std::pair<std::string, std::string> >::const_iterator it = items.begin(); it != items.end(); ++it) for (std::vector<std::pair<std::string, std::string> >::const_iterator iter = items.begin(); iter != items.end(); ++iter)
{ {
mRaceList->addItem(it->second, it->first); mRaceList->addItem(iter->second, iter->first);
if (Misc::StringUtils::ciEqual(it->first, mCurrentRaceId)) if (Misc::StringUtils::ciEqual(iter->first, mCurrentRaceId))
mRaceList->setIndexSelected(index); mRaceList->setIndexSelected(index);
++index; ++index;
} }

@ -91,8 +91,8 @@ std::list<AiPackage*>::const_iterator AiSequence::erase(std::list<AiPackage*>::c
{ {
if (package == it) if (package == it)
{ {
AiPackage* package = *it; AiPackage* packagePtr = *it;
delete package; delete packagePtr;
return mPackages.erase(it); return mPackages.erase(it);
} }
} }

@ -478,28 +478,28 @@ void CharacterController::refreshIdleAnims(const WeaponInfo* weap, CharacterStat
mIdleState = idle; mIdleState = idle;
size_t numLoops = ~0ul; size_t numLoops = ~0ul;
std::string idle; std::string idleGroup;
MWRender::Animation::AnimPriority idlePriority (Priority_Default); MWRender::Animation::AnimPriority idlePriority (Priority_Default);
// Only play "idleswim" or "idlesneak" if they exist. Otherwise, fallback to // Only play "idleswim" or "idlesneak" if they exist. Otherwise, fallback to
// "idle"+weapon or "idle". // "idle"+weapon or "idle".
if(mIdleState == CharState_IdleSwim && mAnimation->hasAnimation("idleswim")) if(mIdleState == CharState_IdleSwim && mAnimation->hasAnimation("idleswim"))
{ {
idle = "idleswim"; idleGroup = "idleswim";
idlePriority = Priority_SwimIdle; idlePriority = Priority_SwimIdle;
} }
else if(mIdleState == CharState_IdleSneak && mAnimation->hasAnimation("idlesneak")) else if(mIdleState == CharState_IdleSneak && mAnimation->hasAnimation("idlesneak"))
{ {
idle = "idlesneak"; idleGroup = "idlesneak";
idlePriority[MWRender::Animation::BoneGroup_LowerBody] = Priority_SneakIdleLowerBody; idlePriority[MWRender::Animation::BoneGroup_LowerBody] = Priority_SneakIdleLowerBody;
} }
else if(mIdleState != CharState_None) else if(mIdleState != CharState_None)
{ {
idle = "idle"; idleGroup = "idle";
if(weap != sWeaponTypeListEnd) if(weap != sWeaponTypeListEnd)
{ {
idle += weap->shortgroup; idleGroup += weap->shortgroup;
if(!mAnimation->hasAnimation(idle)) if(!mAnimation->hasAnimation(idleGroup))
idle = "idle"; idleGroup = "idle";
// play until the Loop Stop key 2 to 5 times, then play until the Stop key // play until the Loop Stop key 2 to 5 times, then play until the Stop key
// this replicates original engine behavior for the "Idle1h" 1st-person animation // this replicates original engine behavior for the "Idle1h" 1st-person animation
@ -508,7 +508,7 @@ void CharacterController::refreshIdleAnims(const WeaponInfo* weap, CharacterStat
} }
mAnimation->disable(mCurrentIdle); mAnimation->disable(mCurrentIdle);
mCurrentIdle = idle; mCurrentIdle = idleGroup;
if(!mCurrentIdle.empty()) if(!mCurrentIdle.empty())
mAnimation->play(mCurrentIdle, idlePriority, MWRender::Animation::BlendMask_All, false, mAnimation->play(mCurrentIdle, idlePriority, MWRender::Animation::BlendMask_All, false,
1.0f, "start", "stop", 0.0f, numLoops, true); 1.0f, "start", "stop", 0.0f, numLoops, true);
@ -571,8 +571,8 @@ MWWorld::ContainerStoreIterator getActiveWeapon(CreatureStats &stats, MWWorld::I
else if(type == typeid(ESM::Weapon).name()) else if(type == typeid(ESM::Weapon).name())
{ {
MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>(); MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>();
ESM::Weapon::Type type = (ESM::Weapon::Type)ref->mBase->mData.mType; ESM::Weapon::Type weaponType = (ESM::Weapon::Type)ref->mBase->mData.mType;
switch(type) switch(weaponType)
{ {
case ESM::Weapon::ShortBladeOneHand: case ESM::Weapon::ShortBladeOneHand:
case ESM::Weapon::LongBladeOneHand: case ESM::Weapon::LongBladeOneHand:
@ -1741,14 +1741,12 @@ void CharacterController::update(float duration)
cls.skillUsageSucceeded(mPtr, ESM::Skill::Acrobatics, 0); cls.skillUsageSucceeded(mPtr, ESM::Skill::Acrobatics, 0);
// decrease fatigue // decrease fatigue
const MWWorld::Store<ESM::GameSetting> &gmst = world->getStore().get<ESM::GameSetting>();
const float fatigueJumpBase = gmst.find("fFatigueJumpBase")->getFloat(); const float fatigueJumpBase = gmst.find("fFatigueJumpBase")->getFloat();
const float fatigueJumpMult = gmst.find("fFatigueJumpMult")->getFloat(); const float fatigueJumpMult = gmst.find("fFatigueJumpMult")->getFloat();
float normalizedEncumbrance = mPtr.getClass().getNormalizedEncumbrance(mPtr); float normalizedEncumbrance = mPtr.getClass().getNormalizedEncumbrance(mPtr);
if (normalizedEncumbrance > 1) if (normalizedEncumbrance > 1)
normalizedEncumbrance = 1; normalizedEncumbrance = 1;
const float fatigueDecrease = fatigueJumpBase + (1 - normalizedEncumbrance) * fatigueJumpMult; const float fatigueDecrease = fatigueJumpBase + (1 - normalizedEncumbrance) * fatigueJumpMult;
DynamicStat<float> fatigue = cls.getCreatureStats(mPtr).getFatigue();
fatigue.setCurrent(fatigue.getCurrent() - fatigueDecrease); fatigue.setCurrent(fatigue.getCurrent() - fatigueDecrease);
cls.getCreatureStats(mPtr).setFatigue(fatigue); cls.getCreatureStats(mPtr).setFatigue(fatigue);
} }

@ -83,8 +83,8 @@ void MWMechanics::NpcStats::raiseRank(const std::string &faction)
if (it != mFactionRank.end()) if (it != mFactionRank.end())
{ {
// Does the next rank exist? // Does the next rank exist?
const ESM::Faction* faction = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(lower); const ESM::Faction* factionPtr = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(lower);
if (it->second+1 < 10 && !faction->mRanks[it->second+1].empty()) if (it->second+1 < 10 && !factionPtr->mRanks[it->second+1].empty())
it->second += 1; it->second += 1;
} }
} }

@ -495,13 +495,13 @@ namespace MWMechanics
{ {
if (effectIt->mEffectID == ESM::MagicEffect::AbsorbAttribute+i) if (effectIt->mEffectID == ESM::MagicEffect::AbsorbAttribute+i)
{ {
std::vector<ActiveSpells::ActiveEffect> effects; std::vector<ActiveSpells::ActiveEffect> absorbEffects;
ActiveSpells::ActiveEffect effect_ = effect; ActiveSpells::ActiveEffect effect_ = effect;
effect_.mMagnitude *= -1; effect_.mMagnitude *= -1;
effects.push_back(effect_); absorbEffects.push_back(effect_);
// Also make sure to set casterActorId = target, so that the effect on the caster gets purged when the target dies // Also make sure to set casterActorId = target, so that the effect on the caster gets purged when the target dies
caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell("", true, caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell("", true,
effects, mSourceName, target.getClass().getCreatureStats(target).getActorId()); absorbEffects, mSourceName, target.getClass().getCreatureStats(target).getActorId());
} }
} }
} }
@ -512,11 +512,11 @@ namespace MWMechanics
if (isSummoningEffect(effectIt->mEffectID) && !target.isEmpty() && target.getClass().isActor()) if (isSummoningEffect(effectIt->mEffectID) && !target.isEmpty() && target.getClass().isActor())
{ {
CreatureStats& targetStats = target.getClass().getCreatureStats(target); CreatureStats& targetStats = target.getClass().getCreatureStats(target);
std::map<CreatureStats::SummonKey, int>::iterator found = targetStats.getSummonedCreatureMap().find(std::make_pair(effectIt->mEffectID, mId)); std::map<CreatureStats::SummonKey, int>::iterator findCreature = targetStats.getSummonedCreatureMap().find(std::make_pair(effectIt->mEffectID, mId));
if (found != targetStats.getSummonedCreatureMap().end()) if (findCreature != targetStats.getSummonedCreatureMap().end())
{ {
MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(target, found->second); MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(target, findCreature->second);
targetStats.getSummonedCreatureMap().erase(found); targetStats.getSummonedCreatureMap().erase(findCreature);
} }
} }

@ -423,12 +423,12 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
if (ref.getPtr().getTypeName()==typeid (ESM::ItemLevList).name()) if (ref.getPtr().getTypeName()==typeid (ESM::ItemLevList).name())
{ {
const ESM::ItemLevList* levItem = ref.getPtr().get<ESM::ItemLevList>()->mBase; const ESM::ItemLevList* levItemList = ref.getPtr().get<ESM::ItemLevList>()->mBase;
if (topLevel && std::abs(count) > 1 && levItem->mFlags & ESM::ItemLevList::Each) if (topLevel && std::abs(count) > 1 && levItemList->mFlags & ESM::ItemLevList::Each)
{ {
for (int i=0; i<std::abs(count); ++i) for (int i=0; i<std::abs(count); ++i)
addInitialItem(id, owner, count > 0 ? 1 : -1, true, levItem->mId); addInitialItem(id, owner, count > 0 ? 1 : -1, true, levItemList->mId);
return; return;
} }
else else
@ -436,7 +436,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
std::string id = MWMechanics::getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, false); std::string id = MWMechanics::getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, false);
if (id.empty()) if (id.empty())
return; return;
addInitialItem(id, owner, count, false, levItem->mId); addInitialItem(id, owner, count, false, levItemList->mId);
} }
} }
else else

Loading…
Cancel
Save