shithub: heretic

Download patch

ref: c89633a6f115ee889ab5900b466578165955ec5a
parent: 064398f0c16f776f858526a5eed00c35fbf46f4b
author: Jacob Moody <[email protected]>
date: Mon Jan 23 23:56:09 EST 2023

fix wad search path

--- a/d_main.c
+++ b/d_main.c
@@ -12,6 +12,7 @@
 #include "p_local.h"
 #include "soundst.h"
 #include "v_compat.h"
+#include "i_system.h"
 
 // MACROS ------------------------------------------------------------------
 
@@ -75,13 +76,11 @@
 static int demosequence;
 static int pagetic;
 static const char *pagename;
+static char basedefault[1024];
 
 static const char *wadfiles[MAXWADFILES + 1] =
 {
 	"heretic.wad",
-	"texture1.lmp",
-	"texture2.lmp",
-	"pnames.lmp",
 	NULL	/* the last entry MUST be NULL */
 };
 
@@ -827,9 +826,11 @@
 
 void D_DoomMain(void)
 {
-	int p, e, m;
+	int p, e, m, i;
 	char file[MAX_OSPATH];
 	boolean devMap;
+	char *slash;
+	char *wadloc[nelem(wadfiles)];
 
 	M_FindResponseFile();
 	setbuf(stdout, NULL);
@@ -844,7 +845,7 @@
 	autostart = false;
 
 	// wadfiles[0] is a char * to the main wad
-	if (!W_IsWadPresent(wadfiles[0]))
+	if (!I_IdentifyWAD(wadfiles[0]))
 	{ // Change to look for shareware wad
 		wadfiles[0] = SHAREWAREWADNAME;
 	}
@@ -928,16 +929,27 @@
 	printf("V_Init: allocate screens.\n");
 	V_Init();
 
-	// Load defaults before initing other systems
-	printf("M_LoadDefaults: Load system defaults.\n");
-	M_LoadDefaults(CONFIG_FILE_NAME);
-
 	printf("Z_Init: Init zone memory allocation daemon.\n");
 	Z_Init();
 
+	for(i = 0; i < nelem(wadfiles); i++){
+		if(wadfiles[i] == nil){
+			wadloc[i] = nil;
+			break;
+		} else
+			wadloc[i] = I_IdentifyWAD(wadfiles[i]);
+		print("%s %s\n", wadfiles[i], wadloc[i]);
+	}
 	printf("W_Init: Init WADfiles.\n");
-	W_InitMultipleFiles(wadfiles);
+	W_InitMultipleFiles(wadloc);
 
+	strncpy(basedefault, wadloc[0], sizeof(basedefault)-5);
+	basedefault[sizeof(basedefault)-5] = '\0';
+	slash = strrchr(basedefault, '/');
+	if (slash++ == 0)
+		slash = basedefault;
+	strcpy(slash, "cfg");
+
 	if (W_CheckNumForName("E2M1") == -1)
 	{ // Can't find episode 2 maps, must be the shareware WAD
 		shareware = true;
@@ -946,6 +958,10 @@
 	{ // Found extended lump, must be the extended WAD
 		ExtendedWAD = true;
 	}
+
+	// Load defaults before initing other systems
+	printf("M_LoadDefaults: Load system defaults.\n");
+	M_LoadDefaults(basedefault);
 
 #if defined(__WATCOMC__) && defined(_DOS)
 	I_StartupKeyboard();
--- a/i_system.c
+++ b/i_system.c
@@ -129,7 +129,7 @@
 		return path;
 
 	if(home = getenv("home")){
-		snprintf(path, sizeof path, "%s/lib/hexen/%s", home, wadname);
+		snprintf(path, sizeof path, "%s/lib/heretic/%s", home, wadname);
 		free(home);
 
 		if (I_FileExists (path))
@@ -136,11 +136,11 @@
 			return path;
 	}
 
-	snprintf(path, sizeof path, "/sys/lib/hexen/%s", wadname);
+	snprintf(path, sizeof path, "/sys/lib/heretic/%s", wadname);
 	if (I_FileExists (path))
 		return path;
 
-	snprintf(path, sizeof path, "/sys/games/lib/hexen/%s", wadname);
+	snprintf(path, sizeof path, "/sys/games/lib/heretic/%s", wadname);
 	if (I_FileExists (path))
 		return path;
 
--- a/w_wad.c
+++ b/w_wad.c
@@ -102,27 +102,8 @@
 	filelump_t *freeFileInfo;
 	int i;
 
-	handle = -1;
-	/* try the directory from the command line or
-	 *  from the shared data environment variable.
-	 */
-	if (waddir && *waddir)
-	{
-		snprintf (path, sizeof(path), "%s/%s", waddir, filename);
-		handle = open(path, OREAD);
-	}
-#if !defined(_NO_USERDIRS)
-	if (handle == -1)	/* Try UserDIR */
-	{
-		snprintf (path, sizeof(path), "%s%s", basePath, filename);
-		handle = open(path, OREAD);
-	}
-#endif	/* !_NO_USERDIRS */
-	if (handle == -1)	/* Now try CWD */
-	{
-		handle = open(filename, OREAD);
-	}
-	if (handle == -1)
+	handle = open(filename, OREAD);
+	if (handle < 0)
 		return;		/* Didn't find the file. */
 
 	startlump = numlumps;