Various crash fixes

This commit is contained in:
Aruki
2019-02-18 03:54:58 -07:00
parent 4e1560a99c
commit 0827c05802
12 changed files with 99 additions and 48 deletions

View File

@@ -32,14 +32,42 @@ void CTweakManager::LoadTweaks()
// MP2+ - Load tweaks from Standard.ntwk
else
{
TString FilePath = mpProject->DiscFilesystemRoot(false) + "Standard.ntwk";
CFileInStream StandardNTWK(FilePath, EEndian::BigEndian);
CTweakLoader::LoadNTWK(StandardNTWK, mpProject->Game(), mTweakObjects);
if (!mpProject->IsWiiBuild())
{
mStandardFilePath = mpProject->DiscFilesystemRoot(false) / "Standard.ntwk";
}
else
{
// For Wii builds, there is another game-dependent subfolder.
EGame Game = mpProject->Game();
TString GameName = (Game == EGame::Prime ? "MP1" :
Game == EGame::Echoes ? "MP2" :
"MP3");
mStandardFilePath = mpProject->DiscFilesystemRoot(false) / GameName / "Standard.ntwk";
// MP3 might actually be FrontEnd
if (Game == EGame::Corruption && !FileUtil::Exists(mStandardFilePath))
{
mStandardFilePath = mpProject->DiscFilesystemRoot(false) / "fe/Standard.ntwk";
}
}
if (FileUtil::Exists(mStandardFilePath))
{
CFileInStream StandardNTWK(mStandardFilePath, EEndian::BigEndian);
CTweakLoader::LoadNTWK(StandardNTWK, mpProject->Game(), mTweakObjects);
}
}
}
bool CTweakManager::SaveTweaks()
{
// If we don't have any tweaks loaded, nothing to do
if (mTweakObjects.empty())
{
return false;
}
// MP1 - Save all tweak assets
if (mpProject->Game() <= EGame::Prime)
{
@@ -67,8 +95,7 @@ bool CTweakManager::SaveTweaks()
// MP2+ - Save tweaks to Standard.ntwk
else
{
TString FilePath = mpProject->DiscFilesystemRoot(false) + "Standard.ntwk";
CFileOutStream StandardNTWK(FilePath, EEndian::BigEndian);
CFileOutStream StandardNTWK(mStandardFilePath, EEndian::BigEndian);
return CTweakCooker::CookNTWK(mTweakObjects, StandardNTWK);
}
}

View File

@@ -12,6 +12,9 @@ class CTweakManager
/** All tweak resources in the current game */
std::vector< CTweakData* > mTweakObjects;
/** For MP2+, the path to Standard.ntwk */
TString mStandardFilePath;
public:
CTweakManager(CGameProject* pInProject);
~CTweakManager();