artifact.c, cmd.c and makemon.c globals moved to instance_globals.

This commit is contained in:
Bart House
2018-12-19 20:01:55 -08:00
parent 74caa8d8e4
commit f1e48cddfe
9 changed files with 313 additions and 302 deletions
+88
View File
@@ -442,6 +442,78 @@ struct early_opt {
boolean valallowed; boolean valallowed;
}; };
/* special key functions */
enum nh_keyfunc {
NHKF_ESC = 0,
NHKF_DOAGAIN,
NHKF_REQMENU,
/* run ... clicklook need to be in a continuous block */
NHKF_RUN,
NHKF_RUN2,
NHKF_RUSH,
NHKF_FIGHT,
NHKF_FIGHT2,
NHKF_NOPICKUP,
NHKF_RUN_NOPICKUP,
NHKF_DOINV,
NHKF_TRAVEL,
NHKF_CLICKLOOK,
NHKF_REDRAW,
NHKF_REDRAW2,
NHKF_GETDIR_SELF,
NHKF_GETDIR_SELF2,
NHKF_GETDIR_HELP,
NHKF_COUNT,
NHKF_GETPOS_SELF,
NHKF_GETPOS_PICK,
NHKF_GETPOS_PICK_Q, /* quick */
NHKF_GETPOS_PICK_O, /* once */
NHKF_GETPOS_PICK_V, /* verbose */
NHKF_GETPOS_SHOWVALID,
NHKF_GETPOS_AUTODESC,
NHKF_GETPOS_MON_NEXT,
NHKF_GETPOS_MON_PREV,
NHKF_GETPOS_OBJ_NEXT,
NHKF_GETPOS_OBJ_PREV,
NHKF_GETPOS_DOOR_NEXT,
NHKF_GETPOS_DOOR_PREV,
NHKF_GETPOS_UNEX_NEXT,
NHKF_GETPOS_UNEX_PREV,
NHKF_GETPOS_INTERESTING_NEXT,
NHKF_GETPOS_INTERESTING_PREV,
NHKF_GETPOS_VALID_NEXT,
NHKF_GETPOS_VALID_PREV,
NHKF_GETPOS_HELP,
NHKF_GETPOS_MENU,
NHKF_GETPOS_LIMITVIEW,
NHKF_GETPOS_MOVESKIP,
NUM_NHKF
};
/* commands[] is used to directly access cmdlist[] instead of looping
through it to find the entry for a given input character;
move_X is the character used for moving one step in direction X;
alphadirchars corresponds to old sdir,
dirchars corresponds to ``iflags.num_pad ? ndir : sdir'';
pcHack_compat and phone_layout only matter when num_pad is on,
swap_yz only matters when it's off */
struct cmd {
unsigned serialno; /* incremented after each update */
boolean num_pad; /* same as iflags.num_pad except during updates */
boolean pcHack_compat; /* for numpad: affects 5, M-5, and M-0 */
boolean phone_layout; /* inverted keypad: 1,2,3 above, 7,8,9 below */
boolean swap_yz; /* QWERTZ keyboards; use z to move NW, y to zap */
char move_W, move_NW, move_N, move_NE, move_E, move_SE, move_S, move_SW;
const char *dirchars; /* current movement/direction characters */
const char *alphadirchars; /* same as dirchars if !numpad */
const struct ext_func_tab *commands[256]; /* indexed by input character */
char spkeys[NUM_NHKF];
};
/* 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.
@@ -449,19 +521,35 @@ struct early_opt {
* unlike instance_flags, values in the structure can be of any type. */ * unlike instance_flags, values in the structure can be of any type. */
struct instance_globals { struct instance_globals {
/* apply.c */ /* apply.c */
int jumping_is_magic; /* current jump result of magic */ int jumping_is_magic; /* current jump result of magic */
int polearm_range_min; int polearm_range_min;
int polearm_range_max; int polearm_range_max;
/* artifcat.c */ /* artifcat.c */
int spec_dbon_applies; /* coordinate effects from spec_dbon() with int spec_dbon_applies; /* coordinate effects from spec_dbon() with
messages in artifact_hit() */ messages in artifact_hit() */
/* flags including which artifacts have already been created */
boolean artiexist[1 + NROFARTIFACTS + 1];
/* and a discovery list for them (no dummy first entry here) */
xchar artidisco[NROFARTIFACTS];
/* botl.c */ /* botl.c */
int mrank_sz; /* loaded by max_rank_sz */ int mrank_sz; /* loaded by max_rank_sz */
/* cmd.c */
struct cmd Cmd; /* flag.h */
/* dog.c */ /* dog.c */
int petname_used; /* user preferred pet name has been used */ int petname_used; /* user preferred pet name has been used */
/* makemon.c */
struct {
int choice_count;
char mchoices[SPECIAL_PM]; /* value range is 0..127 */
} rndmonst_state;
/* muse.c */ /* muse.c */
boolean m_using; /* kludge to use mondided instead of killed */ boolean m_using; /* kludge to use mondided instead of killed */
int trapx; int trapx;
-74
View File
@@ -529,58 +529,6 @@ enum runmode_types {
struct ext_func_tab; /* from func_tab.h */ struct ext_func_tab; /* from func_tab.h */
#endif #endif
/* special key functions */
enum nh_keyfunc {
NHKF_ESC = 0,
NHKF_DOAGAIN,
NHKF_REQMENU,
/* run ... clicklook need to be in a continuous block */
NHKF_RUN,
NHKF_RUN2,
NHKF_RUSH,
NHKF_FIGHT,
NHKF_FIGHT2,
NHKF_NOPICKUP,
NHKF_RUN_NOPICKUP,
NHKF_DOINV,
NHKF_TRAVEL,
NHKF_CLICKLOOK,
NHKF_REDRAW,
NHKF_REDRAW2,
NHKF_GETDIR_SELF,
NHKF_GETDIR_SELF2,
NHKF_GETDIR_HELP,
NHKF_COUNT,
NHKF_GETPOS_SELF,
NHKF_GETPOS_PICK,
NHKF_GETPOS_PICK_Q, /* quick */
NHKF_GETPOS_PICK_O, /* once */
NHKF_GETPOS_PICK_V, /* verbose */
NHKF_GETPOS_SHOWVALID,
NHKF_GETPOS_AUTODESC,
NHKF_GETPOS_MON_NEXT,
NHKF_GETPOS_MON_PREV,
NHKF_GETPOS_OBJ_NEXT,
NHKF_GETPOS_OBJ_PREV,
NHKF_GETPOS_DOOR_NEXT,
NHKF_GETPOS_DOOR_PREV,
NHKF_GETPOS_UNEX_NEXT,
NHKF_GETPOS_UNEX_PREV,
NHKF_GETPOS_INTERESTING_NEXT,
NHKF_GETPOS_INTERESTING_PREV,
NHKF_GETPOS_VALID_NEXT,
NHKF_GETPOS_VALID_PREV,
NHKF_GETPOS_HELP,
NHKF_GETPOS_MENU,
NHKF_GETPOS_LIMITVIEW,
NHKF_GETPOS_MOVESKIP,
NUM_NHKF
};
enum gloctypes { enum gloctypes {
GLOC_MONS = 0, GLOC_MONS = 0,
GLOC_OBJS, GLOC_OBJS,
@@ -592,26 +540,4 @@ enum gloctypes {
NUM_GLOCS NUM_GLOCS
}; };
/* commands[] is used to directly access cmdlist[] instead of looping
through it to find the entry for a given input character;
move_X is the character used for moving one step in direction X;
alphadirchars corresponds to old sdir,
dirchars corresponds to ``iflags.num_pad ? ndir : sdir'';
pcHack_compat and phone_layout only matter when num_pad is on,
swap_yz only matters when it's off */
struct cmd {
unsigned serialno; /* incremented after each update */
boolean num_pad; /* same as iflags.num_pad except during updates */
boolean pcHack_compat; /* for numpad: affects 5, M-5, and M-0 */
boolean phone_layout; /* inverted keypad: 1,2,3 above, 7,8,9 below */
boolean swap_yz; /* QWERTZ keyboards; use z to move NW, y to zap */
char move_W, move_NW, move_N, move_NE, move_E, move_SE, move_S, move_SW;
const char *dirchars; /* current movement/direction characters */
const char *alphadirchars; /* same as dirchars if !numpad */
const struct ext_func_tab *commands[256]; /* indexed by input character */
char spkeys[NUM_NHKF];
};
extern NEARDATA struct cmd Cmd;
#endif /* FLAG_H */ #endif /* FLAG_H */
+18 -23
View File
@@ -39,11 +39,6 @@ STATIC_DCL int FDECL(count_surround_traps, (int, int));
of hit points that will fit in a 15 bit integer. */ of hit points that will fit in a 15 bit integer. */
#define FATAL_DAMAGE_MODIFIER 200 #define FATAL_DAMAGE_MODIFIER 200
/* flags including which artifacts have already been created */
static boolean artiexist[1 + NROFARTIFACTS + 1];
/* and a discovery list for them (no dummy first entry here) */
STATIC_OVL xchar artidisco[NROFARTIFACTS];
STATIC_DCL void NDECL(hack_artifacts); STATIC_DCL void NDECL(hack_artifacts);
STATIC_DCL boolean FDECL(attacks, (int, struct obj *)); STATIC_DCL boolean FDECL(attacks, (int, struct obj *));
@@ -75,8 +70,8 @@ hack_artifacts()
void void
init_artifacts() init_artifacts()
{ {
(void) memset((genericptr_t) artiexist, 0, sizeof artiexist); (void) memset((genericptr_t) g.artiexist, 0, sizeof g.artiexist);
(void) memset((genericptr_t) artidisco, 0, sizeof artidisco); (void) memset((genericptr_t) g.artidisco, 0, sizeof g.artidisco);
hack_artifacts(); hack_artifacts();
} }
@@ -84,16 +79,16 @@ void
save_artifacts(fd) save_artifacts(fd)
int fd; int fd;
{ {
bwrite(fd, (genericptr_t) artiexist, sizeof artiexist); bwrite(fd, (genericptr_t) g.artiexist, sizeof g.artiexist);
bwrite(fd, (genericptr_t) artidisco, sizeof artidisco); bwrite(fd, (genericptr_t) g.artidisco, sizeof g.artidisco);
} }
void void
restore_artifacts(fd) restore_artifacts(fd)
int fd; int fd;
{ {
mread(fd, (genericptr_t) artiexist, sizeof artiexist); mread(fd, (genericptr_t) g.artiexist, sizeof g.artiexist);
mread(fd, (genericptr_t) artidisco, sizeof artidisco); mread(fd, (genericptr_t) g.artidisco, sizeof g.artidisco);
hack_artifacts(); /* redo non-saved special cases */ hack_artifacts(); /* redo non-saved special cases */
} }
@@ -133,7 +128,7 @@ aligntyp alignment; /* target alignment, or A_NONE */
eligible[0] = 0; /* lint suppression */ eligible[0] = 0; /* lint suppression */
/* gather eligible artifacts */ /* gather eligible artifacts */
for (m = 1, a = &artilist[m]; a->otyp; a++, m++) { for (m = 1, a = &artilist[m]; a->otyp; a++, m++) {
if (artiexist[m]) if (g.artiexist[m])
continue; continue;
if ((a->spfx & SPFX_NOGEN) || unique) if ((a->spfx & SPFX_NOGEN) || unique)
continue; continue;
@@ -193,7 +188,7 @@ aligntyp alignment; /* target alignment, or A_NONE */
if (otmp) { if (otmp) {
otmp = oname(otmp, a->name); otmp = oname(otmp, a->name);
otmp->oartifact = m; otmp->oartifact = m;
artiexist[m] = TRUE; g.artiexist[m] = TRUE;
} }
} else { } else {
/* nothing appropriate could be found; return original object */ /* nothing appropriate could be found; return original object */
@@ -243,7 +238,7 @@ const char *name;
boolean *arex; boolean *arex;
if (otyp && *name) if (otyp && *name)
for (a = artilist + 1, arex = artiexist + 1; a->otyp; a++, arex++) for (a = artilist + 1, arex = g.artiexist + 1; a->otyp; a++, arex++)
if ((int) a->otyp == otyp && !strcmp(a->name, name)) if ((int) a->otyp == otyp && !strcmp(a->name, name))
return *arex; return *arex;
return FALSE; return FALSE;
@@ -265,7 +260,7 @@ boolean mod;
otmp->age = 0; otmp->age = 0;
if (otmp->otyp == RIN_INCREASE_DAMAGE) if (otmp->otyp == RIN_INCREASE_DAMAGE)
otmp->spe = 0; otmp->spe = 0;
artiexist[m] = mod; g.artiexist[m] = mod;
break; break;
} }
return; return;
@@ -275,10 +270,10 @@ int
nartifact_exist() nartifact_exist()
{ {
int a = 0; int a = 0;
int n = SIZE(artiexist); int n = SIZE(g.artiexist);
while (n > 1) while (n > 1)
if (artiexist[--n]) if (g.artiexist[--n])
a++; a++;
return a; return a;
@@ -866,8 +861,8 @@ xchar m;
/* look for this artifact in the discoveries list; /* look for this artifact in the discoveries list;
if we hit an empty slot then it's not present, so add it */ if we hit an empty slot then it's not present, so add it */
for (i = 0; i < NROFARTIFACTS; i++) for (i = 0; i < NROFARTIFACTS; i++)
if (artidisco[i] == 0 || artidisco[i] == m) { if (g.artidisco[i] == 0 || g.artidisco[i] == m) {
artidisco[i] = m; g.artidisco[i] = m;
return; return;
} }
/* there is one slot per artifact, so we should never reach the /* there is one slot per artifact, so we should never reach the
@@ -885,9 +880,9 @@ xchar m;
/* look for this artifact in the discoveries list; /* look for this artifact in the discoveries list;
if we hit an empty slot then it's undiscovered */ if we hit an empty slot then it's undiscovered */
for (i = 0; i < NROFARTIFACTS; i++) for (i = 0; i < NROFARTIFACTS; i++)
if (artidisco[i] == m) if (g.artidisco[i] == m)
return FALSE; return FALSE;
else if (artidisco[i] == 0) else if (g.artidisco[i] == 0)
break; break;
return TRUE; return TRUE;
} }
@@ -901,14 +896,14 @@ winid tmpwin; /* supplied by dodiscover() */
char buf[BUFSZ]; char buf[BUFSZ];
for (i = 0; i < NROFARTIFACTS; i++) { for (i = 0; i < NROFARTIFACTS; i++) {
if (artidisco[i] == 0) if (g.artidisco[i] == 0)
break; /* empty slot implies end of list */ break; /* empty slot implies end of list */
if (tmpwin == WIN_ERR) if (tmpwin == WIN_ERR)
continue; /* for WIN_ERR, we just count */ continue; /* for WIN_ERR, we just count */
if (i == 0) if (i == 0)
putstr(tmpwin, iflags.menu_headings, "Artifacts"); putstr(tmpwin, iflags.menu_headings, "Artifacts");
m = artidisco[i]; m = g.artidisco[i];
otyp = artilist[m].otyp; otyp = artilist[m].otyp;
Sprintf(buf, " %s [%s %s]", artiname(m), Sprintf(buf, " %s [%s %s]", artiname(m),
align_str(artilist[m].alignment), simple_typename(otyp)); align_str(artilist[m].alignment), simple_typename(otyp));
+134 -136
View File
@@ -27,8 +27,6 @@
STATIC_VAR boolean alt_esc = FALSE; STATIC_VAR boolean alt_esc = FALSE;
#endif #endif
struct cmd Cmd = { 0 }; /* flag.h */
extern const char *hu_stat[]; /* hunger status from eat.c */ extern const char *hu_stat[]; /* hunger status from eat.c */
extern const char *enc_stat[]; /* encumbrance status from botl.c */ extern const char *enc_stat[]; /* encumbrance status from botl.c */
@@ -354,7 +352,7 @@ doextcmd(VOID_ARGS)
} }
if (iflags.menu_requested && !accept_menu_prefix(func)) { if (iflags.menu_requested && !accept_menu_prefix(func)) {
pline("'%s' prefix has no effect for the %s command.", pline("'%s' prefix has no effect for the %s command.",
visctrl(Cmd.spkeys[NHKF_REQMENU]), visctrl(g.Cmd.spkeys[NHKF_REQMENU]),
extcmdlist[idx].ef_txt); extcmdlist[idx].ef_txt);
iflags.menu_requested = FALSE; iflags.menu_requested = FALSE;
} }
@@ -3412,8 +3410,8 @@ const char *
key2extcmddesc(key) key2extcmddesc(key)
uchar key; uchar key;
{ {
if (Cmd.commands[key] && Cmd.commands[key]->ef_txt) if (g.Cmd.commands[key] && g.Cmd.commands[key]->ef_txt)
return Cmd.commands[key]->ef_desc; return g.Cmd.commands[key]->ef_desc;
return (char *) 0; return (char *) 0;
} }
@@ -3426,14 +3424,14 @@ const char *command;
/* special case: "nothing" is reserved for unbinding */ /* special case: "nothing" is reserved for unbinding */
if (!strcmp(command, "nothing")) { if (!strcmp(command, "nothing")) {
Cmd.commands[key] = (struct ext_func_tab *) 0; g.Cmd.commands[key] = (struct ext_func_tab *) 0;
return TRUE; return TRUE;
} }
for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++) { for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++) {
if (strcmp(command, extcmd->ef_txt)) if (strcmp(command, extcmd->ef_txt))
continue; continue;
Cmd.commands[key] = extcmd; g.Cmd.commands[key] = extcmd;
#if 0 /* silently accept key binding for unavailable command (!SHELL,&c) */ #if 0 /* silently accept key binding for unavailable command (!SHELL,&c) */
if ((extcmd->flags & CMD_NOT_AVAILABLE) != 0) { if ((extcmd->flags & CMD_NOT_AVAILABLE) != 0) {
char buf[BUFSZ]; char buf[BUFSZ];
@@ -3456,7 +3454,7 @@ commands_init()
for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++) for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++)
if (extcmd->key) if (extcmd->key)
Cmd.commands[extcmd->key] = extcmd; g.Cmd.commands[extcmd->key] = extcmd;
(void) bind_key(C('l'), "redraw"); /* if number_pad is set */ (void) bind_key(C('l'), "redraw"); /* if number_pad is set */
/* 'b', 'B' : go sw */ /* 'b', 'B' : go sw */
@@ -3501,7 +3499,7 @@ boolean *keys_used; /* boolean keys_used[256] */
continue; continue;
if (key == ' ' && !flags.rest_on_space) if (key == ' ' && !flags.rest_on_space)
continue; continue;
if ((extcmd = Cmd.commands[i]) != (struct ext_func_tab *) 0) { if ((extcmd = g.Cmd.commands[i]) != (struct ext_func_tab *) 0) {
if ((cmdflags && !(extcmd->flags & cmdflags)) if ((cmdflags && !(extcmd->flags & cmdflags))
|| (exflags && (extcmd->flags & exflags))) || (exflags && (extcmd->flags & exflags)))
continue; continue;
@@ -3565,29 +3563,29 @@ dokeylist(VOID_ARGS)
putstr(datawin, 0, "Directional keys:"); putstr(datawin, 0, "Directional keys:");
show_direction_keys(datawin, '.', FALSE); /* '.'==self in direction grid */ show_direction_keys(datawin, '.', FALSE); /* '.'==self in direction grid */
keys_used[(uchar) Cmd.move_NW] = keys_used[(uchar) Cmd.move_N] keys_used[(uchar) g.Cmd.move_NW] = keys_used[(uchar) g.Cmd.move_N]
= keys_used[(uchar) Cmd.move_NE] = keys_used[(uchar) Cmd.move_W] = keys_used[(uchar) g.Cmd.move_NE] = keys_used[(uchar) g.Cmd.move_W]
= keys_used[(uchar) Cmd.move_E] = keys_used[(uchar) Cmd.move_SW] = keys_used[(uchar) g.Cmd.move_E] = keys_used[(uchar) g.Cmd.move_SW]
= keys_used[(uchar) Cmd.move_S] = keys_used[(uchar) Cmd.move_SE] = keys_used[(uchar) g.Cmd.move_S] = keys_used[(uchar) g.Cmd.move_SE]
= TRUE; = TRUE;
if (!iflags.num_pad) { if (!iflags.num_pad) {
keys_used[(uchar) highc(Cmd.move_NW)] keys_used[(uchar) highc(g.Cmd.move_NW)]
= keys_used[(uchar) highc(Cmd.move_N)] = keys_used[(uchar) highc(g.Cmd.move_N)]
= keys_used[(uchar) highc(Cmd.move_NE)] = keys_used[(uchar) highc(g.Cmd.move_NE)]
= keys_used[(uchar) highc(Cmd.move_W)] = keys_used[(uchar) highc(g.Cmd.move_W)]
= keys_used[(uchar) highc(Cmd.move_E)] = keys_used[(uchar) highc(g.Cmd.move_E)]
= keys_used[(uchar) highc(Cmd.move_SW)] = keys_used[(uchar) highc(g.Cmd.move_SW)]
= keys_used[(uchar) highc(Cmd.move_S)] = keys_used[(uchar) highc(g.Cmd.move_S)]
= keys_used[(uchar) highc(Cmd.move_SE)] = TRUE; = keys_used[(uchar) highc(g.Cmd.move_SE)] = TRUE;
keys_used[(uchar) C(Cmd.move_NW)] keys_used[(uchar) C(g.Cmd.move_NW)]
= keys_used[(uchar) C(Cmd.move_N)] = keys_used[(uchar) C(g.Cmd.move_N)]
= keys_used[(uchar) C(Cmd.move_NE)] = keys_used[(uchar) C(g.Cmd.move_NE)]
= keys_used[(uchar) C(Cmd.move_W)] = keys_used[(uchar) C(g.Cmd.move_W)]
= keys_used[(uchar) C(Cmd.move_E)] = keys_used[(uchar) C(g.Cmd.move_E)]
= keys_used[(uchar) C(Cmd.move_SW)] = keys_used[(uchar) C(g.Cmd.move_SW)]
= keys_used[(uchar) C(Cmd.move_S)] = keys_used[(uchar) C(g.Cmd.move_S)]
= keys_used[(uchar) C(Cmd.move_SE)] = TRUE; = keys_used[(uchar) C(g.Cmd.move_SE)] = TRUE;
putstr(datawin, 0, ""); putstr(datawin, 0, "");
putstr(datawin, 0, putstr(datawin, 0,
"Shift-<direction> will move in specified direction until you hit"); "Shift-<direction> will move in specified direction until you hit");
@@ -3600,7 +3598,7 @@ dokeylist(VOID_ARGS)
putstr(datawin, 0, ""); putstr(datawin, 0, "");
putstr(datawin, 0, "Miscellaneous keys:"); putstr(datawin, 0, "Miscellaneous keys:");
for (i = 0; misc_keys[i].desc; i++) { for (i = 0; misc_keys[i].desc; i++) {
key = Cmd.spkeys[misc_keys[i].nhkf]; key = g.Cmd.spkeys[misc_keys[i].nhkf];
if (key && ((misc_keys[i].numpad && iflags.num_pad) if (key && ((misc_keys[i].numpad && iflags.num_pad)
|| !misc_keys[i].numpad)) { || !misc_keys[i].numpad)) {
keys_used[(uchar) key] = TRUE; keys_used[(uchar) key] = TRUE;
@@ -3647,7 +3645,7 @@ int NDECL((*fn));
int i; int i;
for (i = 0; i < 256; ++i) for (i = 0; i < 256; ++i)
if (Cmd.commands[i] && Cmd.commands[i]->ef_funct == fn) if (g.Cmd.commands[i] && g.Cmd.commands[i]->ef_funct == fn)
return (char) i; return (char) i;
return '\0'; return '\0';
} }
@@ -4144,7 +4142,7 @@ const char *command;
for (i = 0; i < SIZE(spkeys_binds); i++) { for (i = 0; i < SIZE(spkeys_binds); i++) {
if (!spkeys_binds[i].name || strcmp(command, spkeys_binds[i].name)) if (!spkeys_binds[i].name || strcmp(command, spkeys_binds[i].name))
continue; continue;
Cmd.spkeys[spkeys_binds[i].nhkf] = key; g.Cmd.spkeys[spkeys_binds[i].nhkf] = key;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@@ -4299,97 +4297,97 @@ boolean initial;
if (initial) { if (initial) {
updated = 1; updated = 1;
Cmd.num_pad = FALSE; g.Cmd.num_pad = FALSE;
Cmd.pcHack_compat = Cmd.phone_layout = Cmd.swap_yz = FALSE; g.Cmd.pcHack_compat = g.Cmd.phone_layout = g.Cmd.swap_yz = FALSE;
for (i = 0; i < SIZE(spkeys_binds); i++) for (i = 0; i < SIZE(spkeys_binds); i++)
Cmd.spkeys[spkeys_binds[i].nhkf] = spkeys_binds[i].key; g.Cmd.spkeys[spkeys_binds[i].nhkf] = spkeys_binds[i].key;
commands_init(); commands_init();
} else { } else {
if (backed_dir_cmd) { if (backed_dir_cmd) {
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
Cmd.commands[(uchar) Cmd.dirchars[i]] = back_dir_cmd[i]; g.Cmd.commands[(uchar) g.Cmd.dirchars[i]] = back_dir_cmd[i];
} }
} }
/* basic num_pad */ /* basic num_pad */
flagtemp = iflags.num_pad; flagtemp = iflags.num_pad;
if (flagtemp != Cmd.num_pad) { if (flagtemp != g.Cmd.num_pad) {
Cmd.num_pad = flagtemp; g.Cmd.num_pad = flagtemp;
++updated; ++updated;
} }
/* swap_yz mode (only applicable for !num_pad); intended for /* swap_yz mode (only applicable for !num_pad); intended for
QWERTZ keyboard used in Central Europe, particularly Germany */ QWERTZ keyboard used in Central Europe, particularly Germany */
flagtemp = (iflags.num_pad_mode & 1) ? !Cmd.num_pad : FALSE; flagtemp = (iflags.num_pad_mode & 1) ? !g.Cmd.num_pad : FALSE;
if (flagtemp != Cmd.swap_yz) { if (flagtemp != g.Cmd.swap_yz) {
Cmd.swap_yz = flagtemp; g.Cmd.swap_yz = flagtemp;
++updated; ++updated;
/* Cmd.swap_yz has been toggled; /* g.Cmd.swap_yz has been toggled;
perform the swap (or reverse previous one) */ perform the swap (or reverse previous one) */
for (i = 0; i < SIZE(ylist); i++) { for (i = 0; i < SIZE(ylist); i++) {
c = ylist[i] & 0xff; c = ylist[i] & 0xff;
cmdtmp = Cmd.commands[c]; /* tmp = [y] */ cmdtmp = g.Cmd.commands[c]; /* tmp = [y] */
Cmd.commands[c] = Cmd.commands[c + 1]; /* [y] = [z] */ g.Cmd.commands[c] = g.Cmd.commands[c + 1]; /* [y] = [z] */
Cmd.commands[c + 1] = cmdtmp; /* [z] = tmp */ g.Cmd.commands[c + 1] = cmdtmp; /* [z] = tmp */
} }
} }
/* MSDOS compatibility mode (only applicable for num_pad) */ /* MSDOS compatibility mode (only applicable for num_pad) */
flagtemp = (iflags.num_pad_mode & 1) ? Cmd.num_pad : FALSE; flagtemp = (iflags.num_pad_mode & 1) ? g.Cmd.num_pad : FALSE;
if (flagtemp != Cmd.pcHack_compat) { if (flagtemp != g.Cmd.pcHack_compat) {
Cmd.pcHack_compat = flagtemp; g.Cmd.pcHack_compat = flagtemp;
++updated; ++updated;
/* pcHack_compat has been toggled */ /* pcHack_compat has been toggled */
c = M('5') & 0xff; c = M('5') & 0xff;
cmdtmp = Cmd.commands['5']; cmdtmp = g.Cmd.commands['5'];
Cmd.commands['5'] = Cmd.commands[c]; g.Cmd.commands['5'] = g.Cmd.commands[c];
Cmd.commands[c] = cmdtmp; g.Cmd.commands[c] = cmdtmp;
c = M('0') & 0xff; c = M('0') & 0xff;
Cmd.commands[c] = Cmd.pcHack_compat ? Cmd.commands['I'] : 0; g.Cmd.commands[c] = g.Cmd.pcHack_compat ? g.Cmd.commands['I'] : 0;
} }
/* phone keypad layout (only applicable for num_pad) */ /* phone keypad layout (only applicable for num_pad) */
flagtemp = (iflags.num_pad_mode & 2) ? Cmd.num_pad : FALSE; flagtemp = (iflags.num_pad_mode & 2) ? g.Cmd.num_pad : FALSE;
if (flagtemp != Cmd.phone_layout) { if (flagtemp != g.Cmd.phone_layout) {
Cmd.phone_layout = flagtemp; g.Cmd.phone_layout = flagtemp;
++updated; ++updated;
/* phone_layout has been toggled */ /* phone_layout has been toggled */
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
c = '1' + i; /* 1,2,3 <-> 7,8,9 */ c = '1' + i; /* 1,2,3 <-> 7,8,9 */
cmdtmp = Cmd.commands[c]; /* tmp = [1] */ cmdtmp = g.Cmd.commands[c]; /* tmp = [1] */
Cmd.commands[c] = Cmd.commands[c + 6]; /* [1] = [7] */ g.Cmd.commands[c] = g.Cmd.commands[c + 6]; /* [1] = [7] */
Cmd.commands[c + 6] = cmdtmp; /* [7] = tmp */ g.Cmd.commands[c + 6] = cmdtmp; /* [7] = tmp */
c = (M('1') & 0xff) + i; /* M-1,M-2,M-3 <-> M-7,M-8,M-9 */ c = (M('1') & 0xff) + i; /* M-1,M-2,M-3 <-> M-7,M-8,M-9 */
cmdtmp = Cmd.commands[c]; /* tmp = [M-1] */ cmdtmp = g.Cmd.commands[c]; /* tmp = [M-1] */
Cmd.commands[c] = Cmd.commands[c + 6]; /* [M-1] = [M-7] */ g.Cmd.commands[c] = g.Cmd.commands[c + 6]; /* [M-1] = [M-7] */
Cmd.commands[c + 6] = cmdtmp; /* [M-7] = tmp */ g.Cmd.commands[c + 6] = cmdtmp; /* [M-7] = tmp */
} }
} }
} /*?initial*/ } /*?initial*/
if (updated) if (updated)
Cmd.serialno++; g.Cmd.serialno++;
Cmd.dirchars = !Cmd.num_pad g.Cmd.dirchars = !g.Cmd.num_pad
? (!Cmd.swap_yz ? sdir : sdir_swap_yz) ? (!g.Cmd.swap_yz ? sdir : sdir_swap_yz)
: (!Cmd.phone_layout ? ndir : ndir_phone_layout); : (!g.Cmd.phone_layout ? ndir : ndir_phone_layout);
Cmd.alphadirchars = !Cmd.num_pad ? Cmd.dirchars : sdir; g.Cmd.alphadirchars = !g.Cmd.num_pad ? g.Cmd.dirchars : sdir;
Cmd.move_W = Cmd.dirchars[0]; g.Cmd.move_W = g.Cmd.dirchars[0];
Cmd.move_NW = Cmd.dirchars[1]; g.Cmd.move_NW = g.Cmd.dirchars[1];
Cmd.move_N = Cmd.dirchars[2]; g.Cmd.move_N = g.Cmd.dirchars[2];
Cmd.move_NE = Cmd.dirchars[3]; g.Cmd.move_NE = g.Cmd.dirchars[3];
Cmd.move_E = Cmd.dirchars[4]; g.Cmd.move_E = g.Cmd.dirchars[4];
Cmd.move_SE = Cmd.dirchars[5]; g.Cmd.move_SE = g.Cmd.dirchars[5];
Cmd.move_S = Cmd.dirchars[6]; g.Cmd.move_S = g.Cmd.dirchars[6];
Cmd.move_SW = Cmd.dirchars[7]; g.Cmd.move_SW = g.Cmd.dirchars[7];
if (!initial) { if (!initial) {
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
back_dir_cmd[i] = back_dir_cmd[i] =
(struct ext_func_tab *) Cmd.commands[(uchar) Cmd.dirchars[i]]; (struct ext_func_tab *) g.Cmd.commands[(uchar) g.Cmd.dirchars[i]];
Cmd.commands[(uchar) Cmd.dirchars[i]] = (struct ext_func_tab *) 0; g.Cmd.commands[(uchar) g.Cmd.dirchars[i]] = (struct ext_func_tab *) 0;
} }
backed_dir_cmd = TRUE; backed_dir_cmd = TRUE;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
(void) bind_key(Cmd.dirchars[i], "nothing"); (void) bind_key(g.Cmd.dirchars[i], "nothing");
} }
} }
@@ -4475,7 +4473,7 @@ int start,end;
int i; int i;
for (i = start; i <= end; i++) for (i = start; i <= end; i++)
if (Cmd.spkeys[i] == c) if (g.Cmd.spkeys[i] == c)
return i; return i;
return NHKF_ESC; return NHKF_ESC;
} }
@@ -4497,7 +4495,7 @@ register char *cmd;
context.nopick = 0; context.nopick = 0;
cmd = parse(); cmd = parse();
} }
if (*cmd == Cmd.spkeys[NHKF_ESC]) { if (*cmd == g.Cmd.spkeys[NHKF_ESC]) {
context.move = FALSE; context.move = FALSE;
return; return;
} }
@@ -4529,7 +4527,7 @@ register char *cmd;
prefix_seen = TRUE; prefix_seen = TRUE;
break; break;
case NHKF_RUN2: case NHKF_RUN2:
if (!Cmd.num_pad) if (!g.Cmd.num_pad)
break; break;
/*FALLTHRU*/ /*FALLTHRU*/
case NHKF_RUN: case NHKF_RUN:
@@ -4540,7 +4538,7 @@ register char *cmd;
prefix_seen = TRUE; prefix_seen = TRUE;
break; break;
case NHKF_FIGHT2: case NHKF_FIGHT2:
if (!Cmd.num_pad) if (!g.Cmd.num_pad)
break; break;
/*FALLTHRU*/ /*FALLTHRU*/
/* Effects of movement commands and invisible monsters: /* Effects of movement commands and invisible monsters:
@@ -4575,7 +4573,7 @@ register char *cmd;
prefix_seen = TRUE; prefix_seen = TRUE;
break; break;
case NHKF_DOINV: case NHKF_DOINV:
if (!Cmd.num_pad) if (!g.Cmd.num_pad)
break; break;
(void) ddoinv(); /* a convenience borrowed from the PC */ (void) ddoinv(); /* a convenience borrowed from the PC */
context.move = FALSE; context.move = FALSE;
@@ -4601,7 +4599,7 @@ register char *cmd;
if (movecmd(*cmd)) { /* ordinary movement */ if (movecmd(*cmd)) { /* ordinary movement */
context.run = 0; /* only matters here if it was 8 */ context.run = 0; /* only matters here if it was 8 */
do_walk = TRUE; do_walk = TRUE;
} else if (movecmd(Cmd.num_pad ? unmeta(*cmd) : lowc(*cmd))) { } else if (movecmd(g.Cmd.num_pad ? unmeta(*cmd) : lowc(*cmd))) {
context.run = 1; context.run = 1;
do_rush = TRUE; do_rush = TRUE;
} else if (movecmd(unctrl(*cmd))) { } else if (movecmd(unctrl(*cmd))) {
@@ -4613,9 +4611,9 @@ register char *cmd;
/* some special prefix handling */ /* some special prefix handling */
/* overload 'm' prefix to mean "request a menu" */ /* overload 'm' prefix to mean "request a menu" */
if (prefix_seen && cmd[0] == Cmd.spkeys[NHKF_REQMENU]) { if (prefix_seen && cmd[0] == g.Cmd.spkeys[NHKF_REQMENU]) {
/* (for func_tab cast, see below) */ /* (for func_tab cast, see below) */
const struct ext_func_tab *ft = Cmd.commands[cmd[1] & 0xff]; const struct ext_func_tab *ft = g.Cmd.commands[cmd[1] & 0xff];
int NDECL((*func)) = ft ? ((struct ext_func_tab *) ft)->ef_funct : 0; int NDECL((*func)) = ft ? ((struct ext_func_tab *) ft)->ef_funct : 0;
if (func && accept_menu_prefix(func)) { if (func && accept_menu_prefix(func)) {
@@ -4653,7 +4651,7 @@ register char *cmd;
context.mv = TRUE; context.mv = TRUE;
domove(); domove();
return; return;
} else if (prefix_seen && cmd[1] == Cmd.spkeys[NHKF_ESC]) { } else if (prefix_seen && cmd[1] == g.Cmd.spkeys[NHKF_ESC]) {
/* <prefix><escape> */ /* <prefix><escape> */
/* don't report "unknown command" for change of heart... */ /* don't report "unknown command" for change of heart... */
bad_command = FALSE; bad_command = FALSE;
@@ -4666,7 +4664,7 @@ register char *cmd;
int res, NDECL((*func)); int res, NDECL((*func));
/* current - use *cmd to directly index cmdlist array */ /* current - use *cmd to directly index cmdlist array */
if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) { if ((tlist = g.Cmd.commands[*cmd & 0xff]) != 0) {
if (!wizard && (tlist->flags & WIZMODECMD)) { if (!wizard && (tlist->flags & WIZMODECMD)) {
You_cant("do that!"); You_cant("do that!");
res = 0; res = 0;
@@ -4737,14 +4735,14 @@ int
movecmd(sym) movecmd(sym)
char sym; char sym;
{ {
register const char *dp = index(Cmd.dirchars, sym); register const char *dp = index(g.Cmd.dirchars, sym);
u.dz = 0; u.dz = 0;
if (!dp || !*dp) if (!dp || !*dp)
return 0; return 0;
u.dx = xdir[dp - Cmd.dirchars]; u.dx = xdir[dp - g.Cmd.dirchars];
u.dy = ydir[dp - Cmd.dirchars]; u.dy = ydir[dp - g.Cmd.dirchars];
u.dz = zdir[dp - Cmd.dirchars]; u.dz = zdir[dp - g.Cmd.dirchars];
#if 0 /* now handled elsewhere */ #if 0 /* now handled elsewhere */
if (u.dx && u.dy && NODIAG(u.umonnum)) { if (u.dx && u.dy && NODIAG(u.umonnum)) {
u.dx = u.dy = 0; u.dx = u.dy = 0;
@@ -4768,21 +4766,21 @@ boolean
redraw_cmd(c) redraw_cmd(c)
char c; char c;
{ {
return (boolean) (c == Cmd.spkeys[NHKF_REDRAW] return (boolean) (c == g.Cmd.spkeys[NHKF_REDRAW]
|| (Cmd.num_pad && c == Cmd.spkeys[NHKF_REDRAW2])); || (g.Cmd.num_pad && c == g.Cmd.spkeys[NHKF_REDRAW2]));
} }
boolean boolean
prefix_cmd(c) prefix_cmd(c)
char c; char c;
{ {
return (c == Cmd.spkeys[NHKF_RUSH] return (c == g.Cmd.spkeys[NHKF_RUSH]
|| c == Cmd.spkeys[NHKF_RUN] || c == g.Cmd.spkeys[NHKF_RUN]
|| c == Cmd.spkeys[NHKF_NOPICKUP] || c == g.Cmd.spkeys[NHKF_NOPICKUP]
|| c == Cmd.spkeys[NHKF_RUN_NOPICKUP] || c == g.Cmd.spkeys[NHKF_RUN_NOPICKUP]
|| c == Cmd.spkeys[NHKF_FIGHT] || c == g.Cmd.spkeys[NHKF_FIGHT]
|| (Cmd.num_pad && (c == Cmd.spkeys[NHKF_RUN2] || (g.Cmd.num_pad && (c == g.Cmd.spkeys[NHKF_RUN2]
|| c == Cmd.spkeys[NHKF_FIGHT2]))); || c == g.Cmd.spkeys[NHKF_FIGHT2])));
} }
/* /*
@@ -4841,14 +4839,14 @@ retry:
} }
savech(dirsym); savech(dirsym);
if (dirsym == Cmd.spkeys[NHKF_GETDIR_SELF] if (dirsym == g.Cmd.spkeys[NHKF_GETDIR_SELF]
|| dirsym == Cmd.spkeys[NHKF_GETDIR_SELF2]) { || dirsym == g.Cmd.spkeys[NHKF_GETDIR_SELF2]) {
u.dx = u.dy = u.dz = 0; u.dx = u.dy = u.dz = 0;
} else if (!(is_mov = movecmd(dirsym)) && !u.dz) { } else if (!(is_mov = movecmd(dirsym)) && !u.dz) {
boolean did_help = FALSE, help_requested; boolean did_help = FALSE, help_requested;
if (!index(quitchars, dirsym)) { if (!index(quitchars, dirsym)) {
help_requested = (dirsym == Cmd.spkeys[NHKF_GETDIR_HELP]); help_requested = (dirsym == g.Cmd.spkeys[NHKF_GETDIR_HELP]);
if (help_requested || iflags.cmdassist) { if (help_requested || iflags.cmdassist) {
did_help = help_dir((s && *s == '^') ? dirsym : '\0', did_help = help_dir((s && *s == '^') ? dirsym : '\0',
NHKF_ESC, NHKF_ESC,
@@ -4882,26 +4880,26 @@ boolean nodiag;
centerchar = ' '; centerchar = ' ';
if (nodiag) { if (nodiag) {
Sprintf(buf, " %c ", Cmd.move_N); Sprintf(buf, " %c ", g.Cmd.move_N);
putstr(win, 0, buf); putstr(win, 0, buf);
putstr(win, 0, " | "); putstr(win, 0, " | ");
Sprintf(buf, " %c- %c -%c", Sprintf(buf, " %c- %c -%c",
Cmd.move_W, centerchar, Cmd.move_E); g.Cmd.move_W, centerchar, g.Cmd.move_E);
putstr(win, 0, buf); putstr(win, 0, buf);
putstr(win, 0, " | "); putstr(win, 0, " | ");
Sprintf(buf, " %c ", Cmd.move_S); Sprintf(buf, " %c ", g.Cmd.move_S);
putstr(win, 0, buf); putstr(win, 0, buf);
} else { } else {
Sprintf(buf, " %c %c %c", Sprintf(buf, " %c %c %c",
Cmd.move_NW, Cmd.move_N, Cmd.move_NE); g.Cmd.move_NW, g.Cmd.move_N, g.Cmd.move_NE);
putstr(win, 0, buf); putstr(win, 0, buf);
putstr(win, 0, " \\ | / "); putstr(win, 0, " \\ | / ");
Sprintf(buf, " %c- %c -%c", Sprintf(buf, " %c- %c -%c",
Cmd.move_W, centerchar, Cmd.move_E); g.Cmd.move_W, centerchar, g.Cmd.move_E);
putstr(win, 0, buf); putstr(win, 0, buf);
putstr(win, 0, " / | \\ "); putstr(win, 0, " / | \\ ");
Sprintf(buf, " %c %c %c", Sprintf(buf, " %c %c %c",
Cmd.move_SW, Cmd.move_S, Cmd.move_SE); g.Cmd.move_SW, g.Cmd.move_S, g.Cmd.move_SE);
putstr(win, 0, buf); putstr(win, 0, buf);
}; };
} }
@@ -4940,7 +4938,7 @@ const char *msg;
dothat = "rush"; dothat = "rush";
break; break;
case NHKF_RUN2: case NHKF_RUN2:
if (!Cmd.num_pad) if (!g.Cmd.num_pad)
break; break;
/*FALLTHRU*/ /*FALLTHRU*/
case NHKF_RUN: case NHKF_RUN:
@@ -4948,7 +4946,7 @@ const char *msg;
dothat = "run"; dothat = "run";
break; break;
case NHKF_FIGHT2: case NHKF_FIGHT2:
if (!Cmd.num_pad) if (!g.Cmd.num_pad)
break; break;
/*FALLTHRU*/ /*FALLTHRU*/
case NHKF_FIGHT: case NHKF_FIGHT:
@@ -4964,8 +4962,8 @@ const char *msg;
/* for movement prefix followed by '.' or (numpad && 's') to mean 'self'; /* for movement prefix followed by '.' or (numpad && 's') to mean 'self';
note: '-' for hands (inventory form of 'self') is not handled here */ note: '-' for hands (inventory form of 'self') is not handled here */
if (prefixhandling if (prefixhandling
&& (sym == Cmd.spkeys[NHKF_GETDIR_SELF] && (sym == g.Cmd.spkeys[NHKF_GETDIR_SELF]
|| (Cmd.num_pad && sym == Cmd.spkeys[NHKF_GETDIR_SELF2]))) { || (g.Cmd.num_pad && sym == g.Cmd.spkeys[NHKF_GETDIR_SELF2]))) {
Sprintf(buf, "You can't %s%s yourself.", dothat, how); Sprintf(buf, "You can't %s%s yourself.", dothat, how);
/* for movement prefix followed by up or down */ /* for movement prefix followed by up or down */
} else if (prefixhandling && (sym == '<' || sym == '>')) { } else if (prefixhandling && (sym == '<' || sym == '>')) {
@@ -4981,7 +4979,7 @@ const char *msg;
if (prefixhandling) { if (prefixhandling) {
if (!*buf) if (!*buf)
Sprintf(buf, "Invalid direction for '%s' prefix.", Sprintf(buf, "Invalid direction for '%s' prefix.",
visctrl(Cmd.spkeys[spkey])); visctrl(g.Cmd.spkeys[spkey]));
pline("%s", buf); pline("%s", buf);
return TRUE; return TRUE;
} }
@@ -5039,10 +5037,10 @@ const char *msg;
putstr(win, 0, " < up"); putstr(win, 0, " < up");
putstr(win, 0, " > down"); putstr(win, 0, " > down");
if (!prefixhandling) { if (!prefixhandling) {
int selfi = Cmd.num_pad ? NHKF_GETDIR_SELF2 : NHKF_GETDIR_SELF; int selfi = g.Cmd.num_pad ? NHKF_GETDIR_SELF2 : NHKF_GETDIR_SELF;
Sprintf(buf, " %4s direct at yourself", Sprintf(buf, " %4s direct at yourself",
visctrl(Cmd.spkeys[selfi])); visctrl(g.Cmd.spkeys[selfi]));
putstr(win, 0, buf); putstr(win, 0, buf);
} }
} }
@@ -5351,7 +5349,7 @@ int x, y, mod;
if (iflags.clicklook && mod == CLICK_2) { if (iflags.clicklook && mod == CLICK_2) {
clicklook_cc.x = x; clicklook_cc.x = x;
clicklook_cc.y = y; clicklook_cc.y = y;
cmd[0] = Cmd.spkeys[NHKF_CLICKLOOK]; cmd[0] = g.Cmd.spkeys[NHKF_CLICKLOOK];
return cmd; return cmd;
} }
@@ -5364,7 +5362,7 @@ int x, y, mod;
} else { } else {
u.tx = u.ux + x; u.tx = u.ux + x;
u.ty = u.uy + y; u.ty = u.uy + y;
cmd[0] = Cmd.spkeys[NHKF_TRAVEL]; cmd[0] = g.Cmd.spkeys[NHKF_TRAVEL];
return cmd; return cmd;
} }
@@ -5410,7 +5408,7 @@ int x, y, mod;
if (!m_at(u.ux + x, u.uy + y) if (!m_at(u.ux + x, u.uy + y)
&& !test_move(u.ux, u.uy, x, y, TEST_MOVE)) { && !test_move(u.ux, u.uy, x, y, TEST_MOVE)) {
cmd[1] = Cmd.dirchars[dir]; cmd[1] = g.Cmd.dirchars[dir];
cmd[2] = '\0'; cmd[2] = '\0';
if (iflags.herecmd_menu) { if (iflags.herecmd_menu) {
cmd[0] = there_cmd_menu(FALSE, u.ux + x, u.uy + y); cmd[0] = there_cmd_menu(FALSE, u.ux + x, u.uy + y);
@@ -5461,11 +5459,11 @@ int x, y, mod;
/* move, attack, etc. */ /* move, attack, etc. */
cmd[1] = 0; cmd[1] = 0;
if (mod == CLICK_1) { if (mod == CLICK_1) {
cmd[0] = Cmd.dirchars[dir]; cmd[0] = g.Cmd.dirchars[dir];
} else { } else {
cmd[0] = (Cmd.num_pad cmd[0] = (g.Cmd.num_pad
? M(Cmd.dirchars[dir]) ? M(g.Cmd.dirchars[dir])
: (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */ : (g.Cmd.dirchars[dir] - 'a' + 'A')); /* run command */
} }
return cmd; return cmd;
@@ -5503,7 +5501,7 @@ boolean historical; /* whether to include in message history: True => yes */
} else if (cnt && (key == '\b' || key == STANDBY_erase_char)) { } else if (cnt && (key == '\b' || key == STANDBY_erase_char)) {
cnt = cnt / 10; cnt = cnt / 10;
backspaced = TRUE; backspaced = TRUE;
} else if (key == Cmd.spkeys[NHKF_ESC]) { } else if (key == g.Cmd.spkeys[NHKF_ESC]) {
break; break;
} else if (!allowchars || index(allowchars, key)) { } else if (!allowchars || index(allowchars, key)) {
*count = cnt; *count = cnt;
@@ -5553,7 +5551,7 @@ parse()
#ifdef ALTMETA #ifdef ALTMETA
alt_esc = iflags.altmeta; /* readchar() hack */ alt_esc = iflags.altmeta; /* readchar() hack */
#endif #endif
if (!Cmd.num_pad || (foo = readchar()) == Cmd.spkeys[NHKF_COUNT]) { if (!g.Cmd.num_pad || (foo = readchar()) == g.Cmd.spkeys[NHKF_COUNT]) {
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);
@@ -5564,15 +5562,15 @@ parse()
#endif #endif
if (iflags.debug_fuzzer /* if fuzzing, override '!' and ^Z */ if (iflags.debug_fuzzer /* if fuzzing, override '!' and ^Z */
&& (Cmd.commands[foo & 0x0ff] && (g.Cmd.commands[foo & 0x0ff]
&& (Cmd.commands[foo & 0x0ff]->ef_funct == dosuspend_core && (g.Cmd.commands[foo & 0x0ff]->ef_funct == dosuspend_core
|| Cmd.commands[foo & 0x0ff]->ef_funct == dosh_core))) || g.Cmd.commands[foo & 0x0ff]->ef_funct == dosh_core)))
foo = Cmd.spkeys[NHKF_ESC]; foo = g.Cmd.spkeys[NHKF_ESC];
if (foo == 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 = last_multi = 0;
} else if (foo == Cmd.spkeys[NHKF_DOAGAIN] || in_doagain) { } else if (foo == g.Cmd.spkeys[NHKF_DOAGAIN] || in_doagain) {
multi = last_multi; multi = last_multi;
} else { } else {
last_multi = multi; last_multi = multi;
@@ -5587,20 +5585,20 @@ parse()
save_cm = (char *) 0; save_cm = (char *) 0;
} }
/* in 3.4.3 this was in rhack(), where it was too late to handle M-5 */ /* in 3.4.3 this was in rhack(), where it was too late to handle M-5 */
if (Cmd.pcHack_compat) { if (g.Cmd.pcHack_compat) {
/* This handles very old inconsistent DOS/Windows behaviour /* This handles very old inconsistent DOS/Windows behaviour
in a different way: earlier, the keyboard handler mapped in a different way: earlier, the keyboard handler mapped
these, which caused counts to be strange when entered these, which caused counts to be strange when entered
from the number pad. Now do not map them until here. */ from the number pad. Now do not map them until here. */
switch (foo) { switch (foo) {
case '5': case '5':
foo = Cmd.spkeys[NHKF_RUSH]; foo = g.Cmd.spkeys[NHKF_RUSH];
break; break;
case M('5'): case M('5'):
foo = Cmd.spkeys[NHKF_RUN]; foo = g.Cmd.spkeys[NHKF_RUN];
break; break;
case M('0'): case M('0'):
foo = Cmd.spkeys[NHKF_DOINV]; foo = g.Cmd.spkeys[NHKF_DOINV];
break; break;
default: default:
break; /* as is */ break; /* as is */
@@ -5768,7 +5766,7 @@ dotravel(VOID_ARGS)
iflags.getloc_travelmode = FALSE; iflags.getloc_travelmode = FALSE;
iflags.travelcc.x = u.tx = cc.x; iflags.travelcc.x = u.tx = cc.x;
iflags.travelcc.y = u.ty = cc.y; iflags.travelcc.y = u.ty = cc.y;
cmd[0] = Cmd.spkeys[NHKF_TRAVEL]; cmd[0] = g.Cmd.spkeys[NHKF_TRAVEL];
readchar_queue = cmd; readchar_queue = cmd;
return 0; return 0;
} }
+9
View File
@@ -329,13 +329,22 @@ const struct instance_globals g_init = {
/* artifact.c */ /* artifact.c */
0, /* spec_dbon_applies */ 0, /* spec_dbon_applies */
UNDEFINED_VALUES, /* artiexist */
UNDEFINED_VALUES, /* artdisco */
/* botl.c */ /* botl.c */
0, /* mrank_sz */ 0, /* mrank_sz */
/* cmd.c */
UNDEFINED_VALUES, /* Cmd */
/* dog.c */ /* dog.c */
0, /* petname_used */ 0, /* petname_used */
/* makemon.c */
{ -1, /* choice_count */
{ 0 } }, /* mchoices */
/* mused.c */ /* mused.c */
FALSE, /* m_using */ FALSE, /* m_using */
UNDEFINED_VALUE, /* trapx */ UNDEFINED_VALUE, /* trapx */
+1 -1
View File
@@ -972,7 +972,7 @@ struct obj *obj;
/* construct list of directions to show player for likely choices */ /* construct list of directions to show player for likely choices */
downok = !!can_reach_floor(FALSE); downok = !!can_reach_floor(FALSE);
dsp = dirsyms; dsp = dirsyms;
for (sdp = Cmd.dirchars; *sdp; ++sdp) { for (sdp = g.Cmd.dirchars; *sdp; ++sdp) {
/* filter out useless directions */ /* filter out useless directions */
if (u.uswallow) { if (u.uswallow) {
; /* all directions are viable when swallowed */ ; /* all directions are viable when swallowed */
+46 -46
View File
@@ -100,7 +100,7 @@ const char *goal;
Sprintf(sbuf, Sprintf(sbuf,
"Use '%c', '%c', '%c', '%c' to move the cursor to %s.", /* hjkl */ "Use '%c', '%c', '%c', '%c' to move the cursor to %s.", /* hjkl */
Cmd.move_W, Cmd.move_S, Cmd.move_N, Cmd.move_E, goal); g.Cmd.move_W, g.Cmd.move_S, g.Cmd.move_N, g.Cmd.move_E, goal);
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
"Use 'H', 'J', 'K', 'L' to fast-move the cursor, %s.", "Use 'H', 'J', 'K', 'L' to fast-move the cursor, %s.",
@@ -108,47 +108,47 @@ const char *goal;
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
putstr(tmpwin, 0, "Or enter a background symbol (ex. '<')."); putstr(tmpwin, 0, "Or enter a background symbol (ex. '<').");
Sprintf(sbuf, "Use '%s' to move the cursor on yourself.", Sprintf(sbuf, "Use '%s' to move the cursor on yourself.",
visctrl(Cmd.spkeys[NHKF_GETPOS_SELF])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_SELF]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) {
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_MON_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_MON_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_MON_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_MON_PREV]),
GLOC_MONS); GLOC_MONS);
} }
if (!iflags.terrainmode || (iflags.terrainmode & TER_OBJ) != 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_OBJ) != 0) {
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_OBJ_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_OBJ_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_OBJ_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_OBJ_PREV]),
GLOC_OBJS); GLOC_OBJS);
} }
if (!iflags.terrainmode || (iflags.terrainmode & TER_MAP) != 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_MAP) != 0) {
/* these are primarily useful when choosing a travel /* these are primarily useful when choosing a travel
destination for the '_' command */ destination for the '_' command */
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_DOOR_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_DOOR_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_DOOR_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_DOOR_PREV]),
GLOC_DOOR); GLOC_DOOR);
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_UNEX_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]),
GLOC_EXPLORE); GLOC_EXPLORE);
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]),
GLOC_INTERESTING); GLOC_INTERESTING);
} }
Sprintf(sbuf, "Use '%s' to change fast-move mode to %s.", Sprintf(sbuf, "Use '%s' to change fast-move mode to %s.",
visctrl(Cmd.spkeys[NHKF_GETPOS_MOVESKIP]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_MOVESKIP]),
fastmovemode[!iflags.getloc_moveskip]); fastmovemode[!iflags.getloc_moveskip]);
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
if (!iflags.terrainmode || (iflags.terrainmode & TER_DETECT) == 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_DETECT) == 0) {
Sprintf(sbuf, "Use '%s' to toggle menu listing for possible targets.", Sprintf(sbuf, "Use '%s' to toggle menu listing for possible targets.",
visctrl(Cmd.spkeys[NHKF_GETPOS_MENU])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_MENU]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
"Use '%s' to change the mode of limiting possible targets.", "Use '%s' to change the mode of limiting possible targets.",
visctrl(Cmd.spkeys[NHKF_GETPOS_LIMITVIEW])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_LIMITVIEW]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
if (!iflags.terrainmode) { if (!iflags.terrainmode) {
@@ -156,56 +156,56 @@ const char *goal;
if (getpos_getvalid) { if (getpos_getvalid) {
Sprintf(sbuf, "Use '%s' or '%s' to move to valid locations.", Sprintf(sbuf, "Use '%s' or '%s' to move to valid locations.",
visctrl(Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_VALID_PREV])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_VALID_PREV]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
if (getpos_hilitefunc) { if (getpos_hilitefunc) {
Sprintf(sbuf, "Use '%s' to display valid locations.", Sprintf(sbuf, "Use '%s' to display valid locations.",
visctrl(Cmd.spkeys[NHKF_GETPOS_SHOWVALID])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_SHOWVALID]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
Sprintf(sbuf, "Use '%s' to toggle automatic description.", Sprintf(sbuf, "Use '%s' to toggle automatic description.",
visctrl(Cmd.spkeys[NHKF_GETPOS_AUTODESC])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_AUTODESC]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
if (iflags.cmdassist) { /* assisting the '/' command, I suppose... */ if (iflags.cmdassist) { /* assisting the '/' command, I suppose... */
Sprintf(sbuf, Sprintf(sbuf,
(iflags.getpos_coords == GPCOORDS_NONE) (iflags.getpos_coords == GPCOORDS_NONE)
? "(Set 'whatis_coord' option to include coordinates with '%s' text.)" ? "(Set 'whatis_coord' option to include coordinates with '%s' text.)"
: "(Reset 'whatis_coord' option to omit coordinates from '%s' text.)", : "(Reset 'whatis_coord' option to omit coordinates from '%s' text.)",
visctrl(Cmd.spkeys[NHKF_GETPOS_AUTODESC])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_AUTODESC]));
} }
/* disgusting hack; the alternate selection characters work for any /* disgusting hack; the alternate selection characters work for any
getpos call, but only matter for dowhatis (and doquickwhatis) */ getpos call, but only matter for dowhatis (and doquickwhatis) */
doing_what_is = (goal == what_is_an_unknown_object); doing_what_is = (goal == what_is_an_unknown_object);
if (doing_what_is) { if (doing_what_is) {
Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'", Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]),
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_Q]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_Q]),
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_O]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_O]),
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_V])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_V]));
} else { } else {
Sprintf(kbuf, "'%s'", visctrl(Cmd.spkeys[NHKF_GETPOS_PICK])); Sprintf(kbuf, "'%s'", visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]));
} }
Sprintf(sbuf, "Type a %s when you are at the right place.", kbuf); Sprintf(sbuf, "Type a %s when you are at the right place.", kbuf);
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
if (doing_what_is) { if (doing_what_is) {
Sprintf(sbuf, Sprintf(sbuf,
" '%s' describe current spot, show 'more info', move to another spot.", " '%s' describe current spot, show 'more info', move to another spot.",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_V])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_V]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
" '%s' describe current spot,%s move to another spot;", " '%s' describe current spot,%s move to another spot;",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]),
flags.help ? " prompt if 'more info'," : ""); flags.help ? " prompt if 'more info'," : "");
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
" '%s' describe current spot, move to another spot;", " '%s' describe current spot, move to another spot;",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_Q])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_Q]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
" '%s' describe current spot, stop looking at things;", " '%s' describe current spot, stop looking at things;",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_O])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_O]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
} }
@@ -666,18 +666,18 @@ const char *goal;
int gidx[NUM_GLOCS] = DUMMY; int gidx[NUM_GLOCS] = DUMMY;
for (i = 0; i < SIZE(pick_chars_def); i++) for (i = 0; i < SIZE(pick_chars_def); i++)
pick_chars[i] = Cmd.spkeys[pick_chars_def[i].nhkf]; pick_chars[i] = g.Cmd.spkeys[pick_chars_def[i].nhkf];
pick_chars[SIZE(pick_chars_def)] = '\0'; pick_chars[SIZE(pick_chars_def)] = '\0';
for (i = 0; i < SIZE(mMoOdDxX_def); i++) for (i = 0; i < SIZE(mMoOdDxX_def); i++)
mMoOdDxX[i] = Cmd.spkeys[mMoOdDxX_def[i]]; mMoOdDxX[i] = g.Cmd.spkeys[mMoOdDxX_def[i]];
mMoOdDxX[SIZE(mMoOdDxX_def)] = '\0'; mMoOdDxX[SIZE(mMoOdDxX_def)] = '\0';
if (!goal) if (!goal)
goal = "desired location"; goal = "desired location";
if (flags.verbose) { if (flags.verbose) {
pline("(For instructions type a '%s')", pline("(For instructions type a '%s')",
visctrl(Cmd.spkeys[NHKF_GETPOS_HELP])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_HELP]));
msg_given = TRUE; msg_given = TRUE;
} }
cx = ccp->x; cx = ccp->x;
@@ -712,7 +712,7 @@ const char *goal;
if (iflags.autodescribe) if (iflags.autodescribe)
msg_given = FALSE; msg_given = FALSE;
if (c == Cmd.spkeys[NHKF_ESC]) { if (c == g.Cmd.spkeys[NHKF_ESC]) {
cx = cy = -10; cx = cy = -10;
msg_given = TRUE; /* force clear */ msg_given = TRUE; /* force clear */
result = -1; result = -1;
@@ -734,12 +734,12 @@ const char *goal;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
int dx, dy; int dx, dy;
if (Cmd.dirchars[i] == c) { if (g.Cmd.dirchars[i] == c) {
/* a normal movement letter or digit */ /* a normal movement letter or digit */
dx = xdir[i]; dx = xdir[i];
dy = ydir[i]; dy = ydir[i];
} else if (Cmd.alphadirchars[i] == lowc((char) c) } else if (g.Cmd.alphadirchars[i] == lowc((char) c)
|| (Cmd.num_pad && Cmd.dirchars[i] == (c & 0177))) { || (g.Cmd.num_pad && g.Cmd.dirchars[i] == (c & 0177))) {
/* a shifted movement letter or Meta-digit */ /* a shifted movement letter or Meta-digit */
if (iflags.getloc_moveskip) { if (iflags.getloc_moveskip) {
/* skip same glyphs */ /* skip same glyphs */
@@ -782,15 +782,15 @@ const char *goal;
goto nxtc; goto nxtc;
} }
if (c == Cmd.spkeys[NHKF_GETPOS_HELP] || redraw_cmd(c)) { if (c == g.Cmd.spkeys[NHKF_GETPOS_HELP] || redraw_cmd(c)) {
if (c == Cmd.spkeys[NHKF_GETPOS_HELP]) if (c == g.Cmd.spkeys[NHKF_GETPOS_HELP])
getpos_help(force, goal); getpos_help(force, goal);
else /* ^R */ else /* ^R */
docrt(); /* redraw */ docrt(); /* redraw */
/* update message window to reflect that we're still targetting */ /* update message window to reflect that we're still targetting */
show_goal_msg = TRUE; show_goal_msg = TRUE;
msg_given = TRUE; msg_given = TRUE;
} else if (c == Cmd.spkeys[NHKF_GETPOS_SHOWVALID] } else if (c == g.Cmd.spkeys[NHKF_GETPOS_SHOWVALID]
&& getpos_hilitefunc) { && getpos_hilitefunc) {
if (!hilite_state) { if (!hilite_state) {
(*getpos_hilitefunc)(0); (*getpos_hilitefunc)(0);
@@ -798,7 +798,7 @@ const char *goal;
hilite_state = TRUE; hilite_state = TRUE;
} }
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_AUTODESC]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_AUTODESC]) {
iflags.autodescribe = !iflags.autodescribe; iflags.autodescribe = !iflags.autodescribe;
pline("Automatic description %sis %s.", pline("Automatic description %sis %s.",
flags.verbose ? "of features under cursor " : "", flags.verbose ? "of features under cursor " : "",
@@ -807,7 +807,7 @@ const char *goal;
show_goal_msg = TRUE; show_goal_msg = TRUE;
msg_given = TRUE; msg_given = TRUE;
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_LIMITVIEW]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_LIMITVIEW]) {
static const char *const view_filters[NUM_GFILTER] = { static const char *const view_filters[NUM_GFILTER] = {
"Not limiting targets", "Not limiting targets",
"Limiting targets to in sight", "Limiting targets to in sight",
@@ -825,13 +825,13 @@ const char *goal;
pline("%s.", view_filters[iflags.getloc_filter]); pline("%s.", view_filters[iflags.getloc_filter]);
msg_given = TRUE; msg_given = TRUE;
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_MENU]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_MENU]) {
iflags.getloc_usemenu = !iflags.getloc_usemenu; iflags.getloc_usemenu = !iflags.getloc_usemenu;
pline("%s a menu to show possible targets.", pline("%s a menu to show possible targets.",
iflags.getloc_usemenu ? "Using" : "Not using"); iflags.getloc_usemenu ? "Using" : "Not using");
msg_given = TRUE; msg_given = TRUE;
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_SELF]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_SELF]) {
/* reset 'm&M', 'o&O', &c; otherwise, there's no way for player /* reset 'm&M', 'o&O', &c; otherwise, there's no way for player
to achieve that except by manually cycling through all spots */ to achieve that except by manually cycling through all spots */
for (i = 0; i < NUM_GLOCS; i++) for (i = 0; i < NUM_GLOCS; i++)
@@ -839,7 +839,7 @@ const char *goal;
cx = u.ux; cx = u.ux;
cy = u.uy; cy = u.uy;
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_MOVESKIP]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_MOVESKIP]) {
iflags.getloc_moveskip = !iflags.getloc_moveskip; iflags.getloc_moveskip = !iflags.getloc_moveskip;
pline("%skipping over similar terrain when fastmoving the cursor.", pline("%skipping over similar terrain when fastmoving the cursor.",
iflags.getloc_moveskip ? "S" : "Not s"); iflags.getloc_moveskip ? "S" : "Not s");
@@ -944,8 +944,8 @@ const char *goal;
Strcpy(note, "aborted"); Strcpy(note, "aborted");
else /* hjkl */ else /* hjkl */
Sprintf(note, "use '%c', '%c', '%c', '%c' or '%s'", Sprintf(note, "use '%c', '%c', '%c', '%c' or '%s'",
Cmd.move_W, Cmd.move_S, Cmd.move_N, Cmd.move_E, g.Cmd.move_W, g.Cmd.move_S, g.Cmd.move_N, g.Cmd.move_E,
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]));
pline("Unknown direction: '%s' (%s).", visctrl((char) c), pline("Unknown direction: '%s' (%s).", visctrl((char) c),
note); note);
msg_given = TRUE; msg_given = TRUE;
+13 -18
View File
@@ -1509,11 +1509,6 @@ register struct permonst *ptr;
return alshift; return alshift;
} }
static NEARDATA struct {
int choice_count;
char mchoices[SPECIAL_PM]; /* value range is 0..127 */
} rndmonst_state = { -1, { 0 } };
/* select a random monster type */ /* select a random monster type */
struct permonst * struct permonst *
rndmonst() rndmonst()
@@ -1524,17 +1519,17 @@ rndmonst()
if (u.uz.dnum == quest_dnum && rn2(7) && (ptr = qt_montype()) != 0) if (u.uz.dnum == quest_dnum && rn2(7) && (ptr = qt_montype()) != 0)
return ptr; return ptr;
if (rndmonst_state.choice_count < 0) { /* need to recalculate */ if (g.rndmonst_state.choice_count < 0) { /* need to recalculate */
int zlevel, minmlev, maxmlev; int zlevel, minmlev, maxmlev;
boolean elemlevel; boolean elemlevel;
boolean upper; boolean upper;
rndmonst_state.choice_count = 0; g.rndmonst_state.choice_count = 0;
/* look for first common monster */ /* look for first common monster */
for (mndx = LOW_PM; mndx < SPECIAL_PM; mndx++) { for (mndx = LOW_PM; mndx < SPECIAL_PM; mndx++) {
if (!uncommon(mndx)) if (!uncommon(mndx))
break; break;
rndmonst_state.mchoices[mndx] = 0; g.rndmonst_state.mchoices[mndx] = 0;
} }
if (mndx == SPECIAL_PM) { if (mndx == SPECIAL_PM) {
/* evidently they've all been exterminated */ /* evidently they've all been exterminated */
@@ -1554,7 +1549,7 @@ rndmonst()
*/ */
for ( ; mndx < SPECIAL_PM; mndx++) { /* (`mndx' initialized above) */ for ( ; mndx < SPECIAL_PM; mndx++) { /* (`mndx' initialized above) */
ptr = &mons[mndx]; ptr = &mons[mndx];
rndmonst_state.mchoices[mndx] = 0; g.rndmonst_state.mchoices[mndx] = 0;
if (tooweak(mndx, minmlev) || toostrong(mndx, maxmlev)) if (tooweak(mndx, minmlev) || toostrong(mndx, maxmlev))
continue; continue;
if (upper && !isupper((uchar) def_monsyms[(int) ptr->mlet].sym)) if (upper && !isupper((uchar) def_monsyms[(int) ptr->mlet].sym))
@@ -1568,8 +1563,8 @@ rndmonst()
ct = (int) (ptr->geno & G_FREQ) + align_shift(ptr); ct = (int) (ptr->geno & G_FREQ) + align_shift(ptr);
if (ct < 0 || ct > 127) if (ct < 0 || ct > 127)
panic("rndmonst: bad count [#%d: %d]", mndx, ct); panic("rndmonst: bad count [#%d: %d]", mndx, ct);
rndmonst_state.choice_count += ct; g.rndmonst_state.choice_count += ct;
rndmonst_state.mchoices[mndx] = (char) ct; g.rndmonst_state.mchoices[mndx] = (char) ct;
} }
/* /*
* Possible modification: if choice_count is "too low", * Possible modification: if choice_count is "too low",
@@ -1577,18 +1572,18 @@ rndmonst()
*/ */
} /* choice_count+mchoices[] recalc */ } /* choice_count+mchoices[] recalc */
if (rndmonst_state.choice_count <= 0) { if (g.rndmonst_state.choice_count <= 0) {
/* maybe no common mons left, or all are too weak or too strong */ /* maybe no common mons left, or all are too weak or too strong */
debugpline1("rndmonst: choice_count=%d", rndmonst_state.choice_count); debugpline1("rndmonst: choice_count=%d", g.rndmonst_state.choice_count);
return (struct permonst *) 0; return (struct permonst *) 0;
} }
/* /*
* Now, select a monster at random. * Now, select a monster at random.
*/ */
ct = rnd(rndmonst_state.choice_count); ct = rnd(g.rndmonst_state.choice_count);
for (mndx = LOW_PM; mndx < SPECIAL_PM; mndx++) for (mndx = LOW_PM; mndx < SPECIAL_PM; mndx++)
if ((ct -= (int) rndmonst_state.mchoices[mndx]) <= 0) if ((ct -= (int) g.rndmonst_state.mchoices[mndx]) <= 0)
break; break;
if (mndx == SPECIAL_PM || uncommon(mndx)) { /* shouldn't happen */ if (mndx == SPECIAL_PM || uncommon(mndx)) { /* shouldn't happen */
@@ -1606,10 +1601,10 @@ int mndx; /* particular species that can no longer be created */
{ {
/* cached selection info is out of date */ /* cached selection info is out of date */
if (mndx == NON_PM) { if (mndx == NON_PM) {
rndmonst_state.choice_count = -1; /* full recalc needed */ g.rndmonst_state.choice_count = -1; /* full recalc needed */
} else if (mndx < SPECIAL_PM) { } else if (mndx < SPECIAL_PM) {
rndmonst_state.choice_count -= rndmonst_state.mchoices[mndx]; g.rndmonst_state.choice_count -= g.rndmonst_state.mchoices[mndx];
rndmonst_state.mchoices[mndx] = 0; g.rndmonst_state.mchoices[mndx] = 0;
} /* note: safe to ignore extinction of unique monsters */ } /* note: safe to ignore extinction of unique monsters */
} }
+4 -4
View File
@@ -5570,10 +5570,10 @@ char *buf;
"4=on, phone layout, MSDOS compatible", "4=on, phone layout, MSDOS compatible",
"-1=off, y & z swapped", /*[5]*/ "-1=off, y & z swapped", /*[5]*/
}; };
int indx = Cmd.num_pad int indx = g.Cmd.num_pad
? (Cmd.phone_layout ? (Cmd.pcHack_compat ? 4 : 3) ? (g.Cmd.phone_layout ? (g.Cmd.pcHack_compat ? 4 : 3)
: (Cmd.pcHack_compat ? 2 : 1)) : (g.Cmd.pcHack_compat ? 2 : 1))
: Cmd.swap_yz ? 5 : 0; : g.Cmd.swap_yz ? 5 : 0;
Strcpy(buf, numpadmodes[indx]); Strcpy(buf, numpadmodes[indx]);
} else if (!strcmp(optname, "objects")) { } else if (!strcmp(optname, "objects")) {