Refactor so PWE compiles with the newly externalized LibCommon

This commit is contained in:
Aruki
2018-12-11 22:50:46 -07:00
parent dacd21d7fc
commit 2287b05bc3
298 changed files with 3192 additions and 3184 deletions

View File

@@ -7,7 +7,7 @@
#include "Core/Resource/CWorld.h"
#include "Core/Resource/Animation/CAnimSet.h"
#include "Core/Resource/Script/CScriptLayer.h"
#include <Math/MathUtil.h>
#include <Common/Math/MathUtil.h>
#define REVERT_AUTO_NAMES 1
#define PROCESS_PACKAGES 1
@@ -85,12 +85,12 @@ void ApplyGeneratedName(CResourceEntry *pEntry, const TString& rkDir, const TStr
void GenerateAssetNames(CGameProject *pProj)
{
Log::Write("*** Generating Asset Names ***");
debugf("*** Generating Asset Names ***");
CResourceStore *pStore = pProj->ResourceStore();
#if REVERT_AUTO_NAMES
// Revert all auto-generated asset names back to default to prevent name conflicts resulting in inconsistent results.
Log::Write("Reverting auto-generated names");
debugf("Reverting auto-generated names");
for (CResourceIterator It(pStore); It; ++It)
{
@@ -106,13 +106,13 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_PACKAGES
// Generate names for package named resources
Log::Write("Processing packages");
debugf("Processing packages");
for (u32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++)
for (uint32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++)
{
CPackage *pPkg = pProj->PackageByIndex(iPkg);
for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
{
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
if (rkRes.Name.EndsWith("NODEPEND")) continue;
@@ -128,7 +128,7 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_WORLDS
// Generate world/area names
Log::Write("Processing worlds");
debugf("Processing worlds");
const TString kWorldsRoot = "Worlds/";
for (TResourceIterator<eWorld> It(pStore); It; ++It)
@@ -165,15 +165,15 @@ void GenerateAssetNames(CGameProject *pProj)
ApplyGeneratedName(pSkyEntry, WorldDir + "sky/cooked/", WorldName + "_sky");
// Move sky textures
for (u32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++)
for (uint32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++)
{
CMaterialSet *pSet = pSkyModel->GetMatSet(iSet);
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
{
CMaterial *pMat = pSet->MaterialByIndex(iMat);
for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++)
for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++)
{
CMaterialPass *pPass = pMat->Pass(iPass);
@@ -197,7 +197,7 @@ void GenerateAssetNames(CGameProject *pProj)
}
// Areas
for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
{
// Determine area name
TString AreaName = pWorld->AreaInternalName(iArea);
@@ -233,15 +233,15 @@ void GenerateAssetNames(CGameProject *pProj)
CGameArea *pArea = (CGameArea*) pAreaEntry->Load();
// Area lightmaps
u32 LightmapNum = 0;
uint32 LightmapNum = 0;
CMaterialSet *pMaterials = pArea->Materials();
for (u32 iMat = 0; iMat < pMaterials->NumMaterials(); iMat++)
for (uint32 iMat = 0; iMat < pMaterials->NumMaterials(); iMat++)
{
CMaterial *pMat = pMaterials->MaterialByIndex(iMat);
bool FoundLightmap = false;
for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++)
for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++)
{
CMaterialPass *pPass = pMat->Pass(iPass);
@@ -277,11 +277,11 @@ void GenerateAssetNames(CGameProject *pProj)
}
// Generate names from script instance names
for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++)
for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++)
{
CScriptLayer *pLayer = pArea->ScriptLayer(iLyr);
for (u32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
{
CScriptObject* pInst = pLayer->InstanceByIndex(iInst);
CStructProperty* pProperties = pInst->Template()->Properties();
@@ -327,7 +327,7 @@ void GenerateAssetNames(CGameProject *pProj)
if (Name.EndsWith(".STRG", false))
{
u32 StringPropID = (pProj->Game() <= EGame::Prime ? 0x4 : 0x9182250C);
uint32 StringPropID = (pProj->Game() <= EGame::Prime ? 0x4 : 0x9182250C);
CAssetProperty *pStringProperty = TPropCast<CAssetProperty>(pProperties->ChildByID(StringPropID));
ASSERT(pStringProperty); // Temporary assert to remind myself later to update this code when uncooked properties are added to the template
@@ -353,7 +353,7 @@ void GenerateAssetNames(CGameProject *pProj)
else if (pInst->ObjectTypeID() == 0x0 || pInst->ObjectTypeID() == FOURCC('ACTR') ||
pInst->ObjectTypeID() == 0x8 || pInst->ObjectTypeID() == FOURCC('PLAT'))
{
u32 ModelPropID = (pProj->Game() <= EGame::Prime ? (pInst->ObjectTypeID() == 0x0 ? 0xA : 0x6) : 0xC27FFA8F);
uint32 ModelPropID = (pProj->Game() <= EGame::Prime ? (pInst->ObjectTypeID() == 0x0 ? 0xA : 0x6) : 0xC27FFA8F);
CAssetProperty *pModelProperty = TPropCast<CAssetProperty>(pProperties->ChildByID(ModelPropID));
ASSERT(pModelProperty); // Temporary assert to remind myself later to update this code when uncooked properties are added to the template
@@ -396,22 +396,22 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_MODELS
// Generate Model Lightmap names
Log::Write("Processing model lightmaps");
debugf("Processing model lightmaps");
for (TResourceIterator<eModel> It(pStore); It; ++It)
{
CModel *pModel = (CModel*) It->Load();
u32 LightmapNum = 0;
uint32 LightmapNum = 0;
for (u32 iSet = 0; iSet < pModel->GetMatSetCount(); iSet++)
for (uint32 iSet = 0; iSet < pModel->GetMatSetCount(); iSet++)
{
CMaterialSet *pSet = pModel->GetMatSet(iSet);
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
{
CMaterial *pMat = pSet->MaterialByIndex(iMat);
for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++)
for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++)
{
CMaterialPass *pPass = pMat->Pass(iPass);
@@ -439,7 +439,7 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_AUDIO_GROUPS
// Generate Audio Group names
Log::Write("Processing audio groups");
debugf("Processing audio groups");
const TString kAudioGrpDir = "Audio/";
for (TResourceIterator<eAudioGroup> It(pStore); It; ++It)
@@ -452,7 +452,7 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_AUDIO_MACROS
// Process audio macro/sample names
Log::Write("Processing audio macros");
debugf("Processing audio macros");
const TString kSfxDir = "Audio/Uncategorized/";
for (TResourceIterator<eAudioMacro> It(pStore); It; ++It)
@@ -461,7 +461,7 @@ void GenerateAssetNames(CGameProject *pProj)
TString MacroName = pMacro->MacroName();
ApplyGeneratedName(*It, kSfxDir, MacroName);
for (u32 iSamp = 0; iSamp < pMacro->NumSamples(); iSamp++)
for (uint32 iSamp = 0; iSamp < pMacro->NumSamples(); iSamp++)
{
CAssetID SampleID = pMacro->SampleByIndex(iSamp);
CResourceEntry *pSample = pStore->FindEntry(SampleID);
@@ -484,7 +484,7 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_ANIM_CHAR_SETS
// Generate animation format names
// Hacky syntax because animsets are under eAnimSet in MP1/2 and eCharacter in MP3/DKCR
Log::Write("Processing animation data");
debugf("Processing animation data");
CResourceIterator *pIter = (pProj->Game() <= EGame::Echoes ? (CResourceIterator*) new TResourceIterator<eAnimSet> : (CResourceIterator*) new TResourceIterator<eCharacter>);
CResourceIterator& It = *pIter;
@@ -494,7 +494,7 @@ void GenerateAssetNames(CGameProject *pProj)
TString NewSetName;
CAnimSet *pSet = (CAnimSet*) It->Load();
for (u32 iChar = 0; iChar < pSet->NumCharacters(); iChar++)
for (uint32 iChar = 0; iChar < pSet->NumCharacters(); iChar++)
{
const SSetCharacter *pkChar = pSet->Character(iChar);
@@ -516,7 +516,7 @@ void GenerateAssetNames(CGameProject *pProj)
}
}
for (u32 iOverlay = 0; iOverlay < pkChar->OverlayModels.size(); iOverlay++)
for (uint32 iOverlay = 0; iOverlay < pkChar->OverlayModels.size(); iOverlay++)
{
const SOverlayModel& rkOverlay = pkChar->OverlayModels[iOverlay];
@@ -573,7 +573,7 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_STRINGS
// Generate string names
Log::Write("Processing strings");
debugf("Processing strings");
const TString kStringsDir = "Strings/Uncategorized/";
for (TResourceIterator<eStringTable> It(pStore); It; ++It)
@@ -582,12 +582,12 @@ void GenerateAssetNames(CGameProject *pProj)
CStringTable *pString = (CStringTable*) It->Load();
TString String;
for (u32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++)
for (uint32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++)
String = CStringTable::StripFormatting( pString->String("ENGL", iStr) ).Trimmed();
if (!String.IsEmpty())
{
TString Name = String.SubString(0, Math::Min<u32>(String.Size(), 50)).Trimmed();
TString Name = String.SubString(0, Math::Min<uint32>(String.Size(), 50)).Trimmed();
Name.Replace("\n", " ");
while (Name.EndsWith(".") || TString::IsWhitespace(Name.Back()))
@@ -600,7 +600,7 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_SCANS
// Generate scan names
Log::Write("Processing scans");
debugf("Processing scans");
for (TResourceIterator<eScan> It(pStore); It; ++It)
{
if (It->IsNamed()) continue;
@@ -628,7 +628,7 @@ void GenerateAssetNames(CGameProject *pProj)
CResourceEntry *pEntry = pStore->FindEntry(FrameID);
if (pEntry) ApplyGeneratedName(pEntry, pEntry->DirectoryPath(), "ScanFrame");
for (u32 iImg = 0; iImg < 4; iImg++)
for (uint32 iImg = 0; iImg < 4; iImg++)
{
CAssetID ImageID = pScan->ScanImage(iImg);
CResourceEntry *pImgEntry = pStore->FindEntry(ImageID);
@@ -640,7 +640,7 @@ void GenerateAssetNames(CGameProject *pProj)
#if PROCESS_FONTS
// Generate font names
Log::Write("Processing fonts");
debugf("Processing fonts");
for (TResourceIterator<eFont> It(pStore); It; ++It)
{
CFont *pFont = (CFont*) It->Load();
@@ -659,5 +659,5 @@ void GenerateAssetNames(CGameProject *pProj)
pStore->RootDirectory()->DeleteEmptySubdirectories();
pStore->ConditionalSaveStore();
Log::Write("*** Asset Name Generation FINISHED ***");
debugf("*** Asset Name Generation FINISHED ***");
}

View File

@@ -18,15 +18,15 @@ bool CAssetNameMap::LoadAssetNames(TString Path /*= ""*/)
}
else
{
TString ExpectedIDLength = (mIDLength == e32Bit ? "32-bit" : "64-bit");
TString GotIDLength = (FileIDLength == e32Bit ? "32-bit" : "64-bit");
Log::Error("Failed to load asset names; expected " + ExpectedIDLength + " IDs, got " + GotIDLength);
debugf("Failed to load asset names; expected %s IDs, got %s",
mIDLength == e32Bit ? "32-bit" : "64-bit",
FileIDLength == e32Bit ? "32-bit" : "64-bit" );
return false;
}
}
else
{
Log::Error("Failed to load asset names; couldn't open XML.");
errorf("Failed to load asset names; couldn't open XML.");
return false;
}
}
@@ -117,9 +117,9 @@ void CAssetNameMap::CopyFromStore(CResourceStore *pStore /*= gpResourceStore*/)
TString OldPath = NameInfo.FullPath();
TString NewPath = NewNameInfo.FullPath();
Log::Warning("Detected name conflict when copying asset name from the resource store; renaming.");
Log::Warning("\tOld Path: " + OldPath);
Log::Warning("\tNew Path: " + NewPath);
warnf("Detected name conflict when copying asset name from the resource store; renaming.");
warnf("\tOld Path: %s", *OldPath);
warnf("\tNew Path: %s", *NewPath);
NameInfo.Name = NewNameInfo.Name;
}
@@ -160,7 +160,7 @@ void CAssetNameMap::PostLoadValidate()
// Verify the name/path is valid
if (!CResourceStore::IsValidResourcePath(rkInfo.Directory, rkInfo.Name))
{
Log::Error("Invalid resource path in asset name map: " + rkInfo.Directory + rkInfo.Name + "." + rkInfo.Type.ToString());
errorf("Invalid resource path in asset name map: %s%s.%s", *rkInfo.Directory, *rkInfo.Name, *rkInfo.Type.ToString());
Iter = mMap.erase(Iter);
FoundErrors = true;
}
@@ -168,7 +168,7 @@ void CAssetNameMap::PostLoadValidate()
// Verify correct ID length
if (Iter->first.Length() != mIDLength)
{
Log::Error("Incorrect asset ID length in asset name map: " + Iter->first.ToString());
errorf("Incorrect asset ID length in asset name map: %s", *Iter->first.ToString());
Iter = mMap.erase(Iter);
FoundErrors = true;
}
@@ -178,13 +178,11 @@ void CAssetNameMap::PostLoadValidate()
// If we detected any dupes, then this map can't be used
if (!Dupes.empty())
{
Log::Error("Asset name map is invalid and cannot be used! Duplicate asset entries detected:");
errorf("Asset name map is invalid and cannot be used! Duplicate asset entries detected:");
for (auto Iter = Dupes.begin(); Iter != Dupes.end(); Iter++)
{
const SAssetNameInfo& rkInfo = *Iter;
TString FullPath = rkInfo.FullPath();
Log::Error("\t" + FullPath);
warnf("\t%s", Iter->FullPath());
}
mMap.clear();

View File

@@ -9,13 +9,13 @@
// ************ IDependencyNode ************
IDependencyNode::~IDependencyNode()
{
for (u32 iChild = 0; iChild < mChildren.size(); iChild++)
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
delete mChildren[iChild];
}
bool IDependencyNode::HasDependency(const CAssetID& rkID) const
{
for (u32 iChild = 0; iChild < mChildren.size(); iChild++)
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
{
if (mChildren[iChild]->HasDependency(rkID))
return true;
@@ -26,7 +26,7 @@ bool IDependencyNode::HasDependency(const CAssetID& rkID) const
void IDependencyNode::GetAllResourceReferences(std::set<CAssetID>& rOutSet) const
{
for (u32 iChild = 0; iChild < mChildren.size(); iChild++)
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
mChildren[iChild]->GetAllResourceReferences(rOutSet);
}
@@ -158,7 +158,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
// Recursive function for parsing script dependencies and loading them into the script instance dependency
void* pPropertyData = pInstance->PropertyData();
for (u32 PropertyIdx = 0; PropertyIdx < pStruct->NumChildren(); PropertyIdx++)
for (uint32 PropertyIdx = 0; PropertyIdx < pStruct->NumChildren(); PropertyIdx++)
{
IProperty *pProp = pStruct->ChildByIndex(PropertyIdx);
EPropertyType Type = pProp->Type();
@@ -170,7 +170,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
else if (Type == EPropertyType::Sound)
{
u32 SoundID = TPropCast<CSoundProperty>(pProp)->Value(pPropertyData);
uint32 SoundID = TPropCast<CSoundProperty>(pProp)->Value(pPropertyData);
if (SoundID != -1)
{
@@ -246,13 +246,13 @@ CSetCharacterDependency* CSetCharacterDependency::BuildTree(const SSetCharacter&
&rkChar.EffectParticles
};
for (u32 iVec = 0; iVec < 5; iVec++)
for (uint32 iVec = 0; iVec < 5; iVec++)
{
for (u32 iPart = 0; iPart < pkParticleVectors[iVec]->size(); iPart++)
for (uint32 iPart = 0; iPart < pkParticleVectors[iVec]->size(); iPart++)
pTree->AddDependency(pkParticleVectors[iVec]->at(iPart));
}
for (u32 iOverlay = 0; iOverlay < rkChar.OverlayModels.size(); iOverlay++)
for (uint32 iOverlay = 0; iOverlay < rkChar.OverlayModels.size(); iOverlay++)
{
const SOverlayModel& rkOverlay = rkChar.OverlayModels[iOverlay];
pTree->AddDependency(rkOverlay.ModelID);
@@ -276,13 +276,13 @@ void CSetAnimationDependency::Serialize(IArchive& rArc)
<< SerialParameter("Children", mChildren);
}
CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOwnerSet, u32 AnimIndex)
CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOwnerSet, uint32 AnimIndex)
{
CSetAnimationDependency *pTree = new CSetAnimationDependency;
const SAnimation *pkAnim = pkOwnerSet->Animation(AnimIndex);
// Find relevant character indices
for (u32 iChar = 0; iChar < pkOwnerSet->NumCharacters(); iChar++)
for (uint32 iChar = 0; iChar < pkOwnerSet->NumCharacters(); iChar++)
{
const SSetCharacter *pkChar = pkOwnerSet->Character(iChar);
@@ -340,7 +340,7 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector
mLayerOffsets.push_back(mChildren.size());
std::set<CAssetID> UsedIDs;
for (u32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
{
CScriptInstanceDependency *pTree = CScriptInstanceDependency::BuildTree( pLayer->InstanceByIndex(iInst) );
ASSERT(pTree != nullptr);
@@ -355,34 +355,34 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector
delete pTree;
}
for (u32 iDep = 0; iDep < rkExtraDeps.size(); iDep++)
for (uint32 iDep = 0; iDep < rkExtraDeps.size(); iDep++)
AddDependency(rkExtraDeps[iDep]);
}
void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<u32>& rModuleLayerOffsetsOut) const
void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<uint32>& rModuleLayerOffsetsOut) const
{
CGameTemplate *pGame = NGameList::GetGameTemplate(Game);
// Output module list will be split per-script layer
// The output offset list contains two offsets per layer - start index and end index
for (u32 iLayer = 0; iLayer < mLayerOffsets.size(); iLayer++)
for (uint32 iLayer = 0; iLayer < mLayerOffsets.size(); iLayer++)
{
u32 StartIdx = mLayerOffsets[iLayer];
u32 EndIdx = (iLayer == mLayerOffsets.size() - 1 ? mChildren.size() : mLayerOffsets[iLayer + 1]);
uint32 StartIdx = mLayerOffsets[iLayer];
uint32 EndIdx = (iLayer == mLayerOffsets.size() - 1 ? mChildren.size() : mLayerOffsets[iLayer + 1]);
u32 ModuleStartIdx = rModuleDepsOut.size();
uint32 ModuleStartIdx = 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<u32> UsedObjectTypes;
std::set<uint32> UsedObjectTypes;
for (u32 iInst = StartIdx; iInst < EndIdx; iInst++)
for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++)
{
IDependencyNode *pNode = mChildren[iInst];
if (pNode->Type() != eDNT_ScriptInstance) continue;
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
u32 ObjType = pInst->ObjectType();
uint32 ObjType = pInst->ObjectType();
if (UsedObjectTypes.find(ObjType) == UsedObjectTypes.end())
{
@@ -390,12 +390,12 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>
CScriptTemplate *pTemplate = pGame->TemplateByID(ObjType);
const std::vector<TString>& rkModules = pTemplate->RequiredModules();
for (u32 iMod = 0; iMod < rkModules.size(); iMod++)
for (uint32 iMod = 0; iMod < rkModules.size(); iMod++)
{
TString ModuleName = rkModules[iMod];
bool NewModule = true;
for (u32 iUsed = ModuleStartIdx; iUsed < rModuleDepsOut.size(); iUsed++)
for (uint32 iUsed = ModuleStartIdx; iUsed < rModuleDepsOut.size(); iUsed++)
{
if (rModuleDepsOut[iUsed] == ModuleName)
{

View File

@@ -2,9 +2,9 @@
#define CDEPENDENCYTREE
#include "CResourceEntry.h"
#include <Common/AssertMacro.h>
#include <Common/CAssetID.h>
#include <Common/FileIO.h>
#include <Common/Macros.h>
class CScriptLayer;
class CScriptObject;
@@ -44,8 +44,8 @@ public:
static IDependencyNode* ArchiveConstructor(EDependencyNodeType Type);
// Accessors
inline u32 NumChildren() const { return mChildren.size(); }
inline IDependencyNode* ChildByIndex(u32 Index) const { return mChildren[Index]; }
inline uint NumChildren() const { return mChildren.size(); }
inline IDependencyNode* ChildByIndex(uint Index) const { return mChildren[Index]; }
};
// Basic dependency tree; this class is sufficient for most resource types.
@@ -109,7 +109,7 @@ public:
class CCharPropertyDependency : public CPropertyDependency
{
protected:
u32 mUsedChar;
int mUsedChar;
public:
CCharPropertyDependency()
@@ -117,7 +117,7 @@ public:
, mUsedChar(-1)
{}
CCharPropertyDependency(const TString& rkPropID, const CAssetID& rkAssetID, u32 UsedChar)
CCharPropertyDependency(const TString& rkPropID, const CAssetID& rkAssetID, int UsedChar)
: CPropertyDependency(rkPropID, rkAssetID)
, mUsedChar(UsedChar)
{}
@@ -126,21 +126,21 @@ public:
virtual void Serialize(IArchive& rArc);
// Accessors
inline u32 UsedChar() const { return mUsedChar; }
inline int UsedChar() const { return mUsedChar; }
};
// Node representing a script object. Indicates the type of object.
class CScriptInstanceDependency : public IDependencyNode
{
protected:
u32 mObjectType;
uint mObjectType;
public:
virtual EDependencyNodeType Type() const;
virtual void Serialize(IArchive& rArc);
// Accessors
inline u32 ObjectType() const { return mObjectType; }
inline uint ObjectType() const { return mObjectType; }
// Static
static CScriptInstanceDependency* BuildTree(CScriptObject *pInstance);
@@ -152,17 +152,17 @@ protected:
class CSetCharacterDependency : public CDependencyTree
{
protected:
u32 mCharSetIndex;
uint32 mCharSetIndex;
public:
CSetCharacterDependency() : CDependencyTree() {}
CSetCharacterDependency(u32 SetIndex) : CDependencyTree(), mCharSetIndex(SetIndex) {}
CSetCharacterDependency(uint32 SetIndex) : CDependencyTree(), mCharSetIndex(SetIndex) {}
virtual EDependencyNodeType Type() const;
virtual void Serialize(IArchive& rArc);
// Accessors
inline u32 CharSetIndex() const { return mCharSetIndex; }
inline uint32 CharSetIndex() const { return mCharSetIndex; }
// Static
static CSetCharacterDependency* BuildTree(const SSetCharacter& rkChar);
@@ -172,7 +172,7 @@ public:
class CSetAnimationDependency : public CDependencyTree
{
protected:
std::set<u32> mCharacterIndices;
std::set<uint32> mCharacterIndices;
public:
CSetAnimationDependency() : CDependencyTree() {}
@@ -181,36 +181,36 @@ public:
virtual void Serialize(IArchive& rArc);
// Accessors
inline bool IsUsedByCharacter(u32 CharIdx) const { return mCharacterIndices.find(CharIdx) != mCharacterIndices.end(); }
inline bool IsUsedByCharacter(uint32 CharIdx) const { return mCharacterIndices.find(CharIdx) != mCharacterIndices.end(); }
inline bool IsUsedByAnyCharacter() const { return !mCharacterIndices.empty(); }
// Static
static CSetAnimationDependency* BuildTree(const CAnimSet *pkOwnerSet, u32 AnimIndex);
static CSetAnimationDependency* BuildTree(const CAnimSet *pkOwnerSet, uint32 AnimIndex);
};
// Node representing an animation event. Indicates which character index uses this event.
class CAnimEventDependency : public CResourceDependency
{
protected:
u32 mCharIndex;
uint32 mCharIndex;
public:
CAnimEventDependency() : CResourceDependency() {}
CAnimEventDependency(const CAssetID& rkID, u32 CharIndex)
CAnimEventDependency(const CAssetID& rkID, uint32 CharIndex)
: CResourceDependency(rkID), mCharIndex(CharIndex) {}
virtual EDependencyNodeType Type() const;
virtual void Serialize(IArchive& rArc);
// Accessors
inline u32 CharIndex() const { return mCharIndex; }
inline uint32 CharIndex() const { return mCharIndex; }
};
// Node representing an area. Tracks dependencies on a per-instance basis and can separate dependencies of different script layers.
class CAreaDependencyTree : public CDependencyTree
{
protected:
std::vector<u32> mLayerOffsets;
std::vector<uint32> mLayerOffsets;
public:
CAreaDependencyTree() : CDependencyTree() {}
@@ -219,11 +219,11 @@ public:
virtual void Serialize(IArchive& rArc);
void AddScriptLayer(CScriptLayer *pLayer, const std::vector<CAssetID>& rkExtraDeps);
void GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<u32>& rModuleLayerOffsetsOut) const;
void GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<uint32>& rModuleLayerOffsetsOut) const;
// Accessors
inline u32 NumScriptLayers() const { return mLayerOffsets.size(); }
inline u32 ScriptLayerOffset(u32 LayerIdx) const { return mLayerOffsets[LayerIdx]; }
inline uint32 NumScriptLayers() const { return mLayerOffsets.size(); }
inline uint32 ScriptLayerOffset(uint32 LayerIdx) const { return mLayerOffsets[LayerIdx]; }
};
#endif // CDEPENDENCYTREE

View File

@@ -5,7 +5,7 @@
#include "Core/CompressionUtil.h"
#include "Core/Resource/CWorld.h"
#include "Core/Resource/Script/CGameTemplate.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <Common/CScopedTimer.h>
#include <Common/FileIO.h>
#include <Common/FileUtil.h>
@@ -92,7 +92,7 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
return !mpProgress->ShouldCancel();
}
void CGameExporter::LoadResource(const CAssetID& rkID, std::vector<u8>& rBuffer)
void CGameExporter::LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuffer)
{
SResourceInstance *pInst = FindResourceInstance(rkID);
if (pInst) LoadResource(*pInst, rBuffer);
@@ -268,7 +268,7 @@ void CGameExporter::LoadPaks()
if (!Pak.IsValid())
{
Log::Error("Couldn't open pak: " + PakPath);
errorf("Couldn't open pak: %s", *PakPath);
continue;
}
@@ -278,38 +278,38 @@ void CGameExporter::LoadPaks()
// MP1-MP3Proto
if (mGame < EGame::Corruption)
{
u32 PakVersion = Pak.ReadLong();
uint32 PakVersion = Pak.ReadLong();
Pak.Seek(0x4, SEEK_CUR);
ASSERT(PakVersion == 0x00030005);
// Echoes demo disc has a pak that ends right here.
if (!Pak.EoF())
{
u32 NumNamedResources = Pak.ReadLong();
uint32 NumNamedResources = Pak.ReadLong();
ASSERT(NumNamedResources > 0);
for (u32 iName = 0; iName < NumNamedResources; iName++)
for (uint32 iName = 0; iName < NumNamedResources; iName++)
{
CFourCC ResType = Pak.ReadLong();
CAssetID ResID(Pak, mGame);
u32 NameLen = Pak.ReadLong();
uint32 NameLen = Pak.ReadLong();
TString Name = Pak.ReadString(NameLen);
pPackage->AddResource(Name, ResID, ResType);
}
u32 NumResources = Pak.ReadLong();
uint32 NumResources = Pak.ReadLong();
// Keep track of which areas have duplicate resources
std::set<CAssetID> PakResourceSet;
bool AreaHasDuplicates = true; // Default to true so that first area is always considered as having duplicates
for (u32 iRes = 0; iRes < NumResources; iRes++)
for (uint32 iRes = 0; iRes < NumResources; iRes++)
{
bool Compressed = (Pak.ReadLong() == 1);
CFourCC ResType = Pak.ReadLong();
CAssetID ResID(Pak, mGame);
u32 ResSize = Pak.ReadLong();
u32 ResOffset = Pak.ReadLong();
uint32 ResSize = Pak.ReadLong();
uint32 ResOffset = Pak.ReadLong();
if (mResourceMap.find(ResID) == mResourceMap.end())
mResourceMap[ResID] = SResourceInstance { PakPath, ResID, ResType, ResOffset, ResSize, Compressed, false };
@@ -333,37 +333,37 @@ void CGameExporter::LoadPaks()
// MP3 + DKCR
else
{
u32 PakVersion = Pak.ReadLong();
u32 PakHeaderLen = Pak.ReadLong();
uint32 PakVersion = Pak.ReadLong();
uint32 PakHeaderLen = Pak.ReadLong();
Pak.Seek(PakHeaderLen - 0x8, SEEK_CUR);
ASSERT(PakVersion == 2);
struct SPakSection {
CFourCC Type; u32 Size;
CFourCC Type; uint32 Size;
};
std::vector<SPakSection> PakSections;
u32 NumPakSections = Pak.ReadLong();
uint32 NumPakSections = Pak.ReadLong();
ASSERT(NumPakSections == 3);
for (u32 iSec = 0; iSec < NumPakSections; iSec++)
for (uint32 iSec = 0; iSec < NumPakSections; iSec++)
{
CFourCC Type = Pak.ReadLong();
u32 Size = Pak.ReadLong();
uint32 Size = Pak.ReadLong();
PakSections.push_back(SPakSection { Type, Size });
}
Pak.SeekToBoundary(64);
for (u32 iSec = 0; iSec < NumPakSections; iSec++)
for (uint32 iSec = 0; iSec < NumPakSections; iSec++)
{
u32 Next = Pak.Tell() + PakSections[iSec].Size;
uint32 Next = Pak.Tell() + PakSections[iSec].Size;
// Named Resources
if (PakSections[iSec].Type == "STRG")
{
u32 NumNamedResources = Pak.ReadLong();
uint32 NumNamedResources = Pak.ReadLong();
for (u32 iName = 0; iName < NumNamedResources; iName++)
for (uint32 iName = 0; iName < NumNamedResources; iName++)
{
TString Name = Pak.ReadString();
CFourCC ResType = Pak.ReadLong();
@@ -375,20 +375,20 @@ void CGameExporter::LoadPaks()
else if (PakSections[iSec].Type == "RSHD")
{
ASSERT(PakSections[iSec + 1].Type == "DATA");
u32 DataStart = Next;
u32 NumResources = Pak.ReadLong();
uint32 DataStart = Next;
uint32 NumResources = Pak.ReadLong();
// Keep track of which areas have duplicate resources
std::set<CAssetID> PakResourceSet;
bool AreaHasDuplicates = true; // Default to true so that first area is always considered as having duplicates
for (u32 iRes = 0; iRes < NumResources; iRes++)
for (uint32 iRes = 0; iRes < NumResources; iRes++)
{
bool Compressed = (Pak.ReadLong() == 1);
CFourCC Type = Pak.ReadLong();
CAssetID ResID(Pak, mGame);
u32 Size = Pak.ReadLong();
u32 Offset = DataStart + Pak.ReadLong();
uint32 Size = Pak.ReadLong();
uint32 Offset = DataStart + Pak.ReadLong();
if (mResourceMap.find(ResID) == mResourceMap.end())
mResourceMap[ResID] = SResourceInstance { PakPath, ResID, Type, Offset, Size, Compressed, false };
@@ -425,7 +425,7 @@ void CGameExporter::LoadPaks()
#endif
}
void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vector<u8>& rBuffer)
void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vector<uint8>& rBuffer)
{
CFileInStream Pak(rkResource.PakFile, IOUtil::eBigEndian);
@@ -440,15 +440,15 @@ void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vecto
if (mGame <= EGame::CorruptionProto)
{
std::vector<u8> CompressedData(rkResource.PakSize);
std::vector<uint8> CompressedData(rkResource.PakSize);
u32 UncompressedSize = Pak.ReadLong();
uint32 UncompressedSize = Pak.ReadLong();
rBuffer.resize(UncompressedSize);
Pak.ReadBytes(CompressedData.data(), CompressedData.size());
if (ZlibCompressed)
{
u32 TotalOut;
uint32 TotalOut;
CompressionUtil::DecompressZlib(CompressedData.data(), CompressedData.size(), rBuffer.data(), rBuffer.size(), TotalOut);
}
else
@@ -462,40 +462,40 @@ void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vecto
CFourCC Magic = Pak.ReadLong();
ASSERT(Magic == "CMPD");
u32 NumBlocks = Pak.ReadLong();
uint32 NumBlocks = Pak.ReadLong();
struct SCompressedBlock {
u32 CompressedSize; u32 UncompressedSize;
uint32 CompressedSize; uint32 UncompressedSize;
};
std::vector<SCompressedBlock> CompressedBlocks;
u32 TotalUncompressedSize = 0;
for (u32 iBlock = 0; iBlock < NumBlocks; iBlock++)
uint32 TotalUncompressedSize = 0;
for (uint32 iBlock = 0; iBlock < NumBlocks; iBlock++)
{
u32 CompressedSize = (Pak.ReadLong() & 0x00FFFFFF);
u32 UncompressedSize = Pak.ReadLong();
uint32 CompressedSize = (Pak.ReadLong() & 0x00FFFFFF);
uint32 UncompressedSize = Pak.ReadLong();
TotalUncompressedSize += UncompressedSize;
CompressedBlocks.push_back( SCompressedBlock { CompressedSize, UncompressedSize } );
}
rBuffer.resize(TotalUncompressedSize);
u32 Offset = 0;
uint32 Offset = 0;
for (u32 iBlock = 0; iBlock < NumBlocks; iBlock++)
for (uint32 iBlock = 0; iBlock < NumBlocks; iBlock++)
{
u32 CompressedSize = CompressedBlocks[iBlock].CompressedSize;
u32 UncompressedSize = CompressedBlocks[iBlock].UncompressedSize;
uint32 CompressedSize = CompressedBlocks[iBlock].CompressedSize;
uint32 UncompressedSize = CompressedBlocks[iBlock].UncompressedSize;
// Block is compressed
if (CompressedSize != UncompressedSize)
{
std::vector<u8> CompressedData(CompressedBlocks[iBlock].CompressedSize);
std::vector<uint8> CompressedData(CompressedBlocks[iBlock].CompressedSize);
Pak.ReadBytes(CompressedData.data(), CompressedData.size());
if (ZlibCompressed)
{
u32 TotalOut;
uint32 TotalOut;
CompressionUtil::DecompressZlib(CompressedData.data(), CompressedData.size(), rBuffer.data() + Offset, UncompressedSize, TotalOut);
}
else
@@ -570,7 +570,7 @@ void CGameExporter::ExportResourceEditorData()
CWorld *pWorld = (CWorld*) It->Load();
// Set area duplicate flags
for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
{
CAssetID AreaID = pWorld->AreaResourceID(iArea);
auto Find = mAreaDuplicateMap.find(AreaID);
@@ -612,7 +612,7 @@ void CGameExporter::ExportResource(SResourceInstance& rRes)
{
if (!rRes.Exported)
{
std::vector<u8> ResourceData;
std::vector<uint8> ResourceData;
LoadResource(rRes, ResourceData);
// Register resource and write to file
@@ -657,11 +657,11 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
// Find the original world name in the package resource names
TString WorldName;
for (u32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++)
for (uint32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++)
{
CPackage *pPkg = mpProject->PackageByIndex(iPkg);
for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
{
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
@@ -712,8 +712,8 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
// MP2 demo - Use text between the first and second underscores
else if (mGame == EGame::EchoesDemo)
{
u32 UnderscoreA = WorldName.IndexOf('_');
u32 UnderscoreB = WorldName.IndexOf('_', UnderscoreA + 1);
uint32 UnderscoreA = WorldName.IndexOf('_');
uint32 UnderscoreB = WorldName.IndexOf('_', UnderscoreA + 1);
if (UnderscoreA != UnderscoreB && UnderscoreA != -1 && UnderscoreB != -1)
WorldName = WorldName.SubString(UnderscoreA + 1, UnderscoreB - UnderscoreA - 1);
@@ -722,8 +722,8 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
// MP2 - Remove text before first underscore and after last underscore, strip remaining underscores (except multiplayer maps, which have one underscore)
else if (mGame == EGame::Echoes)
{
u32 FirstUnderscore = WorldName.IndexOf('_');
u32 LastUnderscore = WorldName.LastIndexOf('_');
uint32 FirstUnderscore = WorldName.IndexOf('_');
uint32 LastUnderscore = WorldName.LastIndexOf('_');
if (FirstUnderscore != LastUnderscore && FirstUnderscore != -1 && LastUnderscore != -1)
{
@@ -739,14 +739,14 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
if (WorldName.StartsWith('!'))
WorldName = WorldName.ChopFront(1);
u32 LastUnderscore = WorldName.LastIndexOf('_');
uint32 LastUnderscore = WorldName.LastIndexOf('_');
WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore);
}
// MP3 - Remove text after last underscore
else if (mGame == EGame::Corruption)
{
u32 LastUnderscore = WorldName.LastIndexOf('_');
uint32 LastUnderscore = WorldName.LastIndexOf('_');
if (LastUnderscore != -1 && !WorldName.StartsWith("front_end_"))
WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore);
@@ -755,7 +755,7 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
// DKCR - Remove text prior to first underscore
else if (mGame == EGame::DKCReturns)
{
u32 Underscore = WorldName.IndexOf('_');
uint32 Underscore = WorldName.IndexOf('_');
WorldName = WorldName.ChopFront(Underscore + 1);
}
}

View File

@@ -8,7 +8,6 @@
#include <Common/CAssetID.h>
#include <Common/Flags.h>
#include <Common/TString.h>
#include <Common/types.h>
#include <map>
#include <nod/nod.hpp>
@@ -54,8 +53,8 @@ class CGameExporter
TString PakFile;
CAssetID ResourceID;
CFourCC ResourceType;
u32 PakOffset;
u32 PakSize;
uint32 PakOffset;
uint32 PakSize;
bool Compressed;
bool Exported;
};
@@ -76,7 +75,7 @@ class CGameExporter
public:
CGameExporter(EDiscType DiscType, EGame Game, bool FrontEnd, ERegion Region, const TString& rkGameName, const TString& rkGameID, float BuildVersion);
bool Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAssetNameMap *pNameMap, CGameInfo *pGameInfo, IProgressNotifier *pProgress);
void LoadResource(const CAssetID& rkID, std::vector<u8>& rBuffer);
void LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuffer);
bool ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot);
inline TString ProjectPath() const { return mProjectPath; }
@@ -85,7 +84,7 @@ protected:
bool ExtractDiscData();
bool ExtractDiscNodeRecursive(const nod::Node *pkNode, const TString& rkDir, bool RootNode, const nod::ExtractionContext& rkContext);
void LoadPaks();
void LoadResource(const SResourceInstance& rkResource, std::vector<u8>& rBuffer);
void LoadResource(const SResourceInstance& rkResource, std::vector<uint8>& rBuffer);
void ExportCookedResources();
void ExportResourceEditorData();
void ExportResource(SResourceInstance& rRes);
@@ -94,7 +93,7 @@ protected:
// Convenience Functions
inline SResourceInstance* FindResourceInstance(const CAssetID& rkID)
{
u64 IntegralID = rkID.ToLongLong();
uint64 IntegralID = rkID.ToLongLong();
auto Found = mResourceMap.find(IntegralID);
return (Found == mResourceMap.end() ? nullptr : &Found->second);
}

View File

@@ -49,7 +49,7 @@ void CGameInfo::Serialize(IArchive& rArc)
TString CGameInfo::GetBuildName(float BuildVer, ERegion Region) const
{
for (u32 iBuild = 0; iBuild < mBuilds.size(); iBuild++)
for (uint32 iBuild = 0; iBuild < mBuilds.size(); iBuild++)
{
const SBuildInfo& rkBuildInfo = mBuilds[iBuild];

View File

@@ -1,7 +1,7 @@
#ifndef CGAMEINFO
#define CGAMEINFO
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <Common/CAssetID.h>
#include <Common/TString.h>
#include <Common/Serialization/IArchive.h>

View File

@@ -14,7 +14,7 @@ CGameProject::~CGameProject()
gpResourceStore = nullptr;
}
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
delete mPackages[iPkg];
delete mpAudioManager;
@@ -45,7 +45,7 @@ bool CGameProject::Serialize(IArchive& rArc)
if (!rArc.IsReader())
{
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
PackageList.push_back( mPackages[iPkg]->DefinitionPath(true) );
}
@@ -56,7 +56,7 @@ bool CGameProject::Serialize(IArchive& rArc)
{
ASSERT(mPackages.empty());
for (u32 iPkg = 0; iPkg < PackageList.size(); iPkg++)
for (uint32 iPkg = 0; iPkg < PackageList.size(); iPkg++)
{
const TString& rkPackagePath = PackageList[iPkg];
TString PackageName = rkPackagePath.GetFileName(false);
@@ -122,7 +122,7 @@ bool CGameProject::MergeISO(const TString& rkIsoPath, nod::DiscWii *pOriginalIso
void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
{
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
{
CPackage *pPkg = mPackages[iPkg];
@@ -130,7 +130,7 @@ void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
// Construct a sorted list of worlds in this package
std::list<const SNamedResource*> PackageWorlds;
for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
{
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
@@ -153,11 +153,11 @@ void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
CAssetID CGameProject::FindNamedResource(const TString& rkName) const
{
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
{
CPackage *pPkg = mPackages[iPkg];
for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
{
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
@@ -171,7 +171,7 @@ CAssetID CGameProject::FindNamedResource(const TString& rkName) const
CPackage* CGameProject::FindPackage(const TString& rkName) const
{
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
{
CPackage *pPackage = mPackages[iPkg];

View File

@@ -11,7 +11,6 @@
#include <Common/EGame.h>
#include <Common/FileUtil.h>
#include <Common/TString.h>
#include <Common/types.h>
#include <Common/FileIO/CFileLock.h>
namespace nod { class DiscWii; }
@@ -92,8 +91,8 @@ public:
inline void SetProjectName(const TString& rkName) { mProjectName = rkName; }
inline TString Name() const { return mProjectName; }
inline u32 NumPackages() const { return mPackages.size(); }
inline CPackage* PackageByIndex(u32 Index) const { return mPackages[Index]; }
inline uint32 NumPackages() const { return mPackages.size(); }
inline CPackage* PackageByIndex(uint32 Index) const { return mPackages[Index]; }
inline void AddPackage(CPackage *pPackage) { mPackages.push_back(pPackage); }
inline CResourceStore* ResourceStore() const { return mpResourceStore; }
inline CGameInfo* GameInfo() const { return mpGameInfo; }

View File

@@ -22,10 +22,10 @@ TString COpeningBanner::EnglishGameName() const
// this and prevent the string-reading function from overrunning the buffer
CMemoryInStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
u32 CharSize = mWii ? 2 : 1;
u32 MaxLen = MaxGameNameLength();
uint32 CharSize = mWii ? 2 : 1;
uint32 MaxLen = MaxGameNameLength();
std::vector<u8> NameBuffer((MaxLen + 1) * CharSize, 0);
std::vector<uint8> NameBuffer((MaxLen + 1) * CharSize, 0);
Banner.GoTo( mWii ? 0xB0 : 0x1860 );
Banner.ReadBytes(NameBuffer.data(), MaxLen * CharSize);
@@ -36,9 +36,9 @@ TString COpeningBanner::EnglishGameName() const
void COpeningBanner::SetEnglishGameName(const TString& rkName)
{
CMemoryOutStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
u32 PadCount = 0;
uint32 PadCount = 0;
u32 MaxLen = MaxGameNameLength();
uint32 MaxLen = MaxGameNameLength();
ASSERT(rkName.Size() <= MaxLen);
if (mWii)
@@ -54,7 +54,7 @@ void COpeningBanner::SetEnglishGameName(const TString& rkName)
PadCount = MaxLen - rkName.Size();
}
for (u32 Pad = 0; Pad < PadCount; Pad++)
for (uint32 Pad = 0; Pad < PadCount; Pad++)
Banner.WriteByte(0);
}
@@ -65,7 +65,7 @@ void COpeningBanner::Save()
Banner.WriteBytes(mBannerData.data(), mBannerData.size());
}
u32 COpeningBanner::MaxGameNameLength() const
uint32 COpeningBanner::MaxGameNameLength() const
{
return (mWii ? 21 : 64);
}

View File

@@ -9,7 +9,7 @@ class CGameProject;
class COpeningBanner
{
CGameProject *mpProj;
std::vector<u8> mBannerData;
std::vector<uint8> mBannerData;
bool mWii;
public:
@@ -18,7 +18,7 @@ public:
void SetEnglishGameName(const TString& rkName);
void Save();
u32 MaxGameNameLength() const;
uint32 MaxGameNameLength() const;
};
#endif // COPENINGBANNER_H

View File

@@ -3,7 +3,7 @@
#include "CGameProject.h"
#include "Core/CompressionUtil.h"
#include "Core/Resource/Cooker/CWorldCooker.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <Common/FileIO.h>
#include <Common/FileUtil.h>
#include <Common/Serialization/XML.h>
@@ -69,7 +69,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
CPackageDependencyListBuilder Builder(this);
std::list<CAssetID> AssetList;
Builder.BuildDependencyList(true, AssetList);
Log::Write(TString::FromInt32(AssetList.size(), 0, 10) + " assets in " + Name() + ".pak");
debugf("%d assets in %s.pak", AssetList.size(), *Name());
// Write new pak
TString PakPath = CookedPackagePath(false);
@@ -77,19 +77,19 @@ void CPackage::Cook(IProgressNotifier *pProgress)
if (!Pak.IsValid())
{
Log::Error("Couldn't cook package " + CookedPackagePath(true) + "; unable to open package for writing");
errorf("Couldn't cook package %s; unable to open package for writing", *CookedPackagePath(true));
return;
}
EGame Game = mpProject->Game();
u32 Alignment = (Game <= EGame::CorruptionProto ? 0x20 : 0x40);
u32 AlignmentMinusOne = Alignment - 1;
uint32 Alignment = (Game <= EGame::CorruptionProto ? 0x20 : 0x40);
uint32 AlignmentMinusOne = Alignment - 1;
u32 TocOffset = 0;
u32 NamesSize = 0;
u32 ResTableOffset = 0;
u32 ResTableSize = 0;
u32 ResDataSize = 0;
uint32 TocOffset = 0;
uint32 NamesSize = 0;
uint32 ResTableOffset = 0;
uint32 ResTableSize = 0;
uint32 ResDataSize = 0;
// Write MP1 pak header
if (Game <= EGame::CorruptionProto)
@@ -123,7 +123,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
Pak.WriteToBoundary(0x40, 0);
// Named Resources
u32 NamesStart = Pak.Tell();
uint32 NamesStart = Pak.Tell();
Pak.WriteLong(mResources.size());
for (auto Iter = mResources.begin(); Iter != mResources.end(); Iter++)
@@ -143,7 +143,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
Pak.WriteLong(AssetList.size());
CAssetID Dummy = CAssetID::InvalidID(Game);
for (u32 iRes = 0; iRes < AssetList.size(); iRes++)
for (uint32 iRes = 0; iRes < AssetList.size(); iRes++)
{
Pak.WriteLongLong(0);
Dummy.Write(Pak);
@@ -157,18 +157,18 @@ void CPackage::Cook(IProgressNotifier *pProgress)
struct SResourceTableInfo
{
CResourceEntry *pEntry;
u32 Offset;
u32 Size;
uint32 Offset;
uint32 Size;
bool Compressed;
};
std::vector<SResourceTableInfo> ResourceTableData(AssetList.size());
u32 ResIdx = 0;
u32 ResDataOffset = Pak.Tell();
uint32 ResIdx = 0;
uint32 ResDataOffset = Pak.Tell();
for (auto Iter = AssetList.begin(); Iter != AssetList.end() && !pProgress->ShouldCancel(); Iter++, ResIdx++)
{
// Initialize entry, recook assets if needed
u32 AssetOffset = Pak.Tell();
uint32 AssetOffset = Pak.Tell();
CAssetID ID = *Iter;
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
ASSERT(pEntry != nullptr);
@@ -193,15 +193,15 @@ void CPackage::Cook(IProgressNotifier *pProgress)
// Load resource data
CFileInStream CookedAsset(pEntry->CookedAssetPath(), IOUtil::eBigEndian);
ASSERT(CookedAsset.IsValid());
u32 ResourceSize = CookedAsset.Size();
uint32 ResourceSize = CookedAsset.Size();
std::vector<u8> ResourceData(ResourceSize);
std::vector<uint8> ResourceData(ResourceSize);
CookedAsset.ReadBytes(ResourceData.data(), ResourceData.size());
// Check if this asset should be compressed; there are a few resource types that are
// always compressed, and some types that are compressed if they're over a certain size
EResType Type = pEntry->ResourceType();
u32 CompressThreshold = (Game <= EGame::CorruptionProto ? 0x400 : 0x80);
uint32 CompressThreshold = (Game <= EGame::CorruptionProto ? 0x400 : 0x80);
bool ShouldAlwaysCompress = (Type == eTexture || Type == eModel || Type == eSkin ||
Type == eAnimSet || Type == eAnimation || Type == eFont);
@@ -230,8 +230,8 @@ void CPackage::Cook(IProgressNotifier *pProgress)
else
{
u32 CompressedSize;
std::vector<u8> CompressedData(ResourceData.size() * 2);
uint32 CompressedSize;
std::vector<uint8> CompressedData(ResourceData.size() * 2);
bool Success = false;
if (Game <= EGame::EchoesDemo || Game == EGame::DKCReturns)
@@ -242,9 +242,9 @@ void CPackage::Cook(IProgressNotifier *pProgress)
// Make sure that the compressed data is actually smaller, accounting for padding + uncompressed size value
if (Success)
{
u32 CompressionHeaderSize = (Game <= EGame::CorruptionProto ? 4 : 0x10);
u32 PaddedUncompressedSize = (ResourceSize + AlignmentMinusOne) & ~AlignmentMinusOne;
u32 PaddedCompressedSize = (CompressedSize + CompressionHeaderSize + AlignmentMinusOne) & ~AlignmentMinusOne;
uint32 CompressionHeaderSize = (Game <= EGame::CorruptionProto ? 4 : 0x10);
uint32 PaddedUncompressedSize = (ResourceSize + AlignmentMinusOne) & ~AlignmentMinusOne;
uint32 PaddedCompressedSize = (CompressedSize + CompressionHeaderSize + AlignmentMinusOne) & ~AlignmentMinusOne;
Success = (PaddedCompressedSize < PaddedUncompressedSize);
}
@@ -307,7 +307,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
// Write resource table for real
Pak.Seek(ResTableOffset+4, SEEK_SET);
for (u32 iRes = 0; iRes < AssetList.size(); iRes++)
for (uint32 iRes = 0; iRes < AssetList.size(); iRes++)
{
const SResourceTableInfo& rkInfo = ResourceTableData[iRes];
CResourceEntry *pEntry = rkInfo.pEntry;
@@ -321,7 +321,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
// Clear recook flag
mNeedsRecook = false;
Log::Write("Finished writing " + PakPath);
debugf("Finished writing %s", *PakPath);
}
Save();
@@ -346,31 +346,31 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
if (!Pak.IsValid() || Pak.Size() == 0)
{
Log::Error("Failed to compare to original asset list; couldn't open the original pak");
errorf("Failed to compare to original asset list; couldn't open the original pak");
return;
}
// Determine pak version
u32 PakVersion = Pak.ReadLong();
uint32 PakVersion = Pak.ReadLong();
std::set<CAssetID> OldListSet;
// Read MP1/2 pak
if (PakVersion == 0x00030005)
{
Pak.Seek(0x4, SEEK_CUR);
u32 NumNamedResources = Pak.ReadLong();
uint32 NumNamedResources = Pak.ReadLong();
for (u32 iName = 0; iName < NumNamedResources; iName++)
for (uint32 iName = 0; iName < NumNamedResources; iName++)
{
Pak.Seek(0x8, SEEK_CUR);
u32 NameLen = Pak.ReadLong();
uint32 NameLen = Pak.ReadLong();
Pak.Seek(NameLen, SEEK_CUR);
}
// Build a set out of the original pak resource list
u32 NumResources = Pak.ReadLong();
uint32 NumResources = Pak.ReadLong();
for (u32 iRes = 0; iRes < NumResources; iRes++)
for (uint32 iRes = 0; iRes < NumResources; iRes++)
{
Pak.Seek(0x8, SEEK_CUR);
OldListSet.insert( CAssetID(Pak, e32Bit) );
@@ -386,15 +386,15 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
// Skip named resources
Pak.Seek(0x44, SEEK_SET);
CFourCC StringSecType = Pak.ReadLong();
u32 StringSecSize = Pak.ReadLong();
uint32 StringSecSize = Pak.ReadLong();
ASSERT(StringSecType == "STRG");
Pak.Seek(0x80 + StringSecSize, SEEK_SET);
// Read resource table
u32 NumResources = Pak.ReadLong();
uint32 NumResources = Pak.ReadLong();
for (u32 iRes = 0; iRes < NumResources; iRes++)
for (uint32 iRes = 0; iRes < NumResources; iRes++)
{
Pak.Seek(0x8, SEEK_CUR);
OldListSet.insert( CAssetID(Pak, e64Bit) );
@@ -411,7 +411,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
{
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
TString Extension = (pEntry ? "." + pEntry->CookedExtension() : "");
Log::Error("Missing resource: " + ID.ToString() + Extension);
warnf("Missing resource: %s%s", *ID.ToString(), *Extension);
}
}
@@ -424,7 +424,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
{
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
TString Extension = (pEntry ? "." + pEntry->CookedExtension() : "");
Log::Error("Extra resource: " + ID.ToString() + Extension);
warnf("Extra resource: %s%s", *ID.ToString(), *Extension);
}
}
}

View File

@@ -71,8 +71,8 @@ public:
inline TString Name() const { return mPakName; }
inline TString Path() const { return mPakPath; }
inline CGameProject* Project() const { return mpProject; }
inline u32 NumNamedResources() const { return mResources.size(); }
inline const SNamedResource& NamedResourceByIndex(u32 Idx) const { return mResources[Idx]; }
inline uint32 NumNamedResources() const { return mResources.size(); }
inline const SNamedResource& NamedResourceByIndex(uint32 Idx) const { return mResources[Idx]; }
inline bool NeedsRecook() const { return mNeedsRecook; }
inline void SetPakName(TString NewName) { mPakName = NewName; }

View File

@@ -96,7 +96,7 @@ bool CResourceEntry::LoadMetadata()
}
else
{
Log::Error(Path + ": Failed to load metadata file!");
errorf("%s: Failed to load metadata file!", *Path);
}
return false;
@@ -174,7 +174,7 @@ void CResourceEntry::UpdateDependencies()
if (!mpResource)
{
Log::Error("Unable to update cached dependencies; failed to load resource");
errorf("Unable to update cached dependencies; failed to load resource");
mpDependencies = new CDependencyTree();
return;
}
@@ -237,7 +237,7 @@ bool CResourceEntry::IsInDirectory(CVirtualDirectory *pDir) const
return false;
}
u64 CResourceEntry::Size() const
uint64 CResourceEntry::Size() const
{
if (mCachedSize == -1)
{
@@ -294,8 +294,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
if (!Writer.Save())
{
Log::Error("Failed to save raw resource: " + Path);
DEBUG_BREAK;
errorf("Failed to save raw resource: %s", *Path);
return false;
}
@@ -309,7 +308,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
if (!CookSuccess)
{
Log::Error("Failed to save resource: " + Name() + "." + CookedExtension().ToString());
errorf("Failed to save resource: %s.%s", *Name(), *CookedExtension().ToString());
return false;
}
}
@@ -324,7 +323,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
mpStore->ConditionalSaveStore();
// Flag dirty any packages that contain this resource.
for (u32 iPkg = 0; iPkg < mpStore->Project()->NumPackages(); iPkg++)
for (uint32 iPkg = 0; iPkg < mpStore->Project()->NumPackages(); iPkg++)
{
CPackage *pPkg = mpStore->Project()->PackageByIndex(iPkg);
@@ -352,7 +351,7 @@ bool CResourceEntry::Cook()
CFileOutStream File(Path, IOUtil::eBigEndian);
if (!File.IsValid())
{
Log::Error("Failed to open cooked file for writing: " + Path);
errorf("Failed to open cooked file for writing: %s", *Path);
return false;
}
@@ -390,7 +389,7 @@ CResource* CResourceEntry::Load()
if (!Reader.IsValid())
{
Log::Error("Failed to load raw resource; falling back on cooked. Raw path: " + RawAssetPath());
errorf("Failed to load raw resource; falling back on cooked. Raw path: %s", *RawAssetPath());
delete mpResource;
mpResource = nullptr;
}
@@ -414,7 +413,7 @@ CResource* CResourceEntry::Load()
if (!File.IsValid())
{
Log::Error("Failed to open cooked resource: " + CookedAssetPath(true));
errorf("Failed to open cooked resource: %s", *CookedAssetPath(true));
return nullptr;
}
@@ -423,7 +422,7 @@ CResource* CResourceEntry::Load()
else
{
Log::Error("Couldn't locate resource: " + CookedAssetPath(true));
errorf("Couldn't locate resource: %s", *CookedAssetPath(true));
return nullptr;
}
}
@@ -500,7 +499,10 @@ bool CResourceEntry::MoveAndRename(const TString& rkDir, const TString& rkName,
TString NewRawPath = RawAssetPath();
TString NewMetaPath = MetadataFilePath();
Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->ResourcesDir()) + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->ResourcesDir()));
debugf("MOVING RESOURCE: %s --> %s",
*FileUtil::MakeRelative(OldCookedPath, mpStore->ResourcesDir()),
*FileUtil::MakeRelative(NewCookedPath, mpStore->ResourcesDir())
);
// If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false
ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath && OldMetaPath != NewMetaPath);
@@ -586,7 +588,7 @@ bool CResourceEntry::MoveAndRename(const TString& rkDir, const TString& rkName,
// Otherwise, revert changes and let the caller know the move failed
else
{
Log::Error("MOVE FAILED: " + MoveFailReason);
errorf("MOVE FAILED: %s", *MoveFailReason);
mpDirectory = pOldDir;
mName = OldName;
mpStore->ConditionalDeleteDirectory(pNewDir, false);

View File

@@ -8,7 +8,6 @@
#include <Common/CAssetID.h>
#include <Common/CFourCC.h>
#include <Common/Flags.h>
#include <Common/types.h>
class CResource;
class CGameProject;
@@ -37,7 +36,7 @@ class CResourceEntry
FResEntryFlags mFlags;
mutable bool mMetadataDirty;
mutable u64 mCachedSize;
mutable uint64 mCachedSize;
mutable TString mCachedUppercaseName; // This is used to speed up case-insensitive sorting and filtering.
// Private constructor
@@ -66,7 +65,7 @@ public:
CFourCC CookedExtension() const;
TString MetadataFilePath(bool Relative = false) const;
bool IsInDirectory(CVirtualDirectory *pDir) const;
u64 Size() const;
uint64 Size() const;
bool NeedsRecook() const;
bool Save(bool SkipCacheSave = false);
bool Cook();

View File

@@ -4,7 +4,7 @@
#include "CResourceIterator.h"
#include "Core/IUIRelay.h"
#include "Core/Resource/CResource.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <Common/FileUtil.h>
#include <Common/Log.h>
#include <Common/Serialization/Binary.h>
@@ -54,7 +54,7 @@ void RecursiveGetListOfEmptyDirectories(CVirtualDirectory *pDir, TStringList& rO
}
else
{
for (u32 SubIdx = 0; SubIdx < pDir->NumSubdirectories(); SubIdx++)
for (uint32 SubIdx = 0; SubIdx < pDir->NumSubdirectories(); SubIdx++)
RecursiveGetListOfEmptyDirectories(pDir->SubdirectoryByIndex(SubIdx), rOutList);
}
}
@@ -65,12 +65,12 @@ bool CResourceStore::SerializeDatabaseCache(IArchive& rArc)
if (rArc.ParamBegin("Resources", 0))
{
// Serialize resources
u32 ResourceCount = mResourceEntries.size();
uint32 ResourceCount = mResourceEntries.size();
rArc << SerialParameter("ResourceCount", ResourceCount);
if (rArc.IsReader())
{
for (u32 ResIdx = 0; ResIdx < ResourceCount; ResIdx++)
for (uint32 ResIdx = 0; ResIdx < ResourceCount; ResIdx++)
{
if (rArc.ParamBegin("Resource", 0))
{
@@ -195,12 +195,12 @@ void CResourceStore::CloseProject()
// If there are, that means something didn't clean up resource references properly on project close!!!
if (!mLoadedResources.empty())
{
Log::Error(TString::FromInt32(mLoadedResources.size(), 0, 10) + " resources still loaded on project close:");
warnf("%d resources still loaded on project close:", mLoadedResources.size());
for (auto Iter = mLoadedResources.begin(); Iter != mLoadedResources.end(); Iter++)
{
CResourceEntry *pEntry = Iter->second;
Log::Write("\t" + pEntry->Name() + "." + pEntry->CookedExtension().ToString());
warnf("\t%s.%s", *pEntry->Name(), *pEntry->CookedExtension().ToString());
}
ASSERT(false);
@@ -325,7 +325,7 @@ bool CResourceStore::BuildFromDirectory(bool ShouldGenerateCacheFile)
if (!pTypeInfo)
{
Log::Error("Found resource but couldn't register because failed to identify resource type: " + RelPath);
errorf("Found resource but couldn't register because failed to identify resource type: %s", *RelPath);
continue;
}
@@ -389,7 +389,7 @@ CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType
CResourceEntry *pEntry = FindEntry(rkID);
if (pEntry)
Log::Error("Attempted to register resource that's already tracked in the database: " + rkID.ToString() + " / " + rkDir + " / " + rkName);
errorf("Attempted to register resource that's already tracked in the database: %s / %s / %s", *rkID.ToString(), *rkDir, *rkName);
else
{
@@ -401,7 +401,7 @@ CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType
}
else
Log::Error("Invalid resource path, failed to register: " + rkDir + rkName);
errorf("Invalid resource path, failed to register: %s%s", *rkDir, *rkName);
}
return pEntry;
@@ -419,7 +419,7 @@ CResource* CResourceStore::LoadResource(const CAssetID& rkID)
else
{
// Resource doesn't seem to exist
Log::Error("Can't find requested resource with ID \"" + rkID.ToString() + "\".");;
warnf("Can't find requested resource with ID \"%s\"", *rkID.ToString());
return nullptr;
}
}
@@ -440,7 +440,7 @@ CResource* CResourceStore::LoadResource(const CAssetID& rkID, EResType Type)
CResTypeInfo *pGotType = pRes->TypeInfo();
ASSERT(pExpectedType && pGotType);
Log::Error("Resource with ID \"" + rkID.ToString() + "\" requested with the wrong type; expected " + pExpectedType->TypeName() + " asset, got " + pGotType->TypeName() + " asset");
errorf("Resource with ID \"%s\" requested with the wrong type; expected %s asset, get %s asset", *rkID.ToString(), *pExpectedType->TypeName(), *pGotType->TypeName());
return nullptr;
}
}
@@ -487,7 +487,7 @@ void CResourceStore::TrackLoadedResource(CResourceEntry *pEntry)
void CResourceStore::DestroyUnreferencedResources()
{
// This can be updated to avoid the do-while loop when reference lookup is implemented.
u32 NumDeleted;
uint32 NumDeleted;
do
{
@@ -546,7 +546,7 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo
if (!pContentsFile)
{
Log::Error("Failed to open .contents.txt file: " + rkTxtPath);
errorf("Failed to open .contents.txt file: %s", *rkTxtPath);
return;
}
@@ -559,12 +559,12 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo
TString Line(LineBuffer);
if (Line.IsEmpty()) break;
u32 IDStart = Line.IndexOfPhrase("0x") + 2;
uint32 IDStart = Line.IndexOfPhrase("0x") + 2;
if (IDStart == 1) continue;
u32 IDEnd = Line.IndexOf(" \t", IDStart);
u32 PathStart = IDEnd + 1;
u32 PathEnd = Line.Size() - 5;
uint32 IDEnd = Line.IndexOf(" \t", IDStart);
uint32 PathStart = IDEnd + 1;
uint32 PathEnd = Line.Size() - 5;
TString IDStr = Line.SubString(IDStart, IDEnd - IDStart);
TString Path = Line.SubString(PathStart, PathEnd - PathStart);
@@ -576,7 +576,7 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo
if (pEntry)
{
// Chop name to just after "x_rep"
u32 RepStart = Path.IndexOfPhrase("_rep");
uint32 RepStart = Path.IndexOfPhrase("_rep");
if (RepStart != -1)
Path = Path.ChopFront(RepStart + 5);

View File

@@ -7,7 +7,6 @@
#include <Common/CFourCC.h>
#include <Common/FileUtil.h>
#include <Common/TString.h>
#include <Common/types.h>
#include <map>
#include <set>
@@ -82,8 +81,8 @@ public:
inline TString ResourcesDir() const { return IsEditorStore() ? DatabaseRootPath() : DatabaseRootPath() + "Resources/"; }
inline TString DatabasePath() const { return DatabaseRootPath() + "ResourceDatabaseCache.bin"; }
inline CVirtualDirectory* RootDirectory() const { return mpDatabaseRoot; }
inline u32 NumTotalResources() const { return mResourceEntries.size(); }
inline u32 NumLoadedResources() const { return mLoadedResources.size(); }
inline uint32 NumTotalResources() const { return mResourceEntries.size(); }
inline uint32 NumLoadedResources() const { return mLoadedResources.size(); }
inline bool IsCacheDirty() const { return mDatabaseCacheDirty; }
inline void SetCacheDirty() { mDatabaseCacheDirty = true; }

View File

@@ -22,7 +22,7 @@ CVirtualDirectory::CVirtualDirectory(CVirtualDirectory *pParent, const TString&
CVirtualDirectory::~CVirtualDirectory()
{
for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
delete mSubdirectories[iSub];
}
@@ -31,7 +31,7 @@ bool CVirtualDirectory::IsEmpty(bool CheckFilesystem) const
if (!mResources.empty())
return false;
for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
if (!mSubdirectories[iSub]->IsEmpty(CheckFilesystem))
return false;
@@ -66,10 +66,10 @@ CVirtualDirectory* CVirtualDirectory::GetRoot()
CVirtualDirectory* CVirtualDirectory::FindChildDirectory(const TString& rkName, bool AllowCreate)
{
u32 SlashIdx = rkName.IndexOf("\\/");
uint32 SlashIdx = rkName.IndexOf("\\/");
TString DirName = (SlashIdx == -1 ? rkName : rkName.SubString(0, SlashIdx));
for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
{
CVirtualDirectory *pChild = mSubdirectories[iSub];
@@ -126,7 +126,7 @@ CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkPath)
CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkName, EResType Type)
{
for (u32 iRes = 0; iRes < mResources.size(); iRes++)
for (uint32 iRes = 0; iRes < mResources.size(); iRes++)
{
if (rkName.CaseInsensitiveCompare(mResources[iRes]->Name()) && mResources[iRes]->ResourceType() == Type)
return mResources[iRes];
@@ -150,14 +150,14 @@ bool CVirtualDirectory::AddChild(const TString &rkPath, CResourceEntry *pEntry)
else if (IsValidDirectoryPath(rkPath))
{
u32 SlashIdx = rkPath.IndexOf("\\/");
uint32 SlashIdx = rkPath.IndexOf("\\/");
TString DirName = (SlashIdx == -1 ? rkPath : rkPath.SubString(0, SlashIdx));
TString Remaining = (SlashIdx == -1 ? "" : rkPath.SubString(SlashIdx + 1, rkPath.Size() - SlashIdx));
// Check if this subdirectory already exists
CVirtualDirectory *pSubdir = nullptr;
for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
{
if (mSubdirectories[iSub]->Name() == DirName)
{
@@ -264,7 +264,7 @@ void CVirtualDirectory::SortSubdirectories()
bool CVirtualDirectory::Rename(const TString& rkNewName)
{
Log::Write("MOVING DIRECTORY: " + FullPath() + " -> " + mpParent->FullPath() + rkNewName + '/');
debugf("MOVING DIRECTORY: %s --> %s", *FullPath(), *mpParent->FullPath() + rkNewName + '/');
if (!IsRoot())
{
@@ -283,7 +283,7 @@ bool CVirtualDirectory::Rename(const TString& rkNewName)
}
}
Log::Error("DIRECTORY MOVE FAILED");
errorf("DIRECTORY MOVE FAILED");
return false;
}
@@ -309,7 +309,7 @@ bool CVirtualDirectory::Delete()
void CVirtualDirectory::DeleteEmptySubdirectories()
{
for (u32 SubdirIdx = 0; SubdirIdx < mSubdirectories.size(); SubdirIdx++)
for (uint32 SubdirIdx = 0; SubdirIdx < mSubdirectories.size(); SubdirIdx++)
{
CVirtualDirectory *pDir = mSubdirectories[SubdirIdx];
@@ -332,7 +332,7 @@ bool CVirtualDirectory::CreateFilesystemDirectory()
bool CreateSuccess = FileUtil::MakeDirectory(AbsPath);
if (!CreateSuccess)
Log::Error("FAILED to create filesystem directory: " + AbsPath);
errorf("FAILED to create filesystem directory: %s", *AbsPath);
return CreateSuccess;
}
@@ -345,14 +345,14 @@ bool CVirtualDirectory::SetParent(CVirtualDirectory *pParent)
ASSERT(!pParent->IsDescendantOf(this));
if (mpParent == pParent) return true;
Log::Write("MOVING DIRECTORY: " + FullPath() + " -> " + pParent->FullPath() + mName + '/');
debugf("MOVING DIRECTORY: %s -> %s", *FullPath(), *(pParent->FullPath() + mName + '/'));
// Check for a conflict
CVirtualDirectory *pConflictDir = pParent->FindChildDirectory(mName, false);
if (pConflictDir)
{
Log::Error("DIRECTORY MOVE FAILED: Conflicting directory exists at the destination path!");
errorf("DIRECTORY MOVE FAILED: Conflicting directory exists at the destination path!");
return false;
}
@@ -369,7 +369,7 @@ bool CVirtualDirectory::SetParent(CVirtualDirectory *pParent)
}
else
{
Log::Error("DIRECTORY MOVE FAILED: Filesystem move operation failed!");
errorf("DIRECTORY MOVE FAILED: Filesystem move operation failed!");
mpParent->AddChild(this);
return false;
}

View File

@@ -3,7 +3,7 @@
/* Virtual directory system used to look up resources by their location in the filesystem. */
#include "Core/Resource/EResType.h"
#include <Common/AssertMacro.h>
#include <Common/Macros.h>
#include <Common/TString.h>
#include <vector>
@@ -51,10 +51,10 @@ public:
inline bool IsRoot() const { return !mpParent; }
inline TString Name() const { return mName; }
inline u32 NumSubdirectories() const { return mSubdirectories.size(); }
inline CVirtualDirectory* SubdirectoryByIndex(u32 Index) { return mSubdirectories[Index]; }
inline u32 NumResources() const { return mResources.size(); }
inline CResourceEntry* ResourceByIndex(u32 Index) { return mResources[Index]; }
inline uint32 NumSubdirectories() const { return mSubdirectories.size(); }
inline CVirtualDirectory* SubdirectoryByIndex(uint32 Index) { return mSubdirectories[Index]; }
inline uint32 NumResources() const { return mResources.size(); }
inline CResourceEntry* ResourceByIndex(uint32 Index) { return mResources[Index]; }
};
#endif // CVIRTUALDIRECTORY

View File

@@ -1,7 +1,7 @@
#include "DependencyListBuilders.h"
// ************ CCharacterUsageMap ************
bool CCharacterUsageMap::IsCharacterUsed(const CAssetID& rkID, u32 CharacterIndex) const
bool CCharacterUsageMap::IsCharacterUsed(const CAssetID& rkID, uint32 CharacterIndex) const
{
if (mpStore->Game() >= EGame::CorruptionProto) return true;
auto Find = mUsageMap.find(rkID);
@@ -18,7 +18,7 @@ bool CCharacterUsageMap::IsAnimationUsed(const CAssetID& rkID, CSetAnimationDepe
if (Find == mUsageMap.end()) return false;
const std::vector<bool>& rkUsageList = Find->second;
for (u32 iChar = 0; iChar < rkUsageList.size(); iChar++)
for (uint32 iChar = 0; iChar < rkUsageList.size(); iChar++)
{
if (rkUsageList[iChar] && pAnim->IsUsedByCharacter(iChar))
return true;
@@ -37,7 +37,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntr
{
ASSERT(pEntry->ResourceType() == eArea);
for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
{
if (pWorld->AreaResourceID(iArea) == pEntry->ID())
{
@@ -47,12 +47,12 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntr
}
}
void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, u32 AreaIndex)
void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, uint32 AreaIndex)
{
// We only need to search forward from this area to other areas that both use the same character(s) + have duplicates enabled
Clear();
for (u32 iArea = AreaIndex; iArea < pWorld->NumAreas(); iArea++)
for (uint32 iArea = AreaIndex; iArea < pWorld->NumAreas(); iArea++)
{
if (!mIsInitialArea && mStillLookingIDs.empty()) break;
mCurrentAreaAllowsDupes = pWorld->DoesAreaAllowPakDuplicates(iArea);
@@ -66,7 +66,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, u32 AreaIndex)
}
}
void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 LayerIndex)
void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 LayerIndex)
{
Clear();
mLayerIndex = LayerIndex;
@@ -76,10 +76,10 @@ void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 Laye
// Only examine dependencies of the particular layer specified by the caller
bool IsLastLayer = (mLayerIndex == pTree->NumScriptLayers() - 1);
u32 StartIdx = pTree->ScriptLayerOffset(mLayerIndex);
u32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(mLayerIndex + 1));
uint32 StartIdx = pTree->ScriptLayerOffset(mLayerIndex);
uint32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(mLayerIndex + 1));
for (u32 iInst = StartIdx; iInst < EndIdx; iInst++)
for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++)
ParseDependencyNode(pTree->ChildByIndex(iInst));
}
@@ -101,11 +101,11 @@ void CCharacterUsageMap::DebugPrintContents()
std::vector<bool>& rUsedList = Iter->second;
CAnimSet *pSet = mpStore->LoadResource<CAnimSet>(ID);
for (u32 iChar = 0; iChar < pSet->NumCharacters(); iChar++)
for (uint32 iChar = 0; iChar < pSet->NumCharacters(); iChar++)
{
bool Used = (rUsedList.size() > iChar && rUsedList[iChar]);
TString CharName = pSet->Character(iChar)->Name;
Log::Write(ID.ToString() + " : Char " + TString::FromInt32(iChar, 0, 10) + " : " + CharName + " : " + (Used ? "USED" : "UNUSED"));
debugf("%s : Char %d : %s : %s", *ID.ToString(), iChar, *CharName, (Used ? "USED" : "UNUSED"));
}
}
}
@@ -141,7 +141,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
}
std::vector<bool>& rUsageList = mUsageMap[ResID];
u32 UsedChar = pDep->UsedChar();
uint32 UsedChar = pDep->UsedChar();
if (rUsageList.size() <= UsedChar)
rUsageList.resize(UsedChar + 1, false);
@@ -164,7 +164,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
// Look for sub-dependencies of the current node
else
{
for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
ParseDependencyNode(pNode->ChildByIndex(iChild));
}
}
@@ -176,7 +176,7 @@ void CPackageDependencyListBuilder::BuildDependencyList(bool AllowDuplicates, st
FindUniversalAreaAssets();
// Iterate over all resources and parse their dependencies
for (u32 iRes = 0; iRes < mpkPackage->NumNamedResources(); iRes++)
for (uint32 iRes = 0; iRes < mpkPackage->NumNamedResources(); iRes++)
{
const SNamedResource& rkRes = mpkPackage->NamedResourceByIndex(iRes);
CResourceEntry *pEntry = mpStore->FindEntry(rkRes.ID);
@@ -240,7 +240,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
if (mEnableDuplicates)
{
for (u32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++)
for (uint32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++)
{
if (mpWorld->AreaResourceID(iArea) == rkID)
{
@@ -285,7 +285,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
else if (Type == eDNT_AnimEvent)
{
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
u32 CharIndex = pDep->CharIndex();
uint32 CharIndex = pDep->CharIndex();
if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
AddDependency(pCurEntry, pDep->ID(), rOut);
@@ -313,11 +313,11 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
{
if (Type == eDNT_ScriptInstance)
{
u32 ObjType = static_cast<CScriptInstanceDependency*>(pNode)->ObjectType();
uint32 ObjType = static_cast<CScriptInstanceDependency*>(pNode)->ObjectType();
mIsPlayerActor = (ObjType == 0x4C || ObjType == FOURCC('PLAC'));
}
for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut);
if (Type == eDNT_ScriptInstance)
@@ -333,7 +333,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets()
if (pPackage)
{
// Iterate over all the package contents, keep track of all universal area assets
for (u32 ResIdx = 0; ResIdx < pPackage->NumNamedResources(); ResIdx++)
for (uint32 ResIdx = 0; ResIdx < pPackage->NumNamedResources(); ResIdx++)
{
const SNamedResource& rkRes = pPackage->NamedResourceByIndex(ResIdx);
@@ -349,7 +349,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets()
if (pUniverseWorld)
{
// Area IDs
for (u32 AreaIdx = 0; AreaIdx < pUniverseWorld->NumAreas(); AreaIdx++)
for (uint32 AreaIdx = 0; AreaIdx < pUniverseWorld->NumAreas(); AreaIdx++)
{
CAssetID AreaID = pUniverseWorld->AreaResourceID(AreaIdx);
@@ -362,7 +362,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets()
if (pMapWorld)
{
for (u32 DepIdx = 0; DepIdx < pMapWorld->NumDependencies(); DepIdx++)
for (uint32 DepIdx = 0; DepIdx < pMapWorld->NumDependencies(); DepIdx++)
{
CAssetID DepID = pMapWorld->DependencyByIndex(DepIdx);
@@ -378,14 +378,14 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets()
}
// ************ CAreaDependencyListBuilder ************
void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<u32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut)
void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<uint32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut)
{
CAreaDependencyTree *pTree = static_cast<CAreaDependencyTree*>(mpAreaEntry->Dependencies());
// Fill area base used assets set (don't actually add to list yet)
u32 BaseEndIndex = (pTree->NumScriptLayers() > 0 ? pTree->ScriptLayerOffset(0) : pTree->NumChildren());
uint32 BaseEndIndex = (pTree->NumScriptLayers() > 0 ? pTree->ScriptLayerOffset(0) : pTree->NumChildren());
for (u32 iDep = 0; iDep < BaseEndIndex; iDep++)
for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++)
{
CResourceDependency *pRes = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
ASSERT(pRes->Type() == eDNT_ResourceDependency);
@@ -393,17 +393,17 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
}
// Get dependencies of each layer
for (u32 iLyr = 0; iLyr < pTree->NumScriptLayers(); iLyr++)
for (uint32 iLyr = 0; iLyr < pTree->NumScriptLayers(); iLyr++)
{
mLayerUsedAssets.clear();
mCharacterUsageMap.FindUsagesForLayer(mpAreaEntry, iLyr);
rLayerOffsetsOut.push_back(rAssetsOut.size());
bool IsLastLayer = (iLyr == pTree->NumScriptLayers() - 1);
u32 StartIdx = pTree->ScriptLayerOffset(iLyr);
u32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(iLyr + 1));
uint32 StartIdx = pTree->ScriptLayerOffset(iLyr);
uint32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(iLyr + 1));
for (u32 iChild = StartIdx; iChild < EndIdx; iChild++)
for (uint32 iChild = StartIdx; iChild < EndIdx; iChild++)
{
IDependencyNode *pNode = pTree->ChildByIndex(iChild);
@@ -412,7 +412,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
mIsPlayerActor = (pInst->ObjectType() == 0x4C || pInst->ObjectType() == FOURCC('PLAC'));
for (u32 iDep = 0; iDep < pInst->NumChildren(); iDep++)
for (uint32 iDep = 0; iDep < pInst->NumChildren(); iDep++)
{
CPropertyDependency *pDep = static_cast<CPropertyDependency*>(pInst->ChildByIndex(iDep));
@@ -452,7 +452,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
mLayerUsedAssets.clear();
rLayerOffsetsOut.push_back(rAssetsOut.size());
for (u32 iDep = 0; iDep < BaseEndIndex; iDep++)
for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++)
{
CResourceDependency *pDep = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
AddDependency(pDep->ID(), rAssetsOut, pAudioGroupsOut);
@@ -525,7 +525,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
else if (Type == eDNT_AnimEvent)
{
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
u32 CharIndex = pDep->CharIndex();
uint32 CharIndex = pDep->CharIndex();
if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
@@ -534,10 +534,10 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
else if (Type == eDNT_SetCharacter)
{
// Note: For MP1/2 PlayerActor, always treat as if Empty Suit is the only used one
const u32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5);
const uint32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5);
CSetCharacterDependency *pChar = static_cast<CSetCharacterDependency*>(pNode);
u32 SetIndex = pChar->CharSetIndex();
uint32 SetIndex = pChar->CharSetIndex();
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
}
@@ -552,7 +552,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
if (ParseChildren)
{
for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut, pAudioGroupsOut);
}
}

View File

@@ -13,7 +13,7 @@ class CCharacterUsageMap
std::map<CAssetID, std::vector<bool>> mUsageMap;
std::set<CAssetID> mStillLookingIDs;
CResourceStore *mpStore;
u32 mLayerIndex;
uint32 mLayerIndex;
bool mIsInitialArea;
bool mCurrentAreaAllowsDupes;
@@ -22,12 +22,12 @@ public:
: mpStore(pStore), mLayerIndex(-1), mIsInitialArea(true), mCurrentAreaAllowsDupes(false)
{}
bool IsCharacterUsed(const CAssetID& rkID, u32 CharacterIndex) const;
bool IsCharacterUsed(const CAssetID& rkID, uint32 CharacterIndex) const;
bool IsAnimationUsed(const CAssetID& rkID, CSetAnimationDependency *pAnim) const;
void FindUsagesForAsset(CResourceEntry *pEntry);
void FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntry);
void FindUsagesForArea(CWorld *pWorld, u32 AreaIndex);
void FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 LayerIndex);
void FindUsagesForArea(CWorld *pWorld, uint32 AreaIndex);
void FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 LayerIndex);
void Clear();
void DebugPrintContents();
@@ -91,7 +91,7 @@ public:
ASSERT(mpAreaEntry->ResourceType() == eArea);
}
void BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<u32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut = nullptr);
void BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<uint32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut = nullptr);
void AddDependency(const CAssetID& rkID, std::list<CAssetID>& rOut, std::set<CAssetID> *pAudioGroupsOut);
void EvaluateDependencyNode(CResourceEntry *pCurEntry, IDependencyNode *pNode, std::list<CAssetID>& rOut, std::set<CAssetID> *pAudioGroupsOut);
};