Runtime: Resolve -Wrange-loop-analysis warnings (part 2)

This commit is contained in:
Luke Street 2020-09-18 17:04:50 -04:00
parent 834fe39074
commit 76de1541f2
18 changed files with 47 additions and 47 deletions

View File

@ -20,7 +20,7 @@ CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& savw, C
SetIsMapped(i, mapped); SetIsMapped(i, mapped);
} }
for (const TEditorId doorId : savw.GetDoors()) { for (const auto& doorId : savw.GetDoors()) {
SetDoorVisited(doorId, reader.ReadEncoded(1) != 0); SetDoorVisited(doorId, reader.ReadEncoded(1) != 0);
} }
@ -46,7 +46,7 @@ void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAss
} }
} }
for (const TEditorId doorId : savw.GetDoors()) { for (const auto& doorId : savw.GetDoors()) {
writer.WriteEncoded(u32(IsDoorVisited(doorId)), 1); writer.WriteEncoded(u32(IsDoorVisited(doorId)), 1);
} }

View File

@ -167,7 +167,7 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const {
const TLockedToken<CSaveWorld> saveWorld = const TLockedToken<CSaveWorld> saveWorld =
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()}); g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()});
for (const TEditorId cineId : saveWorld->GetCinematics()) { for (const auto& cineId : saveWorld->GetCinematics()) {
w.WriteEncoded(u32(GetCinematicState(world.first, cineId)), 1); w.WriteEncoded(u32(GetCinematicState(world.first, cineId)), 1);
} }
} }

View File

