Even more globals moved to instance_globals.c

This commit is contained in:
Bart House
2018-12-19 20:01:55 -08:00
parent ff5fe26e72
commit e4ab048c90
14 changed files with 269 additions and 239 deletions
+61 -1
View File
@@ -552,6 +552,32 @@ struct trapinfo {
boolean force_bungle; boolean force_bungle;
}; };
typedef struct {
xchar gnew; /* perhaps move this bit into the rm structure. */
int glyph;
} gbuf_entry;
enum vanq_order_modes {
VANQ_MLVL_MNDX = 0,
VANQ_MSTR_MNDX,
VANQ_ALPHA_SEP,
VANQ_ALPHA_MIX,
VANQ_MCLS_HTOL,
VANQ_MCLS_LTOH,
VANQ_COUNT_H_L,
VANQ_COUNT_L_H,
NUM_VANQ_ORDER_MODES
};
struct rogueroom {
xchar rlx, rly;
xchar dx, dy;
boolean real;
uchar doortable;
int nroom; /* Only meaningful for "real" rooms */
};
/* instance_globals holds engine state that does not need to be /* instance_globals holds engine state that does not need to be
* persisted upon game exit. The initialization state is well defined * persisted upon game exit. The initialization state is well defined
* an set in decl.c during early early engine initialization. * an set in decl.c during early early engine initialization.
@@ -559,6 +585,7 @@ struct trapinfo {
* unlike instance_flags, values in the structure can be of any type. */ * unlike instance_flags, values in the structure can be of any type. */
#define BSIZE 20 #define BSIZE 20
#define WIZKIT_MAX 128
struct instance_globals { struct instance_globals {
@@ -603,6 +630,7 @@ struct instance_globals {
coord clicklook_cc; coord clicklook_cc;
winid en_win; winid en_win;
boolean en_via_menu; boolean en_via_menu;
int last_multi;
/* dbridge.c */ /* dbridge.c */
struct entity occupants[ENTITIES]; struct entity occupants[ENTITIES];
@@ -611,6 +639,12 @@ struct instance_globals {
boolean did_dig_msg; boolean did_dig_msg;
/* display.c */
gbuf_entry gbuf[ROWNO][COLNO];
char gbuf_start[ROWNO];
char gbuf_stop[ROWNO];
/* do.c */ /* do.c */
boolean at_ladder; boolean at_ladder;
char *dfr_pre_msg; /* pline() before level change */ char *dfr_pre_msg; /* pline() before level change */
@@ -622,6 +656,11 @@ struct instance_globals {
int gloc_filter_floodfill_match_glyph; int gloc_filter_floodfill_match_glyph;
int via_naming; int via_naming;
/* do_wear.c */
/* starting equipment gets auto-worn at beginning of new game,
and we don't want stealth or displacement feedback then */
boolean initial_don; /* manipulated in set_wear() */
/* dog.c */ /* dog.c */
int petname_used; /* user preferred pet name has been used */ int petname_used; /* user preferred pet name has been used */
xchar gtyp; /* type of dog's current goal */ xchar gtyp; /* type of dog's current goal */
@@ -648,12 +687,29 @@ struct instance_globals {
/* eat.c */ /* eat.c */
boolean force_save_hs; boolean force_save_hs;
char *eatmbuf; /* set by cpostfx() */
/* end.c */ /* end.c */
struct valuable_data gems[LAST_GEM + 1 - FIRST_GEM + 1]; /* +1 for glass */ struct valuable_data gems[LAST_GEM + 1 - FIRST_GEM + 1]; /* +1 for glass */
struct valuable_data amulets[LAST_AMULET + 1 - FIRST_AMULET]; struct valuable_data amulets[LAST_AMULET + 1 - FIRST_AMULET];
struct val_list valuables[3]; struct val_list valuables[3];
int vanq_sortmode;
/* extralev.c */
struct rogueroom r[3][3];
/* files.c */
char wizkit[WIZKIT_MAX];
int lockptr;
char *config_section_chosen;
char *config_section_current;
int nesting;
int symset_count; /* for pick-list building only */
boolean chosen_symset_start;
boolean chosen_symset_end;
int symset_which_set;
/* hack.c */ /* hack.c */
anything tmp_anything; anything tmp_anything;
int wc; /* current weight_cap(); valid after call to inv_weight() */ int wc; /* current weight_cap(); valid after call to inv_weight() */
@@ -727,6 +783,10 @@ struct instance_globals {
modified */ modified */
int distantname; int distantname;
/* options.c */
struct symsetentry *symset_list; /* files.c will populate this with
list of available sets */
/* pickup.c */ /* pickup.c */
int oldcap; /* last encumberance */ int oldcap; /* last encumberance */
/* current_container is set in use_container(), to be used by the /* current_container is set in use_container(), to be used by the
+4 -7
View File
@@ -5320,9 +5320,6 @@ boolean doit;
return ch; return ch;
} }
static NEARDATA int last_multi;
/* /*
* convert a MAP window position into a movecmd * convert a MAP window position into a movecmd
*/ */
@@ -5543,7 +5540,7 @@ parse()
long tmpmulti = multi; long tmpmulti = multi;
foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti, FALSE); foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti, FALSE);
last_multi = multi = tmpmulti; g.last_multi = multi = tmpmulti;
} }
#ifdef ALTMETA #ifdef ALTMETA
alt_esc = FALSE; /* readchar() reset */ alt_esc = FALSE; /* readchar() reset */
@@ -5557,11 +5554,11 @@ parse()
if (foo == g.Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */ if (foo == g.Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */
clear_nhwindow(WIN_MESSAGE); clear_nhwindow(WIN_MESSAGE);
multi = last_multi = 0; multi = g.last_multi = 0;
} else if (foo == g.Cmd.spkeys[NHKF_DOAGAIN] || in_doagain) { } else if (foo == g.Cmd.spkeys[NHKF_DOAGAIN] || in_doagain) {
multi = last_multi; multi = g.last_multi;
} else { } else {
last_multi = multi; g.last_multi = multi;
savech(0); /* reset input queue */ savech(0); /* reset input queue */
savech((char) foo); savech((char) foo);
} }
+28
View File
@@ -354,6 +354,7 @@ const struct instance_globals g_init = {
UNDEFINED_VALUES, /* clicklook_cc */ UNDEFINED_VALUES, /* clicklook_cc */
WIN_ERR, /* en_win */ WIN_ERR, /* en_win */
FALSE, /* en_via_menu */ FALSE, /* en_via_menu */
UNDEFINED_VALUE, /* last_multi */
/* dbridge.c */ /* dbridge.c */
UNDEFINED_VALUES, UNDEFINED_VALUES,
@@ -361,6 +362,11 @@ const struct instance_globals g_init = {
/* dig.c */ /* dig.c */
UNDEFINED_VALUE, /* did_dig_msg */ UNDEFINED_VALUE, /* did_dig_msg */
/* display.c */
UNDEFINED_VALUES,
UNDEFINED_VALUES,
UNDEFINED_VALUES,
/* do.c */ /* do.c */
FALSE, /* at_ladder */ FALSE, /* at_ladder */
NULL, /* dfr_pre_msg */ NULL, /* dfr_pre_msg */
@@ -372,6 +378,9 @@ const struct instance_globals g_init = {
UNDEFINED_VALUE, /* gloc_filter_floodfill_match_glyph */ UNDEFINED_VALUE, /* gloc_filter_floodfill_match_glyph */
0, /* via_naming */ 0, /* via_naming */
/* do_wear.c */
FALSE, /* initial_don */
/* dog.c */ /* dog.c */
0, /* petname_used */ 0, /* petname_used */
UNDEFINED_VALUE, /* gtyp */ UNDEFINED_VALUE, /* gtyp */
@@ -398,11 +407,27 @@ const struct instance_globals g_init = {
/* eat.c */ /* eat.c */
FALSE, /* force_save_hs */ FALSE, /* force_save_hs */
NULL, /* eatmbuf */
/* end.c */ /* end.c */
UNDEFINED_VALUES, UNDEFINED_VALUES,
UNDEFINED_VALUES, UNDEFINED_VALUES,
UNDEFINED_VALUES, UNDEFINED_VALUES,
VANQ_MLVL_MNDX,
/* extralev.c */
UNDEFINED_VALUES,
/* files.c */
UNDEFINED_VALUES, /* wizkit */
UNDEFINED_VALUE, /* lockptr */
NULL, /* config_section_chosen */
NULL, /* config_section_current */
0, /* nesting */
0, /* symset_count */
FALSE, /* chosen_symset_start */
FALSE, /* chosen_symset_end */
0, /* symset_which_set */
/* hack.c */ /* hack.c */
UNDEFINED_VALUES, UNDEFINED_VALUES,
@@ -461,6 +486,9 @@ const struct instance_globals g_init = {
/* objname.c */ /* objname.c */
0, /* distantname */ 0, /* distantname */
/* options.c */
NULL, /* symset_list */
/* pickup.c */ /* pickup.c */
0, /* oldcap */ 0, /* oldcap */
UNDEFINED_PTR, /* current_container */ UNDEFINED_PTR, /* current_container */
-2
View File
@@ -5,8 +5,6 @@
#include "hack.h" #include "hack.h"
static NEARDATA boolean did_dig_msg;
STATIC_DCL boolean NDECL(rm_waslit); STATIC_DCL boolean NDECL(rm_waslit);
STATIC_DCL void FDECL(mkcavepos, STATIC_DCL void FDECL(mkcavepos,
(XCHAR_P, XCHAR_P, int, BOOLEAN_P, BOOLEAN_P)); (XCHAR_P, XCHAR_P, int, BOOLEAN_P, BOOLEAN_P));
+24 -33
View File
@@ -1378,15 +1378,6 @@ docrt()
/* Glyph Buffering (3rd screen) ============================================ /* Glyph Buffering (3rd screen) ============================================
*/ */
typedef struct {
xchar new; /* perhaps move this bit into the rm structure. */
int glyph;
} gbuf_entry;
static gbuf_entry gbuf[ROWNO][COLNO];
static char gbuf_start[ROWNO];
static char gbuf_stop[ROWNO];
/* FIXME: This is a dirty hack, because newsym() doesn't distinguish /* FIXME: This is a dirty hack, because newsym() doesn't distinguish
* between object piles and single objects, it doesn't mark the location * between object piles and single objects, it doesn't mark the location
* for update. */ * for update. */
@@ -1395,11 +1386,11 @@ newsym_force(x, y)
register int x, y; register int x, y;
{ {
newsym(x,y); newsym(x,y);
gbuf[y][x].new = 1; g.gbuf[y][x].gnew = 1;
if (gbuf_start[y] > x) if (g.gbuf_start[y] > x)
gbuf_start[y] = x; g.gbuf_start[y] = x;
if (gbuf_stop[y] < x) if (g.gbuf_stop[y] < x)
gbuf_stop[y] = x; g.gbuf_stop[y] = x;
} }
/* /*
@@ -1475,13 +1466,13 @@ int x, y, glyph;
return; return;
} }
if (gbuf[y][x].glyph != glyph || iflags.use_background_glyph) { if (g.gbuf[y][x].glyph != glyph || iflags.use_background_glyph) {
gbuf[y][x].glyph = glyph; g.gbuf[y][x].glyph = glyph;
gbuf[y][x].new = 1; g.gbuf[y][x].gnew = 1;
if (gbuf_start[y] > x) if (g.gbuf_start[y] > x)
gbuf_start[y] = x; g.gbuf_start[y] = x;
if (gbuf_stop[y] < x) if (g.gbuf_stop[y] < x)
gbuf_stop[y] = x; g.gbuf_stop[y] = x;
} }
} }
@@ -1494,12 +1485,12 @@ int x, y, glyph;
int i; \ int i; \
\ \
for (i = 0; i < ROWNO; i++) { \ for (i = 0; i < ROWNO; i++) { \
gbuf_start[i] = COLNO - 1; \ g.gbuf_start[i] = COLNO - 1; \
gbuf_stop[i] = 0; \ g.gbuf_stop[i] = 0; \
} \ } \
} }
static gbuf_entry nul_gbuf = { 0, cmap_to_glyph(S_stone) }; static const gbuf_entry nul_gbuf = { 0, cmap_to_glyph(S_stone) };
/* /*
* Turn the 3rd screen into stone. * Turn the 3rd screen into stone.
*/ */
@@ -1510,7 +1501,7 @@ clear_glyph_buffer()
register gbuf_entry *gptr; register gbuf_entry *gptr;
for (y = 0; y < ROWNO; y++) { for (y = 0; y < ROWNO; y++) {
gptr = &gbuf[y][0]; gptr = &g.gbuf[y][0];
for (x = COLNO; x; x--) { for (x = COLNO; x; x--) {
*gptr++ = nul_gbuf; *gptr++ = nul_gbuf;
} }
@@ -1528,8 +1519,8 @@ int start, stop, y;
register int x; register int x;
for (x = start; x <= stop; x++) for (x = start; x <= stop; x++)
if (gbuf[y][x].glyph != cmap_to_glyph(S_stone)) if (g.gbuf[y][x].glyph != cmap_to_glyph(S_stone))
print_glyph(WIN_MAP, x, y, gbuf[y][x].glyph, get_bk_glyph(x,y)); print_glyph(WIN_MAP, x, y, g.gbuf[y][x].glyph, get_bk_glyph(x,y));
} }
void void
@@ -1575,11 +1566,11 @@ int cursor_on_u;
#endif #endif
for (y = 0; y < ROWNO; y++) { for (y = 0; y < ROWNO; y++) {
register gbuf_entry *gptr = &gbuf[y][x = gbuf_start[y]]; register gbuf_entry *gptr = &g.gbuf[y][x = g.gbuf_start[y]];
for (; x <= gbuf_stop[y]; gptr++, x++) for (; x <= g.gbuf_stop[y]; gptr++, x++)
if (gptr->new) { if (gptr->gnew) {
print_glyph(WIN_MAP, x, y, gptr->glyph, get_bk_glyph(x, y)); print_glyph(WIN_MAP, x, y, gptr->glyph, get_bk_glyph(x, y));
gptr->new = 0; gptr->gnew = 0;
} }
} }
@@ -1791,7 +1782,7 @@ xchar x, y;
{ {
if (x < 0 || y < 0 || x >= COLNO || y >= ROWNO) if (x < 0 || y < 0 || x >= COLNO || y >= ROWNO)
return cmap_to_glyph(S_room); /* XXX */ return cmap_to_glyph(S_room); /* XXX */
return gbuf[y][x].glyph; return g.gbuf[y][x].glyph;
} }
/* /*
@@ -1812,7 +1803,7 @@ xchar x, y;
struct rm *lev = &levl[x][y]; struct rm *lev = &levl[x][y];
if (iflags.use_background_glyph && lev->seenv != 0 if (iflags.use_background_glyph && lev->seenv != 0
&& gbuf[y][x].glyph != cmap_to_glyph(S_stone)) { && g.gbuf[y][x].glyph != cmap_to_glyph(S_stone)) {
switch (lev->typ) { switch (lev->typ) {
case SCORR: case SCORR:
case STONE: case STONE:
+4 -8
View File
@@ -71,10 +71,6 @@ struct obj *otmp;
} }
} }
/* starting equipment gets auto-worn at beginning of new game,
and we don't want stealth or displacement feedback then */
static boolean initial_don = FALSE; /* manipulated in set_wear() */
/* putting on or taking off an item which confers stealth; /* putting on or taking off an item which confers stealth;
give feedback and discover it iff stealth state is changing */ give feedback and discover it iff stealth state is changing */
STATIC_OVL STATIC_OVL
@@ -84,7 +80,7 @@ struct obj *obj;
long oldprop; /* prop[].extrinsic, with obj->owornmask stripped by caller */ long oldprop; /* prop[].extrinsic, with obj->owornmask stripped by caller */
boolean on; boolean on;
{ {
if (on ? initial_don : context.takeoff.cancelled_don) if (on ? g.initial_don : context.takeoff.cancelled_don)
return; return;
if (!oldprop /* extrinsic stealth from something else */ if (!oldprop /* extrinsic stealth from something else */
@@ -118,7 +114,7 @@ struct obj *obj;
long oldprop; /* prop[].extrinsic, with obj->owornmask stripped by caller */ long oldprop; /* prop[].extrinsic, with obj->owornmask stripped by caller */
boolean on; boolean on;
{ {
if (on ? initial_don : context.takeoff.cancelled_don) if (on ? g.initial_don : context.takeoff.cancelled_don)
return; return;
if (!oldprop /* extrinsic displacement from something else */ if (!oldprop /* extrinsic displacement from something else */
@@ -1161,7 +1157,7 @@ void
set_wear(obj) set_wear(obj)
struct obj *obj; /* if null, do all worn items; otherwise just obj itself */ struct obj *obj; /* if null, do all worn items; otherwise just obj itself */
{ {
initial_don = !obj; g.initial_don = !obj;
if (!obj ? ublindf != 0 : (obj == ublindf)) if (!obj ? ublindf != 0 : (obj == ublindf))
(void) Blindf_on(ublindf); (void) Blindf_on(ublindf);
@@ -1187,7 +1183,7 @@ struct obj *obj; /* if null, do all worn items; otherwise just obj itself */
if (!obj ? uarms != 0 : (obj == uarms)) if (!obj ? uarms != 0 : (obj == uarms))
(void) Shield_on(); (void) Shield_on();
initial_don = FALSE; g.initial_don = FALSE;
} }
/* check whether the target object is currently being put on (or taken off-- /* check whether the target object is currently being put on (or taken off--
+1 -1
View File
@@ -1334,7 +1334,7 @@ genericptr_t distance;
} }
} }
static struct qmchoices { static const struct qmchoices {
int mndx; /* type of pet, 0 means any */ int mndx; /* type of pet, 0 means any */
char mlet; /* symbol of pet, 0 means any */ char mlet; /* symbol of pet, 0 means any */
unsigned mappearance; /* mimic this */ unsigned mappearance; /* mimic this */
+1 -1
View File
@@ -569,7 +569,7 @@ const char *known_restrictions[] = {
"primary", "rogue", (const char *) 0, "primary", "rogue", (const char *) 0,
}; };
struct symparse loadsyms[] = { const struct symparse loadsyms[] = {
{ SYM_CONTROL, 0, "start" }, { SYM_CONTROL, 0, "start" },
{ SYM_CONTROL, 0, "begin" }, { SYM_CONTROL, 0, "begin" },
{ SYM_CONTROL, 1, "finish" }, { SYM_CONTROL, 1, "finish" },
+11 -13
View File
@@ -144,17 +144,15 @@ static const struct {
{ "", 0, 0, 0 } }; { "", 0, 0, 0 } };
#define TTSZ SIZE(tintxts) #define TTSZ SIZE(tintxts)
static char *eatmbuf = 0; /* set by cpostfx() */
/* called after mimicing is over */ /* called after mimicing is over */
STATIC_PTR int STATIC_PTR int
eatmdone(VOID_ARGS) eatmdone(VOID_ARGS)
{ {
/* release `eatmbuf' */ /* release `eatmbuf' */
if (eatmbuf) { if (g.eatmbuf) {
if (nomovemsg == eatmbuf) if (nomovemsg == g.eatmbuf)
nomovemsg = 0; nomovemsg = 0;
free((genericptr_t) eatmbuf), eatmbuf = 0; free((genericptr_t) g.eatmbuf), g.eatmbuf = 0;
} }
/* update display */ /* update display */
if (youmonst.m_ap_type) { if (youmonst.m_ap_type) {
@@ -171,7 +169,7 @@ eatmupdate()
const char *altmsg = 0; const char *altmsg = 0;
int altapp = 0; /* lint suppression */ int altapp = 0; /* lint suppression */
if (!eatmbuf || nomovemsg != eatmbuf) if (!g.eatmbuf || nomovemsg != g.eatmbuf)
return; return;
if (is_obj_mappear(&youmonst,ORANGE) && !Hallucination) { if (is_obj_mappear(&youmonst,ORANGE) && !Hallucination) {
@@ -188,11 +186,11 @@ eatmupdate()
if (altmsg) { if (altmsg) {
/* replace end-of-mimicking message */ /* replace end-of-mimicking message */
if (strlen(altmsg) > strlen(eatmbuf)) { if (strlen(altmsg) > strlen(g.eatmbuf)) {
free((genericptr_t) eatmbuf); free((genericptr_t) g.eatmbuf);
eatmbuf = (char *) alloc(strlen(altmsg) + 1); g.eatmbuf = (char *) alloc(strlen(altmsg) + 1);
} }
nomovemsg = strcpy(eatmbuf, altmsg); nomovemsg = strcpy(g.eatmbuf, altmsg);
/* update current image */ /* update current image */
youmonst.mappearance = altapp; youmonst.mappearance = altapp;
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
@@ -947,7 +945,7 @@ int pm;
/* in case `afternmv' didn't get called for previously mimicking /* in case `afternmv' didn't get called for previously mimicking
gold, clean up now to avoid `eatmbuf' memory leak */ gold, clean up now to avoid `eatmbuf' memory leak */
if (eatmbuf) if (g.eatmbuf)
(void) eatmdone(); (void) eatmdone();
switch (pm) { switch (pm) {
@@ -1033,8 +1031,8 @@ int pm;
? "You suddenly dread being peeled and mimic %s again!" ? "You suddenly dread being peeled and mimic %s again!"
: "You now prefer mimicking %s again.", : "You now prefer mimicking %s again.",
an(Upolyd ? youmonst.data->mname : urace.noun)); an(Upolyd ? youmonst.data->mname : urace.noun));
eatmbuf = dupstr(buf); g.eatmbuf = dupstr(buf);
nomovemsg = eatmbuf; nomovemsg = g.eatmbuf;
afternmv = eatmdone; afternmv = eatmdone;
/* ??? what if this was set before? */ /* ??? what if this was set before? */
youmonst.m_ap_type = M_AP_OBJECT; youmonst.m_ap_type = M_AP_OBJECT;
+10 -24
View File
@@ -1637,19 +1637,6 @@ int status;
nethack_exit(status); nethack_exit(status);
} }
enum vanq_order_modes {
VANQ_MLVL_MNDX = 0,
VANQ_MSTR_MNDX,
VANQ_ALPHA_SEP,
VANQ_ALPHA_MIX,
VANQ_MCLS_HTOL,
VANQ_MCLS_LTOH,
VANQ_COUNT_H_L,
VANQ_COUNT_L_H,
NUM_VANQ_ORDER_MODES
};
static const char *vanqorders[NUM_VANQ_ORDER_MODES] = { static const char *vanqorders[NUM_VANQ_ORDER_MODES] = {
"traditional: by monster level, by internal monster index", "traditional: by monster level, by internal monster index",
"by monster toughness, by internal monster index", "by monster toughness, by internal monster index",
@@ -1660,7 +1647,6 @@ static const char *vanqorders[NUM_VANQ_ORDER_MODES] = {
"by count, high to low, by internal index within tied count", "by count, high to low, by internal index within tied count",
"by count, low to high, by internal index within tied count", "by count, low to high, by internal index within tied count",
}; };
static int vanq_sortmode = VANQ_MLVL_MNDX;
STATIC_PTR int CFDECLSPEC STATIC_PTR int CFDECLSPEC
vanqsort_cmp(vptr1, vptr2) vanqsort_cmp(vptr1, vptr2)
@@ -1672,7 +1658,7 @@ const genericptr vptr2;
const char *name1, *name2, *punct; const char *name1, *name2, *punct;
schar mcls1, mcls2; schar mcls1, mcls2;
switch (vanq_sortmode) { switch (g.vanq_sortmode) {
default: default:
case VANQ_MLVL_MNDX: case VANQ_MLVL_MNDX:
/* sort by monster level */ /* sort by monster level */
@@ -1724,7 +1710,7 @@ const genericptr vptr2;
if (res == 0) { if (res == 0) {
mlev1 = mons[indx1].mlevel, mlev2 = mons[indx2].mlevel; mlev1 = mons[indx1].mlevel, mlev2 = mons[indx2].mlevel;
res = mlev1 - mlev2; /* mlevel low to high */ res = mlev1 - mlev2; /* mlevel low to high */
if (vanq_sortmode == VANQ_MCLS_HTOL) if (g.vanq_sortmode == VANQ_MCLS_HTOL)
res = -res; /* mlevel high to low */ res = -res; /* mlevel high to low */
} }
break; break;
@@ -1732,7 +1718,7 @@ const genericptr vptr2;
case VANQ_COUNT_L_H: case VANQ_COUNT_L_H:
died1 = mvitals[indx1].died, died2 = mvitals[indx2].died; died1 = mvitals[indx1].died, died2 = mvitals[indx2].died;
res = died2 - died1; /* dead count high to low */ res = died2 - died1; /* dead count high to low */
if (vanq_sortmode == VANQ_COUNT_L_H) if (g.vanq_sortmode == VANQ_COUNT_L_H)
res = -res; /* dead count low to high */ res = -res; /* dead count low to high */
break; break;
} }
@@ -1759,7 +1745,7 @@ set_vanq_order()
continue; continue;
any.a_int = i + 1; any.a_int = i + 1;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, vanqorders[i], add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, vanqorders[i],
(i == vanq_sortmode) ? MENU_SELECTED : MENU_UNSELECTED); (i == g.vanq_sortmode) ? MENU_SELECTED : MENU_UNSELECTED);
} }
end_menu(tmpwin, "Sort order for vanquished monster counts"); end_menu(tmpwin, "Sort order for vanquished monster counts");
@@ -1768,12 +1754,12 @@ set_vanq_order()
if (n > 0) { if (n > 0) {
choice = selected[0].item.a_int - 1; choice = selected[0].item.a_int - 1;
/* skip preselected entry if we have more than one item chosen */ /* skip preselected entry if we have more than one item chosen */
if (n > 1 && choice == vanq_sortmode) if (n > 1 && choice == g.vanq_sortmode)
choice = selected[1].item.a_int - 1; choice = selected[1].item.a_int - 1;
free((genericptr_t) selected); free((genericptr_t) selected);
vanq_sortmode = choice; g.vanq_sortmode = choice;
} }
return (n < 0) ? -1 : vanq_sortmode; return (n < 0) ? -1 : g.vanq_sortmode;
} }
/* #vanquished command */ /* #vanquished command */
@@ -1835,9 +1821,9 @@ boolean ask;
if (set_vanq_order() < 0) if (set_vanq_order() < 0)
return; return;
} }
uniq_header = (vanq_sortmode == VANQ_ALPHA_SEP); uniq_header = (g.vanq_sortmode == VANQ_ALPHA_SEP);
class_header = (vanq_sortmode == VANQ_MCLS_LTOH class_header = (g.vanq_sortmode == VANQ_MCLS_LTOH
|| vanq_sortmode == VANQ_MCLS_HTOL); || g.vanq_sortmode == VANQ_MCLS_HTOL);
klwin = create_nhwindow(NHW_MENU); klwin = create_nhwindow(NHW_MENU);
putstr(klwin, 0, "Vanquished creatures:"); putstr(klwin, 0, "Vanquished creatures:");
+1 -1
View File
@@ -5,7 +5,7 @@
#include "hack.h" #include "hack.h"
/* Note: Arrays are column first, while the screen is row first */ /* Note: Arrays are column first, while the screen is row first */
static int explosion[3][3] = { { S_explode1, S_explode4, S_explode7 }, static const int explosion[3][3] = { { S_explode1, S_explode4, S_explode7 },
{ S_explode2, S_explode5, S_explode8 }, { S_explode2, S_explode5, S_explode8 },
{ S_explode3, S_explode6, S_explode9 } }; { S_explode3, S_explode6, S_explode9 } };
+35 -43
View File
@@ -8,19 +8,11 @@
#include "hack.h" #include "hack.h"
struct rogueroom {
xchar rlx, rly;
xchar dx, dy;
boolean real;
uchar doortable;
int nroom; /* Only meaningful for "real" rooms */
};
#define UP 1 #define UP 1
#define DOWN 2 #define DOWN 2
#define LEFT 4 #define LEFT 4
#define RIGHT 8 #define RIGHT 8
static NEARDATA struct rogueroom r[3][3];
STATIC_DCL void FDECL(roguejoin, (int, int, int, int, int)); STATIC_DCL void FDECL(roguejoin, (int, int, int, int, int));
STATIC_DCL void FDECL(roguecorr, (int, int, int)); STATIC_DCL void FDECL(roguecorr, (int, int, int));
STATIC_DCL void FDECL(miniwalk, (int, int)); STATIC_DCL void FDECL(miniwalk, (int, int));
@@ -59,20 +51,20 @@ int x, y, dir;
register int fromx, fromy, tox, toy; register int fromx, fromy, tox, toy;
if (dir == DOWN) { if (dir == DOWN) {
r[x][y].doortable &= ~DOWN; g.r[x][y].doortable &= ~DOWN;
if (!r[x][y].real) { if (!g.r[x][y].real) {
fromx = r[x][y].rlx; fromx = g.r[x][y].rlx;
fromy = r[x][y].rly; fromy = g.r[x][y].rly;
fromx += 1 + 26 * x; fromx += 1 + 26 * x;
fromy += 7 * y; fromy += 7 * y;
} else { } else {
fromx = r[x][y].rlx + rn2(r[x][y].dx); fromx = g.r[x][y].rlx + rn2(g.r[x][y].dx);
fromy = r[x][y].rly + r[x][y].dy; fromy = g.r[x][y].rly + g.r[x][y].dy;
fromx += 1 + 26 * x; fromx += 1 + 26 * x;
fromy += 7 * y; fromy += 7 * y;
if (!IS_WALL(levl[fromx][fromy].typ)) if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?", fromx, fromy); impossible("down: no wall at %d,%d?", fromx, fromy);
dodoor(fromx, fromy, &rooms[r[x][y].nroom]); dodoor(fromx, fromy, &rooms[g.r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR; levl[fromx][fromy].doormask = D_NODOOR;
fromy++; fromy++;
} }
@@ -81,40 +73,40 @@ int x, y, dir;
return; return;
} }
y++; y++;
r[x][y].doortable &= ~UP; g.r[x][y].doortable &= ~UP;
if (!r[x][y].real) { if (!g.r[x][y].real) {
tox = r[x][y].rlx; tox = g.r[x][y].rlx;
toy = r[x][y].rly; toy = g.r[x][y].rly;
tox += 1 + 26 * x; tox += 1 + 26 * x;
toy += 7 * y; toy += 7 * y;
} else { } else {
tox = r[x][y].rlx + rn2(r[x][y].dx); tox = g.r[x][y].rlx + rn2(g.r[x][y].dx);
toy = r[x][y].rly - 1; toy = g.r[x][y].rly - 1;
tox += 1 + 26 * x; tox += 1 + 26 * x;
toy += 7 * y; toy += 7 * y;
if (!IS_WALL(levl[tox][toy].typ)) if (!IS_WALL(levl[tox][toy].typ))
impossible("up: no wall at %d,%d?", tox, toy); impossible("up: no wall at %d,%d?", tox, toy);
dodoor(tox, toy, &rooms[r[x][y].nroom]); dodoor(tox, toy, &rooms[g.r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR; levl[tox][toy].doormask = D_NODOOR;
toy--; toy--;
} }
roguejoin(fromx, fromy, tox, toy, FALSE); roguejoin(fromx, fromy, tox, toy, FALSE);
return; return;
} else if (dir == RIGHT) { } else if (dir == RIGHT) {
r[x][y].doortable &= ~RIGHT; g.r[x][y].doortable &= ~RIGHT;
if (!r[x][y].real) { if (!g.r[x][y].real) {
fromx = r[x][y].rlx; fromx = g.r[x][y].rlx;
fromy = r[x][y].rly; fromy = g.r[x][y].rly;
fromx += 1 + 26 * x; fromx += 1 + 26 * x;
fromy += 7 * y; fromy += 7 * y;
} else { } else {
fromx = r[x][y].rlx + r[x][y].dx; fromx = g.r[x][y].rlx + g.r[x][y].dx;
fromy = r[x][y].rly + rn2(r[x][y].dy); fromy = g.r[x][y].rly + rn2(g.r[x][y].dy);
fromx += 1 + 26 * x; fromx += 1 + 26 * x;
fromy += 7 * y; fromy += 7 * y;
if (!IS_WALL(levl[fromx][fromy].typ)) if (!IS_WALL(levl[fromx][fromy].typ))
impossible("down: no wall at %d,%d?", fromx, fromy); impossible("down: no wall at %d,%d?", fromx, fromy);
dodoor(fromx, fromy, &rooms[r[x][y].nroom]); dodoor(fromx, fromy, &rooms[g.r[x][y].nroom]);
levl[fromx][fromy].doormask = D_NODOOR; levl[fromx][fromy].doormask = D_NODOOR;
fromx++; fromx++;
} }
@@ -123,20 +115,20 @@ int x, y, dir;
return; return;
} }
x++; x++;
r[x][y].doortable &= ~LEFT; g.r[x][y].doortable &= ~LEFT;
if (!r[x][y].real) { if (!g.r[x][y].real) {
tox = r[x][y].rlx; tox = g.r[x][y].rlx;
toy = r[x][y].rly; toy = g.r[x][y].rly;
tox += 1 + 26 * x; tox += 1 + 26 * x;
toy += 7 * y; toy += 7 * y;
} else { } else {
tox = r[x][y].rlx - 1; tox = g.r[x][y].rlx - 1;
toy = r[x][y].rly + rn2(r[x][y].dy); toy = g.r[x][y].rly + rn2(g.r[x][y].dy);
tox += 1 + 26 * x; tox += 1 + 26 * x;
toy += 7 * y; toy += 7 * y;
if (!IS_WALL(levl[tox][toy].typ)) if (!IS_WALL(levl[tox][toy].typ))
impossible("left: no wall at %d,%d?", tox, toy); impossible("left: no wall at %d,%d?", tox, toy);
dodoor(tox, toy, &rooms[r[x][y].nroom]); dodoor(tox, toy, &rooms[g.r[x][y].nroom]);
levl[tox][toy].doormask = D_NODOOR; levl[tox][toy].doormask = D_NODOOR;
tox--; tox--;
} }
@@ -157,18 +149,18 @@ int x, y;
while (1) { while (1) {
q = 0; q = 0;
#define doorhere (r[x][y].doortable) #define doorhere (g.r[x][y].doortable)
if (x > 0 && (!(doorhere & LEFT)) if (x > 0 && (!(doorhere & LEFT))
&& (!r[x - 1][y].doortable || !rn2(10))) && (!g.r[x - 1][y].doortable || !rn2(10)))
dirs[q++] = 0; dirs[q++] = 0;
if (x < 2 && (!(doorhere & RIGHT)) if (x < 2 && (!(doorhere & RIGHT))
&& (!r[x + 1][y].doortable || !rn2(10))) && (!g.r[x + 1][y].doortable || !rn2(10)))
dirs[q++] = 1; dirs[q++] = 1;
if (y > 0 && (!(doorhere & UP)) if (y > 0 && (!(doorhere & UP))
&& (!r[x][y - 1].doortable || !rn2(10))) && (!g.r[x][y - 1].doortable || !rn2(10)))
dirs[q++] = 2; dirs[q++] = 2;
if (y < 2 && (!(doorhere & DOWN)) if (y < 2 && (!(doorhere & DOWN))
&& (!r[x][y + 1].doortable || !rn2(10))) && (!g.r[x][y + 1].doortable || !rn2(10)))
dirs[q++] = 3; dirs[q++] = 3;
/* Rogue levels aren't just 3 by 3 mazes; they have some extra /* Rogue levels aren't just 3 by 3 mazes; they have some extra
* connections, thus that 1/10 chance * connections, thus that 1/10 chance
@@ -222,7 +214,7 @@ makeroguerooms()
* Room height may be 2-4 (2-5 on last row), length 2-23 (not * Room height may be 2-4 (2-5 on last row), length 2-23 (not
* counting walls). * counting walls).
*/ */
#define here r[x][y] #define here g.r[x][y]
nroom = 0; nroom = 0;
for (y = 0; y < 3; y++) for (y = 0; y < 3; y++)
@@ -256,7 +248,7 @@ makeroguerooms()
if (here.real) { /* Make a room */ if (here.real) { /* Make a room */
int lowx, lowy, hix, hiy; int lowx, lowy, hix, hiy;
r[x][y].nroom = nroom; g.r[x][y].nroom = nroom;
smeq[nroom] = nroom; smeq[nroom] = nroom;
lowx = 1 + 26 * x + here.rlx; lowx = 1 + 26 * x + here.rlx;
+80 -93
View File
@@ -125,15 +125,12 @@ struct level_ftrack {
#endif #endif
#endif /*HOLD_LOCKFILE_OPEN*/ #endif /*HOLD_LOCKFILE_OPEN*/
#define WIZKIT_MAX 128
static char wizkit[WIZKIT_MAX];
STATIC_DCL FILE *NDECL(fopen_wizkit_file); STATIC_DCL FILE *NDECL(fopen_wizkit_file);
STATIC_DCL void FDECL(wizkit_addinv, (struct obj *)); STATIC_DCL void FDECL(wizkit_addinv, (struct obj *));
#ifdef AMIGA #ifdef AMIGA
extern char PATH[]; /* see sys/amiga/amidos.c */ extern char PATH[]; /* see sys/amiga/amidos.c */
extern char bbs_id[]; extern char bbs_id[];
static int lockptr;
#ifdef __SASC_60 #ifdef __SASC_60
#include <proto/dos.h> #include <proto/dos.h>
#endif #endif
@@ -143,7 +140,6 @@ extern void FDECL(amii_set_text_font, (char *, int));
#endif #endif
#if defined(WIN32) || defined(MSDOS) #if defined(WIN32) || defined(MSDOS)
static int lockptr;
#ifdef MSDOS #ifdef MSDOS
#define Delay(a) msleep(a) #define Delay(a) msleep(a)
#endif #endif
@@ -215,9 +211,6 @@ STATIC_DCL int FDECL(open_levelfile_exclusively, (const char *, int, int));
#endif #endif
static char *config_section_chosen = (char *) 0;
static char *config_section_current = (char *) 0;
/* /*
* fname_encode() * fname_encode()
* *
@@ -1611,8 +1604,6 @@ boolean uncomp;
/* ---------- BEGIN FILE LOCKING HANDLING ----------- */ /* ---------- BEGIN FILE LOCKING HANDLING ----------- */
static int nesting = 0;
#if defined(NO_FILE_LINKS) || defined(USE_FCNTL) /* implies UNIX */ #if defined(NO_FILE_LINKS) || defined(USE_FCNTL) /* implies UNIX */
static int lockfd; /* for lock_file() to pass to unlock_file() */ static int lockfd; /* for lock_file() to pass to unlock_file() */
#endif #endif
@@ -1674,8 +1665,8 @@ int retryct;
const char *lockname; const char *lockname;
#endif #endif
nesting++; g.nesting++;
if (nesting > 1) { if (g.nesting > 1) {
impossible("TRIED TO NEST LOCKS"); impossible("TRIED TO NEST LOCKS");
return TRUE; return TRUE;
} }
@@ -1692,7 +1683,7 @@ int retryct;
if (lockfd == -1) { if (lockfd == -1) {
HUP raw_printf("Cannot open file %s. Is NetHack installed correctly?", HUP raw_printf("Cannot open file %s. Is NetHack installed correctly?",
filename); filename);
nesting--; g.nesting--;
return FALSE; return FALSE;
} }
sflock.l_type = F_WRLCK; sflock.l_type = F_WRLCK;
@@ -1722,7 +1713,7 @@ int retryct;
HUP(void) raw_print("I give up. Sorry."); HUP(void) raw_print("I give up. Sorry.");
HUP raw_printf("Some other process has an unnatural grip on %s.", HUP raw_printf("Some other process has an unnatural grip on %s.",
filename); filename);
nesting--; g.nesting--;
return FALSE; return FALSE;
} }
#else #else
@@ -1742,25 +1733,25 @@ int retryct;
HUP(void) raw_print("I give up. Sorry."); HUP(void) raw_print("I give up. Sorry.");
HUP raw_printf("Perhaps there is an old %s around?", HUP raw_printf("Perhaps there is an old %s around?",
lockname); lockname);
nesting--; g.nesting--;
return FALSE; return FALSE;
} }
break; break;
case ENOENT: case ENOENT:
HUP raw_printf("Can't find file %s to lock!", filename); HUP raw_printf("Can't find file %s to lock!", filename);
nesting--; g.nesting--;
return FALSE; return FALSE;
case EACCES: case EACCES:
HUP raw_printf("No write permission to lock %s!", filename); HUP raw_printf("No write permission to lock %s!", filename);
nesting--; g.nesting--;
return FALSE; return FALSE;
#ifdef VMS /* c__translate(vmsfiles.c) */ #ifdef VMS /* c__translate(vmsfiles.c) */
case EPERM: case EPERM:
/* could be misleading, but usually right */ /* could be misleading, but usually right */
HUP raw_printf("Can't lock %s due to directory protection.", HUP raw_printf("Can't lock %s due to directory protection.",
filename); filename);
nesting--; g.nesting--;
return FALSE; return FALSE;
#endif #endif
case EROFS: case EROFS:
@@ -1769,13 +1760,13 @@ int retryct;
HUP raw_printf("Cannot lock %s.", filename); HUP raw_printf("Cannot lock %s.", filename);
HUP raw_printf( HUP raw_printf(
"(Perhaps you are running NetHack from inside the distribution package?)."); "(Perhaps you are running NetHack from inside the distribution package?).");
nesting--; g.nesting--;
return FALSE; return FALSE;
default: default:
HUP perror(lockname); HUP perror(lockname);
HUP raw_printf("Cannot lock %s for unknown reason (%d).", HUP raw_printf("Cannot lock %s for unknown reason (%d).",
filename, errnosv); filename, errnosv);
nesting--; g.nesting--;
return FALSE; return FALSE;
} }
#endif /* USE_FCNTL */ #endif /* USE_FCNTL */
@@ -1786,23 +1777,23 @@ int retryct;
&& !defined(USE_FCNTL) && !defined(USE_FCNTL)
#ifdef AMIGA #ifdef AMIGA
#define OPENFAILURE(fd) (!fd) #define OPENFAILURE(fd) (!fd)
lockptr = 0; g.lockptr = 0;
#else #else
#define OPENFAILURE(fd) (fd < 0) #define OPENFAILURE(fd) (fd < 0)
lockptr = -1; g.lockptr = -1;
#endif #endif
while (--retryct && OPENFAILURE(lockptr)) { while (--retryct && OPENFAILURE(g.lockptr)) {
#if defined(WIN32) && !defined(WIN_CE) #if defined(WIN32) && !defined(WIN_CE)
lockptr = sopen(lockname, O_RDWR | O_CREAT, SH_DENYRW, S_IWRITE); g.lockptr = sopen(lockname, O_RDWR | O_CREAT, SH_DENYRW, S_IWRITE);
#else #else
(void) DeleteFile(lockname); /* in case dead process was here first */ (void) DeleteFile(lockname); /* in case dead process was here first */
#ifdef AMIGA #ifdef AMIGA
lockptr = Open(lockname, MODE_NEWFILE); g.lockptr = Open(lockname, MODE_NEWFILE);
#else #else
lockptr = open(lockname, O_RDWR | O_CREAT | O_EXCL, S_IWRITE); g.lockptr = open(lockname, O_RDWR | O_CREAT | O_EXCL, S_IWRITE);
#endif #endif
#endif #endif
if (OPENFAILURE(lockptr)) { if (OPENFAILURE(g.lockptr)) {
raw_printf("Waiting for access to %s. (%d retries left).", raw_printf("Waiting for access to %s. (%d retries left).",
filename, retryct); filename, retryct);
Delay(50); Delay(50);
@@ -1810,7 +1801,7 @@ int retryct;
} }
if (!retryct) { if (!retryct) {
raw_printf("I give up. Sorry."); raw_printf("I give up. Sorry.");
nesting--; g.nesting--;
return FALSE; return FALSE;
} }
#endif /* AMIGA || WIN32 || MSDOS */ #endif /* AMIGA || WIN32 || MSDOS */
@@ -1834,7 +1825,7 @@ const char *filename;
const char *lockname; const char *lockname;
#endif #endif
if (nesting == 1) { if (g.nesting == 1) {
#ifdef USE_FCNTL #ifdef USE_FCNTL
sflock.l_type = F_UNLCK; sflock.l_type = F_UNLCK;
if (fcntl(lockfd, F_SETLK, &sflock) == -1) { if (fcntl(lockfd, F_SETLK, &sflock) == -1) {
@@ -1857,15 +1848,15 @@ const char *filename;
#endif /* UNIX || VMS */ #endif /* UNIX || VMS */
#if defined(AMIGA) || defined(WIN32) || defined(MSDOS) #if defined(AMIGA) || defined(WIN32) || defined(MSDOS)
if (lockptr) if (g.lockptr)
Close(lockptr); Close(g.lockptr);
DeleteFile(lockname); DeleteFile(lockname);
lockptr = 0; g.lockptr = 0;
#endif /* AMIGA || WIN32 || MSDOS */ #endif /* AMIGA || WIN32 || MSDOS */
#endif /* USE_FCNTL */ #endif /* USE_FCNTL */
} }
nesting--; g.nesting--;
} }
/* ---------- END FILE LOCKING HANDLING ----------- */ /* ---------- END FILE LOCKING HANDLING ----------- */
@@ -2183,13 +2174,13 @@ char sep;
STATIC_OVL void STATIC_OVL void
free_config_sections() free_config_sections()
{ {
if (config_section_chosen) { if (g.config_section_chosen) {
free(config_section_chosen); free(g.config_section_chosen);
config_section_chosen = NULL; g.config_section_chosen = NULL;
} }
if (config_section_current) { if (g.config_section_current) {
free(config_section_current); free(g.config_section_current);
config_section_current = NULL; g.config_section_current = NULL;
} }
} }
@@ -2208,20 +2199,20 @@ char *buf;
{ {
if (is_config_section(buf)) { if (is_config_section(buf)) {
char *send; char *send;
if (config_section_current) { if (g.config_section_current) {
free(config_section_current); free(g.config_section_current);
} }
config_section_current = dupstr(&buf[1]); g.config_section_current = dupstr(&buf[1]);
send = rindex(config_section_current, ']'); send = rindex(g.config_section_current, ']');
*send = '\0'; *send = '\0';
debugpline1("set config section: '%s'", config_section_current); debugpline1("set config section: '%s'", g.config_section_current);
return TRUE; return TRUE;
} }
if (config_section_current) { if (g.config_section_current) {
if (!config_section_chosen) if (!g.config_section_chosen)
return TRUE; return TRUE;
if (strcmp(config_section_current, config_section_chosen)) if (strcmp(g.config_section_current, g.config_section_chosen))
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@@ -2562,7 +2553,7 @@ char *origbuf;
} }
switch_symbols(TRUE); switch_symbols(TRUE);
} else if (match_varname(buf, "WIZKIT", 6)) { } else if (match_varname(buf, "WIZKIT", 6)) {
(void) strncpy(wizkit, bufp, WIZKIT_MAX - 1); (void) strncpy(g.wizkit, bufp, WIZKIT_MAX - 1);
#ifdef AMIGA #ifdef AMIGA
} else if (match_varname(buf, "FONT", 4)) { } else if (match_varname(buf, "FONT", 4)) {
char *t; char *t;
@@ -2873,58 +2864,58 @@ fopen_wizkit_file()
envp = nh_getenv("WIZKIT"); envp = nh_getenv("WIZKIT");
if (envp && *envp) if (envp && *envp)
(void) strncpy(wizkit, envp, WIZKIT_MAX - 1); (void) strncpy(g.wizkit, envp, WIZKIT_MAX - 1);
if (!wizkit[0]) if (!g.wizkit[0])
return (FILE *) 0; return (FILE *) 0;
#ifdef UNIX #ifdef UNIX
if (access(wizkit, 4) == -1) { if (access(g.wizkit, 4) == -1) {
/* 4 is R_OK on newer systems */ /* 4 is R_OK on newer systems */
/* nasty sneaky attempt to read file through /* nasty sneaky attempt to read file through
* NetHack's setuid permissions -- this is a * NetHack's setuid permissions -- this is a
* place a file name may be wholly under the player's * place a file name may be wholly under the player's
* control * control
*/ */
raw_printf("Access to %s denied (%d).", wizkit, errno); raw_printf("Access to %s denied (%d).", g.wizkit, errno);
wait_synch(); wait_synch();
/* fall through to standard names */ /* fall through to standard names */
} else } else
#endif #endif
if ((fp = fopenp(wizkit, "r")) != (FILE *) 0) { if ((fp = fopenp(g.wizkit, "r")) != (FILE *) 0) {
return fp; return fp;
#if defined(UNIX) || defined(VMS) #if defined(UNIX) || defined(VMS)
} else { } else {
/* access() above probably caught most problems for UNIX */ /* access() above probably caught most problems for UNIX */
raw_printf("Couldn't open requested config file %s (%d).", wizkit, raw_printf("Couldn't open requested config file %s (%d).", g.wizkit,
errno); errno);
wait_synch(); wait_synch();
#endif #endif
} }
#if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32) #if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32)
if ((fp = fopenp(fqname(wizkit, CONFIGPREFIX, 0), "r")) != (FILE *) 0) if ((fp = fopenp(fqname(g.wizkit, CONFIGPREFIX, 0), "r")) != (FILE *) 0)
return fp; return fp;
#else #else
#ifdef VMS #ifdef VMS
envp = nh_getenv("HOME"); envp = nh_getenv("HOME");
if (envp) if (envp)
Sprintf(tmp_wizkit, "%s%s", envp, wizkit); Sprintf(tmp_wizkit, "%s%s", envp, g.wizkit);
else else
Sprintf(tmp_wizkit, "%s%s", "sys$login:", wizkit); Sprintf(tmp_wizkit, "%s%s", "sys$login:", g.wizkit);
if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *) 0) if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *) 0)
return fp; return fp;
#else /* should be only UNIX left */ #else /* should be only UNIX left */
envp = nh_getenv("HOME"); envp = nh_getenv("HOME");
if (envp) if (envp)
Sprintf(tmp_wizkit, "%s/%s", envp, wizkit); Sprintf(tmp_wizkit, "%s/%s", envp, g.wizkit);
else else
Strcpy(tmp_wizkit, wizkit); Strcpy(tmp_wizkit, g.wizkit);
if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *) 0) if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *) 0)
return fp; return fp;
else if (errno != ENOENT) { else if (errno != ENOENT) {
/* e.g., problems when setuid NetHack can't search home /* e.g., problems when setuid NetHack can't search home
* directory restricted to user */ * directory restricted to user */
raw_printf("Couldn't open default wizkit file %s (%d).", tmp_wizkit, raw_printf("Couldn't open default g.wizkit file %s (%d).", tmp_wizkit,
errno); errno);
wait_synch(); wait_synch();
} }
@@ -3106,11 +3097,11 @@ boolean FDECL((*proc), (char *));
continue; continue;
} }
bufp++; bufp++;
if (config_section_chosen) if (g.config_section_chosen)
free(config_section_chosen); free(g.config_section_chosen);
section = choose_random_part(bufp, ','); section = choose_random_part(bufp, ',');
if (section) if (section)
config_section_chosen = dupstr(section); g.config_section_chosen = dupstr(section);
else { else {
config_error_add("No config section to choose"); config_error_add("No config section to choose");
rv = FALSE; rv = FALSE;
@@ -3136,13 +3127,9 @@ boolean FDECL((*proc), (char *));
return rv; return rv;
} }
extern struct symsetentry *symset_list; /* options.c */
extern struct symparse loadsyms[]; /* drawing.c */ extern struct symparse loadsyms[]; /* drawing.c */
extern const char *known_handling[]; /* drawing.c */ extern const char *known_handling[]; /* drawing.c */
extern const char *known_restrictions[]; /* drawing.c */ extern const char *known_restrictions[]; /* drawing.c */
static int symset_count = 0; /* for pick-list building only */
static boolean chosen_symset_start = FALSE, chosen_symset_end = FALSE;
static int symset_which_set = 0;
STATIC_OVL STATIC_OVL
FILE * FILE *
@@ -3167,16 +3154,16 @@ int which_set;
if (!(fp = fopen_sym_file())) if (!(fp = fopen_sym_file()))
return 0; return 0;
symset_count = 0; g.symset_count = 0;
chosen_symset_start = chosen_symset_end = FALSE; g.chosen_symset_start = g.chosen_symset_end = FALSE;
symset_which_set = which_set; g.symset_which_set = which_set;
config_error_init(TRUE, "symbols", FALSE); config_error_init(TRUE, "symbols", FALSE);
parse_conf_file(fp, proc_symset_line); parse_conf_file(fp, proc_symset_line);
(void) fclose(fp); (void) fclose(fp);
if (!chosen_symset_start && !chosen_symset_end) { if (!g.chosen_symset_start && !g.chosen_symset_end) {
/* name caller put in symset[which_set].name was not found; /* name caller put in symset[which_set].name was not found;
if it looks like "Default symbols", null it out and return if it looks like "Default symbols", null it out and return
success to use the default; otherwise, return failure */ success to use the default; otherwise, return failure */
@@ -3188,7 +3175,7 @@ int which_set;
config_error_done(); config_error_done();
return (g.symset[which_set].name == 0) ? 1 : 0; return (g.symset[which_set].name == 0) ? 1 : 0;
} }
if (!chosen_symset_end) if (!g.chosen_symset_end)
config_error_add("Missing finish for symset \"%s\"", config_error_add("Missing finish for symset \"%s\"",
g.symset[which_set].name ? g.symset[which_set].name g.symset[which_set].name ? g.symset[which_set].name
: "unknown"); : "unknown");
@@ -3202,7 +3189,7 @@ boolean
proc_symset_line(buf) proc_symset_line(buf)
char *buf; char *buf;
{ {
return !((boolean) parse_sym_line(buf, symset_which_set)); return !((boolean) parse_sym_line(buf, g.symset_which_set));
} }
/* returns 0 on error */ /* returns 0 on error */
@@ -3235,9 +3222,9 @@ int which_set;
if (!bufp) { if (!bufp) {
if (strncmpi(buf, "finish", 6) == 0) { if (strncmpi(buf, "finish", 6) == 0) {
/* end current graphics set */ /* end current graphics set */
if (chosen_symset_start) if (g.chosen_symset_start)
chosen_symset_end = TRUE; g.chosen_symset_end = TRUE;
chosen_symset_start = FALSE; g.chosen_symset_start = FALSE;
return 1; return 1;
} }
config_error_add("No \"finish\""); config_error_add("No \"finish\"");
@@ -3266,15 +3253,15 @@ int which_set;
tmpsp = tmpsp =
(struct symsetentry *) alloc(sizeof (struct symsetentry)); (struct symsetentry *) alloc(sizeof (struct symsetentry));
tmpsp->next = (struct symsetentry *) 0; tmpsp->next = (struct symsetentry *) 0;
if (!symset_list) { if (!g.symset_list) {
symset_list = tmpsp; g.symset_list = tmpsp;
symset_count = 0; g.symset_count = 0;
} else { } else {
symset_count++; g.symset_count++;
tmpsp->next = symset_list; tmpsp->next = g.symset_list;
symset_list = tmpsp; g.symset_list = tmpsp;
} }
tmpsp->idx = symset_count; tmpsp->idx = g.symset_count;
tmpsp->name = dupstr(bufp); tmpsp->name = dupstr(bufp);
tmpsp->desc = (char *) 0; tmpsp->desc = (char *) 0;
tmpsp->nocolor = 0; tmpsp->nocolor = 0;
@@ -3284,7 +3271,7 @@ int which_set;
break; break;
case 2: case 2:
/* handler type identified */ /* handler type identified */
tmpsp = symset_list; /* most recent symset */ tmpsp = g.symset_list; /* most recent symset */
tmpsp->handling = H_UNK; tmpsp->handling = H_UNK;
i = 0; i = 0;
while (known_handling[i]) { while (known_handling[i]) {
@@ -3296,13 +3283,13 @@ int which_set;
} }
break; break;
case 3: /* description:something */ case 3: /* description:something */
tmpsp = symset_list; /* most recent symset */ tmpsp = g.symset_list; /* most recent symset */
if (tmpsp && !tmpsp->desc) if (tmpsp && !tmpsp->desc)
tmpsp->desc = dupstr(bufp); tmpsp->desc = dupstr(bufp);
break; break;
case 5: case 5:
/* restrictions: xxxx*/ /* restrictions: xxxx*/
tmpsp = symset_list; /* most recent symset */ tmpsp = g.symset_list; /* most recent symset */
for (i = 0; known_restrictions[i]; ++i) { for (i = 0; known_restrictions[i]; ++i) {
if (!strcmpi(known_restrictions[i], bufp)) { if (!strcmpi(known_restrictions[i], bufp)) {
switch (i) { switch (i) {
@@ -3328,7 +3315,7 @@ int which_set;
/* start of symset */ /* start of symset */
if (!strcmpi(bufp, g.symset[which_set].name)) { if (!strcmpi(bufp, g.symset[which_set].name)) {
/* matches desired one */ /* matches desired one */
chosen_symset_start = TRUE; g.chosen_symset_start = TRUE;
/* these init_*() functions clear symset fields too */ /* these init_*() functions clear symset fields too */
if (which_set == ROGUESET) if (which_set == ROGUESET)
init_r_symbols(); init_r_symbols();
@@ -3338,18 +3325,18 @@ int which_set;
break; break;
case 1: case 1:
/* finish symset */ /* finish symset */
if (chosen_symset_start) if (g.chosen_symset_start)
chosen_symset_end = TRUE; g.chosen_symset_end = TRUE;
chosen_symset_start = FALSE; g.chosen_symset_start = FALSE;
break; break;
case 2: case 2:
/* handler type identified */ /* handler type identified */
if (chosen_symset_start) if (g.chosen_symset_start)
set_symhandling(bufp, which_set); set_symhandling(bufp, which_set);
break; break;
/* case 3: (description) is ignored here */ /* case 3: (description) is ignored here */
case 4: /* color:off */ case 4: /* color:off */
if (chosen_symset_start) { if (g.chosen_symset_start) {
if (bufp) { if (bufp) {
if (!strcmpi(bufp, "true") || !strcmpi(bufp, "yes") if (!strcmpi(bufp, "true") || !strcmpi(bufp, "yes")
|| !strcmpi(bufp, "on")) || !strcmpi(bufp, "on"))
@@ -3362,7 +3349,7 @@ int which_set;
} }
break; break;
case 5: /* restrictions: xxxx*/ case 5: /* restrictions: xxxx*/
if (chosen_symset_start) { if (g.chosen_symset_start) {
int n = 0; int n = 0;
while (known_restrictions[n]) { while (known_restrictions[n]) {
@@ -3384,7 +3371,7 @@ int which_set;
} }
} else { /* !SYM_CONTROL */ } else { /* !SYM_CONTROL */
val = sym_val(bufp); val = sym_val(bufp);
if (chosen_symset_start) { if (g.chosen_symset_start) {
if (which_set == PRIMARY) { if (which_set == PRIMARY) {
update_l_symset(symp, val); update_l_symset(symp, val);
} else if (which_set == ROGUESET) { } else if (which_set == ROGUESET) {
+9 -12
View File
@@ -4567,9 +4567,6 @@ int numtotal;
return opt_idx; return opt_idx;
} }
struct symsetentry *symset_list = 0; /* files.c will populate this with
list of available sets */
STATIC_OVL boolean STATIC_OVL boolean
special_handling(optname, setinitial, setfromfile) special_handling(optname, setinitial, setfromfile)
const char *optname; const char *optname;
@@ -5214,14 +5211,14 @@ boolean setinitial, setfromfile;
/* clear symset[].name as a flag to read_sym_file() to build list */ /* clear symset[].name as a flag to read_sym_file() to build list */
symset_name = g.symset[which_set].name; symset_name = g.symset[which_set].name;
g.symset[which_set].name = (char *) 0; g.symset[which_set].name = (char *) 0;
symset_list = (struct symsetentry *) 0; g.symset_list = (struct symsetentry *) 0;
res = read_sym_file(which_set); res = read_sym_file(which_set);
if (res && symset_list) { if (res && g.symset_list) {
char symsetchoice[BUFSZ]; char symsetchoice[BUFSZ];
int let = 'a', biggest = 0, thissize = 0; int let = 'a', biggest = 0, thissize = 0;
sl = symset_list; sl = g.symset_list;
while (sl) { while (sl) {
/* check restrictions */ /* check restrictions */
if ((!rogueflag && sl->rogue) if ((!rogueflag && sl->rogue)
@@ -5252,7 +5249,7 @@ boolean setinitial, setfromfile;
add_menu(tmpwin, NO_GLYPH, &any, let++, 0, ATR_NONE, add_menu(tmpwin, NO_GLYPH, &any, let++, 0, ATR_NONE,
"Default Symbols", MENU_UNSELECTED); "Default Symbols", MENU_UNSELECTED);
sl = symset_list; sl = g.symset_list;
while (sl) { while (sl) {
/* check restrictions */ /* check restrictions */
if ((!rogueflag && sl->rogue) if ((!rogueflag && sl->rogue)
@@ -5284,7 +5281,7 @@ boolean setinitial, setfromfile;
if (chosen > -1) { if (chosen > -1) {
/* chose an actual symset name from file */ /* chose an actual symset name from file */
sl = symset_list; sl = g.symset_list;
while (sl) { while (sl) {
if (sl->idx == chosen) { if (sl->idx == chosen) {
if (symset_name) { if (symset_name) {
@@ -5315,15 +5312,15 @@ boolean setinitial, setfromfile;
/* The symbols file could not be accessed */ /* The symbols file could not be accessed */
pline("Unable to access \"%s\" file.", SYMBOLS); pline("Unable to access \"%s\" file.", SYMBOLS);
return TRUE; return TRUE;
} else if (!symset_list) { } else if (!g.symset_list) {
/* The symbols file was empty */ /* The symbols file was empty */
pline("There were no symbol sets found in \"%s\".", SYMBOLS); pline("There were no symbol sets found in \"%s\".", SYMBOLS);
return TRUE; return TRUE;
} }
/* clean up */ /* clean up */
while (symset_list) { while (g.symset_list) {
sl = symset_list; sl = g.symset_list;
if (sl->name) if (sl->name)
free((genericptr_t) sl->name); free((genericptr_t) sl->name);
sl->name = (char *) 0; sl->name = (char *) 0;
@@ -5332,7 +5329,7 @@ boolean setinitial, setfromfile;
free((genericptr_t) sl->desc); free((genericptr_t) sl->desc);
sl->desc = (char *) 0; sl->desc = (char *) 0;
symset_list = sl->next; g.symset_list = sl->next;
free((genericptr_t) sl); free((genericptr_t) sl);
} }