Runtime: Resolve -Wrange-loop-analysis warnings

This commit is contained in:
Luke Street 2020-09-18 16:47:59 -04:00
parent e531affd21
commit 834fe39074
6 changed files with 19 additions and 19 deletions

View File

@ -29,27 +29,27 @@ CSlideShow::CSlideShow() : CIOWin("SlideShow"), x130_(g_tweakSlideShow->GetX54()
xf8_stickTextures.reserve(18); xf8_stickTextures.reserve(18);
x108_buttonTextures.reserve(8); x108_buttonTextures.reserve(8);
SObjectTag txtrTag(FOURCC('TXTR'), 0); SObjectTag txtrTag(FOURCC('TXTR'), 0);
for (const ITweakPlayerRes::ResId lStickId : g_tweakPlayerRes->x24_lStick) { for (const auto& lStickId : g_tweakPlayerRes->x24_lStick) {
txtrTag.id = lStickId; txtrTag.id = lStickId;
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag)); xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
} }
for (const ITweakPlayerRes::ResId cStickId : g_tweakPlayerRes->x4c_cStick) { for (const auto& cStickId : g_tweakPlayerRes->x4c_cStick) {
txtrTag.id = cStickId; txtrTag.id = cStickId;
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag)); xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
} }
for (const ITweakPlayerRes::ResId lTriggerId : g_tweakPlayerRes->x74_lTrigger) { for (const auto& lTriggerId : g_tweakPlayerRes->x74_lTrigger) {
txtrTag.id = lTriggerId; txtrTag.id = lTriggerId;
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag)); xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
} }
for (const ITweakPlayerRes::ResId rTriggerId : g_tweakPlayerRes->x80_rTrigger) { for (const auto& rTriggerId : g_tweakPlayerRes->x80_rTrigger) {
txtrTag.id = rTriggerId; txtrTag.id = rTriggerId;
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag)); xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
} }
for (const ITweakPlayerRes::ResId bButtonId : g_tweakPlayerRes->xa4_bButton) { for (const auto& bButtonId : g_tweakPlayerRes->xa4_bButton) {
txtrTag.id = bButtonId; txtrTag.id = bButtonId;
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag)); xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
} }
for (const ITweakPlayerRes::ResId yButtonId : g_tweakPlayerRes->xbc_yButton) { for (const auto& yButtonId : g_tweakPlayerRes->xbc_yButton) {
txtrTag.id = yButtonId; txtrTag.id = yButtonId;
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag)); xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
} }

View File

