mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-18 20:43:33 +00:00
Integrated latest changes from nod, and updated the structure of the Disc folder for compatibility with the upcoming Dolphin directory blob updates
This commit is contained in:
parent
2ddba0cacc
commit
665a098d50
@ -63,11 +63,7 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
|
|||||||
mGame,
|
mGame,
|
||||||
mRegion,
|
mRegion,
|
||||||
mGameID,
|
mGameID,
|
||||||
mBuildVersion,
|
mBuildVersion);
|
||||||
mDolPath,
|
|
||||||
mApploaderPath,
|
|
||||||
mPartitionHeaderPath,
|
|
||||||
mFilesystemAddress);
|
|
||||||
|
|
||||||
mpProject->SetProjectName(mGameName);
|
mpProject->SetProjectName(mGameName);
|
||||||
mpStore = mpProject->ResourceStore();
|
mpStore = mpProject->ResourceStore();
|
||||||
@ -111,54 +107,42 @@ bool CGameExporter::ExtractDiscData()
|
|||||||
|
|
||||||
// Create Disc output folder
|
// Create Disc output folder
|
||||||
TString AbsDiscDir = mExportDir + mDiscDir;
|
TString AbsDiscDir = mExportDir + mDiscDir;
|
||||||
|
bool IsWii = (mBuildVersion >= 3.f);
|
||||||
|
if (IsWii) AbsDiscDir += "DATA/";
|
||||||
FileUtil::MakeDirectory(AbsDiscDir);
|
FileUtil::MakeDirectory(AbsDiscDir);
|
||||||
|
|
||||||
// Extract disc filesystem
|
// Extract disc filesystem
|
||||||
nod::Partition *pDataPartition = mpDisc->getDataPartition();
|
nod::Partition *pDataPartition = mpDisc->getDataPartition();
|
||||||
nod::ExtractionContext Context;
|
nod::ExtractionContext Context;
|
||||||
Context.force = false;
|
Context.force = false;
|
||||||
Context.verbose = true;
|
|
||||||
Context.progressCB = [&](const std::string& rkDesc, float ProgressPercent) {
|
Context.progressCB = [&](const std::string& rkDesc, float ProgressPercent) {
|
||||||
mpProgress->Report((int) (ProgressPercent * 10000), 10000, rkDesc);
|
mpProgress->Report((int) (ProgressPercent * 10000), 10000, rkDesc);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Success = ExtractDiscNodeRecursive(&pDataPartition->getFSTRoot(), AbsDiscDir, Context);
|
TString FilesDir = AbsDiscDir + "files/";
|
||||||
|
FileUtil::MakeDirectory(FilesDir);
|
||||||
|
|
||||||
|
bool Success = ExtractDiscNodeRecursive(&pDataPartition->getFSTRoot(), FilesDir, Context);
|
||||||
if (!Success) return false;
|
if (!Success) return false;
|
||||||
|
|
||||||
// Extract the remaining disc data
|
|
||||||
if (!mpProgress->ShouldCancel())
|
if (!mpProgress->ShouldCancel())
|
||||||
{
|
{
|
||||||
// Extract dol
|
Context.progressCB = nullptr;
|
||||||
mDolPath = "boot.dol";
|
|
||||||
CFileOutStream DolFile(mExportDir + mDolPath);
|
|
||||||
if (!DolFile.IsValid()) return false;
|
|
||||||
|
|
||||||
std::unique_ptr<uint8_t[]> pDolBuffer = pDataPartition->getDOLBuf();
|
|
||||||
DolFile.WriteBytes(pDolBuffer.get(), (u32) pDataPartition->getDOLSize());
|
|
||||||
DolFile.Close();
|
|
||||||
|
|
||||||
// Extract apploader
|
|
||||||
mApploaderPath = "apploader.img";
|
|
||||||
CFileOutStream ApploaderFile(mExportDir + mApploaderPath);
|
|
||||||
if (!ApploaderFile.IsValid()) return false;
|
|
||||||
|
|
||||||
std::unique_ptr<uint8_t[]> pApploaderBuffer = pDataPartition->getApploaderBuf();
|
|
||||||
ApploaderFile.WriteBytes(pApploaderBuffer.get(), (u32) pDataPartition->getApploaderSize());
|
|
||||||
ApploaderFile.Close();
|
|
||||||
|
|
||||||
// Extract Wii partition header
|
|
||||||
bool IsWii = (mBuildVersion >= 3.f);
|
|
||||||
|
|
||||||
if (IsWii)
|
if (IsWii)
|
||||||
{
|
{
|
||||||
mFilesystemAddress = 0;
|
// Extract crypto files
|
||||||
mPartitionHeaderPath = "partition_header.bin";
|
if (!pDataPartition->extractCryptoFiles(*AbsDiscDir.ToUTF16(), Context))
|
||||||
nod::DiscWii *pDiscWii = static_cast<nod::DiscWii*>(mpDisc);
|
return false;
|
||||||
Success = pDiscWii->writeOutDataPartitionHeader(*TString(mExportDir + mPartitionHeaderPath).ToUTF16());
|
|
||||||
if (!Success) return false;
|
// Extract disc header files
|
||||||
|
if (!mpDisc->extractDiscHeaderFiles(*AbsDiscDir.ToUTF16(), Context))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
mFilesystemAddress = (u32) pDataPartition->getFSTMemoryAddr();
|
// Extract system files
|
||||||
|
if (!pDataPartition->extractSysFiles(*AbsDiscDir.ToUTF16(), Context))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -215,7 +199,8 @@ void CGameExporter::LoadPaks()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPackage *pPackage = new CPackage(mpProject, PakPath.GetFileName(false), FileUtil::MakeRelative(PakPath.GetFileDirectory(), mExportDir + mDiscDir));
|
TString RelPakPath = FileUtil::MakeRelative(PakPath.GetFileDirectory(), mpProject->DiscFilesystemRoot(false));
|
||||||
|
CPackage *pPackage = new CPackage(mpProject, PakPath.GetFileName(false), RelPakPath);
|
||||||
|
|
||||||
// MP1-MP3Proto
|
// MP1-MP3Proto
|
||||||
if (mGame < eCorruption)
|
if (mGame < eCorruption)
|
||||||
|
@ -23,10 +23,6 @@ class CGameExporter
|
|||||||
TString mGameName;
|
TString mGameName;
|
||||||
TString mGameID;
|
TString mGameID;
|
||||||
float mBuildVersion;
|
float mBuildVersion;
|
||||||
TString mDolPath;
|
|
||||||
TString mApploaderPath;
|
|
||||||
TString mPartitionHeaderPath;
|
|
||||||
u32 mFilesystemAddress;
|
|
||||||
|
|
||||||
// Directories
|
// Directories
|
||||||
TString mExportDir;
|
TString mExportDir;
|
||||||
|
@ -39,17 +39,7 @@ bool CGameProject::Serialize(IArchive& rArc)
|
|||||||
rArc << SERIAL("Name", mProjectName)
|
rArc << SERIAL("Name", mProjectName)
|
||||||
<< SERIAL("Region", mRegion)
|
<< SERIAL("Region", mRegion)
|
||||||
<< SERIAL("GameID", mGameID)
|
<< SERIAL("GameID", mGameID)
|
||||||
<< SERIAL("BuildVersion", mBuildVersion)
|
<< SERIAL("BuildVersion", mBuildVersion);
|
||||||
<< SERIAL("DolPath", mDolPath)
|
|
||||||
<< SERIAL("ApploaderPath", mApploaderPath);
|
|
||||||
|
|
||||||
if (rArc.Game() >= eCorruption)
|
|
||||||
rArc << SERIAL("PartitionHeaderPath", mPartitionHeaderPath);
|
|
||||||
|
|
||||||
if (!IsWiiBuild())
|
|
||||||
rArc << SERIAL("FstAddress", mFilesystemAddress);
|
|
||||||
|
|
||||||
rArc << SERIAL("ResourceDB", mResourceDBPath);
|
|
||||||
|
|
||||||
// Serialize package list
|
// Serialize package list
|
||||||
std::vector<TString> PackageList;
|
std::vector<TString> PackageList;
|
||||||
@ -104,14 +94,11 @@ bool CGameProject::BuildISO(const TString& rkIsoPath, IProgressNotifier *pProgre
|
|||||||
pProgress->Report((int) (ProgressPercent * 10000), 10000, TWideString(rkInfoString).ToUTF8());
|
pProgress->Report((int) (ProgressPercent * 10000), 10000, TWideString(rkInfoString).ToUTF8());
|
||||||
};
|
};
|
||||||
|
|
||||||
nod::DiscBuilderGCN *pBuilder = new nod::DiscBuilderGCN(*rkIsoPath.ToUTF16(), *mGameID, *mProjectName, mFilesystemAddress, ProgressCallback);
|
nod::DiscBuilderGCN *pBuilder = new nod::DiscBuilderGCN(*rkIsoPath.ToUTF16(), ProgressCallback);
|
||||||
pProgress->SetTask(0, "Building " + rkIsoPath.GetFileName());
|
pProgress->SetTask(0, "Building " + rkIsoPath.GetFileName());
|
||||||
|
|
||||||
TWideString ProjRoot = ProjectRoot().ToUTF16();
|
|
||||||
TWideString DiscRoot = DiscDir(false).ToUTF16();
|
TWideString DiscRoot = DiscDir(false).ToUTF16();
|
||||||
TWideString DolPath = ProjRoot + mDolPath.ToUTF16();
|
return pBuilder->buildFromDirectory(*DiscRoot) == nod::EBuildResult::Success;
|
||||||
TWideString ApploaderPath = ProjRoot + mApploaderPath.ToUTF16();
|
|
||||||
return pBuilder->buildFromDirectory(*DiscRoot, *DolPath, *ApploaderPath) == nod::EBuildResult::Success;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,11 +171,7 @@ CGameProject* CGameProject::CreateProjectForExport(
|
|||||||
EGame Game,
|
EGame Game,
|
||||||
ERegion Region,
|
ERegion Region,
|
||||||
const TString& rkGameID,
|
const TString& rkGameID,
|
||||||
float BuildVer,
|
float BuildVer
|
||||||
const TString& rkDolPath,
|
|
||||||
const TString& rkApploaderPath,
|
|
||||||
const TString& rkPartitionHeaderPath,
|
|
||||||
u32 FstAddress
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CGameProject *pProj = new CGameProject;
|
CGameProject *pProj = new CGameProject;
|
||||||
@ -196,10 +179,6 @@ CGameProject* CGameProject::CreateProjectForExport(
|
|||||||
pProj->mRegion = Region;
|
pProj->mRegion = Region;
|
||||||
pProj->mGameID = rkGameID;
|
pProj->mGameID = rkGameID;
|
||||||
pProj->mBuildVersion = BuildVer;
|
pProj->mBuildVersion = BuildVer;
|
||||||
pProj->mDolPath = rkDolPath;
|
|
||||||
pProj->mApploaderPath = rkApploaderPath;
|
|
||||||
pProj->mPartitionHeaderPath = rkPartitionHeaderPath;
|
|
||||||
pProj->mFilesystemAddress = FstAddress;
|
|
||||||
|
|
||||||
pProj->mProjectRoot = rkProjRootDir;
|
pProj->mProjectRoot = rkProjRootDir;
|
||||||
pProj->mProjectRoot.Replace("\\", "/");
|
pProj->mProjectRoot.Replace("\\", "/");
|
||||||
|
@ -21,13 +21,8 @@ class CGameProject
|
|||||||
ERegion mRegion;
|
ERegion mRegion;
|
||||||
TString mGameID;
|
TString mGameID;
|
||||||
float mBuildVersion;
|
float mBuildVersion;
|
||||||
TString mDolPath;
|
|
||||||
TString mApploaderPath;
|
|
||||||
TString mPartitionHeaderPath;
|
|
||||||
u32 mFilesystemAddress;
|
|
||||||
|
|
||||||
TString mProjectRoot;
|
TString mProjectRoot;
|
||||||
TString mResourceDBPath;
|
|
||||||
std::vector<CPackage*> mPackages;
|
std::vector<CPackage*> mPackages;
|
||||||
CResourceStore *mpResourceStore;
|
CResourceStore *mpResourceStore;
|
||||||
CGameInfo *mpGameInfo;
|
CGameInfo *mpGameInfo;
|
||||||
@ -52,7 +47,6 @@ class CGameProject
|
|||||||
, mRegion(eRegion_Unknown)
|
, mRegion(eRegion_Unknown)
|
||||||
, mGameID("000000")
|
, mGameID("000000")
|
||||||
, mBuildVersion(0.f)
|
, mBuildVersion(0.f)
|
||||||
, mResourceDBPath("ResourceDB.rdb")
|
|
||||||
, mpResourceStore(nullptr)
|
, mpResourceStore(nullptr)
|
||||||
{
|
{
|
||||||
mpGameInfo = new CGameInfo();
|
mpGameInfo = new CGameInfo();
|
||||||
@ -75,23 +69,20 @@ public:
|
|||||||
EGame Game,
|
EGame Game,
|
||||||
ERegion Region,
|
ERegion Region,
|
||||||
const TString& rkGameID,
|
const TString& rkGameID,
|
||||||
float BuildVer,
|
float BuildVer
|
||||||
const TString& rkDolPath,
|
|
||||||
const TString& rkApploaderPath,
|
|
||||||
const TString& rkPartitionHeaderPath,
|
|
||||||
u32 FstAddress
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static CGameProject* LoadProject(const TString& rkProjPath, IProgressNotifier *pProgress);
|
static CGameProject* LoadProject(const TString& rkProjPath, IProgressNotifier *pProgress);
|
||||||
|
|
||||||
// Directory Handling
|
// Directory Handling
|
||||||
inline TString ProjectRoot() const { return mProjectRoot; }
|
inline TString ProjectRoot() const { return mProjectRoot; }
|
||||||
inline TString ResourceDBPath(bool Relative) const { return Relative ? mResourceDBPath : mProjectRoot + mResourceDBPath; }
|
inline TString ProjectPath() const { return mProjectRoot + FileUtil::SanitizeName(mProjectName, false) + ".prj"; }
|
||||||
inline TString DiscDir(bool Relative) const { return Relative ? "Disc/" : mProjectRoot + "Disc/"; }
|
inline TString DiscDir(bool Relative) const { return Relative ? "Disc/" : mProjectRoot + "Disc/"; }
|
||||||
inline TString PackagesDir(bool Relative) const { return Relative ? "Packages/" : mProjectRoot + "Packages/"; }
|
inline TString PackagesDir(bool Relative) const { return Relative ? "Packages/" : mProjectRoot + "Packages/"; }
|
||||||
inline TString ResourcesDir(bool Relative) const { return Relative ? "Resources/" : mProjectRoot + "Resources/"; }
|
inline TString ResourcesDir(bool Relative) const { return Relative ? "Resources/" : mProjectRoot + "Resources/"; }
|
||||||
inline TString ProjectPath() const { return mProjectRoot + FileUtil::SanitizeName(mProjectName, false) + ".prj"; }
|
|
||||||
inline TString ResourceCachePath(bool Relative) const { return ResourceDBPath(Relative).GetFileDirectory() + "ResourceCacheData.rcd"; }
|
// Disc Filesystem Management
|
||||||
|
inline TString DiscFilesystemRoot(bool Relative) const { return DiscDir(Relative) + (IsWiiBuild() ? "DATA/" : "") + "files/"; }
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline void SetProjectName(const TString& rkName) { mProjectName = rkName; }
|
inline void SetProjectName(const TString& rkName) { mProjectName = rkName; }
|
||||||
|
@ -446,5 +446,5 @@ TString CPackage::DefinitionPath(bool Relative) const
|
|||||||
TString CPackage::CookedPackagePath(bool Relative) const
|
TString CPackage::CookedPackagePath(bool Relative) const
|
||||||
{
|
{
|
||||||
TString RelPath = mPakPath + mPakName + ".pak";
|
TString RelPath = mPakPath + mPakName + ".pak";
|
||||||
return Relative ? RelPath : mpProject->DiscDir(false) + RelPath;
|
return Relative ? RelPath : mpProject->DiscFilesystemRoot(false) + RelPath;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,7 @@ void CResourceStore::SetProject(CGameProject *pProj)
|
|||||||
|
|
||||||
if (mpProj)
|
if (mpProj)
|
||||||
{
|
{
|
||||||
TString DatabasePath = mpProj->ResourceDBPath(false);
|
mDatabasePath = mpProj->ProjectRoot();
|
||||||
mDatabasePath = DatabasePath.GetFileDirectory();
|
|
||||||
mpDatabaseRoot = new CVirtualDirectory(this);
|
mpDatabaseRoot = new CVirtualDirectory(this);
|
||||||
mGame = mpProj->Game();
|
mGame = mpProj->Game();
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ void CWorldTreeModel::OnProjectChanged(CGameProject *pProj)
|
|||||||
// DKCR - Get worlds from areas.lst
|
// DKCR - Get worlds from areas.lst
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TString AreaListPath = pProj->DiscDir(false) + "areas.lst";
|
TString AreaListPath = pProj->DiscFilesystemRoot(false) + "areas.lst";
|
||||||
|
|
||||||
// I really need a good text stream class at some point
|
// I really need a good text stream class at some point
|
||||||
FILE* pAreaList = fopen(*AreaListPath, "r");
|
FILE* pAreaList = fopen(*AreaListPath, "r");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user