1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-17 01:10:10 +00:00

Fix MSVC warnings about local variables redeclaration (#3130)

This commit is contained in:
Andrei Kortunov 2021-09-29 11:36:05 +04:00 committed by GitHub
parent 5794a3b346
commit fc2076db1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 47 deletions

View File

@ -1171,7 +1171,7 @@ namespace MWMechanics
creatureStats.setAiSetting(CreatureStats::AI_Flee, stat);
if (creature && ptr.get<ESM::Creature>()->mBase->mData.mType == ESM::Creature::Undead)
{
Stat<int> stat = creatureStats.getAiSetting(CreatureStats::AI_Flee);
stat = creatureStats.getAiSetting(CreatureStats::AI_Flee);
stat.setModifier(static_cast<int>(effects.get(ESM::MagicEffect::TurnUndead).getMagnitude()));
creatureStats.setAiSetting(CreatureStats::AI_Flee, stat);
}

View File

@ -514,18 +514,18 @@ namespace MWPhysics
void PhysicsSystem::remove(const MWWorld::Ptr &ptr)
{
if (auto found = mObjects.find(ptr.mRef); found != mObjects.end())
if (auto foundObject = mObjects.find(ptr.mRef); foundObject != mObjects.end())
{
if (mUnrefQueue.get())
mUnrefQueue->push(found->second->getShapeInstance());
mUnrefQueue->push(foundObject->second->getShapeInstance());
mAnimatedObjects.erase(found->second.get());
mAnimatedObjects.erase(foundObject->second.get());
mObjects.erase(found);
mObjects.erase(foundObject);
}
else if (auto found = mActors.find(ptr.mRef); found != mActors.end())
else if (auto foundActor = mActors.find(ptr.mRef); foundActor != mActors.end())
{
mActors.erase(found);
mActors.erase(foundActor);
}
}
@ -591,16 +591,16 @@ namespace MWPhysics
void PhysicsSystem::updateScale(const MWWorld::Ptr &ptr)
{
if (auto found = mObjects.find(ptr.mRef); found != mObjects.end())
if (auto foundObject = mObjects.find(ptr.mRef); foundObject != mObjects.end())
{
float scale = ptr.getCellRef().getScale();
found->second->setScale(scale);
mTaskScheduler->updateSingleAabb(found->second);
foundObject->second->setScale(scale);
mTaskScheduler->updateSingleAabb(foundObject->second);
}
else if (auto found = mActors.find(ptr.mRef); found != mActors.end())
else if (auto foundActor = mActors.find(ptr.mRef); foundActor != mActors.end())
{
found->second->updateScale();
mTaskScheduler->updateSingleAabb(found->second);
foundActor->second->updateScale();
mTaskScheduler->updateSingleAabb(foundActor->second);
}
}
@ -633,32 +633,32 @@ namespace MWPhysics
void PhysicsSystem::updateRotation(const MWWorld::Ptr &ptr, osg::Quat rotate)
{
if (auto found = mObjects.find(ptr.mRef); found != mObjects.end())
if (auto foundObject = mObjects.find(ptr.mRef); foundObject != mObjects.end())
{
found->second->setRotation(rotate);
mTaskScheduler->updateSingleAabb(found->second);
foundObject->second->setRotation(rotate);
mTaskScheduler->updateSingleAabb(foundObject->second);
}
else if (auto found = mActors.find(ptr.mRef); found != mActors.end())
else if (auto foundActor = mActors.find(ptr.mRef); foundActor != mActors.end())
{
if (!found->second->isRotationallyInvariant())
if (!foundActor->second->isRotationallyInvariant())
{
found->second->setRotation(rotate);
mTaskScheduler->updateSingleAabb(found->second);
foundActor->second->setRotation(rotate);
mTaskScheduler->updateSingleAabb(foundActor->second);
}
}
}
void PhysicsSystem::updatePosition(const MWWorld::Ptr &ptr)
{
if (auto found = mObjects.find(ptr.mRef); found != mObjects.end())
if (auto foundObject = mObjects.find(ptr.mRef); foundObject != mObjects.end())
{
found->second->updatePosition();
mTaskScheduler->updateSingleAabb(found->second);
foundObject->second->updatePosition();
mTaskScheduler->updateSingleAabb(foundObject->second);
}
else if (auto found = mActors.find(ptr.mRef); found != mActors.end())
else if (auto foundActor = mActors.find(ptr.mRef); foundActor != mActors.end())
{
found->second->updatePosition();
mTaskScheduler->updateSingleAabb(found->second, true);
foundActor->second->updatePosition();
mTaskScheduler->updateSingleAabb(foundActor->second, true);
}
}

View File

@ -440,7 +440,6 @@ namespace MWRender
static_cast<Terrain::QuadTreeWorld*>(mTerrain.get())->addChunkManager(mGroundcover.get());
mResourceSystem->addResourceManager(mGroundcover.get());
float groundcoverDistance = std::max(0.f, Settings::Manager::getFloat("rendering distance", "Groundcover"));
mGroundcover->setViewDistance(groundcoverDistance);
}

