mirror of
https://github.com/dhewm/dhewm3.git
synced 2024-11-26 14:21:18 +00:00
Replace zlib with integrated miniz
using amalgamated miniz 3.0.2 from https://github.com/richgel999/miniz and minizconf.h from Yamagi Quake II: https://github.com/yquake2/yquake2/blob/master/src/common/unzip/miniz/minizconf.h
This commit is contained in:
parent
a9bee9f76e
commit
1b344d4b78
11 changed files with 9454 additions and 14 deletions
57
README.md
57
README.md
|
@ -67,7 +67,6 @@ The build system is based on CMake: http://cmake.org/
|
||||||
|
|
||||||
Required libraries are not part of the tree. These are:
|
Required libraries are not part of the tree. These are:
|
||||||
|
|
||||||
- zlib
|
|
||||||
- OpenAL (OpenAL Soft required, Creative's and Apple's versions are made of fail)
|
- OpenAL (OpenAL Soft required, Creative's and Apple's versions are made of fail)
|
||||||
- SDL v1.2 or 2.0 (2.0 recommended)
|
- SDL v1.2 or 2.0 (2.0 recommended)
|
||||||
- libcurl (optional, required for server downloads)
|
- libcurl (optional, required for server downloads)
|
||||||
|
@ -108,7 +107,7 @@ build dependecies) it should be the same on other Linux distros and even other U
|
||||||
Open a terminal and follow these steps:
|
Open a terminal and follow these steps:
|
||||||
|
|
||||||
* Install build dependencies:
|
* Install build dependencies:
|
||||||
`sudo apt install git cmake build-essential libsdl2-dev libopenal-dev zlib1g-dev libcurl4-openssl-dev`
|
`sudo apt install git cmake build-essential libsdl2-dev libopenal-dev libcurl4-openssl-dev`
|
||||||
- The build-essential package on Debian/Ubuntu/... installs some basics for compiling code
|
- The build-essential package on Debian/Ubuntu/... installs some basics for compiling code
|
||||||
like GCC (incl. g++), GNU Make and the glibc development package
|
like GCC (incl. g++), GNU Make and the glibc development package
|
||||||
- Instead of libcurl4-openssl-dev, other libcurl*-dev packages should also work - or none at all, curl is optional.
|
- Instead of libcurl4-openssl-dev, other libcurl*-dev packages should also work - or none at all, curl is optional.
|
||||||
|
@ -207,6 +206,32 @@ ADDITIONAL TERMS: The Doom 3 GPL Source Code is also subject to certain additio
|
||||||
|
|
||||||
EXCLUDED CODE: The code described below and contained in the Doom 3 GPL Source Code release is not part of the Program covered by the GPL and is expressly excluded from its terms. You are solely responsible for obtaining from the copyright holder a license for such code and complying with the applicable license terms.
|
EXCLUDED CODE: The code described below and contained in the Doom 3 GPL Source Code release is not part of the Program covered by the GPL and is expressly excluded from its terms. You are solely responsible for obtaining from the copyright holder a license for such code and complying with the applicable license terms.
|
||||||
|
|
||||||
|
## Dear ImGui
|
||||||
|
|
||||||
|
neo/libs/imgui/*
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014-2024 Omar Cornut
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
## PropTree
|
## PropTree
|
||||||
|
|
||||||
neo/tools/common/PropTree/*
|
neo/tools/common/PropTree/*
|
||||||
|
@ -264,6 +289,34 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
## miniz
|
||||||
|
|
||||||
|
src/framework/miniz/*
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2013-2014 RAD Game Tools and Valve Software
|
||||||
|
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
||||||
|
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
## IO on .zip files using minizip
|
## IO on .zip files using minizip
|
||||||
|
|
||||||
|
|
|
@ -190,9 +190,6 @@ if(CMAKE_MAJOR_VERSION LESS 3 OR ( CMAKE_MAJOR_VERSION EQUAL 3 AND CMAKE_MINOR_V
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# libs
|
# libs
|
||||||
find_package(ZLIB REQUIRED)
|
|
||||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
include_directories(${OPENAL_INCLUDE_DIR})
|
include_directories(${OPENAL_INCLUDE_DIR})
|
||||||
|
|
||||||
|
@ -607,6 +604,7 @@ set(src_framework
|
||||||
framework/async/MsgChannel.cpp
|
framework/async/MsgChannel.cpp
|
||||||
framework/async/NetworkSystem.cpp
|
framework/async/NetworkSystem.cpp
|
||||||
framework/async/ServerScan.cpp
|
framework/async/ServerScan.cpp
|
||||||
|
framework/miniz/miniz.c
|
||||||
framework/minizip/ioapi.c
|
framework/minizip/ioapi.c
|
||||||
framework/minizip/unzip.cpp
|
framework/minizip/unzip.cpp
|
||||||
)
|
)
|
||||||
|
@ -1225,7 +1223,6 @@ endif()
|
||||||
idlib
|
idlib
|
||||||
${OPENAL_LIBRARY}
|
${OPENAL_LIBRARY}
|
||||||
${CURL_LIBRARY}
|
${CURL_LIBRARY}
|
||||||
${ZLIB_LIBRARY}
|
|
||||||
${SDLx_LIBRARY}
|
${SDLx_LIBRARY}
|
||||||
${sys_libs}
|
${sys_libs}
|
||||||
)
|
)
|
||||||
|
@ -1260,7 +1257,6 @@ endif()
|
||||||
target_link_libraries(${DHEWM3BINARY}ded
|
target_link_libraries(${DHEWM3BINARY}ded
|
||||||
idlib
|
idlib
|
||||||
${CURL_LIBRARY}
|
${CURL_LIBRARY}
|
||||||
${ZLIB_LIBRARY}
|
|
||||||
${SDLx_LIBRARY}
|
${SDLx_LIBRARY}
|
||||||
${sys_libs}
|
${sys_libs}
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,7 +32,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
#include "idlib/math/Vector.h"
|
#include "idlib/math/Vector.h"
|
||||||
#include "idlib/BitMsg.h"
|
#include "idlib/BitMsg.h"
|
||||||
|
|
||||||
#include "framework/Unzip.h"
|
//#include "framework/Unzip.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============================================================
|
==============================================================
|
||||||
|
@ -240,7 +240,11 @@ public:
|
||||||
private:
|
private:
|
||||||
idStr name; // name of the file in the pak
|
idStr name; // name of the file in the pak
|
||||||
idStr fullPath; // full file path including pak file name
|
idStr fullPath; // full file path including pak file name
|
||||||
ZPOS64_T zipFilePos; // zip file info position in pak
|
#ifdef _WIN32
|
||||||
|
unsigned __int64 zipFilePos; // zip file info position in pak - should be ZPOS64_T, but I don't want miniz.h (through Unzip.h) in this header
|
||||||
|
#else
|
||||||
|
unsigned long long int zipFilePos; // zip file info position in pak
|
||||||
|
#endif
|
||||||
int fileSize; // size of the file
|
int fileSize; // size of the file
|
||||||
void * z; // unzip info
|
void * z; // unzip info
|
||||||
};
|
};
|
||||||
|
|
22
neo/framework/miniz/LICENSE.txt
Normal file
22
neo/framework/miniz/LICENSE.txt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Copyright 2013-2014 RAD Game Tools and Valve Software
|
||||||
|
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
||||||
|
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
7833
neo/framework/miniz/miniz.c
Normal file
7833
neo/framework/miniz/miniz.c
Normal file
File diff suppressed because it is too large
Load diff
1424
neo/framework/miniz/miniz.h
Normal file
1424
neo/framework/miniz/miniz.h
Normal file
File diff suppressed because it is too large
Load diff
59
neo/framework/miniz/minizconf.h
Normal file
59
neo/framework/miniz/minizconf.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 Yamagi Burmeister
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* --------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Some additional definitions required by minizip and not provided
|
||||||
|
* by the miniz library.
|
||||||
|
*
|
||||||
|
* --------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_UNZIP_MINIZCONF_H
|
||||||
|
#define COMMON_UNZIP_MINIZCONF_H
|
||||||
|
|
||||||
|
#ifndef OF
|
||||||
|
#define OF(args) args
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ZEXPORT
|
||||||
|
#define ZEXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef z_off_t
|
||||||
|
#define z_off_t long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||||
|
# define z_off64_t off64_t
|
||||||
|
#else
|
||||||
|
# if defined(_WIN32) && !defined(__GNUC__)
|
||||||
|
# define z_off64_t __int64
|
||||||
|
# else
|
||||||
|
# define z_off64_t z_off_t
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
46
neo/framework/miniz/readme.md
Normal file
46
neo/framework/miniz/readme.md
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
## Miniz
|
||||||
|
|
||||||
|
Miniz is a lossless, high performance data compression library in a single source file that implements the zlib (RFC 1950) and Deflate (RFC 1951) compressed data format specification standards. It supports the most commonly used functions exported by the zlib library, but is a completely independent implementation so zlib's licensing requirements do not apply. Miniz also contains simple to use functions for writing .PNG format image files and reading/writing/appending .ZIP format archives. Miniz's compression speed has been tuned to be comparable to zlib's, and it also has a specialized real-time compressor function designed to compare well against fastlz/minilzo.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Releases are available at the [releases page](https://github.com/richgel999/miniz/releases) as a pair of `miniz.c`/`miniz.h` files which can be simply added to a project. To create this file pair the different source and header files are [amalgamated](https://www.sqlite.org/amalgamation.html) during build. Alternatively use as cmake or meson module (or build system of your choice).
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* MIT licensed
|
||||||
|
* A portable, single source and header file library written in plain C. Tested with GCC, clang and Visual Studio.
|
||||||
|
* Easily tuned and trimmed down by defines
|
||||||
|
* A drop-in replacement for zlib's most used API's (tested in several open source projects that use zlib, such as libpng and libzip).
|
||||||
|
* Fills a single threaded performance vs. compression ratio gap between several popular real-time compressors and zlib. For example, at level 1, miniz.c compresses around 5-9% better than minilzo, but is approx. 35% slower. At levels 2-9, miniz.c is designed to compare favorably against zlib's ratio and speed. See the miniz performance comparison page for example timings.
|
||||||
|
* Not a block based compressor: miniz.c fully supports stream based processing using a coroutine-style implementation. The zlib-style API functions can be called a single byte at a time if that's all you've got.
|
||||||
|
* Easy to use. The low-level compressor (tdefl) and decompressor (tinfl) have simple state structs which can be saved/restored as needed with simple memcpy's. The low-level codec API's don't use the heap in any way.
|
||||||
|
* Entire inflater (including optional zlib header parsing and Adler-32 checking) is implemented in a single function as a coroutine, which is separately available in a small (~550 line) source file: miniz_tinfl.c
|
||||||
|
* A fairly complete (but totally optional) set of .ZIP archive manipulation and extraction API's. The archive functionality is intended to solve common problems encountered in embedded, mobile, or game development situations. (The archive API's are purposely just powerful enough to write an entire archiver given a bit of additional higher-level logic.)
|
||||||
|
|
||||||
|
## Building miniz - Using vcpkg
|
||||||
|
|
||||||
|
You can download and install miniz using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||||
|
|
||||||
|
git clone https://github.com/Microsoft/vcpkg.git
|
||||||
|
cd vcpkg
|
||||||
|
./bootstrap-vcpkg.sh
|
||||||
|
./vcpkg integrate install
|
||||||
|
./vcpkg install miniz
|
||||||
|
|
||||||
|
The miniz port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||||
|
|
||||||
|
## Known Problems
|
||||||
|
|
||||||
|
* No support for encrypted archives. Not sure how useful this stuff is in practice.
|
||||||
|
* Minimal documentation. The assumption is that the user is already familiar with the basic zlib API. I need to write an API wiki - for now I've tried to place key comments before each enum/API, and I've included 6 examples that demonstrate how to use the module's major features.
|
||||||
|
|
||||||
|
## Special Thanks
|
||||||
|
|
||||||
|
Thanks to Alex Evans for the PNG writer function. Also, thanks to Paul Holden and Thorsten Scheuermann for feedback and testing, Matt Pritchard for all his encouragement, and Sean Barrett's various public domain libraries for inspiration (and encouraging me to write miniz.c in C, which was much more enjoyable and less painful than I thought it would be considering I've been programming in C++ for so long).
|
||||||
|
|
||||||
|
Thanks to Bruce Dawson for reporting a problem with the level_and_flags archive API parameter (which is fixed in v1.12) and general feedback, and Janez Zemva for indirectly encouraging me into writing more examples.
|
||||||
|
|
||||||
|
## Patents
|
||||||
|
|
||||||
|
I was recently asked if miniz avoids patent issues. miniz purposely uses the same core algorithms as the ones used by zlib. The compressor uses vanilla hash chaining as described [here](https://datatracker.ietf.org/doc/html/rfc1951#section-4). Also see the [gzip FAQ](https://web.archive.org/web/20160308045258/http://www.gzip.org/#faq11). In my opinion, if miniz falls prey to a patent attack then zlib/gzip are likely to be at serious risk too.
|
|
@ -49,7 +49,9 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <zlib.h>
|
//#include <zlib.h>
|
||||||
|
#include "../miniz/miniz.h" // DG: use miniz instead of zlib
|
||||||
|
#include "../miniz/minizconf.h"
|
||||||
|
|
||||||
#if defined(USE_FILE32API)
|
#if defined(USE_FILE32API)
|
||||||
#define fopen64 fopen
|
#define fopen64 fopen
|
||||||
|
|
|
@ -47,9 +47,10 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _ZLIB_H
|
// DG: we're using miniz.h now, which is included by ioapi.h
|
||||||
#include <zlib.h>
|
//#ifndef _ZLIB_H
|
||||||
#endif
|
//#include <zlib.h>
|
||||||
|
//#endif
|
||||||
|
|
||||||
// TODO #ifndef _ZLIBIOAPI_H
|
// TODO #ifndef _ZLIBIOAPI_H
|
||||||
#include "ioapi.h"
|
#include "ioapi.h"
|
||||||
|
|
|
@ -47,7 +47,7 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
#include "sys/win32/win_local.h"
|
#include "sys/win32/win_local.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <zlib.h>
|
#include "framework/miniz/miniz.h"
|
||||||
|
|
||||||
static unsigned char* compress_for_stbiw(unsigned char* data, int data_len, int* out_len, int quality)
|
static unsigned char* compress_for_stbiw(unsigned char* data, int data_len, int* out_len, int quality)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue