mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- no need to have 2 CRC32 implementations.
Just let Bcrc32 point to zlib instead of having its own implementation.
This commit is contained in:
parent
4e3ad17e4a
commit
3530c52264
19 changed files with 15 additions and 156 deletions
|
@ -725,7 +725,6 @@ set (PCH_SOURCES
|
|||
|
||||
thirdparty/src/base64.cpp
|
||||
thirdparty/src/sjson.cpp
|
||||
thirdparty/src/crc32.cpp
|
||||
thirdparty/src/fix16.cpp
|
||||
thirdparty/src/fix16_str.cpp
|
||||
thirdparty/src/md4.cpp
|
||||
|
|
|
@ -7,7 +7,7 @@ endif()
|
|||
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/include" )
|
||||
|
||||
if (WIN32)
|
||||
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/sdl2")
|
||||
include_directories( "${ZLIB_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/sdl2")
|
||||
else ()
|
||||
include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
|
|
@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "build.h"
|
||||
#include "compat.h"
|
||||
#include "common_game.h"
|
||||
#include "crc32_.h"
|
||||
#include "m_crc32.h"
|
||||
|
||||
//#include "actor.h"
|
||||
#include "globals.h"
|
||||
|
|
|
@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
#include "compat.h"
|
||||
#include "common_game.h"
|
||||
#include "crc32_.h"
|
||||
#include "m_crc32.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "tile.h"
|
||||
|
|
|
@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "crc32_.h"
|
||||
#include "compat.h"
|
||||
#include "cache1d.h"
|
||||
#include "common_game.h"
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "colmatch.h"
|
||||
#include "common.h"
|
||||
#include "compat.h"
|
||||
#include "crc32_.h"
|
||||
#include "engine_priv.h"
|
||||
#include "lz4.h"
|
||||
#include "osd.h"
|
||||
|
@ -7600,21 +7599,6 @@ static int32_t engineLoadTables(void)
|
|||
for (i=0; i<5120; i++)
|
||||
qradarang[10239-i] = -qradarang[i];
|
||||
|
||||
#ifdef B_LITTLE_ENDIAN
|
||||
i = 0;
|
||||
if (Bcrc32((uint8_t *)sintable, sizeof(sintable), 0) != 0xee1e7aba)
|
||||
i |= 1;
|
||||
if (Bcrc32((uint8_t *)radarang, 640*sizeof(radarang[0]), 0) != 0xee893d92)
|
||||
i |= 2;
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
static const char *str[3] = { "sine table", "arctangent table",
|
||||
"sine and arctangent tables" };
|
||||
initprintf("WARNING: Calculated %s differ%s from original!\n",
|
||||
str[i-1], i==3 ? "" : "s");
|
||||
}
|
||||
#endif
|
||||
// TABLES.DAT format:
|
||||
//fr.Read(sintable,2048*2);
|
||||
//fr.Read(radarang,640*2);
|
||||
|
@ -8114,8 +8098,6 @@ int32_t enginePreInit(void)
|
|||
#endif
|
||||
|
||||
|
||||
initcrc32table();
|
||||
|
||||
#ifdef HAVE_CLIPSHAPE_FEATURE
|
||||
engineInitClipMaps();
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
#include "crc32_.h"
|
||||
#include "compat.h"
|
||||
#include "baselayer.h"
|
||||
#include "osd.h"
|
||||
|
@ -15,6 +14,7 @@
|
|||
#include "keyboard.h"
|
||||
#include "control.h"
|
||||
#include "gamecontrol.h"
|
||||
#include "m_crc32.h"
|
||||
|
||||
#define XXH_STATIC_LINKING_ONLY
|
||||
#include "xxhash.h"
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "engine_priv.h"
|
||||
#include "cache1d.h"
|
||||
#include "lz4.h"
|
||||
#include "crc32_.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
|
|
@ -50,3 +50,8 @@ inline uint32_t CRC1 (uint32_t crc, const uint8_t c, const uint32_t *crcTable)
|
|||
{
|
||||
return crcTable[(crc & 0xff) ^ c] ^ (crc >> 8);
|
||||
}
|
||||
|
||||
inline uint32_t Bcrc32(const void* data, int length, uint32_t crc)
|
||||
{
|
||||
return crc32(crc, (const Bytef*)data, length);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ endif()
|
|||
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/include" )
|
||||
|
||||
if (WIN32)
|
||||
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/sdl2" )
|
||||
include_directories( "${ZLIB_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/sdl2" )
|
||||
else ()
|
||||
include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
|
|
@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "compat.h"
|
||||
#include "renderlayer.h"
|
||||
#include "osdcmds.h"
|
||||
#include "crc32_.h"
|
||||
#include "network.h"
|
||||
#include "menus.h"
|
||||
#include "savegame.h"
|
||||
|
@ -5909,8 +5908,6 @@ static void G_Startup(void)
|
|||
timerInit(TICRATE);
|
||||
timerSetCallback(gameTimerHandler);
|
||||
|
||||
initcrc32table();
|
||||
|
||||
G_CompileScripts();
|
||||
|
||||
if (engineInit())
|
||||
|
|
|
@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "cheats.h"
|
||||
#include "common.h"
|
||||
#include "common_game.h"
|
||||
#include "crc32_.h"
|
||||
#include "m_crc32.h"
|
||||
#include "duke3d.h"
|
||||
#include "gameexec.h"
|
||||
#include "namesdyn.h"
|
||||
|
|
|
@ -40,7 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
#include "enet.h"
|
||||
#include "lz4.h"
|
||||
#include "crc32_.h"
|
||||
#include "m_crc32.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ endif()
|
|||
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/include" )
|
||||
|
||||
if (WIN32)
|
||||
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/sdl2")
|
||||
include_directories( "${ZLIB_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/sdl2")
|
||||
else ()
|
||||
include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GDTOA_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
|
|
@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "compat.h"
|
||||
#include "renderlayer.h"
|
||||
#include "osdcmds.h"
|
||||
#include "crc32_.h"
|
||||
#include "net.h"
|
||||
#include "menus.h"
|
||||
#include "savegame.h"
|
||||
|
@ -7319,8 +7318,6 @@ static void G_Startup(void)
|
|||
|
||||
timerInit(TICRATE);
|
||||
|
||||
initcrc32table();
|
||||
|
||||
G_CompileScripts();
|
||||
|
||||
enginecompatibility_mode = ENGINECOMPATIBILITY_19961112;
|
||||
|
|
|
@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "m_argv.h"
|
||||
|
||||
#include "osd.h"
|
||||
#include "crc32_.h"
|
||||
#include "m_crc32.h"
|
||||
#include "printf.h"
|
||||
|
||||
BEGIN_RR_NS
|
||||
|
|
|
@ -28,10 +28,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "premap.h"
|
||||
#include "savegame.h"
|
||||
#include "input.h"
|
||||
#include "m_crc32.h"
|
||||
|
||||
#include "enet.h"
|
||||
#include "lz4.h"
|
||||
#include "crc32_.h"
|
||||
|
||||
BEGIN_RR_NS
|
||||
|
||||
|
|
17
source/thirdparty/include/crc32_.h
vendored
17
source/thirdparty/include/crc32_.h
vendored
|
@ -1,17 +0,0 @@
|
|||
#ifndef crc32_h_
|
||||
#define crc32_h_
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#define POLY 0xEDB88320
|
||||
|
||||
#ifdef BITNESS64
|
||||
extern uint32_t crc32table[8][256];
|
||||
#else
|
||||
extern uint32_t crc32table[4][256];
|
||||
#endif
|
||||
|
||||
extern uint32_t Bcrc32(const void* data, int length, uint32_t crc);
|
||||
extern void initcrc32table(void);
|
||||
|
||||
#endif
|
102
source/thirdparty/src/crc32.cpp
vendored
102
source/thirdparty/src/crc32.cpp
vendored
|
@ -1,102 +0,0 @@
|
|||
// based on http://create.stephan-brumme.com/crc32/Crc32.cpp, zlib license
|
||||
|
||||
#include "compat.h"
|
||||
#include "crc32_.h"
|
||||
|
||||
uint32_t Bcrc32(const void* data, int length, uint32_t crc)
|
||||
{
|
||||
const uint32_t* current = (const uint32_t*) data;
|
||||
uint8_t const * currentChar;
|
||||
crc = ~crc;
|
||||
|
||||
#ifdef BITNESS64
|
||||
// process eight bytes at once (Slicing-by-8)
|
||||
while (length >= 8)
|
||||
{
|
||||
#if B_BIG_ENDIAN != 0
|
||||
uint32_t one = *current ^ B_SWAP32(crc);
|
||||
uint32_t two = *(current+1);
|
||||
crc = crc32table[0][two & 0xFF] ^
|
||||
crc32table[1][(two>> 8) & 0xFF] ^
|
||||
crc32table[2][(two>>16) & 0xFF] ^
|
||||
crc32table[3][(two>>24) & 0xFF] ^
|
||||
crc32table[4][one & 0xFF] ^
|
||||
crc32table[5][(one>> 8) & 0xFF] ^
|
||||
crc32table[6][(one>>16) & 0xFF] ^
|
||||
crc32table[7][(one>>24) & 0xFF];
|
||||
#else
|
||||
uint32_t one = *current ^ crc;
|
||||
uint32_t two = *(current+1);
|
||||
crc = crc32table[0][(two>>24) & 0xFF] ^
|
||||
crc32table[1][(two>>16) & 0xFF] ^
|
||||
crc32table[2][(two>> 8) & 0xFF] ^
|
||||
crc32table[3][two & 0xFF] ^
|
||||
crc32table[4][(one>>24) & 0xFF] ^
|
||||
crc32table[5][(one>>16) & 0xFF] ^
|
||||
crc32table[6][(one>> 8) & 0xFF] ^
|
||||
crc32table[7][one & 0xFF];
|
||||
#endif
|
||||
current += 2;
|
||||
length -= 8;
|
||||
}
|
||||
#else
|
||||
// process four bytes at once (Slicing-by-4)
|
||||
while (length >= 4)
|
||||
{
|
||||
#if B_BIG_ENDIAN != 0
|
||||
uint32_t one = *current++ ^ B_SWAP32(crc);
|
||||
crc = crc32table[0][one & 0xFF] ^
|
||||
crc32table[1][(one>> 8) & 0xFF] ^
|
||||
crc32table[2][(one>>16) & 0xFF] ^
|
||||
crc32table[3][(one>>24) & 0xFF];
|
||||
#else
|
||||
uint32_t one = *current++ ^ crc;
|
||||
crc = crc32table[0][(one>>24) & 0xFF] ^
|
||||
crc32table[1][(one>>16) & 0xFF] ^
|
||||
crc32table[2][(one>> 8) & 0xFF] ^
|
||||
crc32table[3][one & 0xFF];
|
||||
#endif
|
||||
|
||||
length -= 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
currentChar = (uint8_t const *) current;
|
||||
// remaining 1 to 7 bytes (standard algorithm)
|
||||
while (length-- > 0)
|
||||
crc = (crc >> 8) ^ crc32table[0][(crc & 0xFF) ^ *currentChar++];
|
||||
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
#ifdef BITNESS64
|
||||
uint32_t crc32table[8][256];
|
||||
#else
|
||||
uint32_t crc32table[4][256];
|
||||
#endif
|
||||
|
||||
void initcrc32table(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i <= 0xFF; i++)
|
||||
{
|
||||
uint32_t j, crc = i;
|
||||
for (j = 0; j < 8; j++)
|
||||
crc = (crc >> 1) ^ ((crc & 1) * POLY);
|
||||
crc32table[0][i] = crc;
|
||||
}
|
||||
|
||||
for (i = 0; i <= 0xFF; i++)
|
||||
{
|
||||
crc32table[1][i] = (crc32table[0][i] >> 8) ^ crc32table[0][crc32table[0][i] & 0xFF];
|
||||
crc32table[2][i] = (crc32table[1][i] >> 8) ^ crc32table[0][crc32table[1][i] & 0xFF];
|
||||
crc32table[3][i] = (crc32table[2][i] >> 8) ^ crc32table[0][crc32table[2][i] & 0xFF];
|
||||
|
||||
#ifdef BITNESS64
|
||||
crc32table[4][i] = (crc32table[3][i] >> 8) ^ crc32table[0][crc32table[3][i] & 0xFF];
|
||||
crc32table[5][i] = (crc32table[4][i] >> 8) ^ crc32table[0][crc32table[4][i] & 0xFF];
|
||||
crc32table[6][i] = (crc32table[5][i] >> 8) ^ crc32table[0][crc32table[5][i] & 0xFF];
|
||||
crc32table[7][i] = (crc32table[6][i] >> 8) ^ crc32table[0][crc32table[6][i] & 0xFF];
|
||||
#endif
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue