Skip to content

Commit

Permalink
Linux Build
Browse files Browse the repository at this point in the history
  • Loading branch information
Zezula Ladislav committed May 17, 2019
1 parent fb11979 commit f1c5ea8
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/CascCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ LPBYTE LoadExternalFileToMemory(const TCHAR * szFileName, DWORD * pcbFileData)
{
CASC_FREE(pbFileData);
pbFileData = NULL;
cbFileData = NULL;
cbFileData = 0;
}
}
else
Expand Down
13 changes: 0 additions & 13 deletions src/CascCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@
//-----------------------------------------------------------------------------
// CascLib private defines

#define CASC_GAME_HOTS 0x00010000 // Heroes of the Storm
#define CASC_GAME_WOW6 0x00020000 // World of Warcraft - Warlords of Draenor
#define CASC_GAME_DIABLO3 0x00030000 // Diablo 3 since PTR 2.2.0
#define CASC_GAME_OVERWATCH 0x00040000 // Overwatch since PTR 24919
#define CASC_GAME_STARCRAFT2 0x00050000 // Starcraft II - Legacy of the Void, since build 38996
#define CASC_GAME_STARCRAFT1 0x00060000 // Starcraft 1 (remastered)
#define CASC_GAME_WARCRAFT3 0x00070000 // Warcraft III, since version 1.30, build 9655
#define CASC_GAME_MASK 0xFFFF0000 // Mask for getting game ID

#define CASC_EXTRA_FILES 0x20 // Number of extra entries to be reserved for additionally inserted files

#define CASC_PACKAGE_BUFFER 0x1000

#ifdef _DEBUG
#define BREAK_ON_XKEY3(CKey, v0, v1, v2) if(CKey[0] == v0 && CKey[1] == v1 && CKey[2] == v2) { __debugbreak(); }
#define BREAKIF(condition) if(condition) { __debugbreak(); }
Expand Down
66 changes: 33 additions & 33 deletions src/CascFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,71 +461,71 @@ static int LoadBuildProductId(TCascStorage * hs, const char * /* szVariableName
// Product-specific. See https://wowdev.wiki/TACT#Products
switch(dwBuildUid)
{
case 'd3':
case 'd3b': // Diablo 3 Beta (2013)
case 'd3cn': // Diablo 3 China
case 'd3t': // Diablo 3 Test
case 0x00006433: // 'd3'
case 0x00643364: // 'd3b': Diablo 3 Beta (2013)
case 0x6433636e: // 'd3cn': Diablo 3 China
case 0x00643374: // 'd3t': Diablo 3 Test
hs->szProductName = "Diablo 3";
hs->Product = Diablo3;
break;

case 'dst2':
case 0x64737432: // 'dst2':
hs->szProductName = "Destiny 2";
hs->Product = Destiny2;
break;

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

case 'pro':
case 'proc':
case 'prod': // "prodev": Overwatch Dev
case 'proe': // Not on public CDNs
case 'prot': // Overwatch Test
case 'prov': // Overwatch Vendor
case 'prom': // "proms": Overwatch World Cup Viewer
case 0x0070726f: // 'pro':
case 0x70726f63: // 'proc':
case 0x70726f64: // 'prod': "prodev": Overwatch Dev
case 0x70726f65: // 'proe': Not on public CDNs
case 0x70726f74: // 'prot': Overwatch Test
case 0x70726f76: // 'prov': Overwatch Vendor
case 0x70726f6d: // 'prom': "proms": Overwatch World Cup Viewer
hs->szProductName = "Overwatch";
hs->Product = Overwatch;
break;

case 's1': // StarCraft 1
case 's1a': // Starcraft 1 Alpha
case 's1t': // StarCraft 1 Test
case 0x00007331: // 's1': StarCraft 1
case 0x00733161: // 's1a': Starcraft 1 Alpha
case 0x00733174: // 's1t': StarCraft 1 Test
hs->szProductName = "Starcraft 1";
hs->Product = StarCraft1;
break;

case 's2': // StarCraft 2
case 's2b': // Starcraft 2 Beta
case 's2t': // StarCraft 2 Test
case 'sc2': // StarCraft 2 (deprecated)
case 0x00007332: // 's2': StarCraft 2
case 0x00733262: // 's2b': Starcraft 2 Beta
case 0x00733274: // 's2t': StarCraft 2 Test
case 0x00736332: // 'sc2': StarCraft 2 (deprecated)
hs->szProductName = "Starcraft 2";
hs->Product = StarCraft2;
break;

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

case 'w3': // Warcraft III
case 'w3t': // Warcraft III Public Test
case 'war3': // Warcraft III (old)
case 0x00007733: // 'w3': Warcraft III
case 0x00773374: // 'w3t': Warcraft III Public Test
case 0x77617233: // 'war3': Warcraft III (old)
hs->szProductName = "WarCraft 3";
hs->Product = WarCraft3;
break;

case 'wow': // World of Warcraft
case 'wow_': // "wow_beta", "wow_classic", "wow_classic_beta"
case 'wowd': // "wowdev", "wowdemo"
case 'wowe': // "wowe1", "wowe3", "wowe3",
case 'wowt': // World of Warcraft Test
case 'wowv': // World of Warcraft Vendor
case 'wowz': // World of Warcraft Submission (previously Vendor)
case 0x00776f77: // 'wow': World of Warcraft
case 0x776f775f: // "wow_beta", "wow_classic", "wow_classic_beta"
case 0x776f7764: // "wowdev", "wowdemo"
case 0x776f7765: // "wowe1", "wowe3", "wowe3"
case 0x776f7774: // 'wowt': World of Warcraft Test
case 0x776f7776: // 'wowv': World of Warcraft Vendor
case 0x776f777a: // 'wowz': World of Warcraft Submission (previously Vendor)
hs->szProductName = "World Of Warcraft";
hs->Product = WorldOfWarcraft;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/CascOpenStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static int LoadIndexFile_V2(TCascStorage * hs, CASC_INDEX_HEADER & InHeader, LPB
return nError;
}

static int LoadIndexFile(TCascStorage * hs, LPBYTE pbFileData, ULONG cbFileData, DWORD BucketIndex)
static int LoadIndexFile(TCascStorage * hs, LPBYTE pbFileData, DWORD cbFileData, DWORD BucketIndex)
{
CASC_INDEX_HEADER InHeader;

Expand All @@ -587,7 +587,7 @@ static int LoadIndexFile(TCascStorage * hs, LPBYTE pbFileData, ULONG cbFileData,
static int LoadIndexFile(TCascStorage * hs, const TCHAR * szFileName, DWORD BucketIndex)
{
LPBYTE pbFileData;
ULONG cbFileData;
DWORD cbFileData;
int nError = ERROR_SUCCESS;

// WoW6 actually reads THE ENTIRE file to memory. Verified on Mac build (x64).
Expand Down
5 changes: 5 additions & 0 deletions src/CascPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
#define _stprintf sprintf
#define _tremove remove
#define _tmkdir mkdir
#define _access access

#define _stricmp strcasecmp
#define _strnicmp strncasecmp
Expand Down Expand Up @@ -242,6 +243,10 @@
#define ERROR_FILE_OFFLINE 1007 // The file is not available in the local storage
#endif

#ifndef _countof
#define _countof(x) (sizeof(x) / sizeof(x[0]))
#endif

//-----------------------------------------------------------------------------
// Swapping functions

Expand Down
2 changes: 1 addition & 1 deletion src/CascReadFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int EnsureDataStreamIsOpen(TCascFile * hf)
// Open the data stream with write access and sharing for read+write
// to prevent Battle.net Agent detecting a corruption and redownloading the entire package
// pStream = FileStream_OpenFile(szDataFile, STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_FLAT | STREAM_FLAG_FILL_MISSING | BASE_PROVIDER_FILE);
pStream = FileStream_OpenFile(szDataFile, STREAM_FLAG_WRITE_SHARE | STREAM_PROVIDER_FLAT | STREAM_FLAG_FILL_MISSING | BASE_PROVIDER_FILE);
pStream = FileStream_OpenFile(szDataFile, STREAM_FLAG_READ_ONLY | STREAM_FLAG_WRITE_SHARE | STREAM_PROVIDER_FLAT | STREAM_FLAG_FILL_MISSING | BASE_PROVIDER_FILE);
hs->DataFiles[hf->ArchiveIndex] = pStream;
CASC_FREE(szDataFile);
}
Expand Down
49 changes: 25 additions & 24 deletions test/CascTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#define _CRT_SECURE_NO_DEPRECATE
#define __INCLUDE_CRYPTOGRAPHY__
#define __CASCLIB_SELF__ // Don't use CascLib.lib
#include <io.h>
#include <stdio.h>
#include <time.h>

#ifdef _MSC_VER
#include <io.h>
#include <crtdbg.h>
#endif

Expand All @@ -41,7 +41,7 @@
#endif

#ifdef PLATFORM_LINUX
#define CASC_PATH_ROOT "/home/ladik/MPQs"
#define CASC_PATH_ROOT "/mnt/casc"
#endif

#ifdef PLATFORM_MAC
Expand Down Expand Up @@ -158,35 +158,36 @@ static void MakeShortName(const char * szFileName, DWORD dwOpenFlags, char * szS
}
}

static TCHAR * CopyPath(TCHAR * szBuffer, TCHAR * szBufferEnd, const char * szSource)
{
while(szBuffer < szBufferEnd && szSource[0] != 0)
{
if(szSource[0] == '\\' || szSource[0] == '/')
*szBuffer++ = PATH_SEP_CHAR;
else
*szBuffer++ = szSource[0];

szSource++;
}

szBuffer[0] = 0;
return szBuffer;
}

static TCHAR * MakeFullPath(const char * szStorage, TCHAR * szBuffer, size_t ccBuffer)
{
TCHAR * szBufferEnd = szBuffer + ccBuffer - 1;
const char * szPathRoot = CASC_PATH_ROOT;

// If we can access the file directly, use the path as-is
if(_access(szStorage, 0) != -1)
// If we can not access the folder directly, we copy the path root
if(_access(szStorage, 0) == -1)
{
while(szStorage[0] != 0 && szBuffer < szBufferEnd)
*szBuffer++ = *szStorage++;
szBuffer = CopyPath(szBuffer, szBufferEnd, szPathRoot);
szBuffer = CopyPath(szBuffer, szBufferEnd, PATH_SEP_STRING);
}
else
{
// Copy the path prefix
while(szBuffer < szBufferEnd && szPathRoot[0] != 0)
*szBuffer++ = *szPathRoot++;

// Append the separator
if(szBuffer < szBufferEnd)
*szBuffer++ = PATH_SEP_CHAR;

// Append the rest
while(szBuffer < szBufferEnd && szStorage[0] != 0)
*szBuffer++ = *szStorage++;
}

// Append zero and exit
szBuffer[0] = 0;
return szBuffer;

// Copy the rest of the path
return CopyPath(szBuffer, szBufferEnd, szStorage);
}

static int ForceCreatePath(TCHAR * szFullPath)
Expand Down
10 changes: 5 additions & 5 deletions test/TLogHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class TLogHelper

void PrintTotalTime()
{
ULONG TotalTime = SetEndTime();
DWORD TotalTime = SetEndTime();

if(TotalTime != 0)
{
Expand Down Expand Up @@ -265,10 +265,10 @@ class TLogHelper
StartTime = GetCurrentThreadTime();
}

ULONG SetEndTime()
DWORD SetEndTime()
{
EndTime = GetCurrentThreadTime();
return (ULONG)(EndTime - StartTime);
return (DWORD)(EndTime - StartTime);
}

void FormatTotalBytes(char * szBuffer, size_t ccBuffer)
Expand All @@ -283,12 +283,12 @@ class TLogHelper
// Are we already dividing?
if(bDividingOn)
{
szBuffer += sprintf(szBuffer, " %03u", (ULONG)(Bytes / Divider));
szBuffer += sprintf(szBuffer, " %03u", (DWORD)(Bytes / Divider));
Bytes = Bytes % Divider;
}
else if(Bytes > Divider)
{
szBuffer += sprintf(szBuffer, "%u", (ULONG)(Bytes / Divider));
szBuffer += sprintf(szBuffer, "%u", (DWORD)(Bytes / Divider));
Bytes = Bytes % Divider;
bDividingOn = true;
}
Expand Down

0 comments on commit f1c5ea8

Please sign in to comment.