flag adjustments (trunk only)

Move all system or port specific flags to sysflags which is used only if
SYSFLAGS is defined, and leave everything else in flags unconditional.
This commit is contained in:
nethack.allison
2003-11-09 11:48:38 +00:00
parent da80c0572e
commit 7bab241f17
17 changed files with 107 additions and 73 deletions

View File

@@ -98,3 +98,7 @@ tty: add window port routines for saving/restoring message history
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

View File

@@ -1,4 +1,4 @@
/* 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. */
@@ -16,55 +16,34 @@
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) */
@@ -90,11 +69,6 @@ struct flag {
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.
*
@@ -135,6 +109,42 @@ struct flag {
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.
@@ -279,6 +289,9 @@ struct instance_flags {
#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 */

View File

@@ -13,7 +13,7 @@
* 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"

View File

@@ -137,6 +137,9 @@ struct trap *ftrap = (struct trap *)0;
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;

View File

@@ -1792,9 +1792,9 @@ char *tmp_levels;
}
# endif
}
# ifdef MFLOPPY
# if defined(SYSFLAGS) && defined(MFLOPPY)
else
saveprompt = flags.asksavedisk;
saveprompt = sysflags.asksavedisk;
# endif
(void) strncpy(SAVEP, bufp, SAVESIZE-1);
@@ -1866,14 +1866,16 @@ char *tmp_levels;
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"))

View File

@@ -7,6 +7,9 @@
#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
@@ -40,14 +43,14 @@ static struct Bool_Opt
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
@@ -95,8 +98,8 @@ static struct Bool_Opt
#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
@@ -140,8 +143,8 @@ static struct Bool_Opt
{"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
@@ -500,6 +503,10 @@ initoptions()
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;

View File

@@ -383,6 +383,9 @@ unsigned int *stuckid, *steedid; /* STEED */
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

View File

@@ -287,6 +287,9 @@ register int fd, mode;
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);

View File

@@ -266,8 +266,7 @@ saveDiskPrompt(start)
{
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);

View File

@@ -121,7 +121,7 @@ int how;
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;
@@ -310,7 +310,7 @@ 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;

View File

@@ -187,7 +187,7 @@ register struct IntuiMessage *message;
/* 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;
@@ -293,7 +293,7 @@ arrow:
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 */
@@ -813,7 +813,7 @@ GetFMsg(port)
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);

View File

@@ -1256,7 +1256,7 @@ SetBorder( gd )
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

View File

@@ -517,7 +517,7 @@ amiv_flush_glyph_buffer( vw )
amiv_start_glyphout( WIN_MAP );
#ifdef OPT_DISPMAP
if(flags.fast_map){
if(sysflags.fast_map){
#endif
#ifdef DISPMAP
display_map( vw );
@@ -756,7 +756,7 @@ amiv_lprint_glyph(window,color_index, glyph)
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
@@ -789,7 +789,7 @@ amiv_lprint_glyph(window,color_index, glyph)
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;
@@ -823,11 +823,11 @@ amiv_lprint_glyph(window,color_index, glyph)
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 );
@@ -1232,7 +1232,7 @@ dispmap_sanity(){
mxsize != mysize ||
dispmap_sanity1(mxsize) ||
dispmap_sanity1(mysize)){
flags.fast_map = 0;
sysflags.fast_map = 0;
}
}
int

View File

@@ -121,7 +121,7 @@ ami_wininit_data( void )
#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
@@ -1228,7 +1228,7 @@ amii_init_nhwindows(argcp,argv)
break;
case SA_Pens:
scrntags[i].ti_Data = (long)flags.amii_dripens;
scrntags[i].ti_Data = (long)sysflags.amii_dripens;
break;
}
}
@@ -1239,7 +1239,7 @@ amii_init_nhwindows(argcp,argv)
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 )
@@ -1286,7 +1286,7 @@ amii_init_nhwindows(argcp,argv)
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);

View File

@@ -336,8 +336,8 @@ EditColor( )
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 );
@@ -781,7 +781,7 @@ DrawCol( w, idx, colors )
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 );
@@ -790,7 +790,7 @@ DrawCol( w, idx, colors )
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 );
@@ -908,7 +908,7 @@ amii_setpens( int count )
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]));
}
}
@@ -919,7 +919,7 @@ amii_setpens( int count )
{
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]));
}
}
@@ -928,7 +928,7 @@ amii_setpens( int count )
#endif
if( count != amii_numcolors )
{
memcpy( flags.amii_curmap, amii_initmap,
memcpy( sysflags.amii_curmap, amii_initmap,
amii_numcolors*sizeof(amii_initmap[0]));
}
@@ -937,7 +937,7 @@ amii_setpens( int count )
*/
if( HackScreen != NULL )
{
LoadRGB4( &HackScreen->ViewPort, flags.amii_curmap, amii_numcolors );
LoadRGB4( &HackScreen->ViewPort, sysflags.amii_curmap, amii_numcolors );
}
}
@@ -1151,12 +1151,12 @@ void amii_change_color( pen, val, rev )
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 *
@@ -1169,7 +1169,7 @@ amii_get_color_string( )
*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 );
}

View File

@@ -2267,7 +2267,7 @@ mac_putstr (winid win, int attr, const char *str) {
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);

View File

@@ -277,7 +277,7 @@ int start;
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);
@@ -348,7 +348,7 @@ comspec_exists()
void
gameDiskPrompt()
{
if (flags.asksavedisk) {
if (sysflags.asksavedisk) {
if (record_exists() && comspec_exists())
return;
(void) putchar('\n');