Skip to content

Commit aaa8ab0

Browse files
committed
Updated CascLib
Disabled Jolt Dummy Trace Asserting Fixed ItemDisplayInfo geosetGroupIndex range Updated Submodule Engine
1 parent e8a9c89 commit aaa8ab0

14 files changed

Lines changed: 91 additions & 52 deletions

File tree

Dependencies/casc/Casc/CascCommon.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#if defined(_DEBUG) && !defined(CASCLIB_NODEBUG)
2525
#define CASCLIB_DEBUG
26-
#define CASCLIB_WRITE_VERIFIED_FILENAMES // If defined, TRootHandler_WoW will save all files whose hashes are confirmed
26+
//#define CASCLIB_WRITE_VERIFIED_FILENAMES // If defined, TRootHandler_WoW will save all files whose hashes are confirmed
2727
#endif
2828

2929
#include "CascPort.h"
@@ -110,14 +110,13 @@ typedef struct _CASC_BUILD_FILE
110110
} CASC_BUILD_FILE, *PCASC_BUILD_FILE;
111111

112112
// Information about index file
113-
struct CASC_INDEX
113+
typedef struct _CASC_INDEX
114114
{
115115
CASC_BLOB FileData;
116116
LPTSTR szFileName; // Full name of the index file
117117
DWORD NewSubIndex; // New subindex
118118
DWORD OldSubIndex; // Old subindex
119-
};
120-
typedef CASC_INDEX * PCASC_INDEX;
119+
} CASC_INDEX, *PCASC_INDEX;
121120

122121
// Normalized header of the index files.
123122
// Both version 1 and version 2 are converted to this structure
@@ -534,4 +533,4 @@ void CascDumpFile(HANDLE hFile, const char * szDumpFile = NULL);
534533
void CascDumpStorage(HANDLE hStorage, const char * szDumpFile = NULL);
535534
#endif
536535

537-
#endif // __CASCCOMMON_H__
536+
#endif // __CASCCOMMON_H__

Dependencies/casc/Casc/CascFiles.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,3 +1883,4 @@ void WINAPI CascCdnFree(void * buffer)
18831883
{
18841884
CASC_FREE(buffer);
18851885
}
1886+

Dependencies/casc/Casc/CascIndexFiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,4 +833,4 @@ void FreeIndexFiles(TCascStorage * hs)
833833
// Free the file name
834834
CASC_FREE(IndexFile.szFileName);
835835
}
836-
}
836+
}

Dependencies/casc/Casc/CascLib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,4 +436,4 @@ DWORD GetCascError();
436436
} // extern "C"
437437
#endif
438438

439-
#endif // __CASCLIB_H__
439+
#endif // __CASCLIB_H__

Dependencies/casc/Casc/CascOpenStorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,4 +1563,4 @@ bool WINAPI CascCloseStorage(HANDLE hStorage)
15631563
// Only free the storage if the reference count reaches 0
15641564
hs->Release();
15651565
return true;
1566-
}
1566+
}

Dependencies/casc/Casc/CascRootFile_OW.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct _APM_HEADER_V3
3434
// Followed by the array of APM_ENTRY (count is in "EntryCount")
3535
// Followed by the array of APM_PACKAGE (count is in "PackageCount")
3636

37-
} APM_HEADER_V3, * PAPM_HEADER_V3;
37+
} APM_HEADER_V3, *PAPM_HEADER_V3;
3838

3939
typedef struct _APM_HEADER_V2
4040
{
@@ -48,7 +48,7 @@ typedef struct _APM_HEADER_V2
4848
// Followed by the array of APM_ENTRY (count is in "EntryCount")
4949
// Followed by the array of APM_PACKAGE (count is in "PackageCount")
5050

51-
} APM_HEADER_V2, * PAPM_HEADER_V2;
51+
} APM_HEADER_V2, *PAPM_HEADER_V2;
5252

5353
typedef struct _APM_HEADER_V1
5454
{
@@ -61,15 +61,15 @@ typedef struct _APM_HEADER_V1
6161
// Followed by the array of APM_ENTRY (count is in "EntryCount")
6262
// Followed by the array of APM_PACKAGE (count is in "PackageCount")
6363

64-
} APM_HEADER_V1, * PAPM_HEADER_V1;
64+
} APM_HEADER_V1, *PAPM_HEADER_V1;
6565

6666
// On-disk format, size = 0x0C
6767
typedef struct _APM_ENTRY_V1
6868
{
6969
DWORD Index;
7070
DWORD HashA_Lo; // Must split the hashes in order to make this structure properly aligned
7171
DWORD HashA_Hi;
72-
} APM_ENTRY_V1, * PAPM_ENTRY_V1;
72+
} APM_ENTRY_V1, *PAPM_ENTRY_V1;
7373

7474
// On-disk format, size = 0x14
7575
typedef struct _APM_ENTRY_V2
@@ -91,7 +91,7 @@ typedef struct _APM_PACKAGE_ENTRY_V1
9191
ULONGLONG PackageGUID; // 077 file
9292
ULONGLONG Unknown1;
9393
DWORD Unknown2;
94-
} APM_PACKAGE_ENTRY_V1, * PAPM_PACKAGE_ENTRY_V1;
94+
} APM_PACKAGE_ENTRY_V1, *PAPM_PACKAGE_ENTRY_V1;
9595

9696
// On-disk format
9797
typedef struct _APM_PACKAGE_ENTRY_V2

Dependencies/casc/Casc/CascRootFile_WoW.cpp

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ typedef enum _ROOT_FORMAT
3535
RootFormatWoW_v2, // Since build 30080 (WoW 8.2.0)
3636
} ROOT_FORMAT, *PROOT_FORMAT;
3737

38+
// The last byte of the structure causes wrong alignment with default compiler options
39+
#pragma pack(push, 1)
40+
typedef struct _FILE_ROOT_GROUP_HEADER_58221 // Since build 58221 (11.1.0.58221)
41+
{
42+
DWORD NumberOfFiles; // Number of entries
43+
DWORD LocaleFlags; // File locale mask (CASC_LOCALE_XXX)
44+
DWORD ContentFlags1;
45+
DWORD ContentFlags2;
46+
BYTE ContentFlags3;
47+
48+
} FILE_ROOT_GROUPHEADER_58221, *PFILE_ROOT_GROUPHEADER_58221;
49+
#pragma pack(pop)
50+
3851
// ROOT file header since build 50893 (10.1.7)
3952
typedef struct _FILE_ROOT_HEADER_50893
4053
{
@@ -43,7 +56,7 @@ typedef struct _FILE_ROOT_HEADER_50893
4356
DWORD Version; // Must be 1
4457
DWORD TotalFiles;
4558
DWORD FilesWithNameHash;
46-
} FILE_ROOT_HEADER_50893, * PFILE_ROOT_HEADER_50893;
59+
} FILE_ROOT_HEADER_50893, *PFILE_ROOT_HEADER_50893;
4760

4861
// ROOT file header since build 30080 (8.2.0)
4962
typedef struct _FILE_ROOT_HEADER_30080
@@ -97,7 +110,7 @@ struct TRootHandler_WoW : public TFileTreeRoot
97110
{
98111
public:
99112

100-
typedef LPBYTE (*CAPTURE_ROOT_HEADER)(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless);
113+
typedef LPBYTE (*CAPTURE_ROOT_HEADER)(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless, PDWORD Version);
101114

102115
TRootHandler_WoW(ROOT_FORMAT aRootFormat, DWORD aFileCounterHashless, LPCTSTR szDumpFile = NULL) : TFileTreeRoot(FTREE_FLAGS_WOW)
103116
{
@@ -155,7 +168,7 @@ struct TRootHandler_WoW : public TFileTreeRoot
155168
#endif
156169

157170
// Check for the new format (World of Warcraft 10.1.7, build 50893)
158-
static LPBYTE CaptureRootHeader_50893(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless)
171+
static LPBYTE CaptureRootHeader_50893(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless, PDWORD Version)
159172
{
160173
FILE_ROOT_HEADER_50893 RootHeader;
161174

@@ -167,7 +180,7 @@ struct TRootHandler_WoW : public TFileTreeRoot
167180
// Verify the root file header
168181
if(RootHeader.Signature != CASC_WOW_ROOT_SIGNATURE)
169182
return NULL;
170-
if(RootHeader.Version != 1)
183+
if(RootHeader.Version != 1 && RootHeader.Version != 2)
171184
return NULL;
172185
if(RootHeader.FilesWithNameHash > RootHeader.TotalFiles)
173186
return NULL;
@@ -177,11 +190,12 @@ struct TRootHandler_WoW : public TFileTreeRoot
177190

178191
*RootFormat = RootFormatWoW_v2;
179192
*FileCounterHashless = RootHeader.TotalFiles - RootHeader.FilesWithNameHash;
193+
*Version = RootHeader.Version;
180194
return pbRootPtr + RootHeader.SizeOfHeader;
181195
}
182196

183197
// Check for the root format for build 30080+ (WoW 8.2.0)
184-
static LPBYTE CaptureRootHeader_30080(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless)
198+
static LPBYTE CaptureRootHeader_30080(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless, PDWORD Version)
185199
{
186200
FILE_ROOT_HEADER_30080 RootHeader;
187201

@@ -198,11 +212,12 @@ struct TRootHandler_WoW : public TFileTreeRoot
198212

199213
*RootFormat = RootFormatWoW_v2;
200214
*FileCounterHashless = RootHeader.TotalFiles - RootHeader.FilesWithNameHash;
215+
*Version = 0;
201216
return pbRootPtr + sizeof(FILE_ROOT_HEADER_30080);
202217
}
203218

204219
// Check for the root format for build 18125+ (WoW 6.0.1)
205-
static LPBYTE CaptureRootHeader_18125(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless)
220+
static LPBYTE CaptureRootHeader_18125(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless, PDWORD Version)
206221
{
207222
size_t DataLength;
208223

@@ -218,10 +233,11 @@ struct TRootHandler_WoW : public TFileTreeRoot
218233

219234
*RootFormat = RootFormatWoW_v1;
220235
*FileCounterHashless = 0;
236+
*Version = 0;
221237
return pbRootPtr;
222238
}
223239

224-
static LPBYTE CaptureRootHeader(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless)
240+
static LPBYTE CaptureRootHeader(LPBYTE pbRootPtr, LPBYTE pbRootEnd, PROOT_FORMAT RootFormat, PDWORD FileCounterHashless, PDWORD Version)
225241
{
226242
CAPTURE_ROOT_HEADER PfnCaptureRootHeader[] =
227243
{
@@ -234,24 +250,42 @@ struct TRootHandler_WoW : public TFileTreeRoot
234250
{
235251
LPBYTE pbCapturedPtr;
236252

237-
if((pbCapturedPtr = PfnCaptureRootHeader[i](pbRootPtr, pbRootEnd, RootFormat, FileCounterHashless)) != NULL)
253+
if((pbCapturedPtr = PfnCaptureRootHeader[i](pbRootPtr, pbRootEnd, RootFormat, FileCounterHashless, Version)) != NULL)
238254
{
239255
return pbCapturedPtr;
240256
}
241257
}
242258
return NULL;
243259
}
244260

245-
LPBYTE CaptureRootGroup(FILE_ROOT_GROUP & RootGroup, LPBYTE pbRootPtr, LPBYTE pbRootEnd)
261+
LPBYTE CaptureRootGroup(FILE_ROOT_GROUP & RootGroup, LPBYTE pbRootPtr, LPBYTE pbRootEnd, DWORD dwRootVersion)
246262
{
247263
// Reset the entire root group structure
248264
memset(&RootGroup, 0, sizeof(FILE_ROOT_GROUP));
249265

250-
// Validate the locale block header
251-
if((pbRootPtr + sizeof(FILE_ROOT_GROUP_HEADER)) >= pbRootEnd)
252-
return NULL;
253-
memcpy(&RootGroup.Header, pbRootPtr, sizeof(FILE_ROOT_GROUP_HEADER));
254-
pbRootPtr = pbRootPtr + sizeof(FILE_ROOT_GROUP_HEADER);
266+
if(dwRootVersion == 0 || dwRootVersion == 1)
267+
{
268+
// Validate the locale block header
269+
if((pbRootPtr + sizeof(FILE_ROOT_GROUP_HEADER)) >= pbRootEnd)
270+
return NULL;
271+
memcpy(&RootGroup.Header, pbRootPtr, sizeof(FILE_ROOT_GROUP_HEADER));
272+
pbRootPtr = pbRootPtr + sizeof(FILE_ROOT_GROUP_HEADER);
273+
}
274+
else if(dwRootVersion == 2)
275+
{
276+
PFILE_ROOT_GROUPHEADER_58221 pRootGroupHeader;
277+
278+
// Get pointer to the root group header
279+
if((pbRootPtr + sizeof(FILE_ROOT_GROUPHEADER_58221)) >= pbRootEnd)
280+
return NULL;
281+
pRootGroupHeader = (PFILE_ROOT_GROUPHEADER_58221)pbRootPtr;
282+
pbRootPtr = pbRootPtr + sizeof(FILE_ROOT_GROUPHEADER_58221);
283+
284+
// Convert to old ContentFlags for now...
285+
RootGroup.Header.NumberOfFiles = pRootGroupHeader->NumberOfFiles;
286+
RootGroup.Header.ContentFlags = pRootGroupHeader->ContentFlags1 | pRootGroupHeader->ContentFlags2 | (DWORD)(pRootGroupHeader->ContentFlags3 << 17);
287+
RootGroup.Header.LocaleFlags = pRootGroupHeader->LocaleFlags;
288+
}
255289

256290
// Validate the array of file data IDs
257291
if((pbRootPtr + (sizeof(DWORD) * RootGroup.Header.NumberOfFiles)) >= pbRootEnd)
@@ -380,7 +414,8 @@ struct TRootHandler_WoW : public TFileTreeRoot
380414
LPBYTE pbRootEnd,
381415
DWORD dwLocaleMask,
382416
BYTE bOverrideLowViolence,
383-
BYTE bAudioLocale)
417+
BYTE bAudioLocale,
418+
DWORD dwRootVersion)
384419
{
385420
FILE_ROOT_GROUP RootBlock;
386421

@@ -395,7 +430,7 @@ struct TRootHandler_WoW : public TFileTreeRoot
395430
//OutputDebugStringA(szMessage);
396431

397432
// Validate the file locale block
398-
pbRootPtr = CaptureRootGroup(RootBlock, pbRootPtr, pbRootEnd);
433+
pbRootPtr = CaptureRootGroup(RootBlock, pbRootPtr, pbRootEnd, dwRootVersion);
399434
if(pbRootPtr == NULL)
400435
return ERROR_BAD_FORMAT;
401436

@@ -481,33 +516,34 @@ struct TRootHandler_WoW : public TFileTreeRoot
481516
LPBYTE pbRootPtr,
482517
LPBYTE pbRootEnd,
483518
DWORD dwLocaleMask,
484-
BYTE bAudioLocale)
519+
BYTE bAudioLocale,
520+
DWORD dwRootVersion)
485521
{
486522
DWORD dwErrCode;
487523

488524
// Load the locale as-is
489-
dwErrCode = ParseWowRootFile_Level2(hs, pbRootPtr, pbRootEnd, dwLocaleMask, false, bAudioLocale);
525+
dwErrCode = ParseWowRootFile_Level2(hs, pbRootPtr, pbRootEnd, dwLocaleMask, false, bAudioLocale, dwRootVersion);
490526
if(dwErrCode != ERROR_SUCCESS)
491527
return dwErrCode;
492528

493529
// If we wanted enGB, we also load enUS for the missing files
494530
if(dwLocaleMask == CASC_LOCALE_ENGB)
495-
ParseWowRootFile_Level2(hs, pbRootPtr, pbRootEnd, CASC_LOCALE_ENUS, false, bAudioLocale);
531+
ParseWowRootFile_Level2(hs, pbRootPtr, pbRootEnd, CASC_LOCALE_ENUS, false, bAudioLocale, dwRootVersion);
496532

497533
if(dwLocaleMask == CASC_LOCALE_PTPT)
498-
ParseWowRootFile_Level2(hs, pbRootPtr, pbRootEnd, CASC_LOCALE_PTBR, false, bAudioLocale);
534+
ParseWowRootFile_Level2(hs, pbRootPtr, pbRootEnd, CASC_LOCALE_PTBR, false, bAudioLocale, dwRootVersion);
499535

500536
return ERROR_SUCCESS;
501537
}
502538

503539
// WoW.exe: 004146C7 (BuildManifest::Load)
504-
DWORD Load(TCascStorage * hs, LPBYTE pbRootPtr, LPBYTE pbRootEnd, DWORD dwLocaleMask)
540+
DWORD Load(TCascStorage * hs, LPBYTE pbRootPtr, LPBYTE pbRootEnd, DWORD dwLocaleMask, DWORD dwRootVersion)
505541
{
506542
DWORD dwErrCode;
507543

508-
dwErrCode = ParseWowRootFile_Level1(hs, pbRootPtr, pbRootEnd, dwLocaleMask, 0);
544+
dwErrCode = ParseWowRootFile_Level1(hs, pbRootPtr, pbRootEnd, dwLocaleMask, 0, dwRootVersion);
509545
if(dwErrCode == ERROR_SUCCESS)
510-
dwErrCode = ParseWowRootFile_Level1(hs, pbRootPtr, pbRootEnd, dwLocaleMask, 1);
546+
dwErrCode = ParseWowRootFile_Level1(hs, pbRootPtr, pbRootEnd, dwLocaleMask, 1, dwRootVersion);
511547

512548
#ifdef CASCLIB_DEBUG
513549
// Dump the array of the file data IDs
@@ -618,10 +654,11 @@ DWORD RootHandler_CreateWoW(TCascStorage * hs, CASC_BLOB & RootFile, DWORD dwLoc
618654
LPBYTE pbRootEnd = RootFile.End();
619655
LPBYTE pbRootPtr;
620656
DWORD FileCounterHashless = 0;
657+
DWORD RootVersion = 0;
621658
DWORD dwErrCode = ERROR_BAD_FORMAT;
622659

623660
// Verify the root header
624-
if((pbRootPtr = TRootHandler_WoW::CaptureRootHeader(pbRootFile, pbRootEnd, &RootFormat, &FileCounterHashless)) == NULL)
661+
if((pbRootPtr = TRootHandler_WoW::CaptureRootHeader(pbRootFile, pbRootEnd, &RootFormat, &FileCounterHashless, &RootVersion)) == NULL)
625662
return ERROR_BAD_FORMAT;
626663

627664
#ifdef CASCLIB_WRITE_VERIFIED_FILENAMES
@@ -639,7 +676,7 @@ DWORD RootHandler_CreateWoW(TCascStorage * hs, CASC_BLOB & RootFile, DWORD dwLoc
639676
//fp = fopen("E:\\file-data-ids2.txt", "wt");
640677

641678
// Load the root directory. If load failed, we free the object
642-
dwErrCode = pRootHandler->Load(hs, pbRootPtr, pbRootEnd, dwLocaleMask);
679+
dwErrCode = pRootHandler->Load(hs, pbRootPtr, pbRootEnd, dwLocaleMask, RootVersion);
643680
if(dwErrCode != ERROR_SUCCESS)
644681
{
645682
delete pRootHandler;

Dependencies/casc/Casc/DllMain.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ EXPORTS
3131

3232
CascAddEncryptionKey
3333
CascAddStringEncryptionKey
34+
CascImportKeysFromString
35+
CascImportKeysFromFile
3436
CascFindEncryptionKey
3537
CascGetNotFoundEncryptionKey
3638

Dependencies/jolt/Jolt/Core/IssueReporting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ JPH_NAMESPACE_BEGIN
1212

1313
static void DummyTrace([[maybe_unused]] const char *inFMT, ...)
1414
{
15-
JPH_ASSERT(false);
15+
//JPH_ASSERT(false);
1616
};
1717

1818
TraceFunction Trace = DummyTrace;

Source/AssetConverter-App/AssetConverter-App/Extractors/ClientDBExtractor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <FileFormat/Novus/ClientDB/ClientDB.h>
1717
#include <FileFormat/Novus/Model/ComplexModel.h>
1818

19-
#include <Meta/Generated/ClientDB.h>
19+
#include <Meta/Generated/Shared/ClientDB.h>
2020

2121
#include <filesystem>
2222
namespace fs = std::filesystem;
@@ -1021,7 +1021,7 @@ bool ClientDBExtractor::ExtractItemDisplayInfo(const std::string& name)
10211021

10221022
// goesetGroup
10231023
const u32* goesetGroups = db2Parser.GetFieldPtr<u32>(layout, sectionID, recordID, recordData, 13);
1024-
for (u32 geosetGroupIndex = 0; geosetGroupIndex < 6; geosetGroupIndex++)
1024+
for (u32 geosetGroupIndex = 0; geosetGroupIndex < 4; geosetGroupIndex++)
10251025
{
10261026
itemDisplayInfo.modelGeosetGroups[geosetGroupIndex] = static_cast<u8>(goesetGroups[geosetGroupIndex]);
10271027
}

0 commit comments

Comments
 (0)