]> granicus.if.org Git - nethack/commitdiff
Enclose savefile format change by STORE_PLNAME_IN_FILE macro.
authorwarwick <warwick>
Mon, 22 Jul 2002 09:13:04 +0000 (09:13 +0000)
committerwarwick <warwick>
Mon, 22 Jul 2002 09:13:04 +0000 (09:13 +0000)
include/patchlevel.h
src/files.c
src/restore.c
src/save.c

index 6bcdc2faf255dd1957ef0bb1c219c0c033639b28..a09bd0cf5ca3c29208f7e08b64e443904d08b452 100644 (file)
@@ -13,7 +13,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      1
+#define EDITLEVEL      0
 
 #define COPYRIGHT_BANNER_A \
 "NetHack, Copyright 1985-2002"
index 7e9e91ac26db946be8f78fac8497cbe649d7a444..507dc8eed516ebcf91b35808b4f25f69fb07a38d 100644 (file)
@@ -19,7 +19,7 @@
 #include <errno.h>
 #endif
 
-#if defined(UNIX)
+#if defined(UNIX) && defined(QT_GRAPHICS)
 #include <dirent.h>
 #endif
 
@@ -812,6 +812,7 @@ static char*
 plname_from_file(filename)
 const char* filename;
 {
+#ifdef STORE_PLNAME_IN_FILE
     int fd;
     char* result = 0;
 
@@ -831,12 +832,35 @@ const char* filename;
     compress(SAVEF);
 
     return result;
+#else
+    /* Name not stored in save file, so we have to extract it from
+       the filename, which loses information
+       (eg. "/", "_", and "." characters are lost. */
+    int k;
+    int uid;
+    char name[NAME_MAX];
+#ifdef COMPRESS_EXTENSION
+#define EXTSTR COMPRESS_EXTENSION
+#else
+#define EXTSTR ""
+#endif
+    if ( sscanf( filename, "%*[^/]/%d%[^.]" EXTSTR, &uid, name ) == 2 ) {
+#undef EXTSTR
+    /* "_" most likely means " ", which certainly looks nicer */
+       for (k=0; name[k]; k++)
+           if ( name[k]=='_' )
+               name[k]=' ';
+       return strdup(name);
+    } else {
+       return 0;
+    }
+#endif
 }
 
 char**
 get_saved_games()
 {
-#ifdef UNIX
+#if defined(UNIX) && defined(QT_GRAPHICS)
     int myuid=getuid();
     struct dirent **namelist;
     int n = scandir("save", &namelist, 0, alphasort);;
@@ -852,9 +876,8 @@ get_saved_games()
                    char* r;
                    Sprintf(filename,"save/%d%s",uid,name);
                    r = plname_from_file(filename);
-                   if ( r ) {
+                   if ( r )
                        result[j++] = r;
-                   }
                }
            }
        }
index 86e07885110e1b509f6cf8ca2edf446eabf36b09..899b5a69d2c16ca2693a127593ae4a5650564a1f 100644 (file)
@@ -542,7 +542,9 @@ register int fd;
        int rtmp;
        struct obj *otmp;
 
+#ifdef STORE_PLNAME_IN_FILE
        mread(fd, (genericptr_t) plname, PL_NSIZ);
+#endif
 
        restoring = TRUE;
        getlev(fd, 0, (xchar)0, FALSE);
@@ -623,7 +625,9 @@ register int fd;
        (void) lseek(fd, (off_t)0, 0);
 #endif
        (void) uptodate(fd, (char *)0);         /* skip version info */
+#ifdef STORE_PLNAME_IN_FILE
        mread(fd, (genericptr_t) plname, PL_NSIZ);
+#endif
        getlev(fd, 0, (xchar)0, FALSE);
        (void) close(fd);
 
index 42a29f099a3cebe81fe88d75af77904677e7edbd..ee4d51e1fa9b67e1d0bbbcaee9077b3bb6ccd88c 100644 (file)
@@ -204,7 +204,9 @@ dosave0()
 #endif /* MFLOPPY */
 
        store_version(fd);
+#ifdef STORE_PLNAME_IN_FILE
        bwrite(fd, (genericptr_t) plname, PL_NSIZ);
+#endif
        ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
 #ifdef STEED
        usteed_id = (u.usteed ? u.usteed->m_id : 0);
@@ -373,7 +375,9 @@ savestateinlock()
                    (void) write(fd, (genericptr_t) &currlev, sizeof(currlev));
                    save_savefile_name(fd);
                    store_version(fd);
+#ifdef STORE_PLNAME_IN_FILE
                    bwrite(fd, (genericptr_t) plname, PL_NSIZ);
+#endif
                    ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
 #ifdef STEED
                    usteed_id = (u.usteed ? u.usteed->m_id : 0);