From 9e38af74211899e90e30cb0d890b81cfdcd96f77 Mon Sep 17 00:00:00 2001
From: toaster <rollerorbital@gmail.com>
Date: Fri, 6 Dec 2019 17:13:04 +0000
Subject: [PATCH] * Fix unintentional order-of-operations crash with
 non-DEVELOP executables (resolves #461). * Update md5s. * Update modversion.

TODO: Should we change MODID, given 2.0 apparently had a different MODID to 2.1?
---
 src/config.h.in |  8 ++++----
 src/d_main.c    | 40 ++++++++++++++--------------------------
 src/doomdef.h   |  4 ++--
 src/w_wad.c     |  4 ++--
 4 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/src/config.h.in b/src/config.h.in
index 58d07e26d2..407d0565ee 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -29,11 +29,11 @@
  * Last updated 2015 / 05 / 03 - v2.1.15 - main assets
  * Last updated 2018 / ?? / ?? - v2.2 - patch.pk3
  */
-#define ASSET_HASH_SRB2_PK3   "c1b9577687f8a795104aef4600720ea7"
-#define ASSET_HASH_ZONES_PK3  "303838c6c534d9540288360fa49cca60"
-#define ASSET_HASH_PLAYER_DTA "cfca0f1c73023cbbd8f844f45480f799"
+#define ASSET_HASH_SRB2_PK3   "3944e92e74078145abb312ad0b736966"
+#define ASSET_HASH_ZONES_PK3  "eeda723d16dc26a7450669b4c06d3ffc"
+#define ASSET_HASH_PLAYER_DTA "56a247e074dd0dc794b6617efef1e918"
 #ifdef USE_PATCH_DTA
-#define ASSET_HASH_PATCH_PK3  "dbbf8bc6121618ee3be2d5b14650429b"
+#define ASSET_HASH_PATCH_PK3  "there is no patch.pk3, only zuul"
 #endif
 
 #endif
diff --git a/src/d_main.c b/src/d_main.c
index 5853fccf09..3132b61825 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1155,31 +1155,10 @@ void D_SRB2Main(void)
 	// Have to be done here before files are loaded
 	M_InitCharacterTables();
 
-	mainwads = 0;
-
-#ifndef DEVELOP // md5s last updated 12/14/14
-
-	// Check MD5s of autoloaded files
-	W_VerifyFileMD5(mainwads++, ASSET_HASH_SRB2_PK3); // srb2.pk3
-	W_VerifyFileMD5(mainwads++, ASSET_HASH_ZONES_PK3); // zones.pk3
-	W_VerifyFileMD5(mainwads++, ASSET_HASH_PLAYER_DTA); // player.dta
-#ifdef USE_PATCH_DTA
-	W_VerifyFileMD5(mainwads++, ASSET_HASH_PATCH_DTA); // patch.pk3
-#endif
-	// don't check music.dta because people like to modify it, and it doesn't matter if they do
-	// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
-	//mainwads++; // music.dta does not increment mainwads (see <= 2.1.21)
-	//mainwads++; // neither does music_new.dta
-#else
-
-	mainwads++;	// srb2.pk3
-	mainwads++; // zones.pk3
-	mainwads++; // player.dta
+	mainwads = 3; // doesn't include music.dta
 #ifdef USE_PATCH_DTA
-	mainwads++; // patch.dta
+	mainwads++;
 #endif
-	//mainwads++; // music.dta does not increment mainwads (see <= 2.1.21)
-	//mainwads++; // neither does music_new.dta
 
 	// load wad, including the main wad file
 	CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
@@ -1191,11 +1170,20 @@ void D_SRB2Main(void)
 #endif
 	D_CleanFile();
 
-#endif //ifndef DEVELOP
+#ifndef DEVELOP // md5s last updated 06/12/19 (ddmmyy)
 
-	mainwadstally = packetsizetally;
+	// Check MD5s of autoloaded files
+	W_VerifyFileMD5(0, ASSET_HASH_SRB2_PK3); // srb2.pk3
+	W_VerifyFileMD5(1, ASSET_HASH_ZONES_PK3); // zones.pk3
+	W_VerifyFileMD5(2, ASSET_HASH_PLAYER_DTA); // player.dta
+#ifdef USE_PATCH_DTA
+	W_VerifyFileMD5(3, ASSET_HASH_PATCH_DTA); // patch.pk3
+#endif
+	// don't check music.dta because people like to modify it, and it doesn't matter if they do
+	// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
+#endif //ifndef DEVELOP
 
-	mainwadstally = packetsizetally;
+	mainwadstally = packetsizetally; // technically not accurate atm, remember to port the two-stage -file process from kart in 2.2.x
 
 	cht_Init();
 
diff --git a/src/doomdef.h b/src/doomdef.h
index 511dad8582..1f57521344 100644
--- a/src/doomdef.h
+++ b/src/doomdef.h
@@ -129,7 +129,7 @@
 extern FILE *logstream;
 #endif
 
-#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
+//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
 #ifdef DEVELOP
 #define VERSION    0 // Game version
 #define SUBVERSION 0 // more precise version number
@@ -206,7 +206,7 @@ extern FILE *logstream;
 // it's only for detection of the version the player is using so the MS can alert them of an update.
 // Only set it higher, not lower, obviously.
 // Note that we use this to help keep internal testing in check; this is why v2.1.0 is not version "1".
-#define MODVERSION 30
+#define MODVERSION 31
 
 // To version config.cfg, MAJOREXECVERSION is set equal to MODVERSION automatically.
 // Increment MINOREXECVERSION whenever a config change is needed that does not correspond
diff --git a/src/w_wad.c b/src/w_wad.c
index 2690253e44..7534b8484a 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -1670,12 +1670,12 @@ void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5)
 	{
 		char actualmd5text[2*MD5_LEN+1];
 		PrintMD5String(wadfiles[wadfilenum]->md5sum, actualmd5text);
-/*#ifdef _DEBUG
+#ifdef _DEBUG
 		CONS_Printf
 #else
 		I_Error
 #endif
-			(M_GetText("File is corrupt or has been modified: %s (found md5: %s, wanted: %s)\n"), wadfiles[wadfilenum]->filename, actualmd5text, matchmd5);*/
+			(M_GetText("File is corrupt or has been modified: %s (found md5: %s, wanted: %s)\n"), wadfiles[wadfilenum]->filename, actualmd5text, matchmd5);
 	}
 #endif
 }
-- 
GitLab