From 591b832a84e7aa5809f24189013c65801bbf9b53 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Wed, 21 Aug 2002 03:26:25 +0000 Subject: [PATCH] Don't chdir with NOCWD_ASSUMPTIONS --- sys/share/pcmain.c | 4 ++-- sys/share/pcsys.c | 6 +++++- sys/share/pcunix.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index 2da4d4280..41d8ed31c 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -221,7 +221,7 @@ char *argv[]; */ if (!strncmp(argv[1], "-s", 2)) { #if !defined(MSWIN_GRAPHICS) -# ifdef CHDIR +# if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(hackdir,0); # endif prscore(argc, argv); @@ -252,7 +252,7 @@ char *argv[]; /* chdir shouldn't be called before this point to keep the * code parallel to other ports. */ -#ifdef CHDIR +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(hackdir,1); #endif diff --git a/sys/share/pcsys.c b/sys/share/pcsys.c index 38a4c0724..9c3f76284 100644 --- a/sys/share/pcsys.c +++ b/sys/share/pcsys.c @@ -95,7 +95,9 @@ dosh() # endif suspend_nhwindows((char *)0); # endif /* TOS */ +# ifndef NOCWD_ASSUMPTIONS chdirx(orgdir, 0); +# endif # ifdef __GO32__ if (system(comspec) < 0) { /* wsu@eecs.umich.edu */ # else @@ -120,7 +122,9 @@ dosh() if (iflags.BIOS) (void)Cursconf(1, -1); # endif +# ifndef NOCWD_ASSUMPTIONS chdirx(hackdir, 0); +# endif get_scr_size(); /* maybe the screen mode changed (TH) */ # if defined(MSDOS) && defined(NO_TERMS) if (grmode) gr_init(); @@ -512,7 +516,7 @@ static void msexit() #ifdef MFLOPPY if (ramdisk) copybones(TOPERM); #endif -#ifdef CHDIR +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdir(orgdir); /* chdir, not chdirx */ chdrive(orgdir); #endif diff --git a/sys/share/pcunix.c b/sys/share/pcunix.c index 7f63f4e3a..96d7c5865 100644 --- a/sys/share/pcunix.c +++ b/sys/share/pcunix.c @@ -106,7 +106,9 @@ getlock() /* we ignore QUIT and INT at this point */ if (!lock_file(HLOCK, LOCKPREFIX, 10)) { wait_synch(); +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); +#endif error("Quitting."); } @@ -116,7 +118,9 @@ getlock() fq_lock = fqname(lock, LEVELPREFIX, 1); if((fd = open(fq_lock,0)) == -1) { if(errno == ENOENT) goto gotlock; /* no such file */ +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); +#endif #if defined(WIN32) error("Bad directory or name: %s\n%s\n", fq_lock, strerror(errno)); @@ -169,12 +173,16 @@ getlock() goto gotlock; } else { unlock_file(HLOCK); +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); +#endif error("Couldn't destroy old game."); } else { unlock_file(HLOCK); +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); +#endif error("%s", ""); } @@ -183,7 +191,9 @@ gotlock: if (fd == -1) ern = errno; unlock_file(HLOCK); if(fd == -1) { +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); +#endif #if defined(WIN32) error("cannot creat file (%s.)\n%s\n%s\"%s\" exists?\n", fq_lock, strerror(ern), " Are you sure that the directory", @@ -194,11 +204,15 @@ gotlock: } else { if(write(fd, (char *) &hackpid, sizeof(hackpid)) != sizeof(hackpid)){ +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); +#endif error("cannot write lock (%s)", fq_lock); } if(close(fd) == -1) { +#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); +#endif error("cannot close lock (%s)", fq_lock); } } -- 2.49.0