General: Make use of ranged for where applicable

This commit is contained in:
Lioncash 2020-06-22 02:56:45 -04:00
parent 8dd4fb24d9
commit ea86654935
16 changed files with 138 additions and 133 deletions

View File

@ -527,10 +527,8 @@ void GenerateAssetNames(CGameProject *pProj)
}
}
for (uint32 iOverlay = 0; iOverlay < pkChar->OverlayModels.size(); iOverlay++)
for (const auto& rkOverlay : pkChar->OverlayModels)
{
const SOverlayModel& rkOverlay = pkChar->OverlayModels[iOverlay];
if (rkOverlay.ModelID.IsValid() || rkOverlay.SkinID.IsValid())
{
TString TypeName = (
@ -564,17 +562,16 @@ void GenerateAssetNames(CGameProject *pProj)
std::set<CAnimPrimitive> AnimPrimitives;
pSet->GetUniquePrimitives(AnimPrimitives);
for (auto It = AnimPrimitives.begin(); It != AnimPrimitives.end(); It++)
for (const auto& rkPrim : AnimPrimitives)
{
const CAnimPrimitive& rkPrim = *It;
CAnimation *pAnim = rkPrim.Animation();
if (pAnim)
if (pAnim != nullptr)
{
ApplyGeneratedName(pAnim->Entry(), SetDir, rkPrim.Name());
CAnimEventData *pEvents = pAnim->EventData();
if (pEvents)
if (pEvents != nullptr)
ApplyGeneratedName(pEvents->Entry(), SetDir, rkPrim.Name());
}
}

View File

@ -149,13 +149,14 @@ void CAssetNameMap::PostLoadValidate()
mIsValid = false;
std::set<SAssetNameInfo> Dupes;
for (auto Iter = mMap.begin(); Iter != mMap.end(); Iter++)
for (auto Iter = mMap.begin(); Iter != mMap.end(); ++Iter)
{
const SAssetNameInfo& rkInfo = Iter->second;
if (mUsedSet.find(rkInfo) != mUsedSet.end())
{
Dupes.insert(rkInfo);
}
else
{
mUsedSet.insert(rkInfo);
@ -183,15 +184,17 @@ void CAssetNameMap::PostLoadValidate()
{
errorf("Asset name map is invalid and cannot be used! Duplicate asset entries detected:");
for (auto Iter = Dupes.begin(); Iter != Dupes.end(); Iter++)
for (const auto& dupe : Dupes)
{
warnf("\t%s", *Iter->FullPath());
warnf("\t%s", *dupe.FullPath());
}
mMap.clear();
}
else
{
mIsValid = !FoundErrors;
}
}
TString CAssetNameMap::DefaultNameMapPath(EIDLength IDLength)

View File

@ -238,8 +238,8 @@ std::unique_ptr<CSetCharacterDependency> CSetCharacterDependency::BuildTree(cons
for (const auto& vec : particleVectors)
{
for (uint32 iPart = 0; iPart < vec->size(); iPart++)
pTree->AddDependency(vec->at(iPart));
for (const auto& dependency : *vec)
pTree->AddDependency(dependency);
}
for (const SOverlayModel& overlay : rkChar.OverlayModels)
@ -331,7 +331,7 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector
for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
{
auto pTree = CScriptInstanceDependency::BuildTree( pLayer->InstanceByIndex(iInst) );
auto pTree = CScriptInstanceDependency::BuildTree(pLayer->InstanceByIndex(iInst));
ASSERT(pTree != nullptr);
// Note: MP2+ need to track all instances (not just instances with dependencies) to be able to build the layer module list
@ -342,8 +342,8 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector
}
}
for (uint32 iDep = 0; iDep < rkExtraDeps.size(); iDep++)
AddDependency(rkExtraDeps[iDep]);
for (const auto& dep : rkExtraDeps)
AddDependency(dep);
}
void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<uint32>& rModuleLayerOffsetsOut) const
@ -352,35 +352,34 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>
// Output module list will be split per-script layer
// The output offset list contains two offsets per layer - start index and end index
for (uint32 iLayer = 0; iLayer < mLayerOffsets.size(); iLayer++)
for (size_t iLayer = 0; iLayer < mLayerOffsets.size(); iLayer++)
{
uint32 StartIdx = mLayerOffsets[iLayer];
uint32 EndIdx = (iLayer == mLayerOffsets.size() - 1 ? mChildren.size() : mLayerOffsets[iLayer + 1]);
const size_t StartIdx = mLayerOffsets[iLayer];
const size_t EndIdx = (iLayer == mLayerOffsets.size() - 1 ? mChildren.size() : mLayerOffsets[iLayer + 1]);
uint32 ModuleStartIdx = rModuleDepsOut.size();
const auto ModuleStartIdx = static_cast<uint32>(rModuleDepsOut.size());
rModuleLayerOffsetsOut.push_back(ModuleStartIdx);
// Keep track of which types we've already checked on this layer to speed things up a little...
std::set<uint32> UsedObjectTypes;
for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++)
for (size_t iInst = StartIdx; iInst < EndIdx; iInst++)
{
auto& pNode = mChildren[iInst];
const auto& pNode = mChildren[iInst];
if (pNode->Type() != EDependencyNodeType::ScriptInstance)
continue;
const auto *pInst = static_cast<CScriptInstanceDependency*>(pNode.get());
uint32 ObjType = pInst->ObjectType();
const uint32 ObjType = pInst->ObjectType();
if (UsedObjectTypes.find(ObjType) == UsedObjectTypes.end())
{
// Get the module list for this object type and check whether any of them are new before adding them to the output list
CScriptTemplate *pTemplate = pGame->TemplateByID(ObjType);
const CScriptTemplate *pTemplate = pGame->TemplateByID(ObjType);
const std::vector<TString>& rkModules = pTemplate->RequiredModules();
for (uint32 iMod = 0; iMod < rkModules.size(); iMod++)
for (const auto& ModuleName : rkModules)
{
TString ModuleName = rkModules[iMod];
bool NewModule = true;
for (uint32 iUsed = ModuleStartIdx; iUsed < rModuleDepsOut.size(); iUsed++)
@ -400,6 +399,6 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>
}
}
rModuleLayerOffsetsOut.push_back(rModuleDepsOut.size());
rModuleLayerOffsetsOut.push_back(static_cast<uint32>(rModuleDepsOut.size()));
}
}

View File

@ -1,6 +1,7 @@
#include "CGameInfo.h"
#include "CResourceStore.h"
#include <Common/FileUtil.h>
#include <algorithm>
constexpr char gkGameInfoDir[] = "resources/gameinfo";
constexpr char gkGameInfoExt[] = "xml";
@ -23,14 +24,17 @@ bool CGameInfo::LoadGameInfo(TString Path)
Serialize(Reader);
return true;
}
else return false;
return false;
}
bool CGameInfo::SaveGameInfo(TString Path /*= ""*/)
bool CGameInfo::SaveGameInfo(TString Path)
{
ASSERT(mGame != EGame::Invalid); // can't save game info that was never loaded
if (Path.IsEmpty()) Path = GetDefaultGameInfoPath(mGame);
if (Path.IsEmpty())
Path = GetDefaultGameInfoPath(mGame);
CXMLWriter Writer(Path, "GameInfo", 0, mGame);
Serialize(Writer);
return Writer.Save();
@ -53,21 +57,19 @@ void CGameInfo::Serialize(IArchive& rArc)
TString CGameInfo::GetBuildName(float BuildVer, ERegion Region) const
{
for (uint32 iBuild = 0; iBuild < mBuilds.size(); iBuild++)
{
const SBuildInfo& rkBuildInfo = mBuilds[iBuild];
const auto it = std::find_if(mBuilds.cbegin(), mBuilds.cend(),
[=](const auto& entry) { return entry.Version == BuildVer && entry.Region == Region; });
if (rkBuildInfo.Version == BuildVer && rkBuildInfo.Region == Region)
return rkBuildInfo.Name;
}
if (it == mBuilds.cend())
return "Unknown Build";
return "Unknown Build";
return it->Name;
}
TString CGameInfo::GetAreaName(const CAssetID &rkID) const
{
auto Iter = mAreaNameMap.find(rkID);
return (Iter == mAreaNameMap.end() ? "" : Iter->second);
const auto Iter = mAreaNameMap.find(rkID);
return Iter == mAreaNameMap.cend() ? "" : Iter->second;
}
// ************ STATIC ************
@ -86,7 +88,7 @@ TString CGameInfo::GetDefaultGameInfoPath(EGame Game)
if (Game == EGame::Invalid)
return "";
TString GameName = GetGameShortName(Game);
const TString GameName = GetGameShortName(Game);
return TString::Format("%s/%s/GameInfo%s.%s", *gDataDir, *gkGameInfoDir, *GameName, *gkGameInfoExt);
}

