CCollisionLoader: Collapse for loop into ranged for

Also removes a delete left behind in an error case.
This commit is contained in:
Lioncash 2020-06-12 12:52:26 -04:00
parent 3449f60317
commit 3b3b2cc80f
1 changed files with 4 additions and 7 deletions

View File

@ -231,16 +231,15 @@ std::unique_ptr<CCollisionMeshGroup> 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<CCollisionMeshGroup> CCollisionLoader::LoadDCLN(IInputStream& rD
{
Loader.mpMesh->mAABox = CAABox::skInfinite;
for (uint i=0; i<Loader.mpMesh->mIndexData.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);
}
}