Allow MICRO and WIN32 code paths to diverge

There's still a lot of overlap for 3.4.1, but not
100% any longer and it facilitates some improvements
- Allow error save files on WIN32
This commit is contained in:
nethack.allison
2002-03-30 19:09:56 +00:00
parent c49130e5bd
commit 51f9892b3b
18 changed files with 84 additions and 72 deletions
+1 -1
View File
@@ -130,7 +130,7 @@ long FDECL(dlb_ftell, (DLB_P));
#else #else
#define WRTMODE "w+" #define WRTMODE "w+"
#endif #endif
#if (defined(MICRO) && !defined(AMIGA)) || defined(THINK_C) || defined(__MWERKS__) #if (defined(MICRO) && !defined(AMIGA)) || defined(THINK_C) || defined(__MWERKS__) || defined(WIN32)
# define RDBMODE "rb" # define RDBMODE "rb"
# define WRBMODE "w+b" # define WRBMODE "w+b"
#else #else
+8 -8
View File
@@ -1176,7 +1176,7 @@ E struct monst *FDECL(mk_mplayer, (struct permonst *,XCHAR_P,
E void FDECL(create_mplayers, (int,BOOLEAN_P)); E void FDECL(create_mplayers, (int,BOOLEAN_P));
E void FDECL(mplayer_talk, (struct monst *)); E void FDECL(mplayer_talk, (struct monst *));
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
/* ### msdos.c,os2.c,tos.c,winnt.c ### */ /* ### msdos.c,os2.c,tos.c,winnt.c ### */
@@ -1226,7 +1226,7 @@ E int NDECL((*nt_kbhit));
E void FDECL(Delay, (int)); E void FDECL(Delay, (int));
# endif /* WIN32 */ # endif /* WIN32 */
#endif /* MICRO */ #endif /* MICRO || WIN32 */
/* ### mthrowu.c ### */ /* ### mthrowu.c ### */
@@ -1366,15 +1366,15 @@ E int NDECL(dohistory);
/* ### pcmain.c ### */ /* ### pcmain.c ### */
#if defined(MICRO) #if defined(MICRO) || defined(WIN32)
# ifdef CHDIR # ifdef CHDIR
E void FDECL(chdirx, (char *,BOOLEAN_P)); E void FDECL(chdirx, (char *,BOOLEAN_P));
# endif /* CHDIR */ # endif /* CHDIR */
#endif /* MICRO */ #endif /* MICRO || WIN32 */
/* ### pcsys.c ### */ /* ### pcsys.c ### */
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
E void NDECL(flushout); E void NDECL(flushout);
E int NDECL(dosh); E int NDECL(dosh);
# ifdef MFLOPPY # ifdef MFLOPPY
@@ -1390,11 +1390,11 @@ E void FDECL(getreturn, (const char *));
E void VDECL(msmsg, (const char *,...)); E void VDECL(msmsg, (const char *,...));
# endif # endif
E FILE *FDECL(fopenp, (const char *,const char *)); E FILE *FDECL(fopenp, (const char *,const char *));
#endif /* MICRO */ #endif /* MICRO || WIN32 */
/* ### pctty.c ### */ /* ### pctty.c ### */
#if defined(MICRO) #if defined(MICRO) || defined(WIN32)
E void NDECL(gettty); E void NDECL(gettty);
E void FDECL(settty, (const char *)); E void FDECL(settty, (const char *));
E void NDECL(setftty); E void NDECL(setftty);
@@ -1402,7 +1402,7 @@ E void VDECL(error, (const char *,...));
#if defined(TIMED_DELAY) && defined(_MSC_VER) #if defined(TIMED_DELAY) && defined(_MSC_VER)
E void FDECL(msleep, (unsigned)); E void FDECL(msleep, (unsigned));
#endif #endif
#endif /* MICRO */ #endif /* MICRO || WIN32 */
/* ### pcunix.c ### */ /* ### pcunix.c ### */
+1 -1
View File
@@ -225,7 +225,7 @@ typedef xchar boolean; /* 0 or 1 */
#endif #endif
#if defined(MICRO) #if defined(MICRO)
#if !defined(AMIGA) && !defined(TOS) && !defined(OS2_HPFS) && !defined(WIN32) #if !defined(AMIGA) && !defined(TOS) && !defined(OS2_HPFS)
#define SHORT_FILENAMES /* filenames are 8.3 */ #define SHORT_FILENAMES /* filenames are 8.3 */
#endif #endif
#endif #endif
+25 -8
View File
@@ -18,9 +18,7 @@
#define PC_LOCKING /* Prevent overwrites of aborted or in-progress games */ #define PC_LOCKING /* Prevent overwrites of aborted or in-progress games */
/* without first receiving confirmation. */ /* without first receiving confirmation. */
#define NOCWD_ASSUMPTIONS /* Allow paths to be specified for HACKDIR,
LEVELDIR, SAVEDIR, BONESDIR, DATADIR,
SCOREDIR, LOCKDIR, and CONFIGDIR */
/* /*
* ----------------------------------------------------------------- * -----------------------------------------------------------------
@@ -29,7 +27,15 @@
*/ */
/* #define SHORT_FILENAMES /* All NT filesystems support long names now */ /* #define SHORT_FILENAMES /* All NT filesystems support long names now */
#define MICRO /* always define this! */ #ifdef MICRO
#undef MICRO /* never define this! */
#endif
#define NOCWD_ASSUMPTIONS /* Always define this. There are assumptions that
it is defined for WIN32.
Allow paths to be specified for HACKDIR,
LEVELDIR, SAVEDIR, BONESDIR, DATADIR,
SCOREDIR, LOCKDIR, and CONFIGDIR */
#define NO_TERMS #define NO_TERMS
#define ASCIIGRAPH #define ASCIIGRAPH
@@ -104,11 +110,22 @@
#define FILENAME_CMP stricmp /* case insensitive */ #define FILENAME_CMP stricmp /* case insensitive */
#endif #endif
#ifdef MICRO #if 0
# ifndef MICRO_H #ifndef C
#include "micro.h" /* contains necessary externs for [os_name].c */ #define C(c) (0x1f & (c))
# endif
#endif #endif
#ifndef M
#define M(c) (0x80 | (c))
#endif
extern char levels[], bones[], permbones[],
#endif /* 0 */
/* this was part of the MICRO stuff in the past */
extern const char *alllevels, *allbones;
extern char hackdir[];
#define ABORT C('a')
#define getuid() 1
#define getlogin() ((char *)0)
#include <fcntl.h> #include <fcntl.h>
#ifndef __BORLANDC__ #ifndef __BORLANDC__
+4 -4
View File
@@ -19,7 +19,7 @@ STATIC_DCL void NDECL(do_positionbar);
void void
moveloop() moveloop()
{ {
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
char ch; char ch;
int abort_lev; int abort_lev;
#endif #endif
@@ -315,7 +315,7 @@ moveloop()
flags.move = 1; flags.move = 1;
if(multi >= 0 && occupation) { if(multi >= 0 && occupation) {
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
abort_lev = 0; abort_lev = 0;
if (kbhit()) { if (kbhit()) {
if ((ch = Getchar()) == ABORT) if ((ch = Getchar()) == ABORT)
@@ -331,14 +331,14 @@ moveloop()
#endif #endif
occupation = 0; occupation = 0;
if( if(
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
abort_lev || abort_lev ||
#endif #endif
monster_nearby()) { monster_nearby()) {
stop_occupation(); stop_occupation();
reset_eat(); reset_eat();
} }
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
if (!(++occtime % 7)) if (!(++occtime % 7))
display_nhwindow(WIN_MAP, FALSE); display_nhwindow(WIN_MAP, FALSE);
#endif #endif
+1 -1
View File
@@ -56,7 +56,7 @@ register unsigned int lth;
#if defined(MONITOR_HEAP) || defined(WIZARD) #if defined(MONITOR_HEAP) || defined(WIZARD)
# ifdef MICRO # if defined(MICRO) || defined(WIN32)
/* we actually want to know which systems have an ANSI run-time library /* we actually want to know which systems have an ANSI run-time library
* to know which support the new %p format for printing pointers. * to know which support the new %p format for printing pointers.
* due to the presence of things like gcc, NHSTDC is not a good test. * due to the presence of things like gcc, NHSTDC is not a good test.
+4 -2
View File
@@ -77,10 +77,12 @@ NEARDATA long yn_number = 0L;
const char disclosure_options[] = "iavgc"; const char disclosure_options[] = "iavgc";
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
char hackdir[PATHLEN]; /* where rumors, help, record are */ char hackdir[PATHLEN]; /* where rumors, help, record are */
# ifdef MICRO
char levels[PATHLEN]; /* where levels are */ char levels[PATHLEN]; /* where levels are */
#endif /* MICRO */ # endif
#endif /* MICRO || WIN32 */
#ifdef MFLOPPY #ifdef MFLOPPY
+17 -3
View File
@@ -240,6 +240,10 @@ register struct monst *mtmp;
return; return;
} }
#if defined(WIN32)
#define NOTIFY_NETHACK_BUGS
#endif
/*VARARGS1*/ /*VARARGS1*/
void void
panic VA_DECL(const char *, str) panic VA_DECL(const char *, str)
@@ -260,15 +264,25 @@ panic VA_DECL(const char *, str)
"Program initialization has failed." : "Program initialization has failed." :
"Suddenly, the dungeon collapses."); "Suddenly, the dungeon collapses.");
#if defined(WIZARD) && !defined(MICRO) #if defined(WIZARD) && !defined(MICRO)
# if defined(NOTIFY_NETHACK_BUGS)
if (!wizard)
raw_printf("Report error to \"%s\".\n%s.\n",
"nethack-bugs@nethack.org",
!program_state.something_worth_saving ? "" :
"An error save file will be created.\n");
else if (program_state.something_worth_saving)
raw_print("\nAn error save file will be created.\n");
# else
if (!wizard) if (!wizard)
raw_printf("Report error to \"%s\"%s.", raw_printf("Report error to \"%s\"%s.",
# ifdef WIZARD_NAME /*(KR1ED)*/ # ifdef WIZARD_NAME /*(KR1ED)*/
WIZARD_NAME, WIZARD_NAME,
# else # else
WIZARD, WIZARD,
# endif # endif
!program_state.something_worth_saving ? "" : !program_state.something_worth_saving ? "" :
" and it may be possible to rebuild."); " and it may be possible to rebuild.");
# endif
if (program_state.something_worth_saving) { if (program_state.something_worth_saving) {
set_error_savefile(); set_error_savefile();
(void) dosave0(); (void) dosave0();
+12 -12
View File
@@ -238,7 +238,7 @@ int lev;
set_levelfile_name(lock, lev); set_levelfile_name(lock, lev);
fq_lock = fqname(lock, LEVELPREFIX, 0); fq_lock = fqname(lock, LEVELPREFIX, 0);
#if defined(MICRO) #if defined(MICRO) || defined(WIN32)
/* Use O_TRUNC to force the file to be shortened if it already /* Use O_TRUNC to force the file to be shortened if it already
* exists and is currently longer. * exists and is currently longer.
*/ */
@@ -249,7 +249,7 @@ int lev;
# else # else
fd = creat(fq_lock, FCMASK); fd = creat(fq_lock, FCMASK);
# endif # endif
#endif /* MICRO */ #endif /* MICRO || WIN32 */
if (fd >= 0) if (fd >= 0)
level_info[lev].flags |= LFILE_EXISTS; level_info[lev].flags |= LFILE_EXISTS;
@@ -377,7 +377,7 @@ char **bonesid;
file = set_bonestemp_name(); file = set_bonestemp_name();
file = fqname(file, BONESPREFIX, 0); file = fqname(file, BONESPREFIX, 0);
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
/* Use O_TRUNC to force the file to be shortened if it already /* Use O_TRUNC to force the file to be shortened if it already
* exists and is currently longer. * exists and is currently longer.
*/ */
@@ -399,7 +399,7 @@ char **bonesid;
*/ */
(void) chmod(file, FCMASK | 007); /* allow other users full access */ (void) chmod(file, FCMASK | 007); /* allow other users full access */
# endif /* VMS && !SECURE */ # endif /* VMS && !SECURE */
#endif /* MICRO */ #endif /* MICRO || WIN32*/
return fd; return fd;
} }
@@ -499,7 +499,7 @@ set_savefile_name()
regularize(SAVEF+7); regularize(SAVEF+7);
Strcat(SAVEF, ";1"); Strcat(SAVEF, ";1");
#else #else
# if defined(MICRO) && !defined(WIN32) # if defined(MICRO)
Strcpy(SAVEF, SAVEP); Strcpy(SAVEF, SAVEP);
# ifdef AMIGA # ifdef AMIGA
strncat(SAVEF, bbs_id, PATHLEN); strncat(SAVEF, bbs_id, PATHLEN);
@@ -566,7 +566,7 @@ create_savefile()
int fd; int fd;
fq_save = fqname(SAVEF, SAVEPREFIX, 0); fq_save = fqname(SAVEF, SAVEPREFIX, 0);
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
fd = open(fq_save, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK); fd = open(fq_save, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK);
#else #else
# ifdef MAC # ifdef MAC
@@ -1112,7 +1112,7 @@ const char *filename;
} }
} }
#if defined(MICRO) || defined(MAC) || defined(__BEOS__) #if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32)
if ((fp = fopenp(fqname(configfile, CONFIGPREFIX, 0), "r")) if ((fp = fopenp(fqname(configfile, CONFIGPREFIX, 0), "r"))
!= (FILE *)0) != (FILE *)0)
return(fp); return(fp);
@@ -1538,7 +1538,7 @@ const char *filename;
#define tmp_levels (char *)0 #define tmp_levels (char *)0
#define tmp_ramdisk (char *)0 #define tmp_ramdisk (char *)0
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
#undef tmp_levels #undef tmp_levels
char tmp_levels[PATHLEN]; char tmp_levels[PATHLEN];
# ifdef MFLOPPY # ifdef MFLOPPY
@@ -1553,7 +1553,7 @@ const char *filename;
if (!(fp = fopen_config_file(filename))) return; if (!(fp = fopen_config_file(filename))) return;
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
# ifdef MFLOPPY # ifdef MFLOPPY
# ifndef AMIGA # ifndef AMIGA
tmp_ramdisk[0] = 0; tmp_ramdisk[0] = 0;
@@ -1735,7 +1735,7 @@ const char *dir;
wait_synch(); wait_synch();
} }
#endif /* !UNIX && !VMS */ #endif /* !UNIX && !VMS */
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
char tmp[PATHLEN]; char tmp[PATHLEN];
# ifdef OS2_CODEVIEW /* explicit path on opening for OS/2 */ # ifdef OS2_CODEVIEW /* explicit path on opening for OS/2 */
@@ -1768,7 +1768,7 @@ const char *dir;
(void) close(fd); (void) close(fd);
} else /* open succeeded */ } else /* open succeeded */
(void) close(fd); (void) close(fd);
#else /* MICRO */ #else /* MICRO || WIN32*/
# ifdef MAC # ifdef MAC
/* Create the "record" file, if necessary */ /* Create the "record" file, if necessary */
@@ -1777,7 +1777,7 @@ const char *dir;
if (fd != -1) macclose (fd); if (fd != -1) macclose (fd);
# endif /* MAC */ # endif /* MAC */
#endif /* MICRO */ #endif /* MICRO || WIN32*/
} }
/* ---------- END SCOREBOARD CREATION ----------- */ /* ---------- END SCOREBOARD CREATION ----------- */
+3 -3
View File
@@ -62,7 +62,7 @@ static struct Bool_Opt
#else #else
{"checkspace", (boolean *)0, FALSE, SET_IN_FILE}, {"checkspace", (boolean *)0, FALSE, SET_IN_FILE},
#endif #endif
# ifdef MICRO # if defined(MICRO) || defined(WIN32)
{"color", &iflags.wc_color,TRUE, SET_IN_GAME}, /*WC*/ {"color", &iflags.wc_color,TRUE, SET_IN_GAME}, /*WC*/
# else /* systems that support multiple terminals, many monochrome */ # else /* systems that support multiple terminals, many monochrome */
{"color", &iflags.wc_color, FALSE, SET_IN_GAME}, /*WC*/ {"color", &iflags.wc_color, FALSE, SET_IN_GAME}, /*WC*/
@@ -144,7 +144,7 @@ static struct Bool_Opt
{"prayconfirm", &flags.prayconfirm, TRUE, SET_IN_GAME}, {"prayconfirm", &flags.prayconfirm, TRUE, SET_IN_GAME},
{"preload_tiles", &iflags.wc_preload_tiles, TRUE, DISP_IN_GAME}, /*WC*/ {"preload_tiles", &iflags.wc_preload_tiles, TRUE, DISP_IN_GAME}, /*WC*/
{"pushweapon", &flags.pushweapon, FALSE, SET_IN_GAME}, {"pushweapon", &flags.pushweapon, FALSE, SET_IN_GAME},
#if defined(MICRO) && !defined(AMIGA) && !defined(MSWIN_GRAPHICS) #if defined(MICRO) && !defined(AMIGA)
{"rawio", &iflags.rawio, FALSE, DISP_IN_GAME}, {"rawio", &iflags.rawio, FALSE, DISP_IN_GAME},
#else #else
{"rawio", (boolean *)0, FALSE, SET_IN_FILE}, {"rawio", (boolean *)0, FALSE, SET_IN_FILE},
@@ -2198,7 +2198,7 @@ map_menu_cmd(ch)
} }
#if defined(MICRO) || defined(MAC) #if defined(MICRO) || defined(MAC) || defined(WIN32)
# define OPTIONS_HEADING "OPTIONS" # define OPTIONS_HEADING "OPTIONS"
#else #else
# define OPTIONS_HEADING "NETHACKOPTIONS" # define OPTIONS_HEADING "NETHACKOPTIONS"
+1 -1
View File
@@ -6,7 +6,7 @@
#include "lev.h" #include "lev.h"
#include "tcap.h" /* for TERMLIB and ASCIIGRAPH */ #include "tcap.h" /* for TERMLIB and ASCIIGRAPH */
#ifdef MICRO #if defined(MICRO)
extern int dotcnt; /* shared with save */ extern int dotcnt; /* shared with save */
extern int dotrow; /* shared with save */ extern int dotrow; /* shared with save */
#endif #endif
+1 -1
View File
@@ -37,7 +37,7 @@ static long final_fpos;
#define POINTSMIN 1 /* must be > 0 */ #define POINTSMIN 1 /* must be > 0 */
#define ENTRYMAX 100 /* must be >= 10 */ #define ENTRYMAX 100 /* must be >= 10 */
#if !defined(MICRO) && !defined(MAC) #if !defined(MICRO) && !defined(MAC) && !defined(WIN32)
#define PERS_IS_UID /* delete for PERSMAX per name; now per uid */ #define PERS_IS_UID /* delete for PERSMAX per name; now per uid */
#endif #endif
struct toptenentry { struct toptenentry {
+1 -22
View File
@@ -56,7 +56,7 @@ STATIC_DCL boolean NDECL(comspec_exists);
extern int GUILaunched; /* from nttty.c */ extern int GUILaunched; /* from nttty.c */
#endif #endif
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
void void
flushout() flushout()
@@ -528,25 +528,4 @@ static void msexit()
#endif #endif
return; return;
} }
#ifdef WIN32
/*
* This is a kludge. Just before the release of 3.3.0 the latest
* version of a popular MAPI mail product was found to exhibit
* a strange result where the current directory was changed out
* from under NetHack resulting in a failure of all subsequent
* file operations in NetHack. This routine is called prior
* to all file open/renames/deletes in file.c.
*
* A more elegant solution will be sought after 3.3.0 is released.
*/
void dircheck()
{
char dirbuf[BUFSZ];
dirbuf[0] = '\0';
if (getcwd(dirbuf, sizeof dirbuf) != (char *)0)
/* pline("%s,%s",dirbuf,hackdir); */
if (strcmp(dirbuf,hackdir) != 0)
chdir(hackdir); /* chdir, not chdirx */
}
#endif
#endif /* MICRO || WIN32 || OS2 */ #endif /* MICRO || WIN32 || OS2 */
+1 -1
View File
@@ -48,7 +48,7 @@ int fd;
return(0); return(0);
} }
# else # else
# if defined(MICRO) && !defined(NO_FSTAT) # if (defined(MICRO) || defined(WIN32)) && !defined(NO_FSTAT)
if(fstat(fd, &buf)) { if(fstat(fd, &buf)) {
if(moves > 1) pline("Cannot get status of saved level? "); if(moves > 1) pline("Cannot get status of saved level? ");
else pline("Cannot get status of saved game"); else pline("Cannot get status of saved game");
+1 -1
View File
@@ -47,7 +47,7 @@
# define O_BINARY 0 # define O_BINARY 0
#endif #endif
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
# define OMASK FCMASK # define OMASK FCMASK
#else #else
# define OMASK 0644 # define OMASK 0644
+1 -1
View File
@@ -703,7 +703,7 @@ static const char *build_opts[] = {
#ifdef TERMINFO #ifdef TERMINFO
"terminal info library", "terminal info library",
#else #else
# if defined(TERMLIB) || (!defined(MICRO) && defined(TTY_GRAPHICS)) # if defined(TERMLIB) || ((!defined(MICRO) && !defined(WIN32)) && defined(TTY_GRAPHICS))
"terminal capability library", "terminal capability library",
# endif # endif
#endif #endif
+1 -1
View File
@@ -38,7 +38,7 @@ extern int NDECL(fclose_text_file);
extern void NDECL(init_colormap); extern void NDECL(init_colormap);
extern void NDECL(merge_colormap); extern void NDECL(merge_colormap);
#if defined(MICRO) #if defined(MICRO) || defined(WIN32)
#undef exit #undef exit
# if !defined(MSDOS) && !defined(WIN32) # if !defined(MSDOS) && !defined(WIN32)
extern void FDECL(exit, (int)); extern void FDECL(exit, (int));
+1 -1
View File
@@ -13,7 +13,7 @@ const char * FDECL(tilename, (int, int));
void NDECL(init_tilemap); void NDECL(init_tilemap);
void FDECL(process_substitutions, (FILE *)); void FDECL(process_substitutions, (FILE *));
#ifdef MICRO #if defined(MICRO) || defined(WIN32)
#undef exit #undef exit
#if !defined(MSDOS) && !defined(WIN32) #if !defined(MSDOS) && !defined(WIN32)
extern void FDECL(exit, (int)); extern void FDECL(exit, (int));