From: nethack.allison Date: Mon, 2 Sep 2002 14:10:05 +0000 (+0000) Subject: win32 recover; also a core bit from Yitzhak X-Git-Tag: MOVE2GIT~2447 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98d53c93a860a1c1f97afa7a68244446685367c8;p=nethack win32 recover; also a core bit from Yitzhak --- diff --git a/src/eat.c b/src/eat.c index 39ca9d6b1..02f9e4edc 100644 --- a/src/eat.c +++ b/src/eat.c @@ -33,6 +33,7 @@ STATIC_DCL void FDECL(start_tin, (struct obj *)); STATIC_DCL int FDECL(eatcorpse, (struct obj *)); STATIC_DCL void FDECL(start_eating, (struct obj *)); STATIC_DCL void FDECL(fprefx, (struct obj *)); +STATIC_DCL void FDECL(accessory_has_effect, (struct obj *)); STATIC_DCL void FDECL(fpostfx, (struct obj *)); STATIC_DCL int NDECL(bite); STATIC_DCL int FDECL(edibility_prompts, (struct obj *)); diff --git a/util/recover.c b/util/recover.c index f3b27a458..cc1b819f3 100644 --- a/util/recover.c +++ b/util/recover.c @@ -12,6 +12,7 @@ #include #endif #ifdef WIN32 +#include #include "win32api.h" #endif @@ -20,10 +21,6 @@ extern int FDECL(vms_creat, (const char *,unsigned)); extern int FDECL(vms_open, (const char *,int,unsigned)); #endif /* VMS */ -#if defined(WIN32) && !defined(WIN_CE) -static boolean is_NetHack_process(pid); -#endif - int FDECL(restore_savefile, (char *)); void FDECL(set_levelfile_name, (int)); int FDECL(open_levelfile, (int)); @@ -224,6 +221,16 @@ char *basename; (void) strcpy(lock, basename); gfd = open_levelfile(0); if (gfd < 0) { +#if defined(WIN32) && !defined(WIN_CE) + if(errno == EACCES) { + Fprintf(stderr, + "\nThere are files from a game in progress under your name."); + Fprintf(stderr,"\nThe files are locked or inaccessible."); + Fprintf(stderr,"\nPerhaps the other game is still running?\n"); + } else + Fprintf(stderr, + "\nTrouble accessing level 0 (errno = %d).\n", errno); +#endif Fprintf(stderr, "Cannot open level 0 for %s.\n", basename); return(-1); } @@ -234,15 +241,6 @@ char *basename; Close(gfd); return(-1); } -#if defined(WIN32) && !defined(WIN_CE) - if (is_NetHack_process(hpid)) { - Fprintf(stderr, "%s\n%s%s%s\n", - "Those level files belong to an active NetHack process and cannot be recovered.", - "recovery for \"", basename, "\" aborting."); - Close(gfd); - return(-1); - } -#endif if (read(gfd, (genericptr_t) &savelev, sizeof(savelev)) != sizeof(savelev)) { Fprintf(stderr, @@ -398,53 +396,4 @@ void nhce_message(FILE* f, const char* str, ...) } #endif -#if defined(WIN32) && !defined(WIN_CE) -#include - -boolean -is_NetHack_process(pid) -int pid; -{ - HANDLE hProcessSnap = NULL; - PROCESSENTRY32 pe32 = {0}; - boolean bRet = FALSE; - HINSTANCE hinstLib; - genericptr_t ProcTest; - BOOL fFreeResult; - - hinstLib = LoadLibrary("KERNEL32"); - if (hinstLib != NULL) { - ProcTest = (genericptr_t) GetProcAddress(hinstLib, "Process32Next"); - if (!ProcTest) { - fFreeResult = FreeLibrary(hinstLib); - return FALSE; - } - fFreeResult = FreeLibrary(hinstLib); - } - - - hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (hProcessSnap == INVALID_HANDLE_VALUE) - return FALSE; - - /* Set size of the processentry32 structure before using it. */ - pe32.dwSize = sizeof(PROCESSENTRY32); - if (Process32First(hProcessSnap, &pe32)) { - do { - if (pe32.th32ProcessID == (unsigned)pid && pe32.szExeFile && - ((strlen(pe32.szExeFile) >= 12 && - !strcmpi(&pe32.szExeFile[strlen(pe32.szExeFile) - 12], "nethackw.exe")) || - (strlen(pe32.szExeFile) >= 11 && - !strcmpi(&pe32.szExeFile[strlen(pe32.szExeFile) - 11], "nethack.exe")))) - bRet = TRUE; - } - while (Process32Next(hProcessSnap, &pe32)); - } - else - bRet = FALSE; - CloseHandle(hProcessSnap); - return bRet; -} -#endif - /*recover.c*/