Data files now go in DATADIR/games/d2x, user files now go in ~/.d2x
authorBradley Bell <btb@icculus.org>
Mon, 28 Jan 2002 00:03:47 +0000 (00:03 +0000)
committerBradley Bell <btb@icculus.org>
Mon, 28 Jan 2002 00:03:47 +0000 (00:03 +0000)
NEWS
acconfig.h
cfile/cfile.c
configure.ac
main/inferno.c
main/newdemo.c

diff --git a/NEWS b/NEWS
index 3c9df09..441df96 100644 (file)
--- a/NEWS
+++ b/NEWS
   synchronization with d1x far, far easier.
 - Fixed assembly bug causing crash on game start.  Thanks to Craig
   Hadady <chadady@iglou.com>
+- Applied chdir patch from Falk Hueffner
+  <falk.hueffner@student.uni-tuebingen.de>, and added code to load
+  hogfiles from a central location, so it now doesn't matter what dir
+  you start d2x from.
 
 --- Version 0.1.1 ---
 Assembly under mingw32 now works.
index abc0079..089cb92 100644 (file)
@@ -34,6 +34,9 @@
 /* Define to use SDL Joystick */
 #undef SDL_JOYSTICK
 
+/* Define this to be the shared game directory root */
+#undef SHAREPATH
+
 @BOTTOM@
 
 /* General defines */
index 7418ba3..ad31044 100644 (file)
@@ -106,6 +106,7 @@ FILE * cfile_get_filehandle( char * filename, char * mode )
        }
        if ( (fp==NULL) && (AltHogdir_initialized) )    {
                strcpy( temp, AltHogDir );
+               strcat( temp, "/");
                strcat( temp, filename );
                *critical_error_counter_ptr = 0;
                fp = fopen( temp, mode );
index 5a892b0..2ea443f 100644 (file)
@@ -38,6 +38,14 @@ else
     GL_LIBS="GL GLU"
 fi
 
+dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
+test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
+test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
+
+dnl Set default locations to find data files.
+eval foo="$datadir"
+default_sharepath="$foo/games/$PACKAGE"
+
 CFLAGS="-Wall $CFLAGS"
 
 dnl Enable editor build?
@@ -97,6 +105,14 @@ else
     CFLAGS="-g $CFLAGS"
 fi
 
+AC_ARG_WITH(sharepath,
+  [[  --with-sharepath=DIR    Use DIR for shared game data [DATADIR/games/d2x]]],
+  sharepath=$withval, sharepath="auto")
+if test "x$sharepath" = "xauto" -o "x$sharepath" = "xyes" -o "x$sharepath" = "x"; then
+    sharepath="$default_sharepath"
+fi
+AC_DEFINE_UNQUOTED(SHAREPATH, "$sharepath")
+
 # Test for DJGPP
 AM_CONDITIONAL(DJGPP, test "$host_os" = "msdosdjgpp")
 if test "$host_os" = "msdosdjgpp"; then
index 7db5387..9bd6fe3 100644 (file)
@@ -13,13 +13,16 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 
 /*
  * $Source: /cvs/cvsroot/d2x/main/inferno.c,v $
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
  * $Author: bradleyb $
- * $Date: 2002-01-18 07:01:37 $
+ * $Date: 2002-01-28 00:03:47 $
  *
  * FIXME: put description here
  *
  * $Log: not supported by cvs2svn $
+ * Revision 1.19  2002/01/18 07:01:37  bradleyb
+ * allow -h for help
+ *
  * Revision 1.18  2001/12/28 09:26:41  bradleyb
  * document -nomovies option
  *
@@ -69,6 +72,13 @@ char copyright[] = "DESCENT II  COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef __unix__
+#include <unistd.h>
+#include <limits.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#endif
+
 #include "pstypes.h"
 #include "strutil.h"
 #include "console.h"
@@ -504,6 +514,24 @@ int main(int argc,char **argv)
 
        error_init(NULL, NULL);
 
+#ifdef __unix__
+       {
+               char *home = getenv("HOME");
+
+               if (home) {
+                       char buf[PATH_MAX + 5];
+                       
+                       strcpy(buf, home);
+                       strcat(buf, "/.d2x");
+                       if (chdir(buf)) {
+                               mkdir(buf, 0755);
+                               if (chdir(buf))
+                                       fprintf(stderr, "Cannot change to ~/.d2x\n");
+                       }
+               }
+       }
+#endif
+
        InitArgs( argc,argv );
 
        if ( FindArg( "-debug") )
@@ -520,6 +548,9 @@ int main(int argc,char **argv)
 
        arch_init();
 
+       //tell cfile where hogdir is
+       cfile_use_alternate_hogdir(SHAREPATH);
+
        //tell cfile about our counter
        cfile_set_critical_error_counter_ptr(&descent_critical_error);
 
index 1f77609..753c079 100644 (file)
@@ -21,6 +21,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #include <string.h>    // for memset
 #include <errno.h>
 #include <ctype.h>      /* for isdigit */
+#ifdef __unix__
+#include <sys/stat.h>
+#include <sys/types.h>
+#endif
 
 #include "u_mem.h"
 #include "inferno.h"
@@ -94,10 +98,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 
 void DoJasonInterpolate (fix recorded_time);
 
-#ifndef __MINGW32__
-void mkdir (char*); /* no idea */
-#endif
-
 //#include "nocfile.h"
 
 //Does demo start automatically?
@@ -2960,7 +2960,7 @@ void newdemo_start_recording()
        #else
        if (outfile == NULL) {                                                  //dir doesn't exist and no errno on mac!
        #endif  
-               mkdir(DEMO_DIR);                                                                //try making directory
+               mkdir(DEMO_DIR, 0755); //try making directory
                outfile = fopen( DEMO_FILENAME, "wb" );
        }