mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-16 08:27:01 +00:00
General: Make use of ranged for where applicable
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user