View File

@ -22,8 +22,10 @@ CVertexArrayManager::~CVertexArrayManager()
sVAManagers.erase(sVAManagers.begin() + mVectorIndex);
if (sVAManagers.size() > mVectorIndex)
{
for (auto it = sVAManagers.begin() + mVectorIndex; it != sVAManagers.end(); it++)
(*it)->mVectorIndex--;
}
}
// ************ PUBLIC ************
@ -34,15 +36,16 @@ void CVertexArrayManager::SetCurrent()
void CVertexArrayManager::BindVAO(CVertexBuffer *pVBO)
{
auto it = mVBOMap.find(pVBO);
const auto it = mVBOMap.find(pVBO);
if (it != mVBOMap.end())
if (it != mVBOMap.cend())
{
glBindVertexArray(it->second);
}
else
{
GLuint VAO = pVBO->CreateVAO();
mVBOMap[pVBO] = VAO;
const GLuint VAO = pVBO->CreateVAO();
mVBOMap.insert_or_assign(pVBO, VAO);
glBindVertexArray(VAO);
}
}
@ -50,40 +53,41 @@ void CVertexArrayManager::BindVAO(CVertexBuffer *pVBO)
void CVertexArrayManager::BindVAO(CDynamicVertexBuffer *pVBO)
{
// Overload for CDynamicVertexBuffer
auto it = mDynamicVBOMap.find(pVBO);
const auto it = mDynamicVBOMap.find(pVBO);
if (it != mDynamicVBOMap.end())
if (it != mDynamicVBOMap.cend())
{
glBindVertexArray(it->second);
}
else
{
GLuint VAO = pVBO->CreateVAO();
mDynamicVBOMap[pVBO] = VAO;
const GLuint VAO = pVBO->CreateVAO();
mDynamicVBOMap.insert_or_assign(pVBO, VAO);
glBindVertexArray(VAO);
}
}
void CVertexArrayManager::DeleteVAO(CVertexBuffer *pVBO)
{
auto it = mVBOMap.find(pVBO);
const auto it = mVBOMap.find(pVBO);
if (it != mVBOMap.end())
{
glDeleteVertexArrays(1, &it->second);
mVBOMap.erase(it);
}
if (it == mVBOMap.cend())
return;
glDeleteVertexArrays(1, &it->second);
mVBOMap.erase(it);
}
void CVertexArrayManager::DeleteVAO(CDynamicVertexBuffer *pVBO)
{
// Overload for CDynamicVertexBuffer
auto it = mDynamicVBOMap.find(pVBO);
const auto it = mDynamicVBOMap.find(pVBO);
if (it != mDynamicVBOMap.end())
{
glDeleteVertexArrays(1, &it->second);
mDynamicVBOMap.erase(it);
}
if (it == mDynamicVBOMap.cend())
return;
glDeleteVertexArrays(1, &it->second);
mDynamicVBOMap.erase(it);
}
// ************ STATIC ************
@ -94,12 +98,12 @@ CVertexArrayManager* CVertexArrayManager::Current()
void CVertexArrayManager::DeleteAllArraysForVBO(CVertexBuffer *pVBO)
{
for (uint32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
sVAManagers[iVAM]->DeleteVAO(pVBO);
for (auto* vam : sVAManagers)
vam->DeleteVAO(pVBO);
}
void CVertexArrayManager::DeleteAllArraysForVBO(CDynamicVertexBuffer *pVBO)
{
for (uint32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
sVAManagers[iVAM]->DeleteVAO(pVBO);
for (auto* vam : sVAManagers)
vam->DeleteVAO(pVBO);
}

View File

@ -177,10 +177,9 @@ public:
CAnimation* FindAnimationAsset(uint32 AnimID) const
{
if (AnimID >= 0 && AnimID < mAnimPrimitives.size())
if (AnimID < mAnimPrimitives.size())
{
CAnimPrimitive Prim = mAnimPrimitives[AnimID];
return Prim.Animation();
return mAnimPrimitives[AnimID].Animation();
}
return nullptr;
@ -188,8 +187,8 @@ public:
void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
{
for (uint32 iAnim = 0; iAnim < mAnimPrimitives.size(); iAnim++)
rPrimSet.insert(mAnimPrimitives[iAnim]);
for (const auto& primitive : mAnimPrimitives)
rPrimSet.insert(primitive);
}
// Accessors
@ -198,26 +197,25 @@ public:
const SSetCharacter* Character(uint32 Index) const
{
ASSERT(Index >= 0 && Index < NumCharacters());
ASSERT(Index < NumCharacters());
return &mCharacters[Index];
}
const SAnimation* Animation(uint32 Index) const
{
ASSERT(Index >= 0 && Index < NumAnimations());
ASSERT(Index < NumAnimations());
return &mAnimations[Index];
}
CAnimEventData* AnimationEventData(uint32 Index) const
{
ASSERT(Index >= 0 && Index < NumAnimations());
ASSERT(Index < NumAnimations());
if (Game() <= EGame::Prime)
{
const CAnimPrimitive& rkPrim = mAnimPrimitives[Index];
return rkPrim.Animation() ? rkPrim.Animation()->EventData() : nullptr;
}
else
{
return (Index < mAnimEvents.size() ? mAnimEvents[Index].get() : nullptr);

View File

@ -122,17 +122,20 @@ uint32 CGameArea::TotalInstanceCount() const
{
uint32 Num = 0;
for (uint32 iLyr = 0; iLyr < mScriptLayers.size(); iLyr++)
Num += mScriptLayers[iLyr]->NumInstances();
for (const auto& layer : mScriptLayers)
Num += layer->NumInstances();
return Num;
}
CScriptObject* CGameArea::InstanceByID(uint32 InstanceID)
{
auto it = mObjectMap.find(InstanceID);
if (it != mObjectMap.end()) return it->second;
else return nullptr;
const auto it = mObjectMap.find(InstanceID);
if (it != mObjectMap.cend())
return it->second;
return nullptr;
}
uint32 CGameArea::FindUnusedInstanceID() const

View File

@ -1,8 +1,8 @@
#include "CLight.h"
#include "Core/Render/CGraphics.h"
#include <Common/Common.h>
#include <cfloat>
#include <cmath>
#include <float.h>
constexpr uint32_t CLIGHT_NO_RADIUS = 0x40;
constexpr uint32_t CLIGHT_NO_INTENSITY = 0x80;

View File

@ -33,17 +33,16 @@ void CMaterialCooker::WriteMatSetPrime(IOutputStream& rOut)
{
// Gather texture list from the materials before starting
mTextureIDs.clear();
uint32 NumMats = mpSet->mMaterials.size();
const size_t NumMats = mpSet->mMaterials.size();
for (uint32 iMat = 0; iMat < NumMats; iMat++)
for (size_t iMat = 0; iMat < NumMats; iMat++)
{
CMaterial *pMat = mpSet->mMaterials[iMat].get();
const CMaterial *pMat = mpSet->mMaterials[iMat].get();
uint32 NumPasses = pMat->PassCount();
for (uint32 iPass = 0; iPass < NumPasses; iPass++)
const size_t NumPasses = pMat->PassCount();
for (size_t iPass = 0; iPass < NumPasses; iPass++)
{
CTexture *pTex = pMat->Pass(iPass)->Texture();
if (pTex)
if (const CTexture* pTex = pMat->Pass(iPass)->Texture())
mTextureIDs.push_back(pTex->ID().ToLong());
}
}
@ -53,23 +52,23 @@ void CMaterialCooker::WriteMatSetPrime(IOutputStream& rOut)
mTextureIDs.erase(std::unique(mTextureIDs.begin(), mTextureIDs.end()), mTextureIDs.end());
// Write texture IDs
rOut.WriteLong(mTextureIDs.size());
rOut.WriteULong(static_cast<uint32>(mTextureIDs.size()));
for (uint32 iTex = 0; iTex < mTextureIDs.size(); iTex++)
rOut.WriteLong(mTextureIDs[iTex]);
for (const auto id : mTextureIDs)
rOut.WriteULong(id);
// Write material offset filler
rOut.WriteLong(NumMats);
uint32 MatOffsetsStart = rOut.Tell();
rOut.WriteULong(static_cast<uint32>(NumMats));
const uint32 MatOffsetsStart = rOut.Tell();
for (uint32 iMat = 0; iMat < NumMats; iMat++)
rOut.WriteLong(0);
for (size_t iMat = 0; iMat < NumMats; iMat++)
rOut.WriteULong(0);
// Write materials
uint32 MatsStart = rOut.Tell();
const uint32 MatsStart = rOut.Tell();
std::vector<uint32> MatEndOffsets(NumMats);
for (uint32 iMat = 0; iMat < NumMats; iMat++)
for (size_t iMat = 0; iMat < NumMats; iMat++)
{
mpMat = mpSet->mMaterials[iMat].get();
WriteMaterialPrime(rOut);
@ -77,11 +76,11 @@ void CMaterialCooker::WriteMatSetPrime(IOutputStream& rOut)
}
// Write material offsets
uint32 MatsEnd = rOut.Tell();
const uint32 MatsEnd = rOut.Tell();
rOut.Seek(MatOffsetsStart, SEEK_SET);
for (uint32 iMat = 0; iMat < NumMats; iMat++)
rOut.WriteLong(MatEndOffsets[iMat]);
for (size_t iMat = 0; iMat < NumMats; iMat++)
rOut.WriteULong(MatEndOffsets[iMat]);
// Done!
rOut.Seek(MatsEnd, SEEK_SET);

View File

@ -270,10 +270,10 @@ void CStringCooker::WriteNameTable(IOutputStream& STRG)
STRG.WriteULong(0); // Dummy name table size
const uint32 NameTableOffsetsStart = STRG.Tell();
for (size_t NameIdx = 0; NameIdx < NameEntries.size(); NameIdx++)
for (const auto& entry : NameEntries)
{
STRG.WriteULong(0); // Dummy name offset
STRG.WriteULong(NameEntries[NameIdx].Index);
STRG.WriteULong(entry.Index);
}
// Write out names

View File

@ -7,9 +7,11 @@ CBasicModel::CBasicModel(CResourceEntry *pEntry)
CBasicModel::~CBasicModel()
{
if (mHasOwnSurfaces)
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
delete mSurfaces[iSurf];
if (!mHasOwnSurfaces)
return;
for (auto* surface : mSurfaces)
delete surface;
}
size_t CBasicModel::GetVertexCount() const

View File

@ -5,7 +5,7 @@
#include "Core/OpenGL/GLCommon.h"
#include <Common/Macros.h>
CModel::CModel(CResourceEntry *pEntry /*= 0*/)
CModel::CModel(CResourceEntry *pEntry)
: CBasicModel(pEntry)
{
mHasOwnMaterials = true;
@ -27,8 +27,8 @@ CModel::~CModel()
if (!mHasOwnMaterials)
return;
for (size_t iMat = 0; iMat < mMaterialSets.size(); iMat++)
delete mMaterialSets[iMat];
for (auto* set : mMaterialSets)
delete set;
}
@ -92,8 +92,8 @@ void CModel::BufferGL()
}
}
for (size_t iIBO = 0; iIBO < mSurfaceIndexBuffers[iSurf].size(); iIBO++)
mSurfaceIndexBuffers[iSurf][iIBO].Buffer();
for (auto& ibo : mSurfaceIndexBuffers[iSurf])
ibo.Buffer();
}
mBuffered = true;
@ -143,10 +143,9 @@ void CModel::DrawSurface(FRenderOptions Options, size_t Surface, size_t MatSet)
mVBO.Bind();
glLineWidth(1.f);
for (size_t iIBO = 0; iIBO < mSurfaceIndexBuffers[Surface].size(); iIBO++)
for (auto& ibo : mSurfaceIndexBuffers[Surface])
{
CIndexBuffer *pIBO = &mSurfaceIndexBuffers[Surface][iIBO];
pIBO->DrawElements();
ibo.DrawElements();
}
mVBO.Unbind();
@ -315,10 +314,10 @@ CIndexBuffer* CModel::InternalGetIBO(size_t Surface, EPrimitiveType Primitive)
std::vector<CIndexBuffer>& pIBOs = mSurfaceIndexBuffers[Surface];
const GLenum Type = GXPrimToGLPrim(Primitive);
for (size_t iIBO = 0; iIBO < pIBOs.size(); iIBO++)
for (auto& ibo : pIBOs)
{
if (pIBOs[iIBO].GetPrimitiveType() == Type)
return &pIBOs[iIBO];
if (ibo.GetPrimitiveType() == Type)
return &ibo;
}
return &pIBOs.emplace_back(Type);

View File

@ -38,8 +38,8 @@ CScriptObject::~CScriptObject()
mpTemplate->RemoveObject(this);
// Note: Incoming links will be deleted by the sender.
for (uint32 iLink = 0; iLink < mOutLinks.size(); iLink++)
delete mOutLinks[iLink];
for (auto* link : mOutLinks)
delete link;
}
// ************ DATA MANIPULATION ************

View File

@ -382,9 +382,9 @@ void ChangeTypeName(IProperty* pProperty, const char* pkOldTypeName, const char*
IProperty* pArchetype = pProperty->RootArchetype();
pArchetype->GatherAllSubInstances(Properties, true);
for (auto Iter = Properties.begin(); Iter != Properties.end(); ++Iter)
for (auto* property : Properties)
{
pProperty = *Iter;
pProperty = property;
if (pProperty->UsesNameMap())
{

View File

@ -140,7 +140,7 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
break;
// Now that all words are updated, calculate the new hashes.
CCRC32 LastValidHash = (RecalcIndex > 0 ? WordCache[RecalcIndex-1].Hash : PrefixHash);
CCRC32 LastValidHash = (RecalcIndex > 0 ? WordCache[RecalcIndex - 1].Hash : PrefixHash);
for (; RecalcIndex < WordCache.size(); RecalcIndex++)
{
@ -169,12 +169,12 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
CCRC32 BaseHash = LastValidHash;
BaseHash.Hash( *rkParams.Suffix );
for (int TypeIdx = 0; TypeIdx < mTypeNames.size(); TypeIdx++)
for (const auto& typeName : mTypeNames)
{
CCRC32 FullHash = BaseHash;
const char* pkTypeName = *mTypeNames[TypeIdx];
const char* pkTypeName = *typeName;
FullHash.Hash( pkTypeName );
uint32 PropertyID = FullHash.Digest();
const uint32 PropertyID = FullHash.Digest();
// Check if this hash is a property ID
if (IsValidPropertyID(PropertyID, pkTypeName, rkParams))
@ -185,9 +185,9 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
// Generate a string with the complete name. (We wait to do this until now to avoid needless string allocation)
PropertyName.Name = rkParams.Prefix;
for (int WordIdx = 0; WordIdx < WordCache.size(); WordIdx++)
for (size_t WordIdx = 0; WordIdx < WordCache.size(); WordIdx++)
{
int Index = WordCache[WordIdx].WordIndex;
const int Index = WordCache[WordIdx].WordIndex;
if (WordIdx > 0 && rkParams.Casing == ENameCasing::Snake_Case)
{
@ -225,9 +225,9 @@ void CPropertyNameGenerator::Generate(const SPropertyNameGenerationParameters& r
{
TString DelimitedXmlList;
for (auto Iter = PropertyName.XmlList.begin(); Iter != PropertyName.XmlList.end(); Iter++)
for (const auto& xml : PropertyName.XmlList)
{
DelimitedXmlList += *Iter + "\n";
DelimitedXmlList += xml + '\n';
}
debugf("%s [%s] : 0x%08X\n%s", *PropertyName.Name, *PropertyName.Type, PropertyName.ID, *DelimitedXmlList);

View File

@ -472,14 +472,13 @@ bool IProperty::ConvertType(EPropertyType NewType, IProperty* pNewArchetype)
}
// Swap out our parent's reference to us to point to the new property.
if (mpParent)
if (mpParent != nullptr)
{
for (size_t SiblingIdx = 0; SiblingIdx < mpParent->mChildren.size(); SiblingIdx++)
for (auto& sibling : mpParent->mChildren)
{
IProperty* pSibling = mpParent->mChildren[SiblingIdx];
if (pSibling == this)
if (sibling == this)
{
mpParent->mChildren[SiblingIdx] = pNewProperty;
sibling = pNewProperty;
break;
}
}