topl.c globals moved to instance_globals.
This commit is contained in:
@@ -464,6 +464,14 @@ struct instance_globals {
|
|||||||
/* pickup.c */
|
/* pickup.c */
|
||||||
int oldcap; /* last encumberance */
|
int oldcap; /* last encumberance */
|
||||||
|
|
||||||
|
/* pline.c */
|
||||||
|
unsigned pline_flags;
|
||||||
|
char prevmsg[BUFSZ];
|
||||||
|
#ifdef DUMPLOG
|
||||||
|
unsigned saved_pline_index; /* slot in saved_plines[] to use next */
|
||||||
|
char *saved_plines[DUMPLOG_MSG_COUNT];
|
||||||
|
#endif
|
||||||
|
|
||||||
/* polyself.c */
|
/* polyself.c */
|
||||||
int sex_change_ok; /* controls whether taking on new form or becoming new
|
int sex_change_ok; /* controls whether taking on new form or becoming new
|
||||||
man can also change sex (ought to be an arg to
|
man can also change sex (ought to be an arg to
|
||||||
|
|||||||
@@ -5771,8 +5771,7 @@ char def;
|
|||||||
{
|
{
|
||||||
char res, qbuf[QBUFSZ];
|
char res, qbuf[QBUFSZ];
|
||||||
#ifdef DUMPLOG
|
#ifdef DUMPLOG
|
||||||
extern unsigned saved_pline_index; /* pline.c */
|
unsigned idx = g.saved_pline_index;
|
||||||
unsigned idx = saved_pline_index;
|
|
||||||
/* buffer to hold query+space+formatted_single_char_response */
|
/* buffer to hold query+space+formatted_single_char_response */
|
||||||
char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */
|
char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */
|
||||||
#endif
|
#endif
|
||||||
@@ -5789,7 +5788,7 @@ char def;
|
|||||||
}
|
}
|
||||||
res = (*windowprocs.win_yn_function)(query, resp, def);
|
res = (*windowprocs.win_yn_function)(query, resp, def);
|
||||||
#ifdef DUMPLOG
|
#ifdef DUMPLOG
|
||||||
if (idx == saved_pline_index) {
|
if (idx == g.saved_pline_index) {
|
||||||
/* when idx is still the same as saved_pline_index, the interface
|
/* when idx is still the same as saved_pline_index, the interface
|
||||||
didn't put the prompt into saved_plines[]; we put a simplified
|
didn't put the prompt into saved_plines[]; we put a simplified
|
||||||
version in there now (without response choices or default) */
|
version in there now (without response choices or default) */
|
||||||
|
|||||||
@@ -348,6 +348,14 @@ const struct instance_globals g_init = {
|
|||||||
/* pickup.c */
|
/* pickup.c */
|
||||||
0, /* oldcap */
|
0, /* oldcap */
|
||||||
|
|
||||||
|
/* pline.c */
|
||||||
|
0, /* pline_flags */
|
||||||
|
UNDEFINED_VALUES, /* prevmsg */
|
||||||
|
#ifdef DUMPLOG
|
||||||
|
0, /* saved_pline_index */
|
||||||
|
UNDEFINED_VALUES,
|
||||||
|
#endif
|
||||||
|
|
||||||
/* polyself.c */
|
/* polyself.c */
|
||||||
0, /* sex_change_ok */
|
0, /* sex_change_ok */
|
||||||
|
|
||||||
|
|||||||
@@ -679,14 +679,12 @@ dump_plines()
|
|||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char buf[BUFSZ], **strp;
|
char buf[BUFSZ], **strp;
|
||||||
extern char *saved_plines[];
|
|
||||||
extern unsigned saved_pline_index;
|
|
||||||
|
|
||||||
Strcpy(buf, " "); /* one space for indentation */
|
Strcpy(buf, " "); /* one space for indentation */
|
||||||
putstr(0, 0, "Latest messages:");
|
putstr(0, 0, "Latest messages:");
|
||||||
for (i = 0, j = (int) saved_pline_index; i < DUMPLOG_MSG_COUNT;
|
for (i = 0, j = (int) g.saved_pline_index; i < DUMPLOG_MSG_COUNT;
|
||||||
++i, j = (j + 1) % DUMPLOG_MSG_COUNT) {
|
++i, j = (j + 1) % DUMPLOG_MSG_COUNT) {
|
||||||
strp = &saved_plines[j];
|
strp = &g.saved_plines[j];
|
||||||
if (*strp) {
|
if (*strp) {
|
||||||
copynchars(&buf[1], *strp, BUFSZ - 1 - 1);
|
copynchars(&buf[1], *strp, BUFSZ - 1 - 1);
|
||||||
putstr(0, 0, buf);
|
putstr(0, 0, buf);
|
||||||
|
|||||||
+16
-22
@@ -6,18 +6,12 @@
|
|||||||
#define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers */
|
#define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers */
|
||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
|
|
||||||
static unsigned pline_flags = 0;
|
|
||||||
static char prevmsg[BUFSZ];
|
|
||||||
|
|
||||||
static char *FDECL(You_buf, (int));
|
static char *FDECL(You_buf, (int));
|
||||||
#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
|
#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
|
||||||
static void FDECL(execplinehandler, (const char *));
|
static void FDECL(execplinehandler, (const char *));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DUMPLOG
|
#ifdef DUMPLOG
|
||||||
/* also used in end.c */
|
|
||||||
unsigned saved_pline_index = 0; /* slot in saved_plines[] to use next */
|
|
||||||
char *saved_plines[DUMPLOG_MSG_COUNT] = { (char *) 0 };
|
|
||||||
|
|
||||||
/* keep the most recent DUMPLOG_MSG_COUNT messages */
|
/* keep the most recent DUMPLOG_MSG_COUNT messages */
|
||||||
void
|
void
|
||||||
@@ -31,8 +25,8 @@ const char *line;
|
|||||||
* The core should take responsibility for that and have
|
* The core should take responsibility for that and have
|
||||||
* this share it.
|
* this share it.
|
||||||
*/
|
*/
|
||||||
unsigned indx = saved_pline_index; /* next slot to use */
|
unsigned indx = g.saved_pline_index; /* next slot to use */
|
||||||
char *oldest = saved_plines[indx]; /* current content of that slot */
|
char *oldest = g.saved_plines[indx]; /* current content of that slot */
|
||||||
|
|
||||||
if (oldest && strlen(oldest) >= strlen(line)) {
|
if (oldest && strlen(oldest) >= strlen(line)) {
|
||||||
/* this buffer will gradually shrink until the 'else' is needed;
|
/* this buffer will gradually shrink until the 'else' is needed;
|
||||||
@@ -41,9 +35,9 @@ const char *line;
|
|||||||
} else {
|
} else {
|
||||||
if (oldest)
|
if (oldest)
|
||||||
free((genericptr_t) oldest);
|
free((genericptr_t) oldest);
|
||||||
saved_plines[indx] = dupstr(line);
|
g.saved_plines[indx] = dupstr(line);
|
||||||
}
|
}
|
||||||
saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT;
|
g.saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called during save (unlike the interface-specific message history,
|
/* called during save (unlike the interface-specific message history,
|
||||||
@@ -55,9 +49,9 @@ dumplogfreemessages()
|
|||||||
unsigned indx;
|
unsigned indx;
|
||||||
|
|
||||||
for (indx = 0; indx < DUMPLOG_MSG_COUNT; ++indx)
|
for (indx = 0; indx < DUMPLOG_MSG_COUNT; ++indx)
|
||||||
if (saved_plines[indx])
|
if (g.saved_plines[indx])
|
||||||
free((genericptr_t) saved_plines[indx]), saved_plines[indx] = 0;
|
free((genericptr_t) g.saved_plines[indx]), g.saved_plines[indx] = 0;
|
||||||
saved_pline_index = 0;
|
g.saved_pline_index = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -139,7 +133,7 @@ VA_DECL(const char *, line)
|
|||||||
* Unfortunately, that means Norep() isn't honored (general issue) and
|
* Unfortunately, that means Norep() isn't honored (general issue) and
|
||||||
* that short lines aren't combined into one longer one (tty behavior).
|
* that short lines aren't combined into one longer one (tty behavior).
|
||||||
*/
|
*/
|
||||||
if ((pline_flags & SUPPRESS_HISTORY) == 0)
|
if ((g.pline_flags & SUPPRESS_HISTORY) == 0)
|
||||||
dumplogmsg(line);
|
dumplogmsg(line);
|
||||||
#endif
|
#endif
|
||||||
/* use raw_print() if we're called too early (or perhaps too late
|
/* use raw_print() if we're called too early (or perhaps too late
|
||||||
@@ -153,11 +147,11 @@ VA_DECL(const char *, line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
msgtyp = MSGTYP_NORMAL;
|
msgtyp = MSGTYP_NORMAL;
|
||||||
no_repeat = (pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE;
|
no_repeat = (g.pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE;
|
||||||
if ((pline_flags & OVERRIDE_MSGTYPE) == 0) {
|
if ((g.pline_flags & OVERRIDE_MSGTYPE) == 0) {
|
||||||
msgtyp = msgtype_type(line, no_repeat);
|
msgtyp = msgtype_type(line, no_repeat);
|
||||||
if (msgtyp == MSGTYP_NOSHOW
|
if (msgtyp == MSGTYP_NOSHOW
|
||||||
|| (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg)))
|
|| (msgtyp == MSGTYP_NOREP && !strcmp(line, g.prevmsg)))
|
||||||
/* FIXME: we need a way to tell our caller that this message
|
/* FIXME: we need a way to tell our caller that this message
|
||||||
* was suppressed so that caller doesn't set iflags.last_msg
|
* was suppressed so that caller doesn't set iflags.last_msg
|
||||||
* for something that hasn't been shown, otherwise a subsequent
|
* for something that hasn't been shown, otherwise a subsequent
|
||||||
@@ -181,7 +175,7 @@ VA_DECL(const char *, line)
|
|||||||
|
|
||||||
/* this gets cleared after every pline message */
|
/* this gets cleared after every pline message */
|
||||||
iflags.last_msg = PLNMSG_UNKNOWN;
|
iflags.last_msg = PLNMSG_UNKNOWN;
|
||||||
(void) strncpy(prevmsg, line, BUFSZ), prevmsg[BUFSZ - 1] = '\0';
|
(void) strncpy(g.prevmsg, line, BUFSZ), g.prevmsg[BUFSZ - 1] = '\0';
|
||||||
if (msgtyp == MSGTYP_STOP)
|
if (msgtyp == MSGTYP_STOP)
|
||||||
display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */
|
display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */
|
||||||
|
|
||||||
@@ -205,9 +199,9 @@ VA_DECL2(unsigned, pflags, const char *, line)
|
|||||||
{
|
{
|
||||||
VA_START(line);
|
VA_START(line);
|
||||||
VA_INIT(line, const char *);
|
VA_INIT(line, const char *);
|
||||||
pline_flags = pflags;
|
g.pline_flags = pflags;
|
||||||
vpline(line, VA_ARGS);
|
vpline(line, VA_ARGS);
|
||||||
pline_flags = 0;
|
g.pline_flags = 0;
|
||||||
VA_END();
|
VA_END();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -218,9 +212,9 @@ VA_DECL(const char *, line)
|
|||||||
{
|
{
|
||||||
VA_START(line);
|
VA_START(line);
|
||||||
VA_INIT(line, const char *);
|
VA_INIT(line, const char *);
|
||||||
pline_flags = PLINE_NOREPEAT;
|
g.pline_flags = PLINE_NOREPEAT;
|
||||||
vpline(line, VA_ARGS);
|
vpline(line, VA_ARGS);
|
||||||
pline_flags = 0;
|
g.pline_flags = 0;
|
||||||
VA_END();
|
VA_END();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -648,9 +648,6 @@ boolean restoring_msghist;
|
|||||||
{
|
{
|
||||||
static boolean initd = FALSE;
|
static boolean initd = FALSE;
|
||||||
int idx;
|
int idx;
|
||||||
#ifdef DUMPLOG
|
|
||||||
extern unsigned saved_pline_index; /* pline.c */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (restoring_msghist && !initd) {
|
if (restoring_msghist && !initd) {
|
||||||
/* we're restoring history from the previous session, but new
|
/* we're restoring history from the previous session, but new
|
||||||
@@ -662,7 +659,7 @@ boolean restoring_msghist;
|
|||||||
initd = TRUE;
|
initd = TRUE;
|
||||||
#ifdef DUMPLOG
|
#ifdef DUMPLOG
|
||||||
/* this suffices; there's no need to scrub saved_pline[] pointers */
|
/* this suffices; there's no need to scrub saved_pline[] pointers */
|
||||||
saved_pline_index = 0;
|
g.saved_pline_index = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user