Fixed all DKCR name generation issues
This commit is contained in:
parent
6a01bf5982
commit
8b84b638ac
|
@ -9,6 +9,7 @@ using namespace boost::filesystem;
|
|||
// Macro encapsulating a TString -> boost::filesystem::path conversion
|
||||
// boost does not handle conversion from UTF-8 correctly so we need to do it manually
|
||||
#define TO_PATH(String) path( *String.ToUTF16() )
|
||||
#define FROM_PATH(Path) TWideString( Path.native() ).ToUTF8()
|
||||
|
||||
namespace FileUtil
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ u64 LastModifiedTime(const TString& rkFilePath)
|
|||
|
||||
TString WorkingDirectory()
|
||||
{
|
||||
return boost::filesystem::current_path().string();
|
||||
return FROM_PATH( boost::filesystem::current_path() );
|
||||
}
|
||||
|
||||
TString MakeAbsolute(TString Path)
|
||||
|
@ -305,11 +306,11 @@ TString SanitizeName(TString Name, bool Directory, bool RootDir /*= false*/)
|
|||
return Name;
|
||||
|
||||
// Remove illegal characters from path
|
||||
u32 NumIllegalChars = sizeof(gskIllegalNameChars) / sizeof(wchar_t);
|
||||
u32 NumIllegalChars = sizeof(gskIllegalNameChars) / sizeof(char);
|
||||
|
||||
for (u32 iChr = 0; iChr < Name.Size(); iChr++)
|
||||
{
|
||||
wchar_t Chr = Name[iChr];
|
||||
char Chr = Name[iChr];
|
||||
bool Remove = false;
|
||||
|
||||
if (Chr >= 0 && Chr <= 31)
|
||||
|
@ -345,7 +346,7 @@ TString SanitizeName(TString Name, bool Directory, bool RootDir /*= false*/)
|
|||
|
||||
for (int iChr = (int) Name.Size() - 1; iChr >= 0; iChr--)
|
||||
{
|
||||
wchar_t Chr = Name[iChr];
|
||||
char Chr = Name[iChr];
|
||||
|
||||
if (Chr == ' ' || Chr == '.')
|
||||
ChopNum++;
|
||||
|
@ -405,7 +406,7 @@ bool IsValidName(const TString& rkName, bool Directory, bool RootDir /*= false*/
|
|||
if (rkName.Size() > 255)
|
||||
return false;
|
||||
|
||||
u32 NumIllegalChars = sizeof(gskIllegalNameChars) / sizeof(wchar_t);
|
||||
u32 NumIllegalChars = sizeof(gskIllegalNameChars) / sizeof(char);
|
||||
|
||||
if (Directory && (rkName == "." || rkName == ".."))
|
||||
return true;
|
||||
|
@ -413,7 +414,7 @@ bool IsValidName(const TString& rkName, bool Directory, bool RootDir /*= false*/
|
|||
// Check for banned characters
|
||||
for (u32 iChr = 0; iChr < rkName.Size(); iChr++)
|
||||
{
|
||||
wchar_t Chr = rkName[iChr];
|
||||
char Chr = rkName[iChr];
|
||||
|
||||
if (Chr >= 0 && Chr <= 31)
|
||||
return false;
|
||||
|
@ -476,7 +477,7 @@ void GetDirectoryContents(TString DirPath, TStringList& rOut, bool Recursive /*=
|
|||
{
|
||||
for (recursive_directory_iterator It( TO_PATH(DirPath) ); It != recursive_directory_iterator(); ++It)
|
||||
{
|
||||
AddFileLambda( It->path().string() );
|
||||
AddFileLambda( FROM_PATH(It->path()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,7 +485,7 @@ void GetDirectoryContents(TString DirPath, TStringList& rOut, bool Recursive /*=
|
|||
{
|
||||
for (directory_iterator It( TO_PATH(DirPath) ); It != directory_iterator(); ++It)
|
||||
{
|
||||
AddFileLambda( It->path().string() );
|
||||
AddFileLambda( FROM_PATH(It->path()) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -494,7 +495,7 @@ TString FindFileExtension(const TString& rkDir, const TString& rkName)
|
|||
{
|
||||
for (directory_iterator It( TO_PATH(rkDir) ); It != directory_iterator(); ++It)
|
||||
{
|
||||
TString Name = It->path().filename().string();
|
||||
TString Name = FROM_PATH( It->path().filename() );
|
||||
if (Name.GetFileName(false) == rkName) return Name.GetFileExtension();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ u64 TString::Hash64() const
|
|||
TWideString TString::ToUTF16() const
|
||||
{
|
||||
TWideString Out;
|
||||
Out.Reserve(Size());
|
||||
|
||||
const char *pkCStr = CString();
|
||||
|
||||
while (pkCStr[0])
|
||||
|
@ -86,12 +88,20 @@ TWideString TString::ToUTF16() const
|
|||
pkCStr += 6;
|
||||
}
|
||||
|
||||
// Invalid?
|
||||
else
|
||||
{
|
||||
CodePoint = pkCStr[0];
|
||||
pkCStr++;
|
||||
}
|
||||
|
||||
// Step 2: Append to output string
|
||||
if ( ((CodePoint >= 0) && (CodePoint <= 0xD7FF)) ||
|
||||
((CodePoint >= 0xE000) && (CodePoint <= 0xFFFF)) )
|
||||
Out.Append((wchar_t) (CodePoint & 0xFFFF));
|
||||
}
|
||||
|
||||
Out.Shrink();
|
||||
return Out;
|
||||
}
|
||||
|
||||
|
|
|
@ -214,6 +214,16 @@ public:
|
|||
return mInternalString.substr(StartPos, Length);
|
||||
}
|
||||
|
||||
inline void Reserve(u32 Amount)
|
||||
{
|
||||
mInternalString.reserve(Amount);
|
||||
}
|
||||
|
||||
inline void Shrink()
|
||||
{
|
||||
mInternalString.shrink_to_fit();
|
||||
}
|
||||
|
||||
inline void Insert(u32 Pos, CharType Chr)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
|
|
@ -97,7 +97,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
|
||||
TString NewDir = (HasCustomDir ? It->DirectoryPath() : "Uncategorized/");
|
||||
TString NewName = (HasCustomName ? It->Name() : It->ID().ToString());
|
||||
It->Move(NewDir, NewName);
|
||||
It->Move(NewDir, NewName, true, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -131,7 +131,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
for (TResourceIterator<eWorld> It(pStore); It; ++It)
|
||||
{
|
||||
// Set world name
|
||||
CWorld *pWorld = (CWorld*) It->Load();
|
||||
TResPtr<CWorld> pWorld = It->Load();
|
||||
TString WorldName = pWorld->Name();
|
||||
TString WorldDir = kWorldsRoot + WorldName + '/';
|
||||
|
||||
|
@ -205,7 +205,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
|||
|
||||
// Rename area stuff
|
||||
CResourceEntry *pAreaEntry = pStore->FindEntry(AreaID);
|
||||
ASSERT(pAreaEntry != nullptr);
|
||||
if (!pAreaEntry) continue; // Some DKCR worlds reference areas that don't exist
|
||||
ApplyGeneratedName(pAreaEntry, WorldMasterDir, AreaName);
|
||||
|
||||
CStringTable *pAreaNameTable = pWorld->AreaName(iArea);
|
||||
|
|
|
@ -204,7 +204,7 @@ bool CVirtualDirectory::RemoveChildDirectory(CVirtualDirectory *pSubdir)
|
|||
// If this is part of the resource store, delete the corresponding filesystem directory
|
||||
if (mpStore && pSubdir->GetRoot() == mpStore->RootDirectory())
|
||||
{
|
||||
TString AbsPath = mpStore->DatabaseRootPath() + pSubdir->FullPath();
|
||||
TString AbsPath = mpStore->ResourcesDir() + pSubdir->FullPath();
|
||||
FileUtil::DeleteDirectory(AbsPath, true);
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,10 @@ void CVirtualDirectory::RemoveEmptySubdirectories()
|
|||
CVirtualDirectory *pDir = mSubdirectories[SubdirIdx];
|
||||
|
||||
if (pDir->IsEmpty())
|
||||
{
|
||||
RemoveChildDirectory(pDir);
|
||||
SubdirIdx--;
|
||||
}
|
||||
else
|
||||
pDir->RemoveEmptySubdirectories();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,13 @@ IMetaAnimation* CMetaAnimFactory::LoadFromStream(IInputStream& rInput, EGame Gam
|
|||
}
|
||||
|
||||
// ************ CMetaAnimationPlay ************
|
||||
CMetaAnimPlay::CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, u32 UnkB)
|
||||
: mPrimitive(rkPrimitive)
|
||||
, mUnknownA(UnkA)
|
||||
, mUnknownB(UnkB)
|
||||
{
|
||||
}
|
||||
|
||||
CMetaAnimPlay::CMetaAnimPlay(IInputStream& rInput, EGame Game)
|
||||
{
|
||||
mPrimitive = CAnimPrimitive(rInput, Game);
|
||||
|
|
|
@ -32,6 +32,12 @@ class CAnimPrimitive
|
|||
public:
|
||||
CAnimPrimitive() : mID(0) {}
|
||||
|
||||
CAnimPrimitive(const CAssetID& rkAnimAssetID, u32 CharAnimID, const TString& rkAnimName)
|
||||
: mID(CharAnimID), mName(rkAnimName)
|
||||
{
|
||||
mpAnim = gpResourceStore->LoadResource(rkAnimAssetID);
|
||||
}
|
||||
|
||||
CAnimPrimitive(IInputStream& rInput, EGame Game)
|
||||
{
|
||||
mpAnim = gpResourceStore->LoadResource( CAssetID(rInput, Game) );
|
||||
|
@ -70,6 +76,7 @@ protected:
|
|||
u32 mUnknownB;
|
||||
|
||||
public:
|
||||
CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, u32 UnkB);
|
||||
CMetaAnimPlay(IInputStream& rInput, EGame Game);
|
||||
virtual EMetaAnimationType Type() const;
|
||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||
|
|
|
@ -137,10 +137,16 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
|
|||
|
||||
for (u32 AnimIdx = 0; AnimIdx < NumAnims; AnimIdx++)
|
||||
{
|
||||
rCHAR.ReadString();
|
||||
TString AnimName = rCHAR.ReadString();
|
||||
CAssetID AnimID(rCHAR, eReturns);
|
||||
rCHAR.Skip(0x25);
|
||||
rChar.DKDependencies.push_back(AnimID);
|
||||
|
||||
// small hack - create a meta-anim for it so we can generate asset names for the ANIM files correctly
|
||||
SAnimation Anim;
|
||||
Anim.Name = AnimName;
|
||||
Anim.pMetaAnim = new CMetaAnimPlay( CAnimPrimitive(AnimID, AnimIdx, AnimName), 0.f, 0 );
|
||||
pSet->mAnimations.push_back(Anim);
|
||||
}
|
||||
|
||||
// The only other thing we care about right now is the dependency list. If this file doesn't have a dependency list, exit out.
|
||||
|
@ -229,6 +235,7 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR)
|
|||
}
|
||||
}
|
||||
|
||||
ProcessPrimitives();
|
||||
return pSet;
|
||||
}
|
||||
|
||||
|
|
|
@ -624,7 +624,9 @@ void CAreaLoader::SetUpObjects(CScriptLayer *pGenLayer)
|
|||
// Check if this is a duplicate of an existing instance (this only happens with DKCR GenericCreature as far as I'm aware)
|
||||
if (mpArea->InstanceByID(InstanceID) != nullptr)
|
||||
{
|
||||
Log::Write("Duplicate SCGN object: [" + pInst->Template()->Name() + "] " + pInst->InstanceName() + " (" + TString::HexString(pInst->InstanceID(), 8, false) + ")");
|
||||
if (pInst->ObjectTypeID() != FOURCC('GCTR'))
|
||||
Log::Write("Duplicate SCGN object: [" + pInst->Template()->Name() + "] " + pInst->InstanceName() + " (" + TString::HexString(pInst->InstanceID(), 8, false) + ")");
|
||||
|
||||
pGenLayer->RemoveInstance(pInst);
|
||||
delete pInst;
|
||||
}
|
||||
|
|
|
@ -335,6 +335,9 @@ void CResourceBrowser::OnGenerateAssetNames()
|
|||
Dialog.DisallowCanceling();
|
||||
Dialog.SetOneShotTask("Generating asset names");
|
||||
|
||||
// Temporarily set root to null to ensure the window doesn't access the resource store while we're running.
|
||||
mpDirectoryModel->SetRoot(mpStore->RootDirectory());
|
||||
|
||||
QFuture<void> Future = QtConcurrent::run(&GenerateAssetNames, mpStore->Project());
|
||||
Dialog.WaitForResults(Future);
|
||||
|
||||
|
|
|
@ -71,6 +71,10 @@
|
|||
<property ID="0x9C403177" type="color">
|
||||
<default>0.0, 0.0, 0.0, 1.0</default>
|
||||
</property>
|
||||
<property ID="0x1F68F1B7" type="bool">
|
||||
<default>false</default>
|
||||
<description>This property was likely used in debug builds. It is not read by the game and has no ingame effect.</description>
|
||||
</property>
|
||||
<property ID="0x29463E36" type="character"/>
|
||||
<property ID="0x103E9376" type="character"/>
|
||||
<property ID="0x7024D89B" type="character"/>
|
||||
|
|
Loading…
Reference in New Issue