From 79875d44e07320968b418449ff0b1a26989dc6f5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Apr 2021 11:29:24 +0200 Subject: [PATCH] - moved MD4 calculator out of backend. Only map hacks use MD4, this does not need to be shared. --- source/common/console/c_enginecmds.cpp | 28 ------------------------ source/core/maphack.cpp | 30 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/source/common/console/c_enginecmds.cpp b/source/common/console/c_enginecmds.cpp index f4801879a..542abe91d 100644 --- a/source/common/console/c_enginecmds.cpp +++ b/source/common/console/c_enginecmds.cpp @@ -52,7 +52,6 @@ #include "version.h" #include "findfile.h" #include "md5.h" -#include "md4.h" extern FILE* Logfile; @@ -319,33 +318,6 @@ CCMD (md5sum) } } -CCMD(md4sum) -{ - if (argv.argc() < 2) - { - Printf("Usage: md4sum ...\n"); - } - for (int i = 1; i < argv.argc(); ++i) - { - FileReader fr = fileSystem.OpenFileReader(argv[i]); - if (!fr.isOpen()) - { - Printf("%s: %s\n", argv[i], strerror(errno)); - } - else - { - auto data = fr.Read(); - uint8_t digest[16]; - md4once(data.Data(), data.Size(), digest); - for (int j = 0; j < 16; ++j) - { - Printf("%02x", digest[j]); - } - Printf(" //*%s\n", argv[i]); - } - } -} - CCMD(printlocalized) { if (argv.argc() > 1) diff --git a/source/core/maphack.cpp b/source/core/maphack.cpp index 39b78bbb3..03a44431c 100644 --- a/source/core/maphack.cpp +++ b/source/core/maphack.cpp @@ -35,6 +35,8 @@ #include "build.h" #include "sc_man.h" #include "printf.h" +#include "c_dispatch.h" +#include "md4.h" static TArray usermaphacks; TArray blockingpairs[MAXWALLS]; @@ -368,3 +370,31 @@ void G_LoadMapHack(const char* filename, const unsigned char* md4) } } +// Map hacks use MD4 instead of MD5. Oh, well... +CCMD(md4sum) +{ + if (argv.argc() < 2) + { + Printf("Usage: md4sum ...\n"); + } + for (int i = 1; i < argv.argc(); ++i) + { + FileReader fr = fileSystem.OpenFileReader(argv[i]); + if (!fr.isOpen()) + { + Printf("%s: %s\n", argv[i], strerror(errno)); + } + else + { + auto data = fr.Read(); + uint8_t digest[16]; + md4once(data.Data(), data.Size(), digest); + for (int j = 0; j < 16; ++j) + { + Printf("%02x", digest[j]); + } + Printf(" //*%s\n", argv[i]); + } + } +} +