From 3b3b2cc80f87f674d4f9020070aac67b13f76f1c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 12 Jun 2020 12:52:26 -0400 Subject: [PATCH] CCollisionLoader: Collapse for loop into ranged for Also removes a delete left behind in an error case. --- src/Core/Resource/Factory/CCollisionLoader.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Core/Resource/Factory/CCollisionLoader.cpp b/src/Core/Resource/Factory/CCollisionLoader.cpp index 357c7601..4ddfc008 100644 --- a/src/Core/Resource/Factory/CCollisionLoader.cpp +++ b/src/Core/Resource/Factory/CCollisionLoader.cpp @@ -231,16 +231,15 @@ std::unique_ptr CCollisionLoader::LoadDCLN(IInputStream& rD CCollisionLoader Loader; Loader.mpGroup = ptr.get(); - uint32 NumMeshes = rDCLN.ReadLong(); + const uint32 NumMeshes = rDCLN.ReadLong(); for (uint32 MeshIdx = 0; MeshIdx < NumMeshes; MeshIdx++) { - uint32 DeafBabe = rDCLN.ReadLong(); + const uint32 DeafBabe = rDCLN.ReadLong(); if (DeafBabe != 0xDEAFBABE) { errorf("%s [0x%X]: Invalid collision magic: 0x%08X", *rDCLN.GetSourceString(), rDCLN.Tell() - 4, DeafBabe); - delete Loader.mpGroup; return nullptr; } @@ -261,11 +260,9 @@ std::unique_ptr CCollisionLoader::LoadDCLN(IInputStream& rD { Loader.mpMesh->mAABox = CAABox::skInfinite; - for (uint i=0; imIndexData.Vertices.size(); i++) + for (const auto& vert : Loader.mpMesh->mIndexData.Vertices) { - Loader.mpMesh->mAABox.ExpandBounds( - Loader.mpMesh->mIndexData.Vertices[i] - ); + Loader.mpMesh->mAABox.ExpandBounds(vert); } }