aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2021-12-18 07:24:46 +0100
committerGitHub <noreply@github.com>2021-12-18 07:24:46 +0100
commite29888e48a41879dba68e690a675324097802270 (patch)
treeac0102cb6c3b58e8eb4fe8d9132a2355b3394855
parent5ced3835f9d52584bc20fb6a3a0e58069374e9af (diff)
parente7af34bcfb5cba3c1ff6ac1b2ebd8c4ba47f1df4 (diff)
Merge pull request #232 from ladislav-zezula/LZ_CannotExtractCHK
Update for protected Starcraft I maps
-rw-r--r--PostBuild.bat34
-rw-r--r--StormLib_vs08.vcproj32
-rw-r--r--StormLib_vs19.vcxproj66
-rw-r--r--StormLib_vs19_dll.vcxproj12
-rw-r--r--StormLib_vs19_test.vcxproj12
-rw-r--r--make-msvc.bat28
-rw-r--r--make.bat8
-rw-r--r--src/SBaseCommon.cpp5
-rw-r--r--src/SBaseFileTable.cpp12
-rw-r--r--src/SFileAddFile.cpp2
-rw-r--r--src/SFileCreateArchive.cpp29
-rw-r--r--src/SFileFindFile.cpp4
-rw-r--r--src/SFileOpenArchive.cpp31
-rw-r--r--src/SFileReadFile.cpp10
-rw-r--r--src/StormCommon.h1
-rw-r--r--src/StormLib.h11
-rw-r--r--test/StormTest.cpp50
-rw-r--r--test/TLogHelper.cpp4
18 files changed, 202 insertions, 149 deletions
diff --git a/PostBuild.bat b/PostBuild.bat
deleted file mode 100644
index c2d2534..0000000
--- a/PostBuild.bat
+++ /dev/null
@@ -1,34 +0,0 @@
-@echo off
-rem Post-build batch for StormLib project
-rem Called as PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) [vs2008]
-rem Example: PostBuild.bat StormLib_dll x64 Debug vs2008
-
-rem Select build type
-if "%1" == "StormLib_dll" goto PostBuild_DLL
-if "%1" == "StormLib" goto PostBuild_LIB
-goto:eof
-
-:PostBuild_DLL
-
-rem Build steps for the DLL. On 32-bit Release version, increment the build number
-if not "x%2" == "xWin32" goto:eof
-if not "x%3" == "xRelease" goto:eof
-PostBuild.exe .\src\DllMain.rc
-goto:eof
-
-:PostBuild_LIB
-
-rem Set target folders
-if "x%2" == "xWin32" set TARGET_DIR_LEVEL2=lib32
-if "x%2" == "xx64" set TARGET_DIR_LEVEL2=lib64
-if "x%4" == "xvs2008" set TARGET_DIR_LEVEL3=vs2008
-
-rem Check & create target folder structure
-if not exist ..\aaa goto:eof
-if not exist ..\aaa\%TARGET_DIR_LEVEL2% md ..\aaa\%TARGET_DIR_LEVEL2%
-if not exist ..\aaa\%TARGET_DIR_LEVEL2%\%TARGET_DIR_LEVEL3% md ..\aaa\%TARGET_DIR_LEVEL2%\%TARGET_DIR_LEVEL3%
-
-rem Copy include and LIB files to the target folder
-copy /Y .\src\StormLib.h ..\aaa\inc >nul
-copy /Y .\src\StormPort.h ..\aaa\inc >nul
-copy /Y .\bin\%1\%2\%3\StormLib???.lib ..\aaa\%TARGET_DIR_LEVEL2%\%TARGET_DIR_LEVEL3% >nul
diff --git a/StormLib_vs08.vcproj b/StormLib_vs08.vcproj
index 0c02e13..4f59a1b 100644
--- a/StormLib_vs08.vcproj
+++ b/StormLib_vs08.vcproj
@@ -80,7 +80,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -145,7 +145,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -209,7 +209,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -274,7 +274,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -336,7 +336,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -399,7 +399,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -461,7 +461,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -524,7 +524,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -588,7 +588,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -653,7 +653,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -717,7 +717,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -782,7 +782,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -844,7 +844,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -907,7 +907,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -969,7 +969,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -1032,7 +1032,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="PostBuild.bat $(ProjectName) $(PlatformName) $(ConfigurationName) vs2008"
+ CommandLine=""
/>
</Configuration>
</Configurations>
diff --git a/StormLib_vs19.vcxproj b/StormLib_vs19.vcxproj
index ffcf960..eba3ea2 100644
--- a/StormLib_vs19.vcxproj
+++ b/StormLib_vs19.vcxproj
@@ -73,7 +73,7 @@
<XPDeprecationWarning>false</XPDeprecationWarning>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<ConfigurationType>StaticLibrary</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -269,12 +269,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugAD|x64'">
@@ -289,12 +291,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugAS|Win32'">
@@ -306,12 +310,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugAS|x64'">
@@ -326,12 +332,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseAD|Win32'">
@@ -342,12 +350,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseAD|x64'">
@@ -361,12 +371,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseAS|Win32'">
@@ -377,12 +389,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseAS|x64'">
@@ -396,12 +410,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugUD|Win32'">
@@ -413,12 +429,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugUD|x64'">
@@ -433,12 +451,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugUS|Win32'">
@@ -450,12 +470,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugUS|x64'">
@@ -470,12 +492,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseUD|Win32'">
@@ -486,12 +510,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseUD|x64'">
@@ -505,12 +531,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseUS|Win32'">
@@ -521,12 +549,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseUS|x64'">
@@ -540,12 +570,14 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<OutputFile>./bin/$(ProjectName)/$(Platform)/$(Configuration)/$(TargetName).lib</OutputFile>
</Lib>
<PostBuildEvent>
- <Command>PostBuild.bat $(ProjectName) $(Platform) $(Configuration)</Command>
+ <Command>
+ </Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
diff --git a/StormLib_vs19_dll.vcxproj b/StormLib_vs19_dll.vcxproj
index 712b427..ba888e9 100644
--- a/StormLib_vs19_dll.vcxproj
+++ b/StormLib_vs19_dll.vcxproj
@@ -28,24 +28,24 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -100,6 +100,7 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<OutputFile>$(OutDir)StormLib.dll</OutputFile>
@@ -123,6 +124,7 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<OutputFile>$(OutDir)StormLib.dll</OutputFile>
@@ -141,6 +143,7 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<OutputFile>$(OutDir)StormLib.dll</OutputFile>
@@ -164,6 +167,7 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<OutputFile>$(OutDir)StormLib.dll</OutputFile>
diff --git a/StormLib_vs19_test.vcxproj b/StormLib_vs19_test.vcxproj
index 3bd8248..d293549 100644
--- a/StormLib_vs19_test.vcxproj
+++ b/StormLib_vs19_test.vcxproj
@@ -28,24 +28,24 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -98,6 +98,7 @@
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -121,6 +122,7 @@
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -138,6 +140,7 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -160,6 +163,7 @@
<PrecompiledHeader />
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
diff --git a/make-msvc.bat b/make-msvc.bat
index 9a2ea8e..099fc19 100644
--- a/make-msvc.bat
+++ b/make-msvc.bat
@@ -21,8 +21,8 @@ if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Professional\VC\Auxil
if exist "%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" set VCVARS_2019=%PROGRAM_FILES_DIR%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
::Build all libraries using Visual Studio 2008 and 2017
-call :BuildLibs "%VCVARS_2008%" x86 %LIB_NAME%_vs08.sln
-call :BuildLibs "%VCVARS_2008%" x64 %LIB_NAME%_vs08.sln
+call :BuildLibs "%VCVARS_2008%" x86 %LIB_NAME%_vs08.sln \vs2008
+call :BuildLibs "%VCVARS_2008%" x64 %LIB_NAME%_vs08.sln \vs2008
call :BuildLibs "%VCVARS_2019%" x86 %LIB_NAME%_vs19.sln
call :BuildLibs "%VCVARS_2019%" x64 %LIB_NAME%_vs19.sln
goto:eof
@@ -35,21 +35,42 @@ goto:eof
:: %1 Full path to the VCVARS.BAT file
:: %2 Target build platform (x86 or x64)
:: %3 Plain name of the /sln solution file
+:: %4 Subdirectory for the target folder of the library ("\vs2008" or "")
::
:BuildLibs
-::set VSCMD_DEBUG=1
call %1 %2
if "%2" == "x86" set SLN_TRG=Win32
+if "%2" == "x86" set LIB_TRG=lib32
if "%2" == "x64" set SLN_TRG=x64
+if "%2" == "x64" set LIB_TRG=lib64
+
+xcopy.exe /Y /D .\src\StormLib.h ..\aaa\inc
+xcopy.exe /Y /D .\src\StormPort.h ..\aaa\inc
+
devenv.com %3 /project "%LIB_NAME%" /rebuild "DebugAD|%SLN_TRG%"
+xcopy.exe /Y /D .\bin\StormLib\%SLN_TRG%\DebugAD\*.lib ..\aaa\%LIB_TRG%%4
+
devenv.com %3 /project "%LIB_NAME%" /rebuild "DebugAS|%SLN_TRG%"
+xcopy.exe /Y /D .\bin\StormLib\%SLN_TRG%\DebugAS\*.lib ..\aaa\%LIB_TRG%%4
+
devenv.com %3 /project "%LIB_NAME%" /rebuild "DebugUD|%SLN_TRG%"
+xcopy.exe /Y /D .\bin\StormLib\%SLN_TRG%\DebugUD\*.lib ..\aaa\%LIB_TRG%%4
+
devenv.com %3 /project "%LIB_NAME%" /rebuild "DebugUS|%SLN_TRG%"
+xcopy.exe /Y /D .\bin\StormLib\%SLN_TRG%\DebugUS\*.lib ..\aaa\%LIB_TRG%%4
+
devenv.com %3 /project "%LIB_NAME%" /rebuild "ReleaseAD|%SLN_TRG%"
+xcopy.exe /Y /D .\bin\StormLib\%SLN_TRG%\ReleaseAD\*.lib ..\aaa\%LIB_TRG%%4
+
devenv.com %3 /project "%LIB_NAME%" /rebuild "ReleaseAS|%SLN_TRG%"
+xcopy.exe /Y /D .\bin\StormLib\%SLN_TRG%\ReleaseAS\*.lib ..\aaa\%LIB_TRG%%4
+
devenv.com %3 /project "%LIB_NAME%" /rebuild "ReleaseUD|%SLN_TRG%"
+xcopy.exe /Y /D .\bin\StormLib\%SLN_TRG%\ReleaseUD\*.lib ..\aaa\%LIB_TRG%%4
+
devenv.com %3 /project "%LIB_NAME%" /rebuild "ReleaseUS|%SLN_TRG%"
+xcopy.exe /Y /D .\bin\StormLib\%SLN_TRG%\ReleaseUS\*.lib ..\aaa\%LIB_TRG%%4
:: Restore environment variables to the old level
set INCLUDE=%SAVE_INCLUDE%
@@ -58,3 +79,4 @@ set PATH=%SAVE_PATH%
set VSINSTALLDIR=
set VCINSTALLDIR=
set DevEnvDir=
+goto:eof
diff --git a/make.bat b/make.bat
index 8765eb5..7b29207 100644
--- a/make.bat
+++ b/make.bat
@@ -35,10 +35,10 @@ del buildfre_wlh_amd64.log
echo.
:COPY_LIBS
-copy /Y .\objfre_wlh_amd64\amd64\%LIBRARY_NAME%.lib ..\aaa\lib64\%LIBRARY_NAME%.lib >nul
-copy /Y .\objfre_w2k_x86\i386\%LIBRARY_NAME%.lib ..\aaa\lib32\%LIBRARY_NAME%.lib >nul
-copy /Y .\src\StormPort.h ..\aaa\inc >nul
-copy /Y .\src\StormLib.h ..\aaa\inc >nul
+xcopy /Y /D .\src\StormLib.h ..\aaa\inc >nul
+xcopy /Y /D .\src\StormPort.h ..\aaa\inc >nul
+xcopy /Y /D .\objfre_w2k_x86\i386\%LIBRARY_NAME%.lib ..\aaa\lib32\%LIBRARY_NAME%.lib >nul
+xcopy /Y /D .\objfre_wlh_amd64\amd64\%LIBRARY_NAME%.lib ..\aaa\lib64\%LIBRARY_NAME%.lib >nul
:CLEANUP
if exist sources-cpp.cpp del sources-cpp.cpp
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp
index a1aa78e..98d541a 100644
--- a/src/SBaseCommon.cpp
+++ b/src/SBaseCommon.cpp
@@ -1334,11 +1334,12 @@ DWORD AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile)
// They are mostly empty on WoW release MPQs, but on MPQs from PTR,
// they contain random non-zero data. Their meaning is unknown.
//
- // These extra values are, however, include in the dwCmpSize in the file
+ // These extra values are, however, included in the dwCmpSize in the file
// table. We cannot ignore them, because compacting archive would fail
//
- if(hf->SectorOffsets[0] > dwSectorOffsLen)
+ // Clear the lower 2 bits in order to make sure that the value is aligned to 4 bytes
+ if((hf->SectorOffsets[0] & 0xFFFFFFFC) > dwSectorOffsLen)
{
// MPQ protectors put some ridiculous values there. We must limit the extra bytes
if(hf->SectorOffsets[0] > (dwSectorOffsLen + 0x400))
diff --git a/src/SBaseFileTable.cpp b/src/SBaseFileTable.cpp
index 7d52f7c..97fa3a2 100644
--- a/src/SBaseFileTable.cpp
+++ b/src/SBaseFileTable.cpp
@@ -893,15 +893,11 @@ static DWORD BuildFileTableFromBlockTable(
TMPQHash * pHash;
LPDWORD DefragmentTable = NULL;
DWORD dwItemCount = 0;
- DWORD dwFlagMask;
// Sanity checks
assert(ha->pFileTable != NULL);
assert(ha->dwFileTableSize >= ha->dwMaxFileCount);
- // MPQs for Warcraft III doesn't know some flags, namely MPQ_FILE_SINGLE_UNIT and MPQ_FILE_PATCH_FILE
- dwFlagMask = (ha->dwFlags & MPQ_FLAG_WAR3_MAP) ? MPQ_FILE_VALID_FLAGS_W3X : MPQ_FILE_VALID_FLAGS;
-
// Defragment the hash table, if needed
if(ha->dwFlags & MPQ_FLAG_HASH_TABLE_CUT)
{
@@ -976,10 +972,12 @@ static DWORD BuildFileTableFromBlockTable(
if(pFileEntry->ByteOffset == 0 && pBlock->dwFSize == 0)
pFileEntry->ByteOffset = ha->pHeader->dwHeaderSize;
+ // Clear file flags that are unknown to this type of map.
+ pFileEntry->dwFlags = pBlock->dwFlags & ha->dwValidFileFlags;
+
// Fill the rest of the file entry
- pFileEntry->dwFileSize = pBlock->dwFSize;
- pFileEntry->dwCmpSize = pBlock->dwCSize;
- pFileEntry->dwFlags = pBlock->dwFlags & dwFlagMask;
+ pFileEntry->dwFileSize = pBlock->dwFSize;
+ pFileEntry->dwCmpSize = pBlock->dwCSize;
}
}
diff --git a/src/SFileAddFile.cpp b/src/SFileAddFile.cpp
index 7b88c12..9c7331b 100644
--- a/src/SFileAddFile.cpp
+++ b/src/SFileAddFile.cpp
@@ -795,7 +795,7 @@ bool WINAPI SFileCreateFile(
if(dwErrCode == ERROR_SUCCESS)
{
// Mask all unsupported flags out
- dwFlags &= (ha->dwFlags & MPQ_FLAG_WAR3_MAP) ? MPQ_FILE_VALID_FLAGS_W3X : MPQ_FILE_VALID_FLAGS;
+ dwFlags &= ha->dwValidFileFlags;
// Check for valid flag combinations
if((dwFlags & (MPQ_FILE_IMPLODE | MPQ_FILE_COMPRESS)) == (MPQ_FILE_IMPLODE | MPQ_FILE_COMPRESS))
diff --git a/src/SFileCreateArchive.cpp b/src/SFileCreateArchive.cpp
index 742b829..4266070 100644
--- a/src/SFileCreateArchive.cpp
+++ b/src/SFileCreateArchive.cpp
@@ -202,20 +202,21 @@ bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCrea
if(dwErrCode == ERROR_SUCCESS)
{
memset(ha, 0, sizeof(TMPQArchive));
- ha->pfnHashString = HashStringSlash;
- ha->pStream = pStream;
- ha->dwSectorSize = pCreateInfo->dwSectorSize;
- ha->UserDataPos = MpqPos;
- ha->MpqPos = MpqPos;
- ha->pHeader = pHeader = (TMPQHeader *)ha->HeaderData;
- ha->dwMaxFileCount = dwHashTableSize;
- ha->dwFileTableSize = 0;
- ha->dwReservedFiles = dwReservedFiles;
- ha->dwFileFlags1 = pCreateInfo->dwFileFlags1;
- ha->dwFileFlags2 = pCreateInfo->dwFileFlags2;
- ha->dwFileFlags3 = pCreateInfo->dwFileFlags3 ? MPQ_FILE_EXISTS : 0;
- ha->dwAttrFlags = pCreateInfo->dwAttrFlags;
- ha->dwFlags = dwMpqFlags | MPQ_FLAG_CHANGED;
+ ha->pfnHashString = HashStringSlash;
+ ha->pStream = pStream;
+ ha->dwSectorSize = pCreateInfo->dwSectorSize;
+ ha->UserDataPos = MpqPos;
+ ha->MpqPos = MpqPos;
+ ha->pHeader = pHeader = (TMPQHeader *)ha->HeaderData;
+ ha->dwMaxFileCount = dwHashTableSize;
+ ha->dwFileTableSize = 0;
+ ha->dwReservedFiles = dwReservedFiles;
+ ha->dwValidFileFlags = (pCreateInfo->dwMpqVersion > 1) ? MPQ_FILE_VALID_FLAGS : MPQ_FILE_VALID_FLAGS_W3X;
+ ha->dwFileFlags1 = pCreateInfo->dwFileFlags1;
+ ha->dwFileFlags2 = pCreateInfo->dwFileFlags2;
+ ha->dwFileFlags3 = pCreateInfo->dwFileFlags3 ? MPQ_FILE_EXISTS : 0;
+ ha->dwAttrFlags = pCreateInfo->dwAttrFlags;
+ ha->dwFlags = dwMpqFlags | MPQ_FLAG_CHANGED;
pStream = NULL;
// Fill the MPQ header
diff --git a/src/SFileFindFile.cpp b/src/SFileFindFile.cpp
index ef8b834..223e194 100644
--- a/src/SFileFindFile.cpp
+++ b/src/SFileFindFile.cpp
@@ -221,7 +221,7 @@ static bool DoMPQSearch_FileEntry(
if((pFileEntry->dwFlags & hs->dwFlagMask) == MPQ_FILE_EXISTS)
{
// Ignore fake files which are not compressed but have size higher than the archive
- if ((pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) == 0 && (pFileEntry->dwFileSize > ha->FileSize))
+ if((pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) == 0 && (pFileEntry->dwFileSize > ha->FileSize))
return false;
// Now we have to check if this file was not enumerated before
@@ -236,8 +236,6 @@ static bool DoMPQSearch_FileEntry(
// Prepare the block index
dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable);
- if(dwBlockIndex == 569)
- szNameBuff[0] = 'F';
// Get the file name. If it's not known, we will create pseudo-name
szFileName = pFileEntry->szFileName;
diff --git a/src/SFileOpenArchive.cpp b/src/SFileOpenArchive.cpp
index ea29850..52e1a39 100644
--- a/src/SFileOpenArchive.cpp
+++ b/src/SFileOpenArchive.cpp
@@ -35,21 +35,28 @@ static MTYPE CheckMapType(LPCTSTR szFileName, LPBYTE pbHeaderBuffer, size_t cbHe
DWORD DwordValue2 = BSWAP_INT32_UNSIGNED(HeaderInt32[2]);
DWORD DwordValue3 = BSWAP_INT32_UNSIGNED(HeaderInt32[3]);
- // Test for AVI files (Warcraft III cinematics) - 'RIFF', 'AVI ' or 'LIST'
- if(DwordValue0 == 0x46464952 && DwordValue2 == 0x20495641 && DwordValue3 == 0x5453494C)
- return MapTypeAviFile;
-
- // Check for Starcraft II maps
+ // 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
if((szExtension = _tcsrchr(szFileName, _T('.'))) != NULL)
{
- // The "NP_Protect" protector places fake Warcraft III header
- // into the Starcraft II maps, whilst SC2 maps have no other header but MPQ v4
+ // Check for Starcraft II maps by extension
if(!_tcsicmp(szExtension, _T(".s2ma")) || !_tcsicmp(szExtension, _T(".SC2Map")) || !_tcsicmp(szExtension, _T(".SC2Mod")))
{
return MapTypeStarcraft2;
}
+
+ // Check for Starcraft I maps by extension
+ if(!_tcsicmp(szExtension, _T(".scm")) || !_tcsicmp(szExtension, _T(".scx")))
+ {
+ return MapTypeStarcraft;
+ }
}
+ // Test for AVI files (Warcraft III cinematics) - 'RIFF', 'AVI ' or 'LIST'
+ if(DwordValue0 == 0x46464952 && DwordValue2 == 0x20495641 && DwordValue3 == 0x5453494C)
+ return MapTypeAviFile;
+
// Check for Warcraft III maps
if(DwordValue0 == 0x57334D48 && DwordValue1 == 0x00000000)
return MapTypeWarcraft3;
@@ -271,6 +278,7 @@ bool WINAPI SFileOpenArchive(
bool bSearchComplete = false;
memset(ha, 0, sizeof(TMPQArchive));
+ ha->dwValidFileFlags = MPQ_FILE_VALID_FLAGS;
ha->pfnHashString = HashStringSlash;
ha->pStream = pStream;
pStream = NULL;
@@ -288,6 +296,8 @@ bool WINAPI SFileOpenArchive(
// Limit the header searching to about 130 MB of data
if(EndOfSearch > 0x08000000)
EndOfSearch = 0x08000000;
+ if(FileSize < HEADER_SEARCH_BUFFER_SIZE)
+ memset(pbHeaderBuffer, 0, HEADER_SEARCH_BUFFER_SIZE);
// Find the offset of MPQ header within the file
while(bSearchComplete == false && ByteOffset < EndOfSearch)
@@ -438,7 +448,14 @@ bool WINAPI SFileOpenArchive(
// Remember whether whis is a map for Warcraft III
if(MapType == MapTypeWarcraft3)
+ {
+ ha->dwValidFileFlags = MPQ_FILE_VALID_FLAGS_W3X;
ha->dwFlags |= MPQ_FLAG_WAR3_MAP;
+ }
+
+ // If this is starcraft map, set the flag mask
+ if(MapType == MapTypeStarcraft)
+ ha->dwValidFileFlags = MPQ_FILE_VALID_FLAGS_SCX;
// Set the size of file sector
ha->dwSectorSize = (0x200 << ha->pHeader->wSectorSize);
diff --git a/src/SFileReadFile.cpp b/src/SFileReadFile.cpp
index 34edc06..1703748 100644
--- a/src/SFileReadFile.cpp
+++ b/src/SFileReadFile.cpp
@@ -663,7 +663,8 @@ static DWORD ReadMpqFileLocalFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePo
bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped)
{
- TMPQFile * hf = (TMPQFile *)hFile;
+ TFileEntry * pFileEntry;
+ TMPQFile * hf;
DWORD dwBytesRead = 0; // Number of bytes read
DWORD dwErrCode = ERROR_SUCCESS;
@@ -673,7 +674,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD
lpOverlapped = lpOverlapped;
// Check valid parameters
- if(!IsValidFileHandle(hFile))
+ if((hf = IsValidFileHandle(hFile)) == NULL)
{
SetLastError(ERROR_INVALID_HANDLE);
return false;
@@ -697,6 +698,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD
}
// Clear the last used compression
+ pFileEntry = hf->pFileEntry;
hf->dwCompression0 = 0;
// If the file is local file, read the data directly from the stream
@@ -706,7 +708,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD
}
// If the file is a patch file, we have to read it special way
- else if(hf->hfPatch != NULL && (hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0)
+ else if(hf->hfPatch != NULL && (pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0)
{
dwErrCode = ReadMpqFilePatchFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead);
}
@@ -718,7 +720,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD
}
// If the file is single unit file, redirect it to read file
- else if(hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT)
+ else if(pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT)
{
dwErrCode = ReadMpqFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead);
}
diff --git a/src/StormCommon.h b/src/StormCommon.h
index e9187f9..f452112 100644
--- a/src/StormCommon.h
+++ b/src/StormCommon.h
@@ -81,6 +81,7 @@ typedef enum _MTYPE
MapTypeNotChecked, // The map type was not checked yet
MapTypeNotRecognized, // The file does not seems to be a map
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
MapTypeStarcraft2 // The file is a Starcraft II map
} MTYPE, *PMTYPE;
diff --git a/src/StormLib.h b/src/StormLib.h
index f7279e6..1335f0e 100644
--- a/src/StormLib.h
+++ b/src/StormLib.h
@@ -25,7 +25,7 @@
/* hash table */
/* 08.12.03 4.11 DCH Fixed bug in reading file sector larger than 0x1000 */
/* on certain files. */
-/* Fixed bug in AddFile with MPQ_FILE_REPLACE_EXISTING */
+/* Fixed bug in AddFile with MPQ_FILE_REPLACEEXISTING */
/* (Thanx Daniel Chiamarello, dchiamarello@madvawes.com)*/
/* 21.12.03 4.50 Lad Completed port for Mac */
/* Fixed bug in compacting (if fsize is mul of 0x1000) */
@@ -193,7 +193,7 @@ extern "C" {
#define MPQ_FLAG_CHECK_SECTOR_CRC 0x00000020 // Checking sector CRC when reading files
#define MPQ_FLAG_SAVING_TABLES 0x00000040 // If set, we are saving MPQ internal files and MPQ tables
#define MPQ_FLAG_PATCH 0x00000080 // If set, this MPQ is a patch archive
-#define MPQ_FLAG_WAR3_MAP 0x00000100 // If set, this MPQ is a map for Warcraft III
+#define MPQ_FLAG_WAR3_MAP 0x00000100 // If set, this MPQ is a Warcraft III map
#define MPQ_FLAG_LISTFILE_NONE 0x00000200 // Set when no (listfile) was found in InvalidateInternalFiles
#define MPQ_FLAG_LISTFILE_NEW 0x00000400 // Set when (listfile) invalidated by InvalidateInternalFiles
#define MPQ_FLAG_LISTFILE_FORCE 0x00000800 // Save updated listfile on exit
@@ -250,6 +250,12 @@ extern "C" {
MPQ_FILE_SIGNATURE | \
MPQ_FILE_EXISTS)
+#define MPQ_FILE_VALID_FLAGS_SCX (MPQ_FILE_IMPLODE | \
+ MPQ_FILE_COMPRESS | \
+ MPQ_FILE_ENCRYPTED | \
+ MPQ_FILE_FIX_KEY | \
+ MPQ_FILE_EXISTS)
+
// We need to mask out the upper 4 bits of the block table index.
// This is because it gets shifted out when calculating block table offset
// BlockTableOffset = pHash->dwBlockIndex << 0x04
@@ -839,6 +845,7 @@ typedef struct _TMPQArchive
DWORD dwFileFlags2; // Flags for (attributes)
DWORD dwFileFlags3; // Flags for (signature)
DWORD dwAttrFlags; // Flags for the (attributes) file, see MPQ_ATTRIBUTE_XXX
+ DWORD dwValidFileFlags; // Valid flags for the current MPQ
DWORD dwFlags; // See MPQ_FLAG_XXXXX
DWORD dwSubType; // See MPQ_SUBTYPE_XXX
diff --git a/test/StormTest.cpp b/test/StormTest.cpp
index 13b0ace..4342e10 100644
--- a/test/StormTest.cpp
+++ b/test/StormTest.cpp
@@ -2646,7 +2646,7 @@ static DWORD TestOpenArchive_Corrupt(LPCTSTR szPlainName)
// Opens a patched MPQ archive
static DWORD TestArchive_Patched(LPCTSTR PatchList[], LPCSTR szPatchedFile, DWORD dwFlags)
{
- TLogHelper Logger("OpenPatchedMpqTest", PatchList[0]);
+ TLogHelper Logger("PatchedMPQ", PatchList[0]);
HANDLE hMpq;
HANDLE hFile;
BYTE Buffer[0x100];
@@ -4336,40 +4336,40 @@ int _tmain(int argc, TCHAR * argv[])
// Search all testing archives and verify their SHA1 hash
//
- if(dwErrCode == ERROR_SUCCESS)
- {
- dwErrCode = FindFiles(ForEachFile_VerifyFileChecksum, szMpqSubDir);
- }
+ //if(dwErrCode == ERROR_SUCCESS)
+ //{
+ // dwErrCode = FindFiles(ForEachFile_VerifyFileChecksum, szMpqSubDir);
+ //}
//
// Test file stream operations
//
- if(dwErrCode == ERROR_SUCCESS)
- {
- for(size_t i = 0; i < _countof(TestList_StreamOps); i++)
- {
- dwErrCode = TestFileStreamOperations(TestList_StreamOps[i].szMpqName1, TestList_StreamOps[i].dwFlags);
- if(dwErrCode != ERROR_SUCCESS)
- break;
- }
- }
+ //if(dwErrCode == ERROR_SUCCESS)
+ //{
+ // for(size_t i = 0; i < _countof(TestList_StreamOps); i++)
+ // {
+ // dwErrCode = TestFileStreamOperations(TestList_StreamOps[i].szMpqName1, TestList_StreamOps[i].dwFlags);
+ // if(dwErrCode != ERROR_SUCCESS)
+ // break;
+ // }
+ //}
//
// Test master-mirror reading operations
//
- if(dwErrCode == ERROR_SUCCESS)
- {
- for(size_t i = 0; i < _countof(TestList_MasterMirror); i++)
- {
- dwErrCode = TestReadFile_MasterMirror(TestList_MasterMirror[i].szMpqName1,
- TestList_MasterMirror[i].szMpqName2,
- TestList_MasterMirror[i].dwFlags != 0);
- if(dwErrCode != ERROR_SUCCESS)
- break;
- }
- }
+ //if(dwErrCode == ERROR_SUCCESS)
+ //{
+ // for(size_t i = 0; i < _countof(TestList_MasterMirror); i++)
+ // {
+ // dwErrCode = TestReadFile_MasterMirror(TestList_MasterMirror[i].szMpqName1,
+ // TestList_MasterMirror[i].szMpqName2,
+ // TestList_MasterMirror[i].dwFlags != 0);
+ // if(dwErrCode != ERROR_SUCCESS)
+ // break;
+ // }
+ //}
//
// Test opening various archives - correct, damaged, protected
diff --git a/test/TLogHelper.cpp b/test/TLogHelper.cpp
index 3d09823..3a82368 100644
--- a/test/TLogHelper.cpp
+++ b/test/TLogHelper.cpp
@@ -120,7 +120,7 @@ TLogHelper::~TLogHelper()
#if defined(_MSC_VER) && defined(_DEBUG)
if(_CrtDumpMemoryLeaks())
{
- PrintMessage(_T("Memory leak(s) detected after %s.\n"), szSaveMainTitle);
+ PrintMessage(_T("Memory leak(s) detected.\n"));
}
#endif // _MSC_VER
}
@@ -423,7 +423,7 @@ char * TLogHelper::CopyFormatCharacter(char * szBuffer, const char *& szFormat)
// String format
if(szFormat[0] == '%')
{
- if(szFormat[1] == 's' && szFormat[2] != ')')
+ if(szFormat[1] == 's')
{
strcpy(szBuffer, szStringFormat);
szFormat += 2;