also look in shared data dir for demos
authorBradley Bell <btb@icculus.org>
Mon, 17 Mar 2003 07:59:11 +0000 (07:59 +0000)
committerBradley Bell <btb@icculus.org>
Mon, 17 Mar 2003 07:59:11 +0000 (07:59 +0000)
ChangeLog
main/menu.c
main/newdemo.c
main/newdemo.h
main/newmenu.c

index 1ac7c5d..ea9ac98 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2003-03-16  Bradley Bell  <bradleyb@smeagol>
 
+       * main/menu.c, main/newdemo.c, main/newdemo.h, main/newmenu.c:
+       also look in shared data dir for demos
+
        * main/newdemo.c, main/newdemo.h: comments/formatting
 
 2003-03-15  Christopher Thielen  <chris@luethy.net>
index bac35a7..e863a95 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: menu.c,v 1.21 2003-03-14 05:11:29 btb Exp $ */
+/* $Id: menu.c,v 1.22 2003-03-17 07:59:11 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -368,13 +368,12 @@ void do_option ( int select)
                case MENU_GAME:
                        break;
                case MENU_DEMO_PLAY:
-                       { 
-                               char demo_file[16];
-                               if (newmenu_get_filename( TXT_SELECT_DEMO, "demos/*.dem", demo_file, 1 ))     {
-                                       newdemo_start_playback(demo_file);
-                               }
-                       }
+               {
+                       char demo_file[16];
+                       if (newmenu_get_filename( TXT_SELECT_DEMO, DEMO_DIR "*.dem", demo_file, 1 ))
+                               newdemo_start_playback(demo_file);
                        break;
+               }
                case MENU_LOAD_GAME:
                        state_restore_all(0, 0, NULL);
                        break;
index 9424233..d13ee6a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: newdemo.c,v 1.10 2003-03-17 07:10:21 btb Exp $ */
+/* $Id: newdemo.c,v 1.11 2003-03-17 07:59:11 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -17,6 +17,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  * Code to make a complete demo playback system.
  *
  * $Log: not supported by cvs2svn $
+ * Revision 1.10  2003/03/17 07:10:21  btb
+ * comments/formatting
+ *
  * Revision 1.12  1995/10/31  10:19:43  allender
  * shareware stuff
  *
@@ -736,6 +739,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #include <string.h> // for memset
 #include <errno.h>
 #include <ctype.h>      /* for isdigit */
+#include <limits.h>
 #ifdef __unix__
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -885,10 +889,8 @@ byte RenderingWasRecorded[32];
 
 #ifndef MACINTOSH
 #define DEMO_FILENAME           "demos/tmpdemo.dem"
-#define DEMO_DIR                "demos/"
 #else
 #define DEMO_FILENAME           ":Demos:tmpdemo.dem"
-#define DEMO_DIR                ":Demos:"
 #endif
 
 #define DEMO_MAX_LEVELS         29
@@ -3851,13 +3853,25 @@ int newdemo_count_demos()
        FILEFINDSTRUCT find;
        int NumFiles=0;
 
-       if( !FileFindFirst("demos/*.dem", &find ) ) {
+       if( !FileFindFirst( DEMO_DIR "*.dem", &find ) ) {
                do {
                        NumFiles++;
                } while( !FileFindNext( &find ) );
                FileFindClose();
        }
 
+       if ( AltHogdir_initialized ) {
+               char search_name[PATH_MAX + 5];
+               strcpy(search_name, AltHogDir);
+               strcat(search_name, "/" DEMO_DIR "*.dem");
+               if( !FileFindFirst( search_name, &find ) ) {
+                       do {
+                               NumFiles++;
+                       } while( !FileFindNext( &find ) );
+                       FileFindClose();
+               }
+       }
+
        return NumFiles;
 }
 
@@ -3865,7 +3879,7 @@ void newdemo_start_playback(char * filename)
 {
        FILEFINDSTRUCT find;
        int rnd_demo = 0;
-       char filename2[7+FILENAME_LEN] = DEMO_DIR;
+       char filename2[PATH_MAX+FILENAME_LEN] = DEMO_DIR;
 
 #ifdef NETWORK
        change_playernum_to(0);
@@ -3885,7 +3899,7 @@ void newdemo_start_playback(char * filename)
                }
                RandFileNum = d_rand() % NumFiles;
                NumFiles = 0;
-               if( !FileFindFirst( "demos/*.dem", &find ) ) {
+               if( !FileFindFirst( DEMO_DIR "*.dem", &find ) ) {
                        do {
                                if ( NumFiles==RandFileNum ) {
                                        filename = (char *)&find.name;
@@ -3895,6 +3909,23 @@ void newdemo_start_playback(char * filename)
                        } while( !FileFindNext( &find ) );
                        FileFindClose();
                }
+
+               if ( filename == NULL && AltHogdir_initialized ) {
+                       char search_name[PATH_MAX + 5];
+                       strcpy(search_name, AltHogDir);
+                       strcat(search_name, "/" DEMO_DIR "*.dem");
+                       if( !FileFindFirst( search_name, &find ) ) {
+                               do {
+                                       if ( NumFiles==RandFileNum ) {
+                                               filename = (char *)&find.name;
+                                               break;
+                                       }
+                                       NumFiles++;
+                               } while( !FileFindNext( &find ) );
+                               FileFindClose();
+                       }
+               }
+
                if ( filename==NULL) return;
        }
 
@@ -3904,6 +3935,14 @@ void newdemo_start_playback(char * filename)
        strcat(filename2,filename);
 
        infile = fopen( filename2, "rb" );
+
+       if (infile==NULL && AltHogdir_initialized) {
+               strcpy(filename2, AltHogDir);
+               strcat(filename2, "/" DEMO_DIR);
+               strcat(filename2, filename);
+               infile = fopen( filename2, "rb" );
+       }
+
        if (infile==NULL) {
                mprintf( (0, "Error reading '%s'\n", filename ));
                return;
index 7cbd448..8659c53 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: newdemo.h,v 1.2 2003-03-17 07:10:21 btb Exp $ */
+/* $Id: newdemo.h,v 1.3 2003-03-17 07:59:11 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -179,6 +179,12 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #define ND_STATE_ONEFRAMEBACKWARD   7
 #define ND_STATE_PRINTSCREEN        8
 
+#ifndef MACINTOSH
+#define DEMO_DIR                "demos/"
+#else
+#define DEMO_DIR                ":Demos:"
+#endif
+
 // Gives state of recorder
 extern int Newdemo_state;
 extern int NewdemoFrameCount;
index 1317f28..d5c9d35 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: newmenu.c,v 1.18 2003-02-28 09:56:10 btb Exp $ */
+/* $Id: newmenu.c,v 1.19 2003-03-17 07:59:11 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -574,6 +574,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #include <stdarg.h>
 #include <ctype.h>
 #include <unistd.h>
+#include <limits.h>
 
 #include "pa_enabl.h"                   //$$POLY_ACC
 #include "error.h"
@@ -2649,6 +2650,24 @@ ReadFileNames:
                FileFindClose();
        }
 
+       if (demo_mode && AltHogdir_initialized) {
+               char filespec2[PATH_MAX + FILENAME_LEN];
+               strcpy(filespec2, AltHogDir);
+               strcat(filespec2, "/");
+               strcat(filespec2, filespec);
+               if ( !FileFindFirst( filespec2, &find ) ) {
+                       do {
+                               if (NumFiles<MAX_FILES) {
+                                       strncpy( &filenames[NumFiles*14], find.name, FILENAME_LEN );
+                                       NumFiles++;
+                               } else {
+                                       break;
+                               }
+                       } while( !FileFindNext( &find ) );
+                       FileFindClose();
+               }
+       }
+
        if ( (NumFiles < 1) && demos_deleted )  {
                exit_value = 0;
                goto ExitFileMenu;