mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- started some reorganization of low level utility code by moving all third party dependencies to a separate place.
This commit is contained in:
parent
820fe8b3f9
commit
669e8fbe48
70 changed files with 104 additions and 99 deletions
|
@ -610,9 +610,10 @@ file( GLOB HEADER_FILES
|
|||
win32/*.h
|
||||
r_data/*.h
|
||||
r_data/models/*.h
|
||||
utility/rapidjson/*.h
|
||||
common/thirdparty/*.h
|
||||
common/thirdparty/rapidjson/*.h
|
||||
common/thirdparty/math./*h
|
||||
utility/sfmt/*.h
|
||||
utility/math./*h
|
||||
utility/*.h
|
||||
scripting/*.h
|
||||
scripting/backend/*.h
|
||||
|
@ -1127,8 +1128,6 @@ set (PCH_SOURCES
|
|||
utility/m_png.cpp
|
||||
utility/m_random.cpp
|
||||
utility/memarena.cpp
|
||||
utility/md5.cpp
|
||||
utility/superfasthash.cpp
|
||||
utility/nodebuilder/nodebuild.cpp
|
||||
utility/nodebuilder/nodebuild_classify_nosse2.cpp
|
||||
utility/nodebuilder/nodebuild_events.cpp
|
||||
|
@ -1148,6 +1147,8 @@ set (PCH_SOURCES
|
|||
utility/v_collection.cpp
|
||||
utility/utf8.cpp
|
||||
utility/zstrformat.cpp
|
||||
common/thirdparty/md5.cpp
|
||||
common/thirdparty/superfasthash.cpp
|
||||
)
|
||||
|
||||
if( ${HAVE_VM_JIT} )
|
||||
|
@ -1171,26 +1172,26 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
|
|||
${FASTMATH_SOURCES}
|
||||
${PCH_SOURCES}
|
||||
utility/x86.cpp
|
||||
utility/strnatcmp.c
|
||||
common/thirdparty/strnatcmp.c
|
||||
utility/zstring.cpp
|
||||
utility/math/asin.c
|
||||
utility/math/atan.c
|
||||
utility/math/const.c
|
||||
utility/math/cosh.c
|
||||
utility/math/exp.c
|
||||
utility/math/isnan.c
|
||||
utility/math/log.c
|
||||
utility/math/log10.c
|
||||
utility/math/mtherr.c
|
||||
utility/math/polevl.c
|
||||
utility/math/pow.c
|
||||
utility/math/powi.c
|
||||
utility/math/sin.c
|
||||
utility/math/sinh.c
|
||||
utility/math/sqrt.c
|
||||
utility/math/tan.c
|
||||
utility/math/tanh.c
|
||||
utility/math/fastsin.cpp
|
||||
common/thirdparty/math/asin.c
|
||||
common/thirdparty/math/atan.c
|
||||
common/thirdparty/math/const.c
|
||||
common/thirdparty/math/cosh.c
|
||||
common/thirdparty/math/exp.c
|
||||
common/thirdparty/math/isnan.c
|
||||
common/thirdparty/math/log.c
|
||||
common/thirdparty/math/log10.c
|
||||
common/thirdparty/math/mtherr.c
|
||||
common/thirdparty/math/polevl.c
|
||||
common/thirdparty/math/pow.c
|
||||
common/thirdparty/math/powi.c
|
||||
common/thirdparty/math/sin.c
|
||||
common/thirdparty/math/sinh.c
|
||||
common/thirdparty/math/sqrt.c
|
||||
common/thirdparty/math/tan.c
|
||||
common/thirdparty/math/tanh.c
|
||||
common/thirdparty/math/fastsin.cpp
|
||||
zzautozend.cpp
|
||||
)
|
||||
|
||||
|
@ -1215,6 +1216,7 @@ endif()
|
|||
target_link_libraries( zdoom ${ZDOOM_LIBS} gdtoa lzma ${ZMUSIC_LIBRARIES} )
|
||||
|
||||
include_directories( .
|
||||
common/thirdparty
|
||||
g_statusbar
|
||||
console
|
||||
playsim
|
||||
|
@ -1353,6 +1355,7 @@ source_group("Game Data\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT
|
|||
source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+")
|
||||
source_group("Map Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/maploader/.+")
|
||||
source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+")
|
||||
source_group("Console" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/console/.+")
|
||||
source_group("Playsim" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/playsim/.+")
|
||||
source_group("Playsim\\Bots" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/playsim/bots/.+")
|
||||
source_group("Playsim\\FraggleScript" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/playsim/fragglescript/.+")
|
||||
|
@ -1413,10 +1416,12 @@ source_group("Scripting\\ZScript frontend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_
|
|||
source_group("Scripting\\Compiler backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/backend/.+")
|
||||
source_group("Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/vm/.+")
|
||||
source_group("Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/.+")
|
||||
source_group("Common" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/.+")
|
||||
source_group("Common\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/.+")
|
||||
source_group("Common\\Third Party\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/math/.+")
|
||||
source_group("Common\\Third Party\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/rapidjson/.+")
|
||||
source_group("Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/utility/.+")
|
||||
source_group("Utility\\Node Builder" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/utility/nodebuilder/.+")
|
||||
source_group("Utility\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/utility/math/.+")
|
||||
source_group("Utility\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/utility/rapidjson/.+")
|
||||
source_group("Utility\\SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/utility/sfmt/.+")
|
||||
source_group("Statusbar" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_statusbar/.+")
|
||||
source_group("Versioning" FILES version.h win32/zdoom.rc)
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
*/
|
||||
|
||||
#include <string.h> /* for memcpy() */
|
||||
#include <algorithm>
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "md5.h"
|
||||
#include "templates.h"
|
||||
#include "files.h"
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
void byteSwap(uint32_t *buf, unsigned words)
|
||||
|
@ -95,20 +93,6 @@ void MD5Context::Update(const uint8_t *buf, unsigned len)
|
|||
memcpy(in, buf, len);
|
||||
}
|
||||
|
||||
void MD5Context::Update(FileReader &file, unsigned len)
|
||||
{
|
||||
uint8_t readbuf[8192];
|
||||
long t;
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
t = MIN<long>(len, sizeof(readbuf));
|
||||
len -= t;
|
||||
t = (long)file.Read(readbuf, t);
|
||||
Update(readbuf, t);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
|
@ -250,46 +234,3 @@ MD5Transform(uint32_t buf[4], const uint32_t in[16])
|
|||
|
||||
#endif
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CCMD md5sum
|
||||
//
|
||||
// Like the command-line tool, because I wanted to make sure I had it right.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#include "c_dispatch.h"
|
||||
#include <errno.h>
|
||||
|
||||
CCMD (md5sum)
|
||||
{
|
||||
if (argv.argc() < 2)
|
||||
{
|
||||
Printf("Usage: md5sum <file> ...\n");
|
||||
}
|
||||
for (int i = 1; i < argv.argc(); ++i)
|
||||
{
|
||||
FileReader fr;
|
||||
if (!fr.OpenFile(argv[i]))
|
||||
{
|
||||
Printf("%s: %s\n", argv[i], strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
MD5Context md5;
|
||||
uint8_t readbuf[8192];
|
||||
size_t len;
|
||||
|
||||
while ((len = fr.Read(readbuf, sizeof(readbuf))) > 0)
|
||||
{
|
||||
md5.Update(readbuf, (unsigned int)len);
|
||||
}
|
||||
md5.Final(readbuf);
|
||||
for(int j = 0; j < 16; ++j)
|
||||
{
|
||||
Printf("%02x", readbuf[j]);
|
||||
}
|
||||
Printf(" *%s\n", argv[i]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,15 +18,12 @@
|
|||
#ifndef MD5_H
|
||||
#define MD5_H
|
||||
|
||||
class FileReader;
|
||||
|
||||
struct MD5Context
|
||||
{
|
||||
MD5Context() { Init(); }
|
||||
|
||||
void Init();
|
||||
void Update(const uint8_t *buf, unsigned len);
|
||||
void Update(FileReader &file, unsigned len);
|
||||
void Final(uint8_t digest[16]);
|
||||
|
||||
private:
|
|
@ -35,6 +35,7 @@
|
|||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
|
@ -68,6 +69,7 @@
|
|||
#include "c_functions.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "v_video.h"
|
||||
#include "md5.h"
|
||||
|
||||
extern FILE *Logfile;
|
||||
extern bool insave;
|
||||
|
@ -1303,3 +1305,45 @@ CCMD(r_showcaps)
|
|||
PRINT_CAP("Truecolor Enabled", RFF_TRUECOLOR)
|
||||
PRINT_CAP("Voxels", RFF_VOXELS)
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CCMD md5sum
|
||||
//
|
||||
// Like the command-line tool, because I wanted to make sure I had it right.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD (md5sum)
|
||||
{
|
||||
if (argv.argc() < 2)
|
||||
{
|
||||
Printf("Usage: md5sum <file> ...\n");
|
||||
}
|
||||
for (int i = 1; i < argv.argc(); ++i)
|
||||
{
|
||||
FileReader fr;
|
||||
if (!fr.OpenFile(argv[i]))
|
||||
{
|
||||
Printf("%s: %s\n", argv[i], strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
MD5Context md5;
|
||||
uint8_t readbuf[8192];
|
||||
size_t len;
|
||||
|
||||
while ((len = fr.Read(readbuf, sizeof(readbuf))) > 0)
|
||||
{
|
||||
md5.Update(readbuf, (unsigned int)len);
|
||||
}
|
||||
md5.Final(readbuf);
|
||||
for(int j = 0; j < 16; ++j)
|
||||
{
|
||||
Printf("%02x", readbuf[j]);
|
||||
}
|
||||
Printf(" *%s\n", argv[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2662,6 +2662,7 @@ static int D_DoomMain_Internal (void)
|
|||
C_InitConback();
|
||||
|
||||
StartScreen->Progress();
|
||||
palMgr.Init(NUM_TRANSLATION_TABLES);
|
||||
V_InitFonts();
|
||||
|
||||
// [CW] Parse any TEAMINFO lumps.
|
||||
|
|
|
@ -83,6 +83,21 @@ FWadCollection Wads;
|
|||
|
||||
// CODE --------------------------------------------------------------------
|
||||
|
||||
void md5Update(FileReader& file, MD5Context &md5, unsigned len)
|
||||
{
|
||||
uint8_t readbuf[8192];
|
||||
unsigned t;
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
t = std::min<unsigned>(len, sizeof(readbuf));
|
||||
len -= t;
|
||||
t = (long)file.Read(readbuf, t);
|
||||
md5.Update(readbuf, t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// uppercoppy
|
||||
|
@ -282,7 +297,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadr)
|
|||
{
|
||||
MD5Context md5;
|
||||
wadreader.Seek(0, FileReader::SeekSet);
|
||||
md5.Update(wadreader, (unsigned)wadreader.GetLength());
|
||||
md5Update(wadreader, md5, (unsigned)wadreader.GetLength());
|
||||
md5.Final(cksum);
|
||||
|
||||
for (size_t j = 0; j < sizeof(cksum); ++j)
|
||||
|
@ -304,7 +319,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadr)
|
|||
{
|
||||
MD5Context md5;
|
||||
auto reader = lump->NewReader();
|
||||
md5.Update(reader, lump->LumpSize);
|
||||
md5Update(reader, md5, lump->LumpSize);
|
||||
md5.Final(cksum);
|
||||
|
||||
for (size_t j = 0; j < sizeof(cksum); ++j)
|
||||
|
@ -966,7 +981,7 @@ void FWadCollection::RenameNerve ()
|
|||
}
|
||||
fr->Seek(0, FileReader::SeekSet);
|
||||
MD5Context md5;
|
||||
md5.Update(*fr, (unsigned)fr->GetLength());
|
||||
md5Update(*fr, md5, (unsigned)fr->GetLength());
|
||||
md5.Final(cksum);
|
||||
if (memcmp(nerve[isizecheck], cksum, 16) == 0)
|
||||
{
|
||||
|
@ -1033,7 +1048,7 @@ void FWadCollection::FixMacHexen()
|
|||
uint8_t checksum[16];
|
||||
MD5Context md5;
|
||||
|
||||
md5.Update(*reader, (unsigned)iwadSize);
|
||||
md5Update(*reader, md5, (unsigned)iwadSize);
|
||||
md5.Final(checksum);
|
||||
|
||||
static const uint8_t HEXEN_DEMO_MD5[16] =
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "md5.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
void md5Update(FileReader& file, MD5Context& md5, unsigned len);
|
||||
|
||||
inline bool P_IsBuildMap(MapData *map)
|
||||
{
|
||||
return false;
|
||||
|
@ -395,19 +397,19 @@ void MapData::GetChecksum(uint8_t cksum[16])
|
|||
|
||||
if (isText)
|
||||
{
|
||||
md5.Update(Reader(ML_TEXTMAP), Size(ML_TEXTMAP));
|
||||
md5Update(Reader(ML_TEXTMAP), md5, Size(ML_TEXTMAP));
|
||||
}
|
||||
else
|
||||
{
|
||||
md5.Update(Reader(ML_LABEL), Size(ML_LABEL));
|
||||
md5.Update(Reader(ML_THINGS), Size(ML_THINGS));
|
||||
md5.Update(Reader(ML_LINEDEFS), Size(ML_LINEDEFS));
|
||||
md5.Update(Reader(ML_SIDEDEFS), Size(ML_SIDEDEFS));
|
||||
md5.Update(Reader(ML_SECTORS), Size(ML_SECTORS));
|
||||
md5Update(Reader(ML_LABEL), md5, Size(ML_LABEL));
|
||||
md5Update(Reader(ML_THINGS), md5, Size(ML_THINGS));
|
||||
md5Update(Reader(ML_LINEDEFS), md5, Size(ML_LINEDEFS));
|
||||
md5Update(Reader(ML_SIDEDEFS), md5, Size(ML_SIDEDEFS));
|
||||
md5Update(Reader(ML_SECTORS), md5, Size(ML_SECTORS));
|
||||
}
|
||||
if (HasBehavior)
|
||||
{
|
||||
md5.Update(Reader(ML_BEHAVIOR), Size(ML_BEHAVIOR));
|
||||
md5Update(Reader(ML_BEHAVIOR), md5, Size(ML_BEHAVIOR));
|
||||
}
|
||||
md5.Final(cksum);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue