From 48d3df5c6e5ca2c0276851676b144cd2c7a08708 Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Thu, 13 Dec 2018 13:32:38 -0500
Subject: [PATCH] Apply srb2home to saveconfig ONLY if srb2home isn't already
 there

---
 src/m_misc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/m_misc.c b/src/m_misc.c
index 6dff4dbe9..474fb46c3 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -509,8 +509,11 @@ void M_SaveConfig(const char *filename)
 		}
 
 		// append srb2home to beginning of filename
-		// configfile already has this applied
-		filepath = va(pandf,srb2home, filename);
+		// but check if srb2home isn't already there, first
+		if (!strstr(filename, srb2home))
+			filepath = va(pandf,srb2home, filename);
+		else
+			filepath = Z_StrDup(filename);
 
 		f = fopen(filepath, "w");
 		// change it only if valid
@@ -518,7 +521,7 @@ void M_SaveConfig(const char *filename)
 			strcpy(configfile, filepath);
 		else
 		{
-			CONS_Alert(CONS_ERROR, M_GetText("Couldn't save game config file %s\n"), filename);
+			CONS_Alert(CONS_ERROR, M_GetText("Couldn't save game config file %s\n"), filepath);
 			return;
 		}
 	}
-- 
GitLab