diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 579289440e..a2dfbeaa48 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/utility/ctpl.h b/src/common/thirdparty/ctpl.h similarity index 100% rename from src/utility/ctpl.h rename to src/common/thirdparty/ctpl.h diff --git a/src/utility/earcut.hpp b/src/common/thirdparty/earcut.hpp similarity index 100% rename from src/utility/earcut.hpp rename to src/common/thirdparty/earcut.hpp diff --git a/src/utility/m_crc32.h b/src/common/thirdparty/m_crc32.h similarity index 100% rename from src/utility/m_crc32.h rename to src/common/thirdparty/m_crc32.h diff --git a/src/utility/math/asin.c b/src/common/thirdparty/math/asin.c similarity index 100% rename from src/utility/math/asin.c rename to src/common/thirdparty/math/asin.c diff --git a/src/utility/math/atan.c b/src/common/thirdparty/math/atan.c similarity index 100% rename from src/utility/math/atan.c rename to src/common/thirdparty/math/atan.c diff --git a/src/utility/math/cmath.h b/src/common/thirdparty/math/cmath.h similarity index 100% rename from src/utility/math/cmath.h rename to src/common/thirdparty/math/cmath.h diff --git a/src/utility/math/const.c b/src/common/thirdparty/math/const.c similarity index 100% rename from src/utility/math/const.c rename to src/common/thirdparty/math/const.c diff --git a/src/utility/math/cosh.c b/src/common/thirdparty/math/cosh.c similarity index 100% rename from src/utility/math/cosh.c rename to src/common/thirdparty/math/cosh.c diff --git a/src/utility/math/exp.c b/src/common/thirdparty/math/exp.c similarity index 100% rename from src/utility/math/exp.c rename to src/common/thirdparty/math/exp.c diff --git a/src/utility/math/fastsin.cpp b/src/common/thirdparty/math/fastsin.cpp similarity index 100% rename from src/utility/math/fastsin.cpp rename to src/common/thirdparty/math/fastsin.cpp diff --git a/src/utility/math/isnan.c b/src/common/thirdparty/math/isnan.c similarity index 100% rename from src/utility/math/isnan.c rename to src/common/thirdparty/math/isnan.c diff --git a/src/utility/math/log.c b/src/common/thirdparty/math/log.c similarity index 100% rename from src/utility/math/log.c rename to src/common/thirdparty/math/log.c diff --git a/src/utility/math/log10.c b/src/common/thirdparty/math/log10.c similarity index 100% rename from src/utility/math/log10.c rename to src/common/thirdparty/math/log10.c diff --git a/src/utility/math/mconf.h b/src/common/thirdparty/math/mconf.h similarity index 100% rename from src/utility/math/mconf.h rename to src/common/thirdparty/math/mconf.h diff --git a/src/utility/math/mtherr.c b/src/common/thirdparty/math/mtherr.c similarity index 100% rename from src/utility/math/mtherr.c rename to src/common/thirdparty/math/mtherr.c diff --git a/src/utility/math/polevl.c b/src/common/thirdparty/math/polevl.c similarity index 100% rename from src/utility/math/polevl.c rename to src/common/thirdparty/math/polevl.c diff --git a/src/utility/math/pow.c b/src/common/thirdparty/math/pow.c similarity index 100% rename from src/utility/math/pow.c rename to src/common/thirdparty/math/pow.c diff --git a/src/utility/math/powi.c b/src/common/thirdparty/math/powi.c similarity index 100% rename from src/utility/math/powi.c rename to src/common/thirdparty/math/powi.c diff --git a/src/utility/math/sin.c b/src/common/thirdparty/math/sin.c similarity index 100% rename from src/utility/math/sin.c rename to src/common/thirdparty/math/sin.c diff --git a/src/utility/math/sinh.c b/src/common/thirdparty/math/sinh.c similarity index 100% rename from src/utility/math/sinh.c rename to src/common/thirdparty/math/sinh.c diff --git a/src/utility/math/sqrt.c b/src/common/thirdparty/math/sqrt.c similarity index 100% rename from src/utility/math/sqrt.c rename to src/common/thirdparty/math/sqrt.c diff --git a/src/utility/math/tan.c b/src/common/thirdparty/math/tan.c similarity index 100% rename from src/utility/math/tan.c rename to src/common/thirdparty/math/tan.c diff --git a/src/utility/math/tanh.c b/src/common/thirdparty/math/tanh.c similarity index 100% rename from src/utility/math/tanh.c rename to src/common/thirdparty/math/tanh.c diff --git a/src/utility/md5.cpp b/src/common/thirdparty/md5.cpp similarity index 86% rename from src/utility/md5.cpp rename to src/common/thirdparty/md5.cpp index 1e0f724404..c2f90cdbc1 100644 --- a/src/utility/md5.cpp +++ b/src/common/thirdparty/md5.cpp @@ -16,11 +16,9 @@ */ #include /* for memcpy() */ +#include -#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(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 - -CCMD (md5sum) -{ - if (argv.argc() < 2) - { - Printf("Usage: md5sum ...\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]); - } - } -} diff --git a/src/utility/md5.h b/src/common/thirdparty/md5.h similarity index 94% rename from src/utility/md5.h rename to src/common/thirdparty/md5.h index 82d4f32dc1..f3aab94d96 100644 --- a/src/utility/md5.h +++ b/src/common/thirdparty/md5.h @@ -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: diff --git a/src/utility/rapidjson/allocators.h b/src/common/thirdparty/rapidjson/allocators.h similarity index 100% rename from src/utility/rapidjson/allocators.h rename to src/common/thirdparty/rapidjson/allocators.h diff --git a/src/utility/rapidjson/document.h b/src/common/thirdparty/rapidjson/document.h similarity index 100% rename from src/utility/rapidjson/document.h rename to src/common/thirdparty/rapidjson/document.h diff --git a/src/utility/rapidjson/encodedstream.h b/src/common/thirdparty/rapidjson/encodedstream.h similarity index 100% rename from src/utility/rapidjson/encodedstream.h rename to src/common/thirdparty/rapidjson/encodedstream.h diff --git a/src/utility/rapidjson/encodings.h b/src/common/thirdparty/rapidjson/encodings.h similarity index 100% rename from src/utility/rapidjson/encodings.h rename to src/common/thirdparty/rapidjson/encodings.h diff --git a/src/utility/rapidjson/error/en.h b/src/common/thirdparty/rapidjson/error/en.h similarity index 100% rename from src/utility/rapidjson/error/en.h rename to src/common/thirdparty/rapidjson/error/en.h diff --git a/src/utility/rapidjson/error/error.h b/src/common/thirdparty/rapidjson/error/error.h similarity index 100% rename from src/utility/rapidjson/error/error.h rename to src/common/thirdparty/rapidjson/error/error.h diff --git a/src/utility/rapidjson/filereadstream.h b/src/common/thirdparty/rapidjson/filereadstream.h similarity index 100% rename from src/utility/rapidjson/filereadstream.h rename to src/common/thirdparty/rapidjson/filereadstream.h diff --git a/src/utility/rapidjson/filewritestream.h b/src/common/thirdparty/rapidjson/filewritestream.h similarity index 100% rename from src/utility/rapidjson/filewritestream.h rename to src/common/thirdparty/rapidjson/filewritestream.h diff --git a/src/utility/rapidjson/fwd.h b/src/common/thirdparty/rapidjson/fwd.h similarity index 100% rename from src/utility/rapidjson/fwd.h rename to src/common/thirdparty/rapidjson/fwd.h diff --git a/src/utility/rapidjson/internal/biginteger.h b/src/common/thirdparty/rapidjson/internal/biginteger.h similarity index 100% rename from src/utility/rapidjson/internal/biginteger.h rename to src/common/thirdparty/rapidjson/internal/biginteger.h diff --git a/src/utility/rapidjson/internal/diyfp.h b/src/common/thirdparty/rapidjson/internal/diyfp.h similarity index 100% rename from src/utility/rapidjson/internal/diyfp.h rename to src/common/thirdparty/rapidjson/internal/diyfp.h diff --git a/src/utility/rapidjson/internal/dtoa.h b/src/common/thirdparty/rapidjson/internal/dtoa.h similarity index 100% rename from src/utility/rapidjson/internal/dtoa.h rename to src/common/thirdparty/rapidjson/internal/dtoa.h diff --git a/src/utility/rapidjson/internal/ieee754.h b/src/common/thirdparty/rapidjson/internal/ieee754.h similarity index 100% rename from src/utility/rapidjson/internal/ieee754.h rename to src/common/thirdparty/rapidjson/internal/ieee754.h diff --git a/src/utility/rapidjson/internal/itoa.h b/src/common/thirdparty/rapidjson/internal/itoa.h similarity index 100% rename from src/utility/rapidjson/internal/itoa.h rename to src/common/thirdparty/rapidjson/internal/itoa.h diff --git a/src/utility/rapidjson/internal/meta.h b/src/common/thirdparty/rapidjson/internal/meta.h similarity index 100% rename from src/utility/rapidjson/internal/meta.h rename to src/common/thirdparty/rapidjson/internal/meta.h diff --git a/src/utility/rapidjson/internal/pow10.h b/src/common/thirdparty/rapidjson/internal/pow10.h similarity index 100% rename from src/utility/rapidjson/internal/pow10.h rename to src/common/thirdparty/rapidjson/internal/pow10.h diff --git a/src/utility/rapidjson/internal/regex.h b/src/common/thirdparty/rapidjson/internal/regex.h similarity index 100% rename from src/utility/rapidjson/internal/regex.h rename to src/common/thirdparty/rapidjson/internal/regex.h diff --git a/src/utility/rapidjson/internal/stack.h b/src/common/thirdparty/rapidjson/internal/stack.h similarity index 100% rename from src/utility/rapidjson/internal/stack.h rename to src/common/thirdparty/rapidjson/internal/stack.h diff --git a/src/utility/rapidjson/internal/strfunc.h b/src/common/thirdparty/rapidjson/internal/strfunc.h similarity index 100% rename from src/utility/rapidjson/internal/strfunc.h rename to src/common/thirdparty/rapidjson/internal/strfunc.h diff --git a/src/utility/rapidjson/internal/strtod.h b/src/common/thirdparty/rapidjson/internal/strtod.h similarity index 100% rename from src/utility/rapidjson/internal/strtod.h rename to src/common/thirdparty/rapidjson/internal/strtod.h diff --git a/src/utility/rapidjson/internal/swap.h b/src/common/thirdparty/rapidjson/internal/swap.h similarity index 100% rename from src/utility/rapidjson/internal/swap.h rename to src/common/thirdparty/rapidjson/internal/swap.h diff --git a/src/utility/rapidjson/istreamwrapper.h b/src/common/thirdparty/rapidjson/istreamwrapper.h similarity index 100% rename from src/utility/rapidjson/istreamwrapper.h rename to src/common/thirdparty/rapidjson/istreamwrapper.h diff --git a/src/utility/rapidjson/memorybuffer.h b/src/common/thirdparty/rapidjson/memorybuffer.h similarity index 100% rename from src/utility/rapidjson/memorybuffer.h rename to src/common/thirdparty/rapidjson/memorybuffer.h diff --git a/src/utility/rapidjson/memorystream.h b/src/common/thirdparty/rapidjson/memorystream.h similarity index 100% rename from src/utility/rapidjson/memorystream.h rename to src/common/thirdparty/rapidjson/memorystream.h diff --git a/src/utility/rapidjson/msinttypes/inttypes.h b/src/common/thirdparty/rapidjson/msinttypes/inttypes.h similarity index 100% rename from src/utility/rapidjson/msinttypes/inttypes.h rename to src/common/thirdparty/rapidjson/msinttypes/inttypes.h diff --git a/src/utility/rapidjson/msinttypes/stdint.h b/src/common/thirdparty/rapidjson/msinttypes/stdint.h similarity index 100% rename from src/utility/rapidjson/msinttypes/stdint.h rename to src/common/thirdparty/rapidjson/msinttypes/stdint.h diff --git a/src/utility/rapidjson/ostreamwrapper.h b/src/common/thirdparty/rapidjson/ostreamwrapper.h similarity index 100% rename from src/utility/rapidjson/ostreamwrapper.h rename to src/common/thirdparty/rapidjson/ostreamwrapper.h diff --git a/src/utility/rapidjson/pointer.h b/src/common/thirdparty/rapidjson/pointer.h similarity index 100% rename from src/utility/rapidjson/pointer.h rename to src/common/thirdparty/rapidjson/pointer.h diff --git a/src/utility/rapidjson/prettywriter.h b/src/common/thirdparty/rapidjson/prettywriter.h similarity index 100% rename from src/utility/rapidjson/prettywriter.h rename to src/common/thirdparty/rapidjson/prettywriter.h diff --git a/src/utility/rapidjson/rapidjson.h b/src/common/thirdparty/rapidjson/rapidjson.h similarity index 100% rename from src/utility/rapidjson/rapidjson.h rename to src/common/thirdparty/rapidjson/rapidjson.h diff --git a/src/utility/rapidjson/reader.h b/src/common/thirdparty/rapidjson/reader.h similarity index 100% rename from src/utility/rapidjson/reader.h rename to src/common/thirdparty/rapidjson/reader.h diff --git a/src/utility/rapidjson/schema.h b/src/common/thirdparty/rapidjson/schema.h similarity index 100% rename from src/utility/rapidjson/schema.h rename to src/common/thirdparty/rapidjson/schema.h diff --git a/src/utility/rapidjson/stream.h b/src/common/thirdparty/rapidjson/stream.h similarity index 100% rename from src/utility/rapidjson/stream.h rename to src/common/thirdparty/rapidjson/stream.h diff --git a/src/utility/rapidjson/stringbuffer.h b/src/common/thirdparty/rapidjson/stringbuffer.h similarity index 100% rename from src/utility/rapidjson/stringbuffer.h rename to src/common/thirdparty/rapidjson/stringbuffer.h diff --git a/src/utility/rapidjson/writer.h b/src/common/thirdparty/rapidjson/writer.h similarity index 100% rename from src/utility/rapidjson/writer.h rename to src/common/thirdparty/rapidjson/writer.h diff --git a/src/utility/strnatcmp.c b/src/common/thirdparty/strnatcmp.c similarity index 100% rename from src/utility/strnatcmp.c rename to src/common/thirdparty/strnatcmp.c diff --git a/src/utility/strnatcmp.h b/src/common/thirdparty/strnatcmp.h similarity index 100% rename from src/utility/strnatcmp.h rename to src/common/thirdparty/strnatcmp.h diff --git a/src/utility/superfasthash.cpp b/src/common/thirdparty/superfasthash.cpp similarity index 100% rename from src/utility/superfasthash.cpp rename to src/common/thirdparty/superfasthash.cpp diff --git a/src/utility/superfasthash.h b/src/common/thirdparty/superfasthash.h similarity index 100% rename from src/utility/superfasthash.h rename to src/common/thirdparty/superfasthash.h diff --git a/src/utility/xs_Float.h b/src/common/thirdparty/xs_Float.h similarity index 100% rename from src/utility/xs_Float.h rename to src/common/thirdparty/xs_Float.h diff --git a/src/console/c_cmds.cpp b/src/console/c_cmds.cpp index 711bcf3b81..601b50c7db 100644 --- a/src/console/c_cmds.cpp +++ b/src/console/c_cmds.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef _WIN32 #include @@ -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 ...\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]); + } + } +} diff --git a/src/d_main.cpp b/src/d_main.cpp index 3a45e34ced..49792c7f91 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -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. diff --git a/src/gamedata/w_wad.cpp b/src/gamedata/w_wad.cpp index 9592683503..52221bdf88 100644 --- a/src/gamedata/w_wad.cpp +++ b/src/gamedata/w_wad.cpp @@ -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(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] = diff --git a/src/p_openmap.cpp b/src/p_openmap.cpp index 765d91797d..efb8571e50 100644 --- a/src/p_openmap.cpp +++ b/src/p_openmap.cpp @@ -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); }