+ Fixed bug in Windows 8

+ Minors
This commit is contained in:
Ladislav
2013-09-01 08:33:13 +02:00
parent 8207b80371
commit 1e1e441c5e
6 changed files with 45 additions and 17 deletions

View File

@@ -16,6 +16,7 @@ zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\Info.plist
zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\*.bat
zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\*.sln
zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\*.vcproj
zip.exe -u9 ..\WWW\web\download\stormlib.zip StormLib\*.vcxproj
echo.
echo Press any key to exit ...

View File

@@ -16,6 +16,7 @@ zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\Info.plist
zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\*.bat
zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\*.sln
zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\*.vcproj
zip.exe -u9 ..\WWW\web\download\stormlib_beta.zip StormLib\*.vcxproj
echo.
echo Press any key to exit ...

View File

@@ -465,7 +465,7 @@ static bool BaseFile_Open(
#ifdef PLATFORM_WINDOWS
{
ULARGE_INTEGER FileSize;
DWORD dwWriteAccess = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? 0 : GENERIC_ALL;
DWORD dwWriteAccess = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? 0 : GENERIC_READ | GENERIC_WRITE;
DWORD dwWriteShare = (dwStreamFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0;
// Open the file

View File

@@ -236,6 +236,7 @@ static void Compress_PKLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu
{
TDataInfo Info; // Data information
char * work_buf = STORM_ALLOC(char, CMP_BUFFER_SIZE);// Pklib's work buffer
// char * work_buf = (char *)malloc(CMP_BUFFER_SIZE); // Pklib's work buffer
unsigned int dict_size; // Dictionary size
unsigned int ctype = CMP_BINARY; // Compression type
@@ -253,8 +254,8 @@ static void Compress_PKLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu
//
// Set the dictionary size
//
// Diablo I ues fixed dictionary size of CMP_IMPLODE_DICT_SIZE3
// Starcraft uses the variable dictionary size based on algorithm below
// Diablo I uses fixed dictionary size of CMP_IMPLODE_DICT_SIZE3
// Starcraft I uses the variable dictionary size based on algorithm below
//
if (cbInBuffer < 0x600)

View File

@@ -1270,7 +1270,8 @@ bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileC
{
TMPQArchive * ha = (TMPQArchive *) hMpq;
if (!IsValidMpqHandle(ha)) {
if (!IsValidMpqHandle(ha))
{
SetLastError(ERROR_INVALID_HANDLE);
return false;
}

View File

@@ -875,23 +875,47 @@ static int CompareHuffmanCompressions0()
//-----------------------------------------------------------------------------
// Compare PKLIB decompression
FILE * data_file;
BYTE pbCompressed1[] = {0x00, 0x04, 0x00, 0x00, 0x04, 0xF0, 0x1F, 0x7B, 0x01, 0xFF};
BYTE pbCompressed2[] = {0x00, 0x04, 0x00, 0x00, 0x04, 0xF0, 0x1F, 0x00, 0x00, 0x04, 0xFC, 0x03};
static int ComparePklibCompressions()
{
char Decompressed[0x1000];
char Compressed[0x1000];
int cbDecompressed = 0x208;
int cbCompressed = sizeof(Compressed);
TFileStream * pStream;
ULONGLONG ByteOffset = 0;
ULONGLONG FileSize = 0;
unsigned char * pbRawData;
unsigned char * pbCompressed;
unsigned char * pbDecompressed;
int cbOutBuffer;
int cbInBuffer;
memset(Decompressed, 0, cbDecompressed);
SCompImplode(Compressed, &cbCompressed, Decompressed, cbDecompressed);
cbDecompressed = sizeof(Decompressed);
SCompExplode(Decompressed, &cbDecompressed, Compressed, cbCompressed);
pStream = FileStream_OpenFile(_T("doc\\data_to_compress.dat"), BASE_PROVIDER_FILE | STREAM_PROVIDER_LINEAR);
if(pStream != NULL)
{
FileStream_GetSize(pStream, &FileSize);
cbOutBuffer = (int)FileSize;
pbRawData = new unsigned char[cbOutBuffer];
pbCompressed = new unsigned char[cbOutBuffer];
pbDecompressed = new unsigned char[cbOutBuffer];
if(pbRawData && pbCompressed && pbDecompressed)
{
FileStream_Read(pStream, &ByteOffset, pbRawData, (DWORD)FileSize);
SCompImplode(pbCompressed, &cbOutBuffer, pbRawData, (DWORD)FileSize);
cbInBuffer = cbOutBuffer;
cbOutBuffer = (int)FileSize;
SCompExplode(pbDecompressed, &cbOutBuffer, pbCompressed, cbInBuffer);
}
delete [] pbDecompressed;
delete [] pbCompressed;
delete [] pbRawData;
FileStream_Close(pStream);
}
return ERROR_SUCCESS;
}
@@ -2177,8 +2201,8 @@ int main(void)
// nError = CompareHuffmanCompressions0();
// }
// if(nError == ERROR_SUCCESS)
// nError = ComparePklibCompressions();
if(nError == ERROR_SUCCESS)
nError = ComparePklibCompressions();
// Test LZMA compression method against the code ripped from Starcraft II
// if(nError == ERROR_SUCCESS)
@@ -2189,8 +2213,8 @@ int main(void)
// nError = TestSectorCompress(MPQ_SECTOR_SIZE);
// Test the archive open and close
if(nError == ERROR_SUCCESS)
nError = TestArchiveOpenAndClose(MAKE_PATH("Battle.net.MPQ"));
// if(nError == ERROR_SUCCESS)
// nError = TestArchiveOpenAndClose(MAKE_PATH("Battle.net.MPQ"));
// if(nError == ERROR_SUCCESS)
// nError = TestFindFiles(MAKE_PATH("2002 - Warcraft III/HumanEd.mpq"));