@ -369,7 +369,7 @@ TAreaId CStateManager::GetVisAreaId() const {
BuildNearList(nearList, camAABB, BuildNearList(nearList, camAABB,
CMaterialFilter(EMaterialTypes::AIBlock, CMaterialList(), CMaterialFilter::EFilterType::Include), CMaterialFilter(EMaterialTypes::AIBlock, CMaterialList(), CMaterialFilter::EFilterType::Include),
nullptr); nullptr);
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (const TCastToConstPtr<CScriptDock> dock = GetObjectById(id)) { if (const TCastToConstPtr<CScriptDock> dock = GetObjectById(id)) {
if (dock->GetAreaId() == curArea && dock->HasPointCrossedDock(*this, camTranslation)) { if (dock->GetAreaId() == curArea && dock->HasPointCrossedDock(*this, camTranslation)) {
return dock->GetCurrentConnectedAreaId(*this); return dock->GetCurrentConnectedAreaId(*this);
@ -752,7 +752,7 @@ void CStateManager::DrawWorld() {
SetupFogForArea(*areaArr[areaCount - 1]); SetupFogForArea(*areaArr[areaCount - 1]);
} }
for (const TUniqueId id : x86c_stateManagerContainer->xf370_) { for (const auto& id : x86c_stateManagerContainer->xf370_) {
if (auto* ent = static_cast<CActor*>(ObjectById(id))) { if (auto* ent = static_cast<CActor*>(ObjectById(id))) {
if (!thermal || (ent->xe6_27_thermalVisorFlags & 1) != 0) { if (!thermal || (ent->xe6_27_thermalVisorFlags & 1) != 0) {
ent->Render(*this); ent->Render(*this);
@ -831,7 +831,7 @@ void CStateManager::DrawWorld() {
if (thermal) { if (thermal) {
if (x86c_stateManagerContainer->xf39c_renderLast.size()) { if (x86c_stateManagerContainer->xf39c_renderLast.size()) {
CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN);
for (const TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) { for (const auto& id : x86c_stateManagerContainer->xf39c_renderLast) {
if (auto* actor = static_cast<CActor*>(ObjectById(id))) { if (auto* actor = static_cast<CActor*>(ObjectById(id))) {
if ((actor->xe6_27_thermalVisorFlags & 1) != 0) { if ((actor->xe6_27_thermalVisorFlags & 1) != 0) {
actor->Render(*this); actor->Render(*this);
@ -843,7 +843,7 @@ void CStateManager::DrawWorld() {
g_Renderer->DoThermalBlendCold(); g_Renderer->DoThermalBlendCold();
xf34_thermalFlag = EThermalDrawFlag::Hot; xf34_thermalFlag = EThermalDrawFlag::Hot;
for (const TUniqueId id : x86c_stateManagerContainer->xf370_) { for (const auto& id : x86c_stateManagerContainer->xf370_) {
if (auto* actor = static_cast<CActor*>(ObjectById(id))) { if (auto* actor = static_cast<CActor*>(ObjectById(id))) {
if ((actor->xe6_27_thermalVisorFlags & 2) != 0) { if ((actor->xe6_27_thermalVisorFlags & 2) != 0) {
actor->Render(*this); actor->Render(*this);
@ -909,7 +909,7 @@ void CStateManager::DrawWorld() {
if (x86c_stateManagerContainer->xf39c_renderLast.size()) { if (x86c_stateManagerContainer->xf39c_renderLast.size()) {
CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN);
for (const TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) { for (const auto& id : x86c_stateManagerContainer->xf39c_renderLast) {
if (auto* actor = static_cast<CActor*>(ObjectById(id))) { if (auto* actor = static_cast<CActor*>(ObjectById(id))) {
if (!thermal || actor->xe6_27_thermalVisorFlags & 0x2) { if (!thermal || actor->xe6_27_thermalVisorFlags & 0x2) {
actor->Render(*this); actor->Render(*this);
@ -1502,7 +1502,7 @@ std::pair<TEditorId, TUniqueId> CStateManager::GenerateObject(TEditorId eid) {
} }
void CStateManager::InitScriptObjects(const std::vector<TEditorId>& ids) { void CStateManager::InitScriptObjects(const std::vector<TEditorId>& ids) {
for (const TEditorId id : ids) { for (const auto& id : ids) {
if (id == kInvalidEditorId) { if (id == kInvalidEditorId) {
continue; continue;
} }
@ -1619,7 +1619,7 @@ void CStateManager::ApplyDamageToWorld(TUniqueId damager, const CActor& actor, c
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
BuildNearList(nearList, aabb, filter, &actor); BuildNearList(nearList, aabb, filter, &actor);
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
CEntity* ent = ObjectById(id); CEntity* ent = ObjectById(id);
if (ent == nullptr) { if (ent == nullptr) {
continue; continue;
@ -1658,7 +1658,7 @@ void CStateManager::ProcessRadiusDamage(const CActor& damager, CActor& damagee,
const zeus::CAABox aabb(damager.GetTranslation() - info.GetRadius(), damager.GetTranslation() + info.GetRadius()); const zeus::CAABox aabb(damager.GetTranslation() - info.GetRadius(), damager.GetTranslation() + info.GetRadius());
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
BuildNearList(nearList, aabb, filter, nullptr); BuildNearList(nearList, aabb, filter, nullptr);
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
CEntity* ent = ObjectById(id); CEntity* ent = ObjectById(id);
if (ent == nullptr || ent->GetUniqueId() == damager.GetUniqueId() || ent->GetUniqueId() == senderId || if (ent == nullptr || ent->GetUniqueId() == damager.GetUniqueId() || ent->GetUniqueId() == senderId ||
ent->GetUniqueId() == damagee.GetUniqueId()) { ent->GetUniqueId() == damagee.GetUniqueId()) {
@ -2317,7 +2317,7 @@ void CStateManager::CrossTouchActors() {
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
BuildNearList(nearList, *touchAABB, filter, &actor); BuildNearList(nearList, *touchAABB, filter, &actor);
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
auto* ent2 = static_cast<CActor*>(ObjectById(id)); auto* ent2 = static_cast<CActor*>(ObjectById(id));
if (!ent2) { if (!ent2) {
continue; continue;
@ -2388,7 +2388,7 @@ void CStateManager::ShowPausedHUDMemo(CAssetId strg, float time) {
} }
void CStateManager::ClearGraveyard() { void CStateManager::ClearGraveyard() {
for (const TUniqueId id : x854_objectGraveyard) { for (const auto& id : x854_objectGraveyard) {
CEntity* ent = GetAllObjectList().GetValidObjectById(id); CEntity* ent = GetAllObjectList().GetValidObjectById(id);
RemoveObject(id); RemoveObject(id);
std::default_delete<CEntity>()(ent); std::default_delete<CEntity>()(ent);

View File

@ -293,7 +293,7 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
} }
bool inactiveHintRemoved = false; bool inactiveHintRemoved = false;
for (const TUniqueId id : x2b0_inactiveCameraHints) { for (const auto& id : x2b0_inactiveCameraHints) {
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.GetObjectById(id)) {
if (hint->GetHelperCount() == 0 || hint->GetInactive()) { if (hint->GetHelperCount() == 0 || hint->GetInactive()) {
for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) { for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) {
@ -313,7 +313,7 @@ void CCameraManager::UpdateCameraHints(float, CStateManager& mgr) {
x2b0_inactiveCameraHints.clear(); x2b0_inactiveCameraHints.clear();
bool activeHintAdded = false; bool activeHintAdded = false;
for (const TUniqueId id : x334_activeCameraHints) { for (const auto& id : x334_activeCameraHints) {
if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CScriptCameraHint> hint = mgr.GetObjectById(id)) {
bool activeHintPresent = false; bool activeHintPresent = false;
for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) { for (auto it = xac_cameraHints.begin(); it != xac_cameraHints.end(); ++it) {

View File

@ -473,7 +473,7 @@ bool CGameCollision::DetectStaticCollisionBoolean_Cached(const CStateManager& mg
bool CGameCollision::DetectDynamicCollisionBoolean(const CCollisionPrimitive& prim, const zeus::CTransform& xf, bool CGameCollision::DetectDynamicCollisionBoolean(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const CStateManager& mgr) { const CStateManager& mgr) {
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (const TCastToConstPtr<CPhysicsActor> actor = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CPhysicsActor> actor = mgr.GetObjectById(id)) {
const CInternalCollisionStructure::CPrimDesc p0(prim, CMaterialFilter::skPassEverything, xf); const CInternalCollisionStructure::CPrimDesc p0(prim, CMaterialFilter::skPassEverything, xf);
const CInternalCollisionStructure::CPrimDesc p1( const CInternalCollisionStructure::CPrimDesc p1(
@ -643,7 +643,7 @@ bool CGameCollision::DetectStaticCollision_Cached_Moving(const CStateManager& mg
bool CGameCollision::DetectDynamicCollision(const CCollisionPrimitive& prim, const zeus::CTransform& xf, bool CGameCollision::DetectDynamicCollision(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, TUniqueId& idOut, const rstl::reserved_vector<TUniqueId, 1024>& nearList, TUniqueId& idOut,
CCollisionInfoList& list, const CStateManager& mgr) { CCollisionInfoList& list, const CStateManager& mgr) {
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (const TCastToConstPtr<CPhysicsActor> actor = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CPhysicsActor> actor = mgr.GetObjectById(id)) {
const CInternalCollisionStructure::CPrimDesc p0(prim, CMaterialFilter::skPassEverything, xf); const CInternalCollisionStructure::CPrimDesc p0(prim, CMaterialFilter::skPassEverything, xf);
const CInternalCollisionStructure::CPrimDesc p1( const CInternalCollisionStructure::CPrimDesc p1(
@ -663,7 +663,7 @@ bool CGameCollision::DetectDynamicCollisionMoving(const CCollisionPrimitive& pri
const zeus::CVector3f& dir, TUniqueId& idOut, CCollisionInfo& infoOut, const zeus::CVector3f& dir, TUniqueId& idOut, CCollisionInfo& infoOut,
double& dOut, const CStateManager& mgr) { double& dOut, const CStateManager& mgr) {
bool ret = false; bool ret = false;
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
double d = dOut; double d = dOut;
CCollisionInfo info; CCollisionInfo info;
if (const TCastToConstPtr<CPhysicsActor> actor = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CPhysicsActor> actor = mgr.GetObjectById(id)) {

View File

@ -137,7 +137,7 @@ void CHudRadarInterface::Draw(const CStateManager& mgr, float alpha) {
drawParms.x0_playerPos = mgr.GetPlayer().GetTranslation(); drawParms.x0_playerPos = mgr.GetPlayer().GetTranslation();
drawParms.x74_alpha = alpha; drawParms.x74_alpha = alpha;
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(id)) {
if (!act->GetActive()) { if (!act->GetActive()) {
continue; continue;

View File

@ -563,7 +563,7 @@ void CFlyingPirate::CheckForProjectiles(CStateManager& mgr) {
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
mgr.BuildNearList(nearList, box, CMaterialFilter::MakeInclude(EMaterialTypes::Projectile), this); mgr.BuildNearList(nearList, box, CMaterialFilter::MakeInclude(EMaterialTypes::Projectile), this);
for (const auto id : nearList) { for (const auto& id : nearList) {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(id)) { if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(id)) {
zeus::CVector3f dist = GetBoundingBox().center() - proj->GetTranslation(); zeus::CVector3f dist = GetBoundingBox().center() - proj->GetTranslation();
if (dist.isMagnitudeSafe()) { if (dist.isMagnitudeSafe()) {

View File

@ -1274,13 +1274,13 @@ void CIceSheegoth::UpdateHealthInfo(CStateManager& mgr) {
hpDelta = std::max(hpDelta, x970_maxHp - colAct->GetHealthInfo(mgr)->GetHP()); hpDelta = std::max(hpDelta, x970_maxHp - colAct->GetHealthInfo(mgr)->GetHP());
} }
for (const TUniqueId uid : xafc_gillColliders) { for (const auto& uid : xafc_gillColliders) {
if (const TCastToConstPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) { if (const TCastToConstPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) {
hpDelta = std::max(hpDelta, x970_maxHp - colAct->GetHealthInfo(mgr)->GetHP()); hpDelta = std::max(hpDelta, x970_maxHp - colAct->GetHealthInfo(mgr)->GetHP());
} }
} }
for (const TUniqueId uid : xb04_) { for (const auto& uid : xb04_) {
if (const TCastToConstPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) { if (const TCastToConstPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) {
hpDelta = std::max(hpDelta, x970_maxHp - colAct->GetHealthInfo(mgr)->GetHP()); hpDelta = std::max(hpDelta, x970_maxHp - colAct->GetHealthInfo(mgr)->GetHP());
} }
@ -1290,13 +1290,13 @@ void CIceSheegoth::UpdateHealthInfo(CStateManager& mgr) {
if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(xaf8_mouthCollider)) { if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(xaf8_mouthCollider)) {
colAct->HealthInfo(mgr)->SetHP(x970_maxHp); colAct->HealthInfo(mgr)->SetHP(x970_maxHp);
} }
for (const TUniqueId uid : xafc_gillColliders) { for (const auto& uid : xafc_gillColliders) {
if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) { if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) {
colAct->HealthInfo(mgr)->SetHP(x970_maxHp); colAct->HealthInfo(mgr)->SetHP(x970_maxHp);
} }
} }
for (const TUniqueId uid : xb04_) { for (const auto& uid : xb04_) {
if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) { if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) {
colAct->HealthInfo(mgr)->SetHP(x970_maxHp); colAct->HealthInfo(mgr)->SetHP(x970_maxHp);
} }
@ -1497,7 +1497,7 @@ bool CIceSheegoth::IsClosestSheegoth(CStateManager& mgr, const rstl::reserved_ve
const zeus::CVector3f& projectileOffset) const { const zeus::CVector3f& projectileOffset) const {
zeus::CVector3f diff = projectileOffset - GetTranslation(); zeus::CVector3f diff = projectileOffset - GetTranslation();
const float diffMag = diff.magSquared(); const float diffMag = diff.magSquared();
for (const TUniqueId uid : nearList) { for (const auto& uid : nearList) {
const CIceSheegoth* goth = CPatterned::CastTo<CIceSheegoth>(mgr.GetObjectById(uid)); const CIceSheegoth* goth = CPatterned::CastTo<CIceSheegoth>(mgr.GetObjectById(uid));
if (!goth || goth->GetUniqueId() == GetUniqueId()) if (!goth || goth->GetUniqueId() == GetUniqueId())
continue; continue;

View File

@ -1316,7 +1316,7 @@ bool CMetroid::ShouldDodge(CStateManager& mgr, float arg) {
return false; return false;
} }
const auto front = xf.frontVector(); const auto front = xf.frontVector();
for (const auto id : nearList) { for (const auto& id : nearList) {
if (TCastToConstPtr<CGameProjectile> projectile = mgr.GetObjectById(id)) { if (TCastToConstPtr<CGameProjectile> projectile = mgr.GetObjectById(id)) {
if (!projectile->HasAttrib(EProjectileAttrib::Ice)) { if (!projectile->HasAttrib(EProjectileAttrib::Ice)) {
continue; continue;

View File

@ -170,7 +170,7 @@ zeus::CQuaternion CRipperControlledPlatform::Move(float arg, CStateManager& mgr)
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, 1024> filteredNearList; rstl::reserved_vector<TUniqueId, 1024> filteredNearList;
mgr.BuildColliderList(nearList, *this, GetMotionVolume(arg)); mgr.BuildColliderList(nearList, *this, GetMotionVolume(arg));
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (!IsRider(id) && !IsSlave(id)) { if (!IsRider(id) && !IsSlave(id)) {
filteredNearList.push_back(id); filteredNearList.push_back(id);
} }

View File

@ -112,7 +112,7 @@ void CSeedling::Render(CStateManager& mgr) {
flags.x2_flags = 3; flags.x2_flags = 3;
flags.x4_color = zeus::skWhite; flags.x4_color = zeus::skWhite;
for (const std::string_view sv : skNeedleLocators[index]) { for (const auto& sv : skNeedleLocators[index]) {
x6bc_spikeData->Render(mgr, GetLctrTransform(sv), x90_actorLights.get(), flags); x6bc_spikeData->Render(mgr, GetLctrTransform(sv), x90_actorLights.get(), flags);
} }
} }
@ -208,7 +208,7 @@ bool CSeedling::ShouldAttack(CStateManager& mgr, float) {
void CSeedling::LaunchNeedles(CStateManager& mgr) { void CSeedling::LaunchNeedles(CStateManager& mgr) {
const auto& needleLocators = skNeedleLocators[size_t(x722_25_curNeedleCluster)]; const auto& needleLocators = skNeedleLocators[size_t(x722_25_curNeedleCluster)];
for (const std::string_view needle : needleLocators) { for (const auto& needle : needleLocators) {
LaunchProjectile(GetLctrTransform(needle), mgr, int(needleLocators.size()), EProjectileAttrib::None, true, {}, LaunchProjectile(GetLctrTransform(needle), mgr, int(needleLocators.size()), EProjectileAttrib::None, true, {},
0xFFFF, false, GetModelData()->GetScale()); 0xFFFF, false, GetModelData()->GetScale());
} }

View File

@ -43,7 +43,7 @@ CAuxWeapon::CAuxWeapon(TUniqueId playerId)
} }
void CAuxWeapon::InitComboData() { void CAuxWeapon::InitComboData() {
for (const auto comboName : skComboNames) { for (const auto& comboName : skComboNames) {
x28_combos.push_back(g_SimplePool->GetObj(comboName)); x28_combos.push_back(g_SimplePool->GetObj(comboName));
} }
} }

View File

@ -147,7 +147,7 @@ CRayCastResult CFlameThrower::DoCollisionCheck(TUniqueId& idOut, const zeus::CAA
lookXf.origin = delta * 0.5f + colPoints[i - 1]; lookXf.origin = delta * 0.5f + colPoints[i - 1];
const zeus::COBBox obb(lookXf, {curRadius, delta.magnitude() * 0.5f, curRadius}); const zeus::COBBox obb(lookXf, {curRadius, delta.magnitude() * 0.5f, curRadius});
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (auto* act = static_cast<CActor*>(mgr.ObjectById(id))) { if (auto* act = static_cast<CActor*>(mgr.ObjectById(id))) {
const CProjectileTouchResult tres = CanCollideWith(*act, mgr); const CProjectileTouchResult tres = CanCollideWith(*act, mgr);
if (tres.GetActorId() == kInvalidUniqueId) { if (tres.GetActorId() == kInvalidUniqueId) {

View File

@ -200,7 +200,7 @@ void CPlayerGun::InitBombData() {
} }
void CPlayerGun::InitMuzzleData() { void CPlayerGun::InitMuzzleData() {
for (const auto muzzleID : g_tweakGunRes->xa4_auxMuzzle) { for (const auto& muzzleID : g_tweakGunRes->xa4_auxMuzzle) {
x7c0_auxMuzzleEffects.push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), muzzleID})); x7c0_auxMuzzleEffects.push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), muzzleID}));
x800_auxMuzzleGenerators.emplace_back(std::make_unique<CElementGen>(x7c0_auxMuzzleEffects.back())); x800_auxMuzzleGenerators.emplace_back(std::make_unique<CElementGen>(x7c0_auxMuzzleEffects.back()));
x800_auxMuzzleGenerators.back()->SetParticleEmission(false); x800_auxMuzzleGenerators.back()->SetParticleEmission(false);

View File

@ -742,7 +742,7 @@ bool CMorphBall::FindClosestSpiderBallWaypoint(CStateManager& mgr, const zeus::C
mgr.BuildNearList(nearList, aabb, CMaterialFilter::skPassEverything, nullptr); mgr.BuildNearList(nearList, aabb, CMaterialFilter::skPassEverything, nullptr);
float minDist = 2.1f; float minDist = 2.1f;
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (const TCastToConstPtr<CScriptSpiderBallAttractionSurface> surface = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CScriptSpiderBallAttractionSurface> surface = mgr.GetObjectById(id)) {
const zeus::CUnitVector3f surfaceNorm(surface->GetTransform().basis[1]); const zeus::CUnitVector3f surfaceNorm(surface->GetTransform().basis[1]);
const zeus::CPlane plane(surfaceNorm, surface->GetTranslation().dot(surfaceNorm)); const zeus::CPlane plane(surfaceNorm, surface->GetTranslation().dot(surfaceNorm));
@ -774,7 +774,7 @@ bool CMorphBall::FindClosestSpiderBallWaypoint(CStateManager& mgr, const zeus::C
} }
} }
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (const TCastToConstPtr<CScriptSpiderBallWaypoint> wp = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CScriptSpiderBallWaypoint> wp = mgr.GetObjectById(id)) {
const CScriptSpiderBallWaypoint* closestWp = nullptr; const CScriptSpiderBallWaypoint* closestWp = nullptr;
zeus::CVector3f worldPoint; zeus::CVector3f worldPoint;
@ -1916,7 +1916,7 @@ bool CMorphBall::BallCloseToCollision(const CStateManager& mgr, float dist, cons
return true; return true;
} }
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (const TCastToConstPtr<CPhysicsActor> act = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CPhysicsActor> act = mgr.GetObjectById(id)) {
if (CCollisionPrimitive::CollideBoolean( if (CCollisionPrimitive::CollideBoolean(
{sphere, filter, zeus::CTransform()}, {sphere, filter, zeus::CTransform()},

View File

@ -2290,7 +2290,7 @@ void CPlayer::UpdatePhazonDamage(float dt, CStateManager& mgr) {
if (CGameCollision::DetectStaticCollisionBoolean(mgr, prim, zeus::CTransform(), filter)) { if (CGameCollision::DetectStaticCollisionBoolean(mgr, prim, zeus::CTransform(), filter)) {
touchingPhazon = true; touchingPhazon = true;
} else { } else {
for (const TUniqueId id : nearList) { for (const auto& id : nearList) {
if (const TCastToConstPtr<CPhysicsActor> act = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CPhysicsActor> act = mgr.GetObjectById(id)) {
const CInternalCollisionStructure::CPrimDesc prim0(prim, filter, zeus::CTransform()); const CInternalCollisionStructure::CPrimDesc prim0(prim, filter, zeus::CTransform());
const CInternalCollisionStructure::CPrimDesc prim1( const CInternalCollisionStructure::CPrimDesc prim1(
@ -2387,7 +2387,7 @@ void CPlayer::AddToPlayerHintRemoveList(TUniqueId id, CStateManager& mgr) {
return; return;
} }
for (const TUniqueId existId : x93c_playerHintsToRemove) { for (const auto& existId : x93c_playerHintsToRemove) {
if (id == existId) { if (id == existId) {
return; return;
} }
@ -2404,7 +2404,7 @@ void CPlayer::AddToPlayerHintAddList(TUniqueId id, CStateManager& mgr) {
return; return;
} }
for (const TUniqueId existId : x980_playerHintsToAdd) { for (const auto& existId : x980_playerHintsToAdd) {
if (id == existId) { if (id == existId) {
return; return;
} }
@ -2421,7 +2421,7 @@ void CPlayer::DeactivatePlayerHint(TUniqueId id, CStateManager& mgr) {
return; return;
} }
for (const TUniqueId existId : x93c_playerHintsToRemove) { for (const auto& existId : x93c_playerHintsToRemove) {
if (id == existId) { if (id == existId) {
return; return;
} }
@ -2448,7 +2448,7 @@ void CPlayer::UpdatePlayerHints(CStateManager& mgr) {
} }
bool needsNewHint = false; bool needsNewHint = false;
for (const TUniqueId id : x93c_playerHintsToRemove) { for (const auto& id : x93c_playerHintsToRemove) {
for (auto it = x838_playerHints.begin(); it != x838_playerHints.end();) { for (auto it = x838_playerHints.begin(); it != x838_playerHints.end();) {
if (it->second == id) { if (it->second == id) {
it = x838_playerHints.erase(it); it = x838_playerHints.erase(it);
@ -2463,7 +2463,7 @@ void CPlayer::UpdatePlayerHints(CStateManager& mgr) {
x93c_playerHintsToRemove.clear(); x93c_playerHintsToRemove.clear();
bool addedHint = false; bool addedHint = false;
for (const TUniqueId id : x980_playerHintsToAdd) { for (const auto& id : x980_playerHintsToAdd) {
if (const TCastToConstPtr<CScriptPlayerHint> hint = mgr.ObjectById(id)) { if (const TCastToConstPtr<CScriptPlayerHint> hint = mgr.ObjectById(id)) {
bool exists = false; bool exists = false;
for (auto& p : x838_playerHints) { for (auto& p : x838_playerHints) {
@ -4252,7 +4252,7 @@ TUniqueId CPlayer::CheckEnemiesAgainstOrbitZone(const rstl::reserved_vector<TUni
const float boxTop = (GetOrbitZoneIdealYScaled(int(info)) - vpHHalf) / vpHHalf; const float boxTop = (GetOrbitZoneIdealYScaled(int(info)) - vpHHalf) / vpHHalf;
const CFirstPersonCamera* fpCam = mgr.GetCameraManager()->GetFirstPersonCamera(); const CFirstPersonCamera* fpCam = mgr.GetCameraManager()->GetFirstPersonCamera();
for (const TUniqueId id : list) { for (const auto& id : list) {
if (const auto* act = static_cast<CActor*>(mgr.ObjectById(id))) { if (const auto* act = static_cast<CActor*>(mgr.ObjectById(id))) {
if (act->GetUniqueId() != GetUniqueId() && ValidateObjectForMode(act->GetUniqueId(), mgr)) { if (act->GetUniqueId() != GetUniqueId() && ValidateObjectForMode(act->GetUniqueId(), mgr)) {
const zeus::CVector3f aimPos = act->GetAimPosition(mgr, 0.f); const zeus::CVector3f aimPos = act->GetAimPosition(mgr, 0.f);
@ -4349,7 +4349,7 @@ TUniqueId CPlayer::FindBestOrbitableObject(const std::vector<TUniqueId>& ids, EP
const CFirstPersonCamera* fpCam = mgr.GetCameraManager()->GetFirstPersonCamera(); const CFirstPersonCamera* fpCam = mgr.GetCameraManager()->GetFirstPersonCamera();
for (const TUniqueId id : ids) { for (const auto& id : ids) {
if (const TCastToConstPtr<CActor> act = mgr.ObjectById(id)) { if (const TCastToConstPtr<CActor> act = mgr.ObjectById(id)) {
const zeus::CVector3f orbitPos = act->GetOrbitPosition(mgr); const zeus::CVector3f orbitPos = act->GetOrbitPosition(mgr);
zeus::CVector3f eyeToOrbit = orbitPos - eyePos; zeus::CVector3f eyeToOrbit = orbitPos - eyePos;
@ -4484,7 +4484,7 @@ void CPlayer::FindOrbitableObjects(const rstl::reserved_vector<TUniqueId, 1024>&
const CFirstPersonCamera* fpCam = mgr.GetCameraManager()->GetFirstPersonCamera(); const CFirstPersonCamera* fpCam = mgr.GetCameraManager()->GetFirstPersonCamera();
const zeus::CVector3f eyePos = GetEyePosition(); const zeus::CVector3f eyePos = GetEyePosition();
for (const TUniqueId id : nearObjects) { for (const auto& id : nearObjects) {
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(id)) { if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(id)) {
if (GetUniqueId() == act->GetUniqueId()) { if (GetUniqueId() == act->GetUniqueId()) {
continue; continue;
@ -4576,7 +4576,7 @@ void CPlayer::AddOrbitDisableSource(CStateManager& mgr, TUniqueId addId) {
return; return;
} }
for (const TUniqueId uid : x9e4_orbitDisableList) { for (const auto& uid : x9e4_orbitDisableList) {
if (uid == addId) { if (uid == addId) {
return; return;
} }

View File

@ -835,7 +835,7 @@ void CScriptSpecialFunction::ThinkChaffTarget(float dt, CStateManager& mgr) {
mgr.BuildNearList(nearList, box, CMaterialFilter::MakeInclude({EMaterialTypes::Projectile}), nullptr); mgr.BuildNearList(nearList, box, CMaterialFilter::MakeInclude({EMaterialTypes::Projectile}), nullptr);
CCameraFilterPassPoly& filter = mgr.GetCameraFilterPass(7); CCameraFilterPassPoly& filter = mgr.GetCameraFilterPass(7);
for (const TUniqueId uid : nearList) { for (const auto& uid : nearList) {
if (const TCastToPtr<CEnergyProjectile> proj = mgr.ObjectById(uid)) { if (const TCastToPtr<CEnergyProjectile> proj = mgr.ObjectById(uid)) {
if (proj->GetHomingTargetId() == GetUniqueId()) { if (proj->GetHomingTargetId() == GetUniqueId()) {
proj->Set3d0_26(true); proj->Set3d0_26(true);

View File

@ -61,7 +61,7 @@ void CScriptSpiderBallWaypoint::AddPreviousWaypoint(TUniqueId uid) { xec_waypoin
TUniqueId CScriptSpiderBallWaypoint::PreviousWaypoint(const CStateManager& mgr, TUniqueId CScriptSpiderBallWaypoint::PreviousWaypoint(const CStateManager& mgr,
ECheckActiveWaypoint checkActive) const { ECheckActiveWaypoint checkActive) const {
for (const TUniqueId id : xec_waypoints) { for (const auto& id : xec_waypoints) {
if (const CEntity* ent = mgr.GetObjectById(id)) { if (const CEntity* ent = mgr.GetObjectById(id)) {
if (checkActive == ECheckActiveWaypoint::SkipCheck) { if (checkActive == ECheckActiveWaypoint::SkipCheck) {
return id; return id;