shithub: choc

Download patch

ref: d706f9693ee6bfd3976fcb232c1563c32b1cff88
parent: 6e099632c653dd42dbe1f719c5887844091da0cc
author: Simon Howard <[email protected]>
date: Mon Mar 28 17:32:14 EDT 2011

Allow .lmp files to be loaded (and demo files to be played back) that
have long filenames (thanks blzut3).

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2312

--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@
        users have reported experiencing.
      * The display settings window in the setup tool has been
        reorganised to a better arrangement.
+     * It is now possible to load .lmp files (and play back demos)
+       with long filenames (thanks blzut3).
 
     Compatibility:
      * Added support for the alternate version of the Final Doom
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -74,27 +74,38 @@
 
 static void ExtractFileBase(char *path, char *dest)
 {
-    char*	src;
-    int		length;
+    char *src;
+    char *filename;
+    int length;
 
     src = path + strlen(path) - 1;
-    
+
     // back up until a \ or the start
     while (src != path && *(src - 1) != DIR_SEPARATOR)
     {
 	src--;
     }
-    
-    // copy up to eight characters
-    memset (dest,0,8);
+
+    filename = src;
+
+    // Copy up to eight characters
+    // Note: Vanilla Doom exits with an error if a filename is specified
+    // with a base of more than eight characters.  To remove the 8.3
+    // filename limit, instead we simply truncate the name.
+
     length = 0;
-    
-    while (*src && *src != '.')
+    memset(dest, 0, 8);
+
+    while (*src != '\0' && *src != '.')
     {
-	if (++length == 9)
-	    I_Error ("Filename base of %s >8 chars",path);
+        if (length >= 8)
+        {
+            printf("Warning: Truncated '%s' lump name to '%.8s'.\n",
+                   filename, dest);
+            break;
+        }
 
-	*dest++ = toupper((int)*src++);
+	dest[length++] = toupper((int)*src++);
     }
 }