mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-08 21:17:53 +00:00
Core: Make use of contains() where applicable
Makes a few checks a little less verbose.
This commit is contained in:
@@ -107,12 +107,12 @@ void CAssetNameMap::CopyFromStore(CResourceStore *pStore /*= gpResourceStore*/)
|
||||
SAssetNameInfo NameInfo { Name, Directory, Type, AutoName, AutoDir };
|
||||
|
||||
// Check for conflicts with new name
|
||||
if (mUsedSet.find(NameInfo) != mUsedSet.end())
|
||||
if (mUsedSet.contains(NameInfo))
|
||||
{
|
||||
SAssetNameInfo NewNameInfo = NameInfo;
|
||||
int NumConflicted = 0;
|
||||
|
||||
while (mUsedSet.find(NewNameInfo) != mUsedSet.end())
|
||||
while (mUsedSet.contains(NewNameInfo))
|
||||
{
|
||||
NewNameInfo.Name = NameInfo.Name + '_' + TString::FromInt32(NumConflicted, 0, 10);
|
||||
NumConflicted++;
|
||||
@@ -153,7 +153,7 @@ void CAssetNameMap::PostLoadValidate()
|
||||
{
|
||||
const SAssetNameInfo& rkInfo = Iter->second;
|
||||
|
||||
if (mUsedSet.find(rkInfo) != mUsedSet.end())
|
||||
if (mUsedSet.contains(rkInfo))
|
||||
{
|
||||
Dupes.insert(rkInfo);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ std::unique_ptr<CSetAnimationDependency> CSetAnimationDependency::BuildTree(cons
|
||||
{
|
||||
const SSetCharacter *pkChar = pkOwnerSet->Character(iChar);
|
||||
|
||||
if (pkChar->UsedAnimationIndices.find(AnimIndex) != pkChar->UsedAnimationIndices.end())
|
||||
if (pkChar->UsedAnimationIndices.contains(AnimIndex))
|
||||
pTree->mCharacterIndices.insert(iChar);
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>
|
||||
const auto *pInst = static_cast<CScriptInstanceDependency*>(pNode.get());
|
||||
const uint32 ObjType = pInst->ObjectType();
|
||||
|
||||
if (UsedObjectTypes.find(ObjType) == UsedObjectTypes.end())
|
||||
if (!UsedObjectTypes.contains(ObjType))
|
||||
{
|
||||
// Get the module list for this object type and check whether any of them are new before adding them to the output list
|
||||
const CScriptTemplate *pTemplate = pGame->TemplateByID(ObjType);
|
||||
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
void Serialize(IArchive& rArc) override;
|
||||
|
||||
// Accessors
|
||||
bool IsUsedByCharacter(uint32 CharIdx) const { return mCharacterIndices.find(CharIdx) != mCharacterIndices.end(); }
|
||||
bool IsUsedByCharacter(uint32 CharIdx) const { return mCharacterIndices.contains(CharIdx); }
|
||||
bool IsUsedByAnyCharacter() const { return !mCharacterIndices.empty(); }
|
||||
|
||||
// Static
|
||||
|
||||
@@ -320,7 +320,7 @@ void CGameExporter::LoadPaks()
|
||||
const uint32 ResSize = Pak.ReadULong();
|
||||
const uint32 ResOffset = Pak.ReadULong();
|
||||
|
||||
if (mResourceMap.find(ResID) == mResourceMap.cend())
|
||||
if (!mResourceMap.contains(ResID))
|
||||
mResourceMap.insert_or_assign(ResID, SResourceInstance{PakPath, ResID, ResType, ResOffset, ResSize, Compressed, false});
|
||||
|
||||
// Check for duplicate resources
|
||||
@@ -329,7 +329,7 @@ void CGameExporter::LoadPaks()
|
||||
mAreaDuplicateMap[ResID] = AreaHasDuplicates;
|
||||
AreaHasDuplicates = false;
|
||||
}
|
||||
else if (!AreaHasDuplicates && PakResourceSet.find(ResID) != PakResourceSet.cend())
|
||||
else if (!AreaHasDuplicates && PakResourceSet.contains(ResID))
|
||||
{
|
||||
AreaHasDuplicates = true;
|
||||
}
|
||||
@@ -399,7 +399,7 @@ void CGameExporter::LoadPaks()
|
||||
const uint32 Size = Pak.ReadULong();
|
||||
const uint32 Offset = DataStart + Pak.ReadULong();
|
||||
|
||||
if (mResourceMap.find(ResID) == mResourceMap.cend())
|
||||
if (!mResourceMap.contains(ResID))
|
||||
mResourceMap.insert_or_assign(ResID, SResourceInstance{PakPath, ResID, Type, Offset, Size, Compressed, false});
|
||||
|
||||
// Check for duplicate resources (unnecessary for DKCR)
|
||||
@@ -410,7 +410,7 @@ void CGameExporter::LoadPaks()
|
||||
mAreaDuplicateMap.insert_or_assign(ResID, AreaHasDuplicates);
|
||||
AreaHasDuplicates = false;
|
||||
}
|
||||
else if (!AreaHasDuplicates && PakResourceSet.find(ResID) != PakResourceSet.cend())
|
||||
else if (!AreaHasDuplicates && PakResourceSet.contains(ResID))
|
||||
{
|
||||
AreaHasDuplicates = true;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||
// Check for missing resources in the new list
|
||||
for (const auto& ID : OldListSet)
|
||||
{
|
||||
if (NewListSet.find(ID) == NewListSet.end())
|
||||
if (!NewListSet.contains(ID))
|
||||
{
|
||||
const CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
||||
const TString Extension = (pEntry != nullptr ? "." + pEntry->CookedExtension() : "");
|
||||
@@ -425,7 +425,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||
// Check for extra resources in the new list
|
||||
for (const auto& ID : NewListSet)
|
||||
{
|
||||
if (OldListSet.find(ID) == OldListSet.end())
|
||||
if (!OldListSet.contains(ID))
|
||||
{
|
||||
const CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
||||
const TString Extension = (pEntry != nullptr ? "." + pEntry->CookedExtension() : "");
|
||||
@@ -439,7 +439,7 @@ bool CPackage::ContainsAsset(const CAssetID& rkID) const
|
||||
if (mCacheDirty)
|
||||
UpdateDependencyCache();
|
||||
|
||||
return mCachedDependencies.find(rkID) != mCachedDependencies.end();
|
||||
return mCachedDependencies.contains(rkID);
|
||||
}
|
||||
|
||||
TString CPackage::DefinitionPath(bool Relative) const
|
||||
|
||||
@@ -131,7 +131,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
|
||||
const CAssetID ResID = pDep->ID();
|
||||
const auto Find = mUsageMap.find(ResID);
|
||||
|
||||
if (!mIsInitialArea && mStillLookingIDs.find(ResID) == mStillLookingIDs.cend())
|
||||
if (!mIsInitialArea && !mStillLookingIDs.contains(ResID))
|
||||
return;
|
||||
|
||||
if (Find != mUsageMap.cend())
|
||||
@@ -197,7 +197,7 @@ void CPackageDependencyListBuilder::BuildDependencyList(bool AllowDuplicates, st
|
||||
continue;
|
||||
}
|
||||
|
||||
mIsUniversalAreaAsset = mUniversalAreaAssets.find(rkRes.ID) != mUniversalAreaAssets.cend();
|
||||
mIsUniversalAreaAsset = mUniversalAreaAssets.contains(rkRes.ID);
|
||||
|
||||
if (rkRes.Type == "MLVL")
|
||||
{
|
||||
@@ -234,9 +234,9 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
||||
if (!IsValid)
|
||||
return;
|
||||
|
||||
if ((mCurrentAreaHasDuplicates && mAreaUsedAssets.find(rkID) != mAreaUsedAssets.end()) ||
|
||||
(!mCurrentAreaHasDuplicates && mPackageUsedAssets.find(rkID) != mPackageUsedAssets.end()) ||
|
||||
(!mIsUniversalAreaAsset && mUniversalAreaAssets.find(rkID) != mUniversalAreaAssets.end()))
|
||||
if ((mCurrentAreaHasDuplicates && mAreaUsedAssets.contains(rkID)) ||
|
||||
(!mCurrentAreaHasDuplicates && mPackageUsedAssets.contains(rkID)) ||
|
||||
(!mIsUniversalAreaAsset && mUniversalAreaAssets.contains(rkID)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -502,7 +502,7 @@ void CAreaDependencyListBuilder::AddDependency(const CAssetID& rkID, std::list<C
|
||||
if (ResType == EResourceType::World || ResType == EResourceType::Area)
|
||||
return;
|
||||
|
||||
if (mBaseUsedAssets.find(rkID) != mBaseUsedAssets.end() || mLayerUsedAssets.find(rkID) != mLayerUsedAssets.end())
|
||||
if (mBaseUsedAssets.contains(rkID) || mLayerUsedAssets.contains(rkID))
|
||||
return;
|
||||
|
||||
// Dependency is valid! Evaluate the node tree (except for SCAN and DGRP)
|
||||
@@ -593,7 +593,7 @@ void CAssetDependencyListBuilder::AddDependency(const CAssetID& kID, std::vector
|
||||
|
||||
const EResourceType ResType = pEntry->ResourceType();
|
||||
|
||||
if (mUsedAssets.find(kID) != mUsedAssets.cend())
|
||||
if (mUsedAssets.contains(kID))
|
||||
return;
|
||||
|
||||
// Dependency is valid! Evaluate the node tree
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
// Find all relevant primitives
|
||||
std::set<CAnimPrimitive> PrimSet;
|
||||
|
||||
if (UsedTransitions.find(mpDefaultTransition.get()) == UsedTransitions.cend())
|
||||
if (!UsedTransitions.contains(mpDefaultTransition.get()))
|
||||
{
|
||||
mpDefaultTransition->GetUniquePrimitives(PrimSet);
|
||||
UsedTransitions.insert(mpDefaultTransition.get());
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
if (pTree->HasDependency(transition.AnimA) &&
|
||||
pTree->HasDependency(transition.AnimB) &&
|
||||
UsedTransitions.find(pTransition) == UsedTransitions.cend())
|
||||
!UsedTransitions.contains(pTransition))
|
||||
{
|
||||
pTransition->GetUniquePrimitives(PrimSet);
|
||||
UsedTransitions.insert(pTransition);
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
IMetaTransition *pTransition = halfTrans.pTransition.get();
|
||||
|
||||
if (pTree->HasDependency(halfTrans.Anim) &&
|
||||
UsedTransitions.find(pTransition) == UsedTransitions.cend())
|
||||
!UsedTransitions.contains(pTransition))
|
||||
{
|
||||
pTransition->GetUniquePrimitives(PrimSet);
|
||||
UsedTransitions.insert(pTransition);
|
||||
|
||||
@@ -177,7 +177,7 @@ CScriptObject* CGameArea::SpawnInstance(CScriptTemplate *pTemplate,
|
||||
|
||||
if (InstanceID != UINT32_MAX)
|
||||
{
|
||||
if (mObjectMap.find(InstanceID) == mObjectMap.cend())
|
||||
if (!mObjectMap.contains(InstanceID))
|
||||
InstanceID = UINT32_MAX;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
bool Accepts(EResourceType Type) const
|
||||
{
|
||||
return mAcceptedTypes.find(Type) != mAcceptedTypes.end();
|
||||
return mAcceptedTypes.contains(Type);
|
||||
}
|
||||
|
||||
bool Accepts(const CResTypeInfo *pType) const
|
||||
|
||||
@@ -456,8 +456,8 @@ void CAnimSetLoader::ProcessPrimitives()
|
||||
|
||||
for (auto& transition : pSet->mTransitions)
|
||||
{
|
||||
if (character.UsedAnimationIndices.find(transition.AnimIdA) == character.UsedAnimationIndices.cend() ||
|
||||
character.UsedAnimationIndices.find(transition.AnimIdB) == character.UsedAnimationIndices.cend())
|
||||
if (!character.UsedAnimationIndices.contains(transition.AnimIdA) ||
|
||||
!character.UsedAnimationIndices.contains(transition.AnimIdB))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -467,7 +467,7 @@ void CAnimSetLoader::ProcessPrimitives()
|
||||
|
||||
for (const auto& primitive : Primitives)
|
||||
{
|
||||
if (character.UsedAnimationIndices.find(primitive.ID()) == character.UsedAnimationIndices.cend())
|
||||
if (!character.UsedAnimationIndices.contains(primitive.ID()))
|
||||
{
|
||||
character.UsedAnimationIndices.insert(primitive.ID());
|
||||
AddedNewAnims = true;
|
||||
@@ -477,7 +477,7 @@ void CAnimSetLoader::ProcessPrimitives()
|
||||
|
||||
for (SHalfTransition& trans : pSet->mHalfTransitions)
|
||||
{
|
||||
if (character.UsedAnimationIndices.find(trans.AnimID) == character.UsedAnimationIndices.cend())
|
||||
if (!character.UsedAnimationIndices.contains(trans.AnimID))
|
||||
continue;
|
||||
|
||||
std::set<CAnimPrimitive> Primitives;
|
||||
@@ -485,7 +485,7 @@ void CAnimSetLoader::ProcessPrimitives()
|
||||
|
||||
for (const auto& primitive : Primitives)
|
||||
{
|
||||
if (character.UsedAnimationIndices.find(primitive.ID()) == character.UsedAnimationIndices.cend())
|
||||
if (!character.UsedAnimationIndices.contains(primitive.ID()))
|
||||
{
|
||||
character.UsedAnimationIndices.insert(primitive.ID());
|
||||
AddedNewAnims = true;
|
||||
|
||||
@@ -398,7 +398,7 @@ void ChangeTypeName(IProperty* pProperty, const char* pkOldTypeName, const char*
|
||||
if (Find != gNameMap.cend())
|
||||
{
|
||||
SNameValue& Value = Find->second;
|
||||
WasRegistered = Value.PropertyList.find(pProperty) != Value.PropertyList.cend();
|
||||
WasRegistered = Value.PropertyList.contains(pProperty);
|
||||
}
|
||||
|
||||
// Create a key for the new property and add it to the list.
|
||||
|
||||
@@ -25,7 +25,7 @@ CScene::~CScene()
|
||||
|
||||
bool CScene::IsNodeIDUsed(uint32 ID) const
|
||||
{
|
||||
return mNodeMap.find(ID) != mNodeMap.cend();
|
||||
return mNodeMap.contains(ID);
|
||||
}
|
||||
|
||||
uint32 CScene::CreateNodeID(uint32 SuggestedID) const
|
||||
|
||||
@@ -27,7 +27,7 @@ void CSplinePathExtra::PostLoad()
|
||||
|
||||
void CSplinePathExtra::FindAttachedWaypoints(std::set<CWaypointExtra*>& rChecked, CWaypointExtra* pWaypoint)
|
||||
{
|
||||
if (rChecked.find(pWaypoint) != rChecked.cend())
|
||||
if (rChecked.contains(pWaypoint))
|
||||
return;
|
||||
|
||||
rChecked.insert(pWaypoint);
|
||||
|
||||
Reference in New Issue
Block a user