aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SFileOpenArchive.cpp31
-rw-r--r--src/StormCommon.h1
-rw-r--r--src/adpcm/adpcm.cpp4
3 files changed, 19 insertions, 17 deletions
diff --git a/src/SFileOpenArchive.cpp b/src/SFileOpenArchive.cpp
index 8c3cc13..b85f24c 100644
--- a/src/SFileOpenArchive.cpp
+++ b/src/SFileOpenArchive.cpp
@@ -22,7 +22,7 @@
//-----------------------------------------------------------------------------
// Local functions
-static MTYPE CheckMapType(ULONGLONG FileSize, LPCTSTR szFileName, LPBYTE pbHeaderBuffer, size_t cbHeaderBuffer)
+static MTYPE CheckMapType(LPCTSTR szFileName, LPBYTE pbHeaderBuffer, size_t cbHeaderBuffer)
{
LPDWORD HeaderInt32 = (LPDWORD)pbHeaderBuffer;
LPCTSTR szExtension;
@@ -35,15 +35,6 @@ static MTYPE CheckMapType(ULONGLONG FileSize, LPCTSTR szFileName, LPBYTE pbHeade
DWORD DwordValue2 = BSWAP_INT32_UNSIGNED(HeaderInt32[2]);
DWORD DwordValue3 = BSWAP_INT32_UNSIGNED(HeaderInt32[3]);
- // Check possible MPQs from Starcraft I BETA. We recognize them by checking the file size.
- // 167 859: patch_rt.mpq (doesn't contain any WAVE files)
- // 55 674 173: StarDat.mpq
- // 183 519 584: Install.exe
- if(FileSize == 55674173 && DwordValue1 == MPQ_HEADER_SIZE_V1 && DwordValue3 == 0x00030000)
- return MapTypeStarcraftBeta;
- if(FileSize == 183519584 && DwordValue0 == 0x00905a4D && DwordValue1 == 3 && DwordValue2 == 4)
- return MapTypeStarcraftBeta;
-
// Check maps by extension (Starcraft, Starcraft II). We must do this before
// checking actual data, because the "NP_Protect" protector places
// fake Warcraft III header into the Starcraft II maps
@@ -84,6 +75,20 @@ static MTYPE CheckMapType(ULONGLONG FileSize, LPCTSTR szFileName, LPBYTE pbHeade
return MapTypeNotRecognized;
}
+static bool IsStarcraftBetaArchive(TMPQHeader * pHeader)
+{
+ // The archive must be version 1, with a standard header size
+ if(pHeader->dwID == ID_MPQ && pHeader->dwHeaderSize == MPQ_HEADER_SIZE_V1)
+ {
+ // Check for known archive sizes
+ return (pHeader->dwArchiveSize == 0x00028FB3 || // patch_rt.mpq
+ pHeader->dwArchiveSize == 0x0351853D || // StarDat.mpq
+ pHeader->dwArchiveSize == 0x0AEC8960); // INSTALL.exe
+
+ }
+ return false;
+}
+
static TMPQUserData * IsValidMpqUserData(ULONGLONG ByteOffset, ULONGLONG FileSize, void * pvUserData)
{
TMPQUserData * pUserData;
@@ -330,7 +335,7 @@ bool WINAPI SFileOpenArchive(
if(MapType == MapTypeNotChecked)
{
// Do nothing if the file is an AVI file
- if((MapType = CheckMapType(FileSize, szMpqName, pbHeaderBuffer, dwBytesAvailable)) == MapTypeAviFile)
+ if((MapType = CheckMapType(szMpqName, pbHeaderBuffer, dwBytesAvailable)) == MapTypeAviFile)
{
dwErrCode = ERROR_AVI_FILE;
break;
@@ -456,10 +461,8 @@ bool WINAPI SFileOpenArchive(
ha->dwFlags |= MPQ_FLAG_LISTFILE_FORCE;
// StarDat.mpq from Starcraft I BETA: Enable special compression types
- if(MapType == MapTypeStarcraftBeta)
- {
+ if(IsStarcraftBetaArchive(ha->pHeader))
ha->dwFlags |= MPQ_FLAG_STARCRAFT_BETA;
- }
// Remember whether whis is a map for Warcraft III
if(MapType == MapTypeWarcraft3)
diff --git a/src/StormCommon.h b/src/StormCommon.h
index d1d7abe..865d975 100644
--- a/src/StormCommon.h
+++ b/src/StormCommon.h
@@ -80,7 +80,6 @@ typedef enum _MTYPE
{
MapTypeNotChecked, // The map type was not checked yet
MapTypeNotRecognized, // The file does not seems to be a map
- MapTypeStarcraftBeta, // The file is StarDat.mpq from Starcraft I BETA
MapTypeAviFile, // The file is actually an AVI file (Warcraft III cinematics)
MapTypeStarcraft, // The file is a Starcraft map
MapTypeWarcraft3, // The file is a Warcraft III map
diff --git a/src/adpcm/adpcm.cpp b/src/adpcm/adpcm.cpp
index 60e6738..1725008 100644
--- a/src/adpcm/adpcm.cpp
+++ b/src/adpcm/adpcm.cpp
@@ -387,7 +387,7 @@ int DecompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int
typedef struct _ADPCM_DATA
{
- unsigned int * pValues;
+ const unsigned int * pValues;
int BitCount;
int field_8;
int field_C;
@@ -404,7 +404,7 @@ static const unsigned int adpcm_values_6[] =
0x46, 0x53, 0x60, 0x6D, 0x7A, 0x86, 0x93, 0xA0, 0xAD, 0xBA, 0xC6, 0xD3, 0xE0, 0xED, 0xFA, 0x106
};
-static unsigned int * InitAdpcmData(PADPCM_DATA pData, unsigned char BitCount)
+static const unsigned int * InitAdpcmData(PADPCM_DATA pData, unsigned char BitCount)
{
switch(BitCount)
{