Fixed crash after generating asset names, added MP2 auto-generated names to the map

This commit is contained in:
Aruki
2017-02-06 15:10:54 -07:00
parent eca833cf89
commit b3a0e52b6f
7 changed files with 66232 additions and 296 deletions

View File

@@ -7,6 +7,7 @@
#include "Core/Resource/Script/CScriptLayer.h"
#include <Math/MathUtil.h>
#define PROCESS_PACKAGES 1
#define PROCESS_WORLDS 1
#define PROCESS_AREAS 1
#define PROCESS_MODELS 1
@@ -94,9 +95,8 @@ TWideString MakeWorldName(EGame Game, TWideString RawName)
{
RawName = RawName.ChopBack(RawName.Size() - LastUnderscore);
RawName = RawName.ChopFront(FirstUnderscore + 1);
RawName.Remove(L'_');
}
RawName.Remove(L'_');
}
// DKCR - Remove text after second-to-last underscore
@@ -116,7 +116,8 @@ void GenerateAssetNames(CGameProject *pProj)
// todo: CAUD/CSMP
CResourceStore *pStore = pProj->ResourceStore();
// Generate names for package named resources first
#if PROCESS_PACKAGES
// Generate names for package named resources
for (u32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++)
{
CPackage *pPkg = pProj->PackageByIndex(iPkg);
@@ -135,6 +136,7 @@ void GenerateAssetNames(CGameProject *pProj)
}
}
}
#endif
#if PROCESS_WORLDS
// Generate world/area names
@@ -171,7 +173,7 @@ void GenerateAssetNames(CGameProject *pProj)
{
// Move sky model
CResourceEntry *pSkyEntry = pSkyModel->Entry();
ApplyGeneratedName(pSkyEntry, WorldDir + L"sky\\cooked\\", L"sky");
ApplyGeneratedName(pSkyEntry, WorldDir + L"sky\\cooked\\", WorldName + L"_" + L"sky");
// Move sky textures
for (u32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++)
@@ -484,8 +486,8 @@ void GenerateAssetNames(CGameProject *pProj)
// Generate string names
for (TResourceIterator<eStringTable> It(pStore); It; ++It)
{
if (It->IsNamed()) continue;
CStringTable *pString = (CStringTable*) It->Load();
if (pString->Entry()->IsNamed()) continue;
TWideString String;
for (u32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++)
@@ -556,7 +558,7 @@ void GenerateAssetNames(CGameProject *pProj)
CTexture *pFontTex = pFont->Texture();
if (pFontTex)
ApplyGeneratedName(pFontTex->Entry(), pFont->Entry()->DirectoryPath(), pFont->Entry()->Name());
ApplyGeneratedName(pFontTex->Entry(), pFont->Entry()->DirectoryPath(), pFont->Entry()->Name() + L"_tex");
}
}
#endif

View File

@@ -321,7 +321,7 @@ bool CResourceEntry::Move(const TWideString& rkDir, const TWideString& rkName)
TString NewCookedPath = CookedAssetPath();
TString NewRawPath = RawAssetPath();
Log::Write("MOVING RESOURCE: " + OldCookedPath + " --> " + NewCookedPath);
Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->CookedDir(false)).ToUTF8() + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->CookedDir(false)).ToUTF8());
// 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);

View File

@@ -582,6 +582,9 @@ bool CResourceStore::DeleteResourceEntry(CResourceEntry *pEntry)
mLoadedResources.erase(It);
}
if (pEntry->Directory())
pEntry->Directory()->RemoveChildResource(pEntry);
auto It = mResourceEntries.find(ID);
ASSERT(It != mResourceEntries.end());
mResourceEntries.erase(It);