Code Cleanup and Reorganization
-------------------------------
removed OVLx section dividers previously used for TRAMPOLINE overlay system
+move all flags that are system or port specific from flag struct to sysflags
+ struct which is used only if SYSFLAGS is defined
+all fields in flags struct are unconditionally present
+
-/* SCCS Id: @(#)flag.h 3.4 2002/08/22 */
+/* SCCS Id: @(#)flag.h 3.4 2003/11/09 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
struct flag {
boolean acoustics; /* allow dungeon sound messages */
-#ifdef AMIFLUSH
- boolean altmeta; /* use ALT keys as META */
- boolean amiflush; /* kill typeahead */
-#endif
-#ifdef MFLOPPY
- boolean asksavedisk;
-#endif
boolean autodig; /* MRKR: Automatically dig */
boolean autoquiver; /* Automatically fill quiver */
boolean beginner;
-#ifdef MAIL
boolean biff; /* enable checking for mail */
-#endif
boolean confirm; /* confirm before hitting tame monsters */
boolean debug; /* in debugging mode */
#define wizard flags.debug
boolean end_own; /* list all own scores */
boolean explore; /* in exploration mode */
-#ifdef OPT_DISPMAP
- boolean fast_map; /* use optimized, less flexible map display */
-#endif
#define discover flags.explore
boolean female;
boolean friday13; /* it's Friday the 13th */
boolean help; /* look in data file for info about stuff */
boolean ignintr; /* ignore interrupts */
-#ifdef INSURANCE
- boolean ins_chkpt; /* checkpoint as appropriate */
-#endif
+ boolean ins_chkpt; /* checkpoint as appropriate; INSURANCE */
boolean invlet_constant; /* let objects keep their inventory symbol */
boolean legacy; /* print game entry "story" */
boolean lit_corridor; /* show a dark corr as lit if it is in sight */
boolean nap; /* `timed_delay' option for display effects */
boolean null; /* OK to send nulls to the terminal */
-#ifdef MAC
- boolean page_wait; /* put up a --More-- after a page of messages */
-#endif
boolean perm_invent; /* keep full inventories up until dismissed */
boolean pickup; /* whether you pickup or move and look */
boolean pushweapon; /* When wielding, push old weapon into second slot */
boolean rest_on_space; /* space means rest */
boolean safe_dog; /* give complete protection to the dog */
-#ifdef EXP_ON_BOTL
boolean showexp; /* show experience points */
-#endif
-#ifdef SCORE_ON_BOTL
boolean showscore; /* show score */
-#endif
boolean silent; /* whether the bell rings or not */
boolean sortpack; /* sorted inventory */
boolean sparkle; /* show "resisting" special FX (Scott Bigham) */
char end_disclose[NUM_DISCLOSURE_OPTIONS + 1]; /* disclose various info
upon exit */
char menu_style; /* User interface style setting */
-#ifdef AMII_GRAPHICS
- int numcols;
- unsigned short amii_dripens[ 20 ]; /* DrawInfo Pens currently there are 13 in v39 */
- AMII_COLOR_TYPE amii_curmap[ AMII_MAXCOLORS ]; /* colormap */
-#endif
/* KMH, role patch -- Variables used during startup.
*
int runmode; /* update screen display during run moves */
};
+/*
+ * System-specific flags that are saved with the game if SYSFLAGS is defined.
+ */
+
+#if defined(AMIFLUSH) || defined(AMII_GRAPHICS) || defined(OPT_DISPMAP)
+#define SYSFLAGS
+#else
+#if defined(MFLOPPY) || defined(MAC)
+#define SYSFLAGS
+#endif
+#endif
+
+#ifdef SYSFLAGS
+struct sysflag {
+ char sysflagsid[10];
+#ifdef AMIFLUSH
+ boolean altmeta; /* use ALT keys as META */
+ boolean amiflush; /* kill typeahead */
+#endif
+#ifdef AMII_GRAPHICS
+ int numcols;
+ unsigned short amii_dripens[ 20 ]; /* DrawInfo Pens currently there are 13 in v39 */
+ AMII_COLOR_TYPE amii_curmap[ AMII_MAXCOLORS ]; /* colormap */
+#endif
+#ifdef OPT_DISPMAP
+ boolean fast_map; /* use optimized, less flexible map display */
+#endif
+#ifdef MFLOPPY
+ boolean asksavedisk;
+#endif
+#ifdef MAC
+ boolean page_wait; /* put up a --More-- after a page of messages */
+#endif
+};
+#endif
+
/*
* Flags that are set each time the game is started.
* These are not saved with the game.
#define preload_tiles wc_preload_tiles
extern NEARDATA struct flag flags;
+#ifdef SYSFLAGS
+extern NEARDATA struct sysflag sysflags;
+#endif
extern NEARDATA struct instance_flags iflags;
/* runmode options */
* Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files.
*/
-#define EDITLEVEL 6
+#define EDITLEVEL 7
#define COPYRIGHT_BANNER_A \
"NetHack, Copyright 1985-2003"
NEARDATA struct monst youmonst = DUMMY;
NEARDATA struct context_info context = DUMMY;
NEARDATA struct flag flags = DUMMY;
+#ifdef SYSFLAGS
+NEARDATA struct sysflag sysflags = DUMMY;
+#endif
NEARDATA struct instance_flags iflags = DUMMY;
NEARDATA struct you u = DUMMY;
}
# endif
}
-# ifdef MFLOPPY
+# if defined(SYSFLAGS) && defined(MFLOPPY)
else
- saveprompt = flags.asksavedisk;
+ saveprompt = sysflags.asksavedisk;
# endif
(void) strncpy(SAVEP, bufp, SAVESIZE-1);
extern int amii_numcolors;
int val = atoi( bufp );
amii_numcolors = 1L << min( DEPTH, val );
+#if defined(SYSFLAGS)
} else if (match_varname(buf, "DRIPENS", 7)) {
int i, val;
char *t;
for (i = 0, t = strtok(bufp, ",/"); t != (char *)0;
i < 20 && (t = strtok((char*)0, ",/")), ++i) {
sscanf(t, "%d", &val );
- flags.amii_dripens[i] = val;
+ sysflags.amii_dripens[i] = val;
}
+#endif
} else if (match_varname(buf, "SCREENMODE", 10 )) {
extern long amii_scrnmode;
if (!stricmp(bufp,"req"))
#include "objclass.h"
#include "flag.h"
NEARDATA struct flag flags; /* provide linkage */
+#ifdef SYSFLAGS
+NEARDATA struct sysflag sysflags; /* provide linkage */
+#endif
NEARDATA struct instance_flags iflags; /* provide linkage */
#define static
#else
int optflags;
} boolopt[] = {
{"acoustics", &flags.acoustics, TRUE, SET_IN_GAME},
-#ifdef AMIGA
- {"altmeta", &flags.altmeta, TRUE, DISP_IN_GAME},
+#if defined(SYSFLAGS) && defined(AMIGA)
+ {"altmeta", &sysflags.altmeta, TRUE, DISP_IN_GAME},
#else
{"altmeta", (boolean *)0, TRUE, DISP_IN_GAME},
#endif
{"ascii_map", &iflags.wc_ascii_map, !PREFER_TILED, SET_IN_GAME}, /*WC*/
-#ifdef MFLOPPY
- {"asksavedisk", &flags.asksavedisk, FALSE, SET_IN_GAME},
+#if defined(SYSFLAGS) && defined(MFLOPPY)
+ {"asksavedisk", &sysflags.asksavedisk, FALSE, SET_IN_GAME},
#else
{"asksavedisk", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#endif
{"female", &flags.female, FALSE, DISP_IN_GAME},
{"fixinv", &flags.invlet_constant, TRUE, SET_IN_GAME},
-#ifdef AMIFLUSH
- {"flush", &flags.amiflush, FALSE, SET_IN_GAME},
+#if defined(SYSFLAGS) && defined(AMIFLUSH)
+ {"flush", &sysflags.amiflush, FALSE, SET_IN_GAME},
#else
{"flush", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"news", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"null", &flags.null, TRUE, SET_IN_GAME},
-#ifdef MAC
- {"page_wait", &flags.page_wait, TRUE, SET_IN_GAME},
+#if defined(SYSFLAGS) && defined(MAC)
+ {"page_wait", &sysflags.page_wait, TRUE, SET_IN_GAME},
#else
{"page_wait", (boolean *)0, FALSE, SET_IN_FILE},
#endif
if (boolopt[i].addr)
*(boolopt[i].addr) = boolopt[i].initvalue;
}
+#ifdef SYSFLAGS
+ Strcpy(sysflags.sysflagsid, "sysflags");
+ sysflags.sysflagsid[9] = (char)sizeof(struct sysflag);
+#endif
flags.end_own = FALSE;
flags.end_top = 3;
flags.end_around = 2;
mread(fd, (genericptr_t) &context, sizeof(struct context_info));
mread(fd, (genericptr_t) &flags, sizeof(struct flag));
if (remember_discover) discover = remember_discover;
+#ifdef SYSFLAGS
+ mread(fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
+#endif
role_init(); /* Reset the initial role, race, gender, and alignment */
#ifdef AMII_GRAPHICS
bwrite(fd, (genericptr_t) &uid, sizeof uid);
bwrite(fd, (genericptr_t) &context, sizeof(struct context_info));
bwrite(fd, (genericptr_t) &flags, sizeof(struct flag));
+#ifdef SYSFLAGS
+ bwrite(fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
+#endif
#ifndef GOLDOBJ
if (u.ugold) {
struct obj *goldobj = mksobj(GOLD_PIECE, FALSE, FALSE);
{
char buf[BUFSIZ], *bp;
BPTR fileLock;
-
- if (flags.asksavedisk) {
+ if (sysflags.asksavedisk) {
/* Don't prompt if you can find the save file */
if (fileLock = Lock(SAVEF, SHARED_LOCK)) {
UnLock(fileLock);
newwin.Screen = HackScreen;
for( i = 0; i < amii_numcolors; ++i )
- flags.amii_curmap[i] = GetRGB4( HackScreen->ViewPort.ColorMap, i );
+ sysflags.amii_curmap[i] = GetRGB4( HackScreen->ViewPort.ColorMap, i );
ripwin = OpenWindow( (void *)&newwin );
if( !ripwin ) goto cleanup;
CloseWindow( ripwin );
Permit();
}
- LoadRGB4( &HackScreen->ViewPort, flags.amii_curmap, amii_numcolors );
+ LoadRGB4( &HackScreen->ViewPort, sysflags.amii_curmap, amii_numcolors );
if(tbmp[0])FreeImageFiles(load_list, tbmp);
if(just_return) return;
/* Allow ALT to function as a META key ... */
/* But make it switchable - alt is needed for some non-US keymaps */
- if(flags.altmeta)
+ if(sysflags.altmeta)
qualifier &= ~(IEQUALIFIER_LALT | IEQUALIFIER_RALT);
numeric_pad = (qualifier & IEQUALIFIER_NUMERICPAD) != 0;
and prevent it from interfering with # command (M-#) */
if (length == ('#'|0x80))
return '#';
- if (alt && flags.altmeta)
+ if (alt && sysflags.altmeta)
length |= 0x80;
return(length);
} /* else shift, ctrl, alt, amiga, F-key, shift-tab, etc */
struct IntuiMessage *msg,*succ,*succ1;
if(msg=(struct IntuiMessage *)GetMsg(port)){
- if(!flags.amiflush)return((struct Message *)msg);
+ if(!sysflags.amiflush)return((struct Message *)msg);
if(msg->Class==RAWKEY){
Forbid();
succ=(struct IntuiMessage *)(port->mp_MsgList.lh_Head);
register short *sp;
register int i, inc = -1, dec = -1;
int borders = 6;
- int hipen = flags.amii_dripens[ SHINEPEN ], shadowpen = flags.amii_dripens[ SHADOWPEN ];
+ int hipen = sysflags.amii_dripens[ SHINEPEN ], shadowpen = sysflags.amii_dripens[ SHADOWPEN ];
#ifdef INTUI_NEW_LOOK
struct DrawInfo *dip;
#endif
amiv_start_glyphout( WIN_MAP );
#ifdef OPT_DISPMAP
- if(flags.fast_map){
+ if(sysflags.fast_map){
#endif
#ifdef DISPMAP
display_map( vw );
w->Height - 1 );
#ifdef OPT_DISPMAP
- if(flags.fast_map){
+ if(sysflags.fast_map){
#endif /* keni */
#ifdef DISPMAP
/* display_map() needs byte-aligned destinations, and we don't want to
struct RastPort *rp = w->RPort;
x = rp->cp_x - pictdata.xsize - 3;
#ifdef OPT_DISPMAP
- if(flags.fast_map){
+ if(sysflags.fast_map){
#endif
#ifdef DISPMAP
x &= -8;
pictdata.xsize, pictdata.ysize, 0xc0 );
apen = rp->FgPen;
- SetAPen( rp, flags.amii_dripens[ SHINEPEN ] );
+ SetAPen( rp, sysflags.amii_dripens[ SHINEPEN ] );
Move( rp, x-1, y + pictdata.ysize );
Draw( rp, x-1, y - 1 );
Draw( rp, x + pictdata.xsize, y - 1 );
- SetAPen( rp, flags.amii_dripens[ SHADOWPEN ] );
+ SetAPen( rp, sysflags.amii_dripens[ SHADOWPEN ] );
Move( rp, x + pictdata.xsize, y );
Draw( rp, x + pictdata.xsize, y + pictdata.ysize );
Draw( rp, x, y + pictdata.ysize );
mxsize != mysize ||
dispmap_sanity1(mxsize) ||
dispmap_sanity1(mysize)){
- flags.fast_map = 0;
+ sysflags.fast_map = 0;
}
}
int
#ifdef OPT_DISPMAP
dispmap_sanity();
#endif
- memcpy(flags.amii_dripens,amii_defpens,sizeof(flags.amii_dripens));
+ memcpy(sysflags.amii_dripens,amii_defpens,sizeof(sysflags.amii_dripens));
}
# ifdef INTUI_NEW_LOOK
break;
case SA_Pens:
- scrntags[i].ti_Data = (long)flags.amii_dripens;
+ scrntags[i].ti_Data = (long)sysflags.amii_dripens;
break;
}
}
amii_bmhd = ReadTileImageFiles( );
else
memcpy( amii_initmap, amii_init_map, sizeof( amii_initmap ) );
- memcpy(flags.amii_curmap,amii_initmap,sizeof(flags.amii_curmap));
+ memcpy(sysflags.amii_curmap,amii_initmap,sizeof(sysflags.amii_curmap));
/* Find out how deep the screen needs to be, 32 planes is enough! */
for( i = 0; i < 32; ++i )
amiIDisplay->ypix = HackScreen->Height;
amiIDisplay->xpix = HackScreen->Width;
- LoadRGB4(&HackScreen->ViewPort, flags.amii_curmap, amii_numcolors );
+ LoadRGB4(&HackScreen->ViewPort, sysflags.amii_curmap, amii_numcolors );
VisualInfo = GetVisualInfo(HackScreen, TAG_END);
MenuStrip = CreateMenus(GTHackMenu, TAG_END);
if( okay )
{
for( i = 0; i < ( amii_numcolors ); ++i )
- flags.amii_curmap[ i ] = colors[ i ];
- LoadRGB4( &scrn->ViewPort, flags.amii_curmap, amii_numcolors );
+ sysflags.amii_curmap[ i ] = colors[ i ];
+ LoadRGB4( &scrn->ViewPort, sysflags.amii_curmap, amii_numcolors );
}
else
LoadRGB4( &scrn->ViewPort, svcolors, amii_numcolors );
if( i == idx )
{
- SetAPen( w->RPort, flags.amii_dripens[ SHADOWPEN ] );
+ SetAPen( w->RPort, sysflags.amii_dripens[ SHADOWPEN ] );
Move( w->RPort, x, y+bxylen-4 );
Draw( w->RPort, x, y );
Draw( w->RPort, x+incx-1, y );
Draw( w->RPort, x+1, y+1 );
Draw( w->RPort, x+incx-2, y+1 );
- SetAPen( w->RPort, flags.amii_dripens[ SHINEPEN ] );
+ SetAPen( w->RPort, sysflags.amii_dripens[ SHINEPEN ] );
Move( w->RPort, x+incx-1, y+1 );
Draw( w->RPort, x+incx-1, y+bxylen-4 );
Draw( w->RPort, x, y+bxylen-4 );
args[1] = amii_numcolors;
if( EasyRequest( NULL, &ea2, NULL, args ) == 1 )
{
- memcpy( flags.amii_curmap, amii_initmap,
+ memcpy( sysflags.amii_curmap, amii_initmap,
amii_numcolors*sizeof(amii_initmap[0]));
}
}
{
if( EasyRequest( NULL, &ea, NULL, NULL ) == 1 )
{
- memcpy( flags.amii_curmap, amii_initmap,
+ memcpy( sysflags.amii_curmap, amii_initmap,
amii_numcolors*sizeof(amii_initmap[0]));
}
}
#endif
if( count != amii_numcolors )
{
- memcpy( flags.amii_curmap, amii_initmap,
+ memcpy( sysflags.amii_curmap, amii_initmap,
amii_numcolors*sizeof(amii_initmap[0]));
}
*/
if( HackScreen != NULL )
{
- LoadRGB4( &HackScreen->ViewPort, flags.amii_curmap, amii_numcolors );
+ LoadRGB4( &HackScreen->ViewPort, sysflags.amii_curmap, amii_numcolors );
}
}
long val;
{
if( rev )
- flags.amii_curmap[ pen ] = ~val;
+ sysflags.amii_curmap[ pen ] = ~val;
else
- flags.amii_curmap[ pen ] = val;
+ sysflags.amii_curmap[ pen ] = val;
if( HackScreen )
- LoadRGB4( &HackScreen->ViewPort, flags.amii_curmap, amii_numcolors );
+ LoadRGB4( &HackScreen->ViewPort, sysflags.amii_curmap, amii_numcolors );
}
char *
*buf = 0;
for( i = 0; i < min(32,amii_numcolors); ++i )
{
- sprintf( s, "%s%03lx", i ? "/" : "", (long)flags.amii_curmap[ i ] );
+ sprintf( s, "%s%03lx", i ? "/" : "", (long)sysflags.amii_curmap[ i ] );
strcat( buf, s );
}
if (win == WIN_MESSAGE) {
r.right -= SBARWIDTH;
r.bottom -= SBARHEIGHT;
- if (flags.page_wait &&
+ if (sysflags.page_wait &&
aWin->last_more_lin <= aWin->y_size - (r.bottom - r.top) / aWin->row_height) {
aWin->last_more_lin = aWin->y_size;
mac_display_nhwindow(win, TRUE);
int fd;
- if (flags.asksavedisk) {
+ if (sysflags.asksavedisk) {
/* Don't prompt if you can find the save file */
if ((fd = open_savefile()) >= 0) {
(void) close(fd);
void
gameDiskPrompt()
{
- if (flags.asksavedisk) {
+ if (sysflags.asksavedisk) {
if (record_exists() && comspec_exists())
return;
(void) putchar('\n');