@ -998,7 +998,7 @@ void CElitePirate::AttractProjectiles(CStateManager& mgr) {
rstl::reserved_vector<TUniqueId, 1024> charNearList; rstl::reserved_vector<TUniqueId, 1024> charNearList;
mgr.BuildNearList(charNearList, aabb, CMaterialFilter::MakeInclude({EMaterialTypes::Character}), nullptr); mgr.BuildNearList(charNearList, aabb, CMaterialFilter::MakeInclude({EMaterialTypes::Character}), nullptr);
for (const TUniqueId projId : projNearList) { for (const auto& projId : projNearList) {
TCastToPtr<CGameProjectile> projectile = mgr.ObjectById(projId); TCastToPtr<CGameProjectile> projectile = mgr.ObjectById(projId);
if (!projectile || projectile->GetType() == EWeaponType::Missile || if (!projectile || projectile->GetType() == EWeaponType::Missile ||
projectile->GetOwnerId() != mgr.GetPlayer().GetUniqueId() || projectile->GetOwnerId() != mgr.GetPlayer().GetUniqueId() ||
@ -1117,7 +1117,7 @@ void CElitePirate::UpdateHealthInfo(CStateManager& mgr) {
void CElitePirate::ExtendTouchBounds(const CStateManager& mgr, const rstl::reserved_vector<TUniqueId, 7>& uids, void CElitePirate::ExtendTouchBounds(const CStateManager& mgr, const rstl::reserved_vector<TUniqueId, 7>& uids,
const zeus::CVector3f& vec) const { const zeus::CVector3f& vec) const {
for (const TUniqueId uid : uids) { for (const auto& uid : uids) {
if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(uid)) { if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(uid)) {
actor->SetExtendedTouchBounds(vec); actor->SetExtendedTouchBounds(vec);
} }
@ -1160,7 +1160,7 @@ bool CElitePirate::IsClosestEnergyAttractor(const CStateManager& mgr,
const rstl::reserved_vector<TUniqueId, 1024>& charNearList, const rstl::reserved_vector<TUniqueId, 1024>& charNearList,
const zeus::CVector3f& projectilePos) const { const zeus::CVector3f& projectilePos) const {
const float distance = (projectilePos - GetTranslation()).magSquared(); const float distance = (projectilePos - GetTranslation()).magSquared();
for (const auto id : charNearList) { for (const auto& id : charNearList) {
if (const TCastToConstPtr<CPatterned> actor = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CPatterned> actor = mgr.GetObjectById(id)) {
if (actor->GetUniqueId() != GetUniqueId() && actor->IsEnergyAttractor() && if (actor->GetUniqueId() != GetUniqueId() && actor->IsEnergyAttractor() &&
(projectilePos - actor->GetTranslation()).magSquared() < distance) { (projectilePos - actor->GetTranslation()).magSquared() < distance) {

View File

@ -175,7 +175,7 @@ bool CFireFlea::CheckNearWater(const CStateManager& mgr, const zeus::CVector3f&
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
mgr.BuildNearList(nearList, GetTranslation(), dir, 2.f, CMaterialFilter::skPassEverything, nullptr); mgr.BuildNearList(nearList, GetTranslation(), dir, 2.f, CMaterialFilter::skPassEverything, nullptr);
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (TCastToConstPtr<CScriptWater>(mgr.GetObjectById(id))) if (TCastToConstPtr<CScriptWater>(mgr.GetObjectById(id)))
return true; return true;
} }

View File

@ -185,7 +185,7 @@ void CFlyingPirate::CFlyingPirateRagDoll::PreRender(const zeus::CVector3f& v, CM
CAnimData* const animData = mData.GetAnimationData(); CAnimData* const animData = mData.GetAnimationData();
const CCharLayoutInfo& layout = animData->GetCharLayoutInfo(); const CCharLayoutInfo& layout = animData->GetCharLayoutInfo();
CHierarchyPoseBuilder& poseBuilder = animData->PoseBuilder(); CHierarchyPoseBuilder& poseBuilder = animData->PoseBuilder();
for (const auto id : layout.GetSegIdList().GetList()) { for (const auto& id : layout.GetSegIdList().GetList()) {
if (layout.GetRootNode()->GetBoneMap()[id].x10_children.size() > 1) { if (layout.GetRootNode()->GetBoneMap()[id].x10_children.size() > 1) {
poseBuilder.GetTreeMap()[id].x4_rotation = zeus::CQuaternion(); poseBuilder.GetTreeMap()[id].x4_rotation = zeus::CQuaternion();
} }
@ -541,7 +541,7 @@ void CFlyingPirate::CalculateRenderBounds() {
} }
bool CFlyingPirate::CanFireMissiles(CStateManager& mgr) { bool CFlyingPirate::CanFireMissiles(CStateManager& mgr) {
for (const auto seg : x864_missileSegments) { for (const auto& seg : x864_missileSegments) {
const zeus::CTransform xf = GetLctrTransform(seg); const zeus::CTransform xf = GetLctrTransform(seg);
const zeus::CVector3f dir = xf.origin + (3.f * xf.frontVector()); const zeus::CVector3f dir = xf.origin + (3.f * xf.frontVector());
CMaterialList matList(EMaterialTypes::Player, EMaterialTypes::ProjectilePassthrough); CMaterialList matList(EMaterialTypes::Player, EMaterialTypes::ProjectilePassthrough);
@ -597,7 +597,7 @@ bool CFlyingPirate::CoverCheck(CStateManager& mgr, float) {
bool CFlyingPirate::CoverFind(CStateManager& mgr, float) { bool CFlyingPirate::CoverFind(CStateManager& mgr, float) {
float closestMag = x568_data.x0_maxCoverDistance * x568_data.x0_maxCoverDistance; float closestMag = x568_data.x0_maxCoverDistance * x568_data.x0_maxCoverDistance;
CScriptCoverPoint* closest = nullptr; CScriptCoverPoint* closest = nullptr;
for (const auto& entity : *mgr.ObjectListById(EGameObjectList::PlatformAndDoor)) { for (const auto entity : *mgr.ObjectListById(EGameObjectList::PlatformAndDoor)) {
if (TCastToPtr<CScriptCoverPoint> cover = entity) { if (TCastToPtr<CScriptCoverPoint> cover = entity) {
if (cover->GetActive() && cover->ShouldLandHere() && !cover->GetInUse(x8_uid) && if (cover->GetActive() && cover->ShouldLandHere() && !cover->GetInUse(x8_uid) &&
cover->GetAreaIdAlways() == x4_areaId) { cover->GetAreaIdAlways() == x4_areaId) {
@ -762,7 +762,7 @@ pas::EStepDirection CFlyingPirate::GetDodgeDirection(CStateManager& mgr, float a
bool canDodgeUp = true; bool canDodgeUp = true;
bool canDodgeDown = true; bool canDodgeDown = true;
pas::EStepDirection direction = pas::EStepDirection::Invalid; pas::EStepDirection direction = pas::EStepDirection::Invalid;
for (const auto& entity : *mgr.ObjectListById(EGameObjectList::AiWaypoint)) { for (const auto entity : *mgr.ObjectListById(EGameObjectList::AiWaypoint)) {
if (entity == this) if (entity == this)
continue; continue;
if (TCastToPtr<CPhysicsActor> actor = entity) { if (TCastToPtr<CPhysicsActor> actor = entity) {
@ -1437,7 +1437,7 @@ void CFlyingPirate::Taunt(CStateManager& mgr, EStateMsg msg, float) {
const TUniqueId playerUid = mgr.GetPlayer().GetUniqueId(); const TUniqueId playerUid = mgr.GetPlayer().GetUniqueId();
x7a0_boneTracking.SetTarget(playerUid); x7a0_boneTracking.SetTarget(playerUid);
bool foundPirate = false; bool foundPirate = false;
for (const auto& obj : *mgr.ObjectListById(EGameObjectList::AiWaypoint)) { for (const auto obj : *mgr.ObjectListById(EGameObjectList::AiWaypoint)) {
if (const CSpacePirate* const pirate = CPatterned::CastTo<CSpacePirate>(obj)) { if (const CSpacePirate* const pirate = CPatterned::CastTo<CSpacePirate>(obj)) {
if (pirate->GetEnableAim() && pirate->IsAlive() && pirate->GetAreaIdAlways() == x4_areaId && if (pirate->GetEnableAim() && pirate->IsAlive() && pirate->GetAreaIdAlways() == x4_areaId &&
(pirate->GetTranslation() - GetTranslation()).magSquared() < (pirate->GetTranslation() - GetTranslation()).magSquared() <
@ -1579,7 +1579,7 @@ void CFlyingPirate::Think(float dt, CStateManager& mgr) {
const zeus::CVector3f dist = const zeus::CVector3f dist =
(GetBoundingBox().center() - mgr.GetPlayer().GetAimPosition(mgr, 0.f)).normalized(); (GetBoundingBox().center() - mgr.GetPlayer().GetAimPosition(mgr, 0.f)).normalized();
if (dist.magSquared() < 0.9f) { if (dist.magSquared() < 0.9f) {
for (const auto& obj : *mgr.ObjectListById(EGameObjectList::AiWaypoint)) { for (const auto obj : *mgr.ObjectListById(EGameObjectList::AiWaypoint)) {
if (const auto* pirate = CPatterned::CastTo<const CSpacePirate>(obj)) { if (const auto* pirate = CPatterned::CastTo<const CSpacePirate>(obj)) {
if (pirate->GetEnableAim() && pirate->GetAreaIdAlways() == x4_areaId) { if (pirate->GetEnableAim() && pirate->GetAreaIdAlways() == x4_areaId) {
x7e4_ += 0.2f; x7e4_ += 0.2f;

View File

@ -247,7 +247,7 @@ void CMetroid::SelectTarget(CStateManager& mgr, EStateMsg msg, float arg) {
mgr.BuildNearList(nearList, zeus::CAABox{pos - range, pos + range}, mgr.BuildNearList(nearList, zeus::CAABox{pos - range, pos + range},
CMaterialFilter::MakeInclude({EMaterialTypes::Character}), nullptr); CMaterialFilter::MakeInclude({EMaterialTypes::Character}), nullptr);
CSpacePirate* closestPirate = nullptr; CSpacePirate* closestPirate = nullptr;
for (const auto id : nearList) { for (const auto& id : nearList) {
if (auto* pirate = CPatterned::CastTo<CSpacePirate>(mgr.ObjectById(id))) { if (auto* pirate = CPatterned::CastTo<CSpacePirate>(mgr.ObjectById(id))) {
if (IsPirateValidTarget(pirate, mgr)) { if (IsPirateValidTarget(pirate, mgr)) {
float distSq = (pirate->GetTranslation() - pos).magSquared(); float distSq = (pirate->GetTranslation() - pos).magSquared();
@ -688,7 +688,7 @@ bool CMetroid::IsHunterAttacking(CStateManager& mgr) {
if (!aiMgr->HasRangedAttackers()) { if (!aiMgr->HasRangedAttackers()) {
return false; return false;
} }
for (const auto id : aiMgr->GetRangedAttackers()) { for (const auto& id : aiMgr->GetRangedAttackers()) {
if (CPatterned::CastTo<CMetroidBeta>(mgr.GetObjectById(id)) != nullptr) { if (CPatterned::CastTo<CMetroidBeta>(mgr.GetObjectById(id)) != nullptr) {
return true; return true;
} }

View File

@ -645,7 +645,7 @@ bool CTryclops::sub8025dbd0(CStateManager& mgr) {
return true; return true;
} }
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (id == GetUniqueId()) { if (id == GetUniqueId()) {
continue; continue;
} }