shithub: hexen

Download patch

ref: e3260fcecfc83f51e83e96e470c4dfbeacfe64d3
parent: 2572893f1b0de5dc64c320151d4428e4c0c5c8b5
author: Jacob Moody <moody@posixcafe.org>
date: Sat Jan 28 22:22:54 EST 2023

use a bit more define magic to diverge less

not pretty but it makes debugging a bit easier

--- a/h2stdinc.h
+++ b/h2stdinc.h
@@ -26,6 +26,14 @@
 
 #define size_t uvlong
 
+#define lseek seek
+#define SEEK_SET 0
+#define O_RDONLY OREAD
+#define O_BINARY 0
+
+#define strncasecmp cistrncmp
+#define strcasecmp cistrcmp
+
 #undef PI
 
 
--- a/m_misc.c
+++ b/m_misc.c
@@ -64,7 +64,7 @@
 
 	for (i = 1; i < myargc; i++)
 	{
-		if (!strcmp(check, myargv[i]))
+		if (!strcasecmp(check, myargv[i]))
 		{
 			return i;
 		}
--- a/p_setup.c
+++ b/p_setup.c
@@ -1434,7 +1434,7 @@
 
 const char *P_GetMapSongLump(int map)
 {
-	if (!cistrcmp(MapInfo[QualifyMap(map)].songLump, DEFAULT_SONG_LUMP))
+	if (!strcasecmp(MapInfo[QualifyMap(map)].songLump, DEFAULT_SONG_LUMP))
 	{
 		return NULL;
 	}
--- a/r_data.c
+++ b/r_data.c
@@ -535,7 +535,7 @@
 
 	for (i = 0; i < numtextures; i++)
 	{
-		if (!cistrncmp(textures[i]->name, name, 8))
+		if (!strncasecmp(textures[i]->name, name, 8))
 			return i;
 	}
 
--- a/s_sound.c
+++ b/s_sound.c
@@ -381,12 +381,12 @@
 	{
 		if (*sc_String == '$')
 		{
-			if (!cistrcmp(sc_String, "$ARCHIVEPATH"))
+			if (!strcasecmp(sc_String, "$ARCHIVEPATH"))
 			{
 				SC_MustGetString();
 				strcpy(ArchivePath, sc_String);
 			}
-			else if (!cistrcmp(sc_String, "$MAP"))
+			else if (!strcasecmp(sc_String, "$MAP"))
 			{
 				SC_MustGetNumber();
 				SC_MustGetString();
--- a/sn_sonix.c
+++ b/sn_sonix.c
@@ -129,7 +129,7 @@
 
 	for (i = 0; i < NUMSFX; i++)
 	{
-		if (!cistrcmp(name, S_sfx[i].tagName))
+		if (!strcasecmp(name, S_sfx[i].tagName))
 		{
 			return i;
 		}
@@ -182,7 +182,7 @@
 			}
 			for (j = 0; j < SEQ_NUMSEQ; j++)
 			{
-				if (!cistrcmp(SequenceTranslate[j].name, sc_String+1))
+				if (!strcasecmp(SequenceTranslate[j].name, sc_String+1))
 				{
 					SequenceTranslate[j].scriptNum = i;
 					inSequence = j;
--- a/w_wad.c
+++ b/w_wad.c
@@ -100,18 +100,18 @@
 	if (waddir && *waddir)
 	{
 		snprintf (path, sizeof(path), "%s/%s", waddir, filename);
-		handle = open(path, OREAD);
+		handle = open(path, O_RDONLY|O_BINARY);
 	}
 #if !defined(_NO_USERDIRS)
 	if (handle == -1)	/* Try UserDIR */
 	{
 		snprintf (path, sizeof(path), "%s%s", basePath, filename);
-		handle = open(path, OREAD);
+		handle = open(path, O_RDONLY|O_BINARY);
 	}
 #endif	/* !_NO_USERDIRS */
 	if (handle == -1)	/* Now try CWD */
 	{
-		handle = open(filename, OREAD);
+		handle = open(filename, O_RDONLY|O_BINARY);
 	}
 	if (handle == -1)
 		return false;	/* Didn't find the file. */
@@ -147,18 +147,18 @@
 	if (waddir && *waddir)
 	{
 		snprintf (path, sizeof(path), "%s/%s", waddir, filename);
-		handle = open(path, OREAD);
+		handle = open(path, O_RDONLY|O_BINARY);
 	}
 #if !defined(_NO_USERDIRS)
 	if (handle == -1)	/* Try UserDIR */
 	{
 		snprintf (path, sizeof(path), "%s%s", basePath, filename);
-		handle = open(path, OREAD);
+		handle = open(path, O_RDONLY|O_BINARY);
 	}
 #endif	/* !_NO_USERDIRS */
 	if (handle == -1)	/* Now try CWD */
 	{
-		handle = open(filename, OREAD);
+		handle = open(filename, O_RDONLY|O_BINARY);
 	}
 	if (handle == -1)
 		return;		/* Didn't find the file. */
@@ -165,7 +165,7 @@
 
 	flength = filelength(handle);
 	startlump = numlumps;
-	if (strcmp(filename + strlen(filename) - 3, "wad") != 0)
+	if (strcasecmp(filename + strlen(filename) - 3, "wad") != 0)
 	{ // Single lump file
 		fileinfo = &singleinfo;
 		freeFileInfo = NULL;
@@ -214,7 +214,7 @@
 			I_Error("W_AddFile: fileinfo malloc failed\n");
 		}
 		freeFileInfo = fileinfo;
-		seek(handle, header.infotableofs, 0);
+		lseek(handle, header.infotableofs, SEEK_SET);
 		read(handle, fileinfo, length);
 		numlumps += header.numlumps;
 	}
@@ -304,8 +304,8 @@
 
 static int IsMarker(const char *marker, const char *name)
 {
-	return !cistrncmp(name, marker, 8) ||
-		(*name == *marker && !cistrncmp(name + 1, marker, 7));
+	return !strncasecmp(name, marker, 8) ||
+		(*name == *marker && !strncasecmp(name + 1, marker, 7));
 }
 
 //==========================================================================
@@ -430,7 +430,7 @@
 	{
 		W_CloseAuxiliary();
 	}
-	if ((handle = open(filename, OREAD)) == -1)
+	if ((handle = open(filename, O_RDONLY|O_BINARY)) == -1)
 	{
 		I_Error("W_OpenAuxiliary: %s not found.", filename);
 		return;
@@ -449,7 +449,7 @@
 	header.infotableofs = LONG(header.infotableofs);
 	length = header.numlumps*sizeof(filelump_t);
 	fileinfo = (filelump_t *) Z_Malloc(length, PU_STATIC, NULL);
-	seek(handle, header.infotableofs, 0);
+	lseek(handle, header.infotableofs, SEEK_SET);
 	read(handle, fileinfo, length);
 	numlumps = header.numlumps;
 
@@ -651,7 +651,7 @@
 	}
 	l = lumpinfo+lump;
 	//I_BeginRead();
-	seek(l->handle, l->position, 0);
+	lseek(l->handle, l->position, SEEK_SET);
 	c = read(l->handle, dest, l->size);
 	if (c < l->size)
 	{