View File

@ -917,9 +917,9 @@ namespace MWWorld
// unload
for (auto iter = mInactiveCells.begin(); iter!=mInactiveCells.end(); )
{
auto* cell = *iter++;
deactivateCell(cell);
unloadInactiveCell(cell);
auto* cellToUnload = *iter++;
deactivateCell(cellToUnload);
unloadInactiveCell(cellToUnload);
}
assert(mActiveCells.empty());
assert(mInactiveCells.empty());

View File

@ -39,8 +39,8 @@ namespace DetourNavigator
if (const btCollisionShape* const avoidShape = shapes.mShapeInstance->getAvoidCollisionShape())
{
const ObjectId avoidId(avoidShape);
CollisionShape collisionShape {shapes.mShapeInstance, *avoidShape};
if (mNavMeshManager.addObject(avoidId, collisionShape, transform, AreaType_null))
CollisionShape avoidCollisionShape {shapes.mShapeInstance, *avoidShape};
if (mNavMeshManager.addObject(avoidId, avoidCollisionShape, transform, AreaType_null))
{
updateAvoidShapeId(id, avoidId);
result = true;

View File

@ -49,9 +49,9 @@ namespace DetourNavigator
std::vector<osg::Vec3f> uniqueVertices;
uniqueVertices.reserve(3 * triangles.size());
for (const RecastMeshTriangle& v : triangles)
for (const osg::Vec3f& v : v.mVertices)
uniqueVertices.push_back(v);
for (const RecastMeshTriangle& triangle : triangles)
for (const osg::Vec3f& vertex : triangle.mVertices)
uniqueVertices.push_back(vertex);
std::sort(uniqueVertices.begin(), uniqueVertices.end());
uniqueVertices.erase(std::unique(uniqueVertices.begin(), uniqueVertices.end()), uniqueVertices.end());
@ -61,15 +61,15 @@ namespace DetourNavigator
std::vector<AreaType> areaTypes;
areaTypes.reserve(triangles.size());
for (const RecastMeshTriangle& v : triangles)
for (const RecastMeshTriangle& triangle : triangles)
{
areaTypes.push_back(v.mAreaType);
areaTypes.push_back(triangle.mAreaType);
for (const osg::Vec3f& v : v.mVertices)
for (const osg::Vec3f& vertex : triangle.mVertices)
{
const auto it = std::lower_bound(uniqueVertices.begin(), uniqueVertices.end(), v);
const auto it = std::lower_bound(uniqueVertices.begin(), uniqueVertices.end(), vertex);
assert(it != uniqueVertices.end());
assert(*it == v);
assert(*it == vertex);
indices.push_back(static_cast<int>(it - uniqueVertices.begin()));
}
}
@ -79,11 +79,11 @@ namespace DetourNavigator
std::vector<float> vertices;
vertices.reserve(3 * uniqueVertices.size());
for (const osg::Vec3f& v : uniqueVertices)
for (const osg::Vec3f& vertex : uniqueVertices)
{
vertices.push_back(v.x() + shift.x());
vertices.push_back(v.y() + shift.y());
vertices.push_back(v.z() + shift.z());
vertices.push_back(vertex.x() + shift.x());
vertices.push_back(vertex.y() + shift.y());
vertices.push_back(vertex.z() + shift.z());
}
return Mesh(std::move(indices), std::move(vertices), std::move(areaTypes));

View File

@ -52,10 +52,10 @@ namespace SceneUtil
for (const Heightfield& heightfield : recastMesh.getHeightfields())
{
const Mesh mesh = makeMesh(heightfield);
const Mesh heightfieldMesh = makeMesh(heightfield);
const int indexShift = static_cast<int>(vertices.size() / 3);
std::copy(mesh.getVertices().begin(), mesh.getVertices().end(), std::back_inserter(vertices));
std::transform(mesh.getIndices().begin(), mesh.getIndices().end(), std::back_inserter(indices),
std::copy(heightfieldMesh.getVertices().begin(), heightfieldMesh.getVertices().end(), std::back_inserter(vertices));
std::transform(heightfieldMesh.getIndices().begin(), heightfieldMesh.getIndices().end(), std::back_inserter(indices),
[&] (int index) { return index + indexShift; });
}