From ada4ce622f793023b58b8132228e2e9040a7167b Mon Sep 17 00:00:00 2001
From: toaster <rollerorbital@gmail.com>
Date: Mon, 28 Jan 2019 16:32:07 +0000
Subject: [PATCH] * Did some reviewing, turns out there's literally no reason
 to disable savemoddata when majormods gets tripped and it's just a stupid
 thing vanilla did for modifiedgame for some reason that we almost inherited
 with our new solution? * Adjusted the save system to acknowledge the new
 status quo. Instead of trying to save modifiedgame in the file like some sort
 of extremely boneheaded honour system everyone and their mothers hacks
 around, we just use it to determine whether the save is for a mod with
 savedata or not (this keeps backwards compatibility based on how we were
 using it, anyways, especially with the *force* parameter...) * Added a menu
 message for attempting to play a demo set on a map that isn't loaded, as
 opposed to letting it I_Error. * Minor tweaks to addons menu representing
 modded status.

---
 src/d_netcmd.c |  6 +++---
 src/g_game.c   | 25 ++++++++++++++++---------
 src/m_menu.c   |  7 +++++--
 3 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/src/d_netcmd.c b/src/d_netcmd.c
index 67f8c3a2b..1c90d1815 100644
--- a/src/d_netcmd.c
+++ b/src/d_netcmd.c
@@ -4910,10 +4910,10 @@ static void Fishcake_OnChange(void)
   */
 static void Command_Isgamemodified_f(void)
 {
-	if (savemoddata)
-		CONS_Printf("The game has been modified with an add-on with its own save data, so you can play Record Attack and earn medals.\n");
-	else if (majormods)
+	if (majormods)
 		CONS_Printf("The game has been modified with major add-ons, so you cannot play Record Attack.\n");
+	else if (savemoddata)
+		CONS_Printf("The game has been modified with an add-on with its own save data, so you can play Record Attack and earn medals.\n");
 	else if (modifiedgame)
 		CONS_Printf("The game has been modified with only minor add-ons. You can play Record Attack, earn medals and unlock extras.\n");
 	else
diff --git a/src/g_game.c b/src/g_game.c
index 1e0744f4c..8dffb7d5f 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -764,7 +764,7 @@ void G_SetGameModified(boolean silent, boolean major)
 	if (!major)
 		return;
 
-	savemoddata = false;
+	//savemoddata = false; -- there is literally no reason to do this anymore.
 	majormods = true;
 
 	if (!silent)
@@ -3933,7 +3933,6 @@ void G_LoadGameData(void)
 // Saves the main data file, which stores information such as emblems found, etc.
 void G_SaveGameData(boolean force)
 {
-	const boolean wasmodified = modifiedgame;
 	size_t length;
 	INT32 i, j;
 	UINT8 btemp;
@@ -3950,9 +3949,7 @@ void G_SaveGameData(boolean force)
 		return;
 	}
 
-	if (force) // SRB2Kart: for enabling unlocks online, even if the game is modified
-		modifiedgame = savemoddata; // L-let's just sort of... hack around the cheat protection, because I'm too worried about just removing it @@;
-	else if (modifiedgame && !savemoddata)
+	if (majormods && !force)
 	{
 		free(savebuffer);
 		save_p = savebuffer = NULL;
@@ -3965,7 +3962,7 @@ void G_SaveGameData(boolean force)
 	WRITEUINT32(save_p, totalplaytime);
 	WRITEUINT32(save_p, matchesplayed);
 
-	btemp = (UINT8)(savemoddata || modifiedgame);
+	btemp = (UINT8)(savemoddata); // what used to be here was profoundly dunderheaded
 	WRITEUINT8(save_p, btemp);
 
 	// TODO put another cipher on these things? meh, I don't care...
@@ -4051,9 +4048,6 @@ void G_SaveGameData(boolean force)
 	FIL_WriteFile(va(pandf, srb2home, gamedatafilename), savebuffer, length);
 	free(savebuffer);
 	save_p = savebuffer = NULL;
-
-	if (force) // Eeeek, I'm sorry for my sins!
-		modifiedgame = wasmodified;
 }
 
 #define VERSIONSIZE 16
@@ -5925,6 +5919,19 @@ void G_DoPlayDemo(char *defdemoname)
 		return;
 	}
 
+	// ...*map* not loaded?
+	if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK))
+	{
+		snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname);
+		CONS_Alert(CONS_ERROR, "%s", msg);
+		M_StartMessage(msg, NULL, MM_NOTHING);
+		Z_Free(pdemoname);
+		Z_Free(demobuffer);
+		demoplayback = false;
+		titledemo = false;
+		return;
+	}
+
 	Z_Free(pdemoname);
 
 	memset(&oldcmd,0,sizeof(oldcmd));
diff --git a/src/m_menu.c b/src/m_menu.c
index 2ea7234c2..9e51cb50e 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -4543,7 +4543,10 @@ static boolean M_AddonsRefresh(void)
 	if ((refreshdirmenu & REFRESHDIR_NORMAL) && !preparefilemenu(true))
 	{
 		UNEXIST;
-		CLEARNAME;
+		if (refreshdirname)
+		{
+			CLEARNAME;
+		}
 		return true;
 	}
 
@@ -4723,7 +4726,7 @@ static void M_DrawAddons(void)
 	V_DrawSmallScaledPatch(x, y + 4, (menusearch[0] ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+3]);
 
 	x = BASEVIDWIDTH - x - 16;
-	V_DrawSmallScaledPatch(x, y + 4, ((!modifiedgame || savemoddata) ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+4]);
+	V_DrawSmallScaledPatch(x, y + 4, ((!majormods) ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+4]);
 
 	if (modifiedgame)
 		V_DrawSmallScaledPatch(x, y + 4, 0, addonsp[NUM_EXT+2]);
-- 
GitLab