Skip to content

Commit f1c5ea8

Browse files
author
Zezula Ladislav
committed
Linux Build
1 parent fb11979 commit f1c5ea8

File tree

8 files changed

+72
-79
lines changed

8 files changed

+72
-79
lines changed

src/CascCommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ LPBYTE LoadExternalFileToMemory(const TCHAR * szFileName, DWORD * pcbFileData)
110110
{
111111
CASC_FREE(pbFileData);
112112
pbFileData = NULL;
113-
cbFileData = NULL;
113+
cbFileData = 0;
114114
}
115115
}
116116
else

src/CascCommon.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,6 @@
4444
//-----------------------------------------------------------------------------
4545
// CascLib private defines
4646

47-
#define CASC_GAME_HOTS 0x00010000 // Heroes of the Storm
48-
#define CASC_GAME_WOW6 0x00020000 // World of Warcraft - Warlords of Draenor
49-
#define CASC_GAME_DIABLO3 0x00030000 // Diablo 3 since PTR 2.2.0
50-
#define CASC_GAME_OVERWATCH 0x00040000 // Overwatch since PTR 24919
51-
#define CASC_GAME_STARCRAFT2 0x00050000 // Starcraft II - Legacy of the Void, since build 38996
52-
#define CASC_GAME_STARCRAFT1 0x00060000 // Starcraft 1 (remastered)
53-
#define CASC_GAME_WARCRAFT3 0x00070000 // Warcraft III, since version 1.30, build 9655
54-
#define CASC_GAME_MASK 0xFFFF0000 // Mask for getting game ID
55-
56-
#define CASC_EXTRA_FILES 0x20 // Number of extra entries to be reserved for additionally inserted files
57-
58-
#define CASC_PACKAGE_BUFFER 0x1000
59-
6047
#ifdef _DEBUG
6148
#define BREAK_ON_XKEY3(CKey, v0, v1, v2) if(CKey[0] == v0 && CKey[1] == v1 && CKey[2] == v2) { __debugbreak(); }
6249
#define BREAKIF(condition) if(condition) { __debugbreak(); }

src/CascFiles.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -461,71 +461,71 @@ static int LoadBuildProductId(TCascStorage * hs, const char * /* szVariableName
461461
// Product-specific. See https://wowdev.wiki/TACT#Products
462462
switch(dwBuildUid)
463463
{
464-
case 'd3':
465-
case 'd3b': // Diablo 3 Beta (2013)
466-
case 'd3cn': // Diablo 3 China
467-
case 'd3t': // Diablo 3 Test
464+
case 0x00006433: // 'd3'
465+
case 0x00643364: // 'd3b': Diablo 3 Beta (2013)
466+
case 0x6433636e: // 'd3cn': Diablo 3 China
467+
case 0x00643374: // 'd3t': Diablo 3 Test
468468
hs->szProductName = "Diablo 3";
469469
hs->Product = Diablo3;
470470
break;
471471

472-
case 'dst2':
472+
case 0x64737432: // 'dst2':
473473
hs->szProductName = "Destiny 2";
474474
hs->Product = Destiny2;
475475
break;
476476

477-
case 'bnt': // Heroes of the Storm Alpha
478-
case 'hero': // Heroes of the Storm Retail
479-
case 'stor': // Heroes of the Storm (deprecated)
477+
case 0x00626e74: // 'bnt': Heroes of the Storm Alpha
478+
case 0x6865726f: // 'hero': Heroes of the Storm Retail
479+
case 0x73746f72: // 'stor': Heroes of the Storm (deprecated)
480480
hs->szProductName = "Heroes Of The Storm";
481481
hs->Product = HeroesOfTheStorm;
482482
break;
483483

484-
case 'pro':
485-
case 'proc':
486-
case 'prod': // "prodev": Overwatch Dev
487-
case 'proe': // Not on public CDNs
488-
case 'prot': // Overwatch Test
489-
case 'prov': // Overwatch Vendor
490-
case 'prom': // "proms": Overwatch World Cup Viewer
484+
case 0x0070726f: // 'pro':
485+
case 0x70726f63: // 'proc':
486+
case 0x70726f64: // 'prod': "prodev": Overwatch Dev
487+
case 0x70726f65: // 'proe': Not on public CDNs
488+
case 0x70726f74: // 'prot': Overwatch Test
489+
case 0x70726f76: // 'prov': Overwatch Vendor
490+
case 0x70726f6d: // 'prom': "proms": Overwatch World Cup Viewer
491491
hs->szProductName = "Overwatch";
492492
hs->Product = Overwatch;
493493
break;
494494

495-
case 's1': // StarCraft 1
496-
case 's1a': // Starcraft 1 Alpha
497-
case 's1t': // StarCraft 1 Test
495+
case 0x00007331: // 's1': StarCraft 1
496+
case 0x00733161: // 's1a': Starcraft 1 Alpha
497+
case 0x00733174: // 's1t': StarCraft 1 Test
498498
hs->szProductName = "Starcraft 1";
499499
hs->Product = StarCraft1;
500500
break;
501501

502-
case 's2': // StarCraft 2
503-
case 's2b': // Starcraft 2 Beta
504-
case 's2t': // StarCraft 2 Test
505-
case 'sc2': // StarCraft 2 (deprecated)
502+
case 0x00007332: // 's2': StarCraft 2
503+
case 0x00733262: // 's2b': Starcraft 2 Beta
504+
case 0x00733274: // 's2t': StarCraft 2 Test
505+
case 0x00736332: // 'sc2': StarCraft 2 (deprecated)
506506
hs->szProductName = "Starcraft 2";
507507
hs->Product = StarCraft2;
508508
break;
509509

510-
case 'vipe': // "viper", "viperdev", "viperv1": Call of Duty Black Ops 4
510+
case 0x76697065: // "viper", "viperdev", "viperv1": Call of Duty Black Ops 4
511511
hs->szProductName = "Call Of Duty Black Ops 4";
512512
hs->Product = CallOfDutyBlackOps4;
513513
break;
514514

515-
case 'w3': // Warcraft III
516-
case 'w3t': // Warcraft III Public Test
517-
case 'war3': // Warcraft III (old)
515+
case 0x00007733: // 'w3': Warcraft III
516+
case 0x00773374: // 'w3t': Warcraft III Public Test
517+
case 0x77617233: // 'war3': Warcraft III (old)
518518
hs->szProductName = "WarCraft 3";
519519
hs->Product = WarCraft3;
520520
break;
521521

522-
case 'wow': // World of Warcraft
523-
case 'wow_': // "wow_beta", "wow_classic", "wow_classic_beta"
524-
case 'wowd': // "wowdev", "wowdemo"
525-
case 'wowe': // "wowe1", "wowe3", "wowe3",
526-
case 'wowt': // World of Warcraft Test
527-
case 'wowv': // World of Warcraft Vendor
528-
case 'wowz': // World of Warcraft Submission (previously Vendor)
522+
case 0x00776f77: // 'wow': World of Warcraft
523+
case 0x776f775f: // "wow_beta", "wow_classic", "wow_classic_beta"
524+
case 0x776f7764: // "wowdev", "wowdemo"
525+
case 0x776f7765: // "wowe1", "wowe3", "wowe3"
526+
case 0x776f7774: // 'wowt': World of Warcraft Test
527+
case 0x776f7776: // 'wowv': World of Warcraft Vendor
528+
case 0x776f777a: // 'wowz': World of Warcraft Submission (previously Vendor)
529529
hs->szProductName = "World Of Warcraft";
530530
hs->Product = WorldOfWarcraft;
531531
break;

src/CascOpenStorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ static int LoadIndexFile_V2(TCascStorage * hs, CASC_INDEX_HEADER & InHeader, LPB
567567
return nError;
568568
}
569569

570-
static int LoadIndexFile(TCascStorage * hs, LPBYTE pbFileData, ULONG cbFileData, DWORD BucketIndex)
570+
static int LoadIndexFile(TCascStorage * hs, LPBYTE pbFileData, DWORD cbFileData, DWORD BucketIndex)
571571
{
572572
CASC_INDEX_HEADER InHeader;
573573

@@ -587,7 +587,7 @@ static int LoadIndexFile(TCascStorage * hs, LPBYTE pbFileData, ULONG cbFileData,
587587
static int LoadIndexFile(TCascStorage * hs, const TCHAR * szFileName, DWORD BucketIndex)
588588
{
589589
LPBYTE pbFileData;
590-
ULONG cbFileData;
590+
DWORD cbFileData;
591591
int nError = ERROR_SUCCESS;
592592

593593
// WoW6 actually reads THE ENTIRE file to memory. Verified on Mac build (x64).

src/CascPort.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
#define _stprintf sprintf
197197
#define _tremove remove
198198
#define _tmkdir mkdir
199+
#define _access access
199200

200201
#define _stricmp strcasecmp
201202
#define _strnicmp strncasecmp
@@ -242,6 +243,10 @@
242243
#define ERROR_FILE_OFFLINE 1007 // The file is not available in the local storage
243244
#endif
244245

246+
#ifndef _countof
247+
#define _countof(x) (sizeof(x) / sizeof(x[0]))
248+
#endif
249+
245250
//-----------------------------------------------------------------------------
246251
// Swapping functions
247252

src/CascReadFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static int EnsureDataStreamIsOpen(TCascFile * hf)
3737
// Open the data stream with write access and sharing for read+write
3838
// to prevent Battle.net Agent detecting a corruption and redownloading the entire package
3939
// pStream = FileStream_OpenFile(szDataFile, STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_FLAT | STREAM_FLAG_FILL_MISSING | BASE_PROVIDER_FILE);
40-
pStream = FileStream_OpenFile(szDataFile, STREAM_FLAG_WRITE_SHARE | STREAM_PROVIDER_FLAT | STREAM_FLAG_FILL_MISSING | BASE_PROVIDER_FILE);
40+
pStream = FileStream_OpenFile(szDataFile, STREAM_FLAG_READ_ONLY | STREAM_FLAG_WRITE_SHARE | STREAM_PROVIDER_FLAT | STREAM_FLAG_FILL_MISSING | BASE_PROVIDER_FILE);
4141
hs->DataFiles[hf->ArchiveIndex] = pStream;
4242
CASC_FREE(szDataFile);
4343
}

test/CascTest.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
#define _CRT_SECURE_NO_DEPRECATE
1313
#define __INCLUDE_CRYPTOGRAPHY__
1414
#define __CASCLIB_SELF__ // Don't use CascLib.lib
15-
#include <io.h>
1615
#include <stdio.h>
1716
#include <time.h>
1817

1918
#ifdef _MSC_VER
19+
#include <io.h>
2020
#include <crtdbg.h>
2121
#endif
2222

@@ -41,7 +41,7 @@
4141
#endif
4242

4343
#ifdef PLATFORM_LINUX
44-
#define CASC_PATH_ROOT "/home/ladik/MPQs"
44+
#define CASC_PATH_ROOT "/mnt/casc"
4545
#endif
4646

4747
#ifdef PLATFORM_MAC
@@ -158,35 +158,36 @@ static void MakeShortName(const char * szFileName, DWORD dwOpenFlags, char * szS
158158
}
159159
}
160160

161+
static TCHAR * CopyPath(TCHAR * szBuffer, TCHAR * szBufferEnd, const char * szSource)
162+
{
163+
while(szBuffer < szBufferEnd && szSource[0] != 0)
164+
{
165+
if(szSource[0] == '\\' || szSource[0] == '/')
166+
*szBuffer++ = PATH_SEP_CHAR;
167+
else
168+
*szBuffer++ = szSource[0];
169+
170+
szSource++;
171+
}
172+
173+
szBuffer[0] = 0;
174+
return szBuffer;
175+
}
176+
161177
static TCHAR * MakeFullPath(const char * szStorage, TCHAR * szBuffer, size_t ccBuffer)
162178
{
163179
TCHAR * szBufferEnd = szBuffer + ccBuffer - 1;
164180
const char * szPathRoot = CASC_PATH_ROOT;
165181

166-
// If we can access the file directly, use the path as-is
167-
if(_access(szStorage, 0) != -1)
182+
// If we can not access the folder directly, we copy the path root
183+
if(_access(szStorage, 0) == -1)
168184
{
169-
while(szStorage[0] != 0 && szBuffer < szBufferEnd)
170-
*szBuffer++ = *szStorage++;
185+
szBuffer = CopyPath(szBuffer, szBufferEnd, szPathRoot);
186+
szBuffer = CopyPath(szBuffer, szBufferEnd, PATH_SEP_STRING);
171187
}
172-
else
173-
{
174-
// Copy the path prefix
175-
while(szBuffer < szBufferEnd && szPathRoot[0] != 0)
176-
*szBuffer++ = *szPathRoot++;
177-
178-
// Append the separator
179-
if(szBuffer < szBufferEnd)
180-
*szBuffer++ = PATH_SEP_CHAR;
181-
182-
// Append the rest
183-
while(szBuffer < szBufferEnd && szStorage[0] != 0)
184-
*szBuffer++ = *szStorage++;
185-
}
186-
187-
// Append zero and exit
188-
szBuffer[0] = 0;
189-
return szBuffer;
188+
189+
// Copy the rest of the path
190+
return CopyPath(szBuffer, szBufferEnd, szStorage);
190191
}
191192

192193
static int ForceCreatePath(TCHAR * szFullPath)

test/TLogHelper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class TLogHelper
215215

216216
void PrintTotalTime()
217217
{
218-
ULONG TotalTime = SetEndTime();
218+
DWORD TotalTime = SetEndTime();
219219

220220
if(TotalTime != 0)
221221
{
@@ -265,10 +265,10 @@ class TLogHelper
265265
StartTime = GetCurrentThreadTime();
266266
}
267267

268-
ULONG SetEndTime()
268+
DWORD SetEndTime()
269269
{
270270
EndTime = GetCurrentThreadTime();
271-
return (ULONG)(EndTime - StartTime);
271+
return (DWORD)(EndTime - StartTime);
272272
}
273273

274274
void FormatTotalBytes(char * szBuffer, size_t ccBuffer)
@@ -283,12 +283,12 @@ class TLogHelper
283283
// Are we already dividing?
284284
if(bDividingOn)
285285
{
286-
szBuffer += sprintf(szBuffer, " %03u", (ULONG)(Bytes / Divider));
286+
szBuffer += sprintf(szBuffer, " %03u", (DWORD)(Bytes / Divider));
287287
Bytes = Bytes % Divider;
288288
}
289289
else if(Bytes > Divider)
290290
{
291-
szBuffer += sprintf(szBuffer, "%u", (ULONG)(Bytes / Divider));
291+
szBuffer += sprintf(szBuffer, "%u", (DWORD)(Bytes / Divider));
292292
Bytes = Bytes % Divider;
293293
bDividingOn = true;
294294
}

0 commit comments

Comments
 (0)