allow dxx.ini to stay with the binary for *NIX systems, with Mac OS 9 don't put user-created files inside the .app bundle

This commit is contained in:
kreatordxx 2008-03-21 13:52:54 +00:00
parent f014231a78
commit b33c08cea2
2 changed files with 15 additions and 6 deletions

View file

@ -3,6 +3,7 @@ D1X-Rebirth Changelog
20080321
--------
2s/palette.c, arch/ogl/gr.c, arch/ogl/ogl.c, arch/sdl/gr.c, include/gr.h, include/palette.h, main/automap.c, main/automap.h, main/credits.c, main/endlevel.c, main/game.c, main/gameseq.c, main/inferno.c, main/kconfig.c, main/kmatrix.c, main/menu.c, main/network.c, main/newmenu.c, main/paging.c, main/scores.c, main/switch.c, main/titles.c, ui/window.c: Simplification of palette code; Properly screen clearing in SDL-only build when palette changes; Removed obsolete functions like gr_update (replaced by gr_flip), gr_palette_fade_in/out, gr_palette_clear; Added functionality to render Automap while menu display as well; Improved blocking of some controls code while Automap active; Fixed some compiler warnings
include/physfsx.h: allow d1x.ini to stay with the binary for *NIX systems, with Mac OS 9 don't put user-created files inside the .app bundle
20080316
--------

View file

@ -38,9 +38,9 @@
#include "args.h"
#include "ignorecase.h"
// Initialise PhysicsFS, set up basic search paths and add arguments from .ini file(s).
// The arguments are used to determine the search paths, so the first .ini file must be
// in the same directory as D1X. A second one can be in the user directory.
// Initialise PhysicsFS, set up basic search paths and add arguments from .ini file.
// The .ini file can be in either the user directory or the same directory as the program.
// The user directory is searched first.
static inline void PHYSFSX_init(int argc, char *argv[])
{
#if defined(__unix__)
@ -51,7 +51,6 @@ static inline void PHYSFSX_init(int argc, char *argv[])
PHYSFS_init(argv[0]);
PHYSFS_permitSymbolicLinks(1);
PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 1);
#if defined(__APPLE__) && defined(__MACH__) // others?
chdir(PHYSFS_getBaseDir()); // make sure relative hogdir and userdir paths work
#endif
@ -63,8 +62,6 @@ static inline void PHYSFSX_init(int argc, char *argv[])
path = "~/Library/Preferences/D1X Rebirth/";
# endif
PHYSFS_removeFromSearchPath(PHYSFS_getBaseDir());
if (path[0] == '~') // yes, this tilde can be put before non-unix paths.
{
const char *home = PHYSFS_getUserDir();
@ -109,11 +106,22 @@ static inline void PHYSFSX_init(int argc, char *argv[])
PHYSFS_addToSearchPath(PHYSFS_getWriteDir(), 1);
#endif
PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 1);
InitArgs( argc,argv );
PHYSFS_removeFromSearchPath(PHYSFS_getBaseDir());
if (!PHYSFS_getWriteDir())
{
#ifdef macintosh // Mac OS 9
char base_dir[PATH_MAX];
strcpy(base_dir, PHYSFS_getBaseDir());
if (strstr(base_dir, ".app:Contents:MacOSClassic:")) // the Mac OS 9 program is still in the .app bundle
strncat(base_dir, ":::", PATH_MAX - 1 - strlen(base_dir)); // go outside the .app bundle (the lazy way)
PHYSFS_setWriteDir(base_dir);
#else
PHYSFS_setWriteDir(PHYSFS_getBaseDir());
#endif
if (!PHYSFS_getWriteDir())
Error("can't set write dir\n");
else