split g into multiple structures

The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.

It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.

Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.

To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.

A global variable named 'amulets', would be found in ga.
    ga.amulets
     ^ ^
A global varable named 'move', would be found in gm.
    gm.moves
     ^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
    gv.val_for_n_or_more
     ^ ^
A global variable named 'youmonst' would be found in gy.
    gy.youmonst
     ^ ^
This commit is contained in:
nhmall
2022-11-29 21:53:21 -05:00
parent e64ed2859d
commit 02a48aa8cf
193 changed files with 10764 additions and 10148 deletions
+8 -8
View File
@@ -226,7 +226,7 @@ void NetHackQtBind::qt_askname()
int ch = -1; // -1 => new game
have_asked = true;
str_copy(default_plname, g.plname, PL_NSIZ);
str_copy(default_plname, gp.plname, PL_NSIZ);
// We do it all here (plus qt_plsel.cpp and qt_svsel.cpp),
// nothing in player_selection().
@@ -241,9 +241,9 @@ void NetHackQtBind::qt_askname()
NetHackQtSavedGameSelector sgsel((const char **) saved);
ch = sgsel.choose();
if (ch >= 0)
str_copy(g.plname, saved[ch], SIZE(g.plname));
str_copy(gp.plname, saved[ch], SIZE(gp.plname));
// caller needs new lock name even if plname[] hasn't changed
// because successful get_saved_games() clobbers g.SAVEF[]
// because successful get_saved_games() clobbers gs.SAVEF[]
::iflags.renameinprogress = TRUE;
}
free_saved_games(saved);
@@ -271,10 +271,10 @@ void NetHackQtBind::qt_askname()
break;
}
if (!*g.plname)
if (!*gp.plname)
// in case Choose() returns with plname[] empty
Strcpy(g.plname, default_plname);
else if (strcmp(g.plname, default_plname) != 0)
Strcpy(gp.plname, default_plname);
else if (strcmp(gp.plname, default_plname) != 0)
// caller needs to set new lock file name
::iflags.renameinprogress = TRUE;
return;
@@ -487,7 +487,7 @@ void NetHackQtBind::qt_update_inventory(int arg UNUSED)
main->updateInventory(); // update the paper doll inventory subset
/* doesn't work yet
if (g.program_state.something_worth_saving && iflags.perm_invent)
if (gp.program_state.something_worth_saving && iflags.perm_invent)
display_inventory(NULL, false);
*/
}
@@ -641,7 +641,7 @@ char NetHackQtBind::qt_more()
// ^C comment in that routine] when the core triggers --More-- via
// done2() -> really_done() -> display_nhwindow(WIN_MESSAGE, TRUE)
// (get rid of this if the exec() loop issue gets properly fixed)
if (::g.program_state.gameover)
if (::gp.program_state.gameover)
return ch; // bypass --More-- and just continue with program exit
NetHackQtMessageWindow *mesgwin = main ? main->GetMessageWindow() : NULL;
+1 -1
View File
@@ -40,7 +40,7 @@ find_tool(int tooltyp)
{
struct obj *o;
for (o = g.invent; o; o = o->nobj) {
for (o = gi.invent; o; o = o->nobj) {
if ((tooltyp == LEASH && o->otyp == LEASH && o->leashmon)
// OIL_LAMP is used for candles, lamps, lantern, candelabrum too
|| (tooltyp == OIL_LAMP && o->lamplit))
+5 -5
View File
@@ -1035,7 +1035,7 @@ void NetHackQtMainWindow::doQuit(bool)
// in case someone wants to change that
#ifdef MACOS
QString info = nh_qsprintf("This will end your NetHack session.%s",
!g.program_state.something_worth_saving ? ""
!gp.program_state.something_worth_saving ? ""
: "\n(Cancel quitting and use the Save command"
"\nto save your current game.)");
/* this is similar to closeEvent but the details are different;
@@ -1053,7 +1053,7 @@ void NetHackQtMainWindow::doQuit(bool)
break; // return to game
case 1:
// quit -- bypass the prompting preformed by done2()
g.program_state.stopprint++;
gp.program_state.stopprint++;
::done(QUIT);
/*NOTREACHED*/
break;
@@ -1320,7 +1320,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
event->key() >= Qt::Key_Left && event->key() <= Qt::Key_Down )
return;
const char* d = g.Cmd.dirchars;
const char* d = gc.Cmd.dirchars;
switch (event->key()) {
case Qt::Key_Up:
if ( dirkey == d[0] )
@@ -1382,7 +1382,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED)
{
int ok = 0;
if ( g.program_state.something_worth_saving ) {
if ( gp.program_state.something_worth_saving ) {
/* this used to offer "Save" and "Cancel"
but cancel (ignoring the close attempt) won't work
if user has clicked on the window's Close button */
@@ -1397,7 +1397,7 @@ void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED)
case 1:
// quit -- bypass the prompting preformed by done2()
ok = 1;
g.program_state.stopprint++;
gp.program_state.stopprint++;
::done(QUIT);
/*NOTREACHED*/
break;
+2 -2
View File
@@ -1066,7 +1066,7 @@ void NetHackQtTextWindow::UseRIP(int how, time_t when)
/* Put name on stone */
(void) snprintf(rip_line[NAME_LINE], STONE_LINE_LEN + 1,
"%.*s", STONE_LINE_LEN, g.plname);
"%.*s", STONE_LINE_LEN, gp.plname);
/* Put $ on stone;
to keep things safe and relatively simple, impose an arbitrary
@@ -1078,7 +1078,7 @@ void NetHackQtTextWindow::UseRIP(int how, time_t when)
(simplest case: ~300K four times in a blessed bag of holding, so
~1.2M; in addition to the hassle of getting such a thing set up,
it would need many gold-rich bones levels or wizard mode wishing) */
long cash = std::max(g.done_money, 0L);
long cash = std::max(gd.done_money, 0L);
/* force less that 10 digits to satisfy elaborate format checking;
it's arbitrary but still way, way more than could ever be needed */
if (cash < 0)
+7 -7
View File
@@ -40,17 +40,17 @@ extern "C" {
/* check whether plname[] is among the list of generic user names */
static bool generic_plname()
{
if (*g.plname) {
if (*gp.plname) {
const char *sptr, *p;
const char *genericusers = sysopt.genericusers;
int ln = (int) strlen(g.plname);
int ln = (int) strlen(gp.plname);
if (!genericusers || !*genericusers)
genericusers = "player games";
else if (!strcmp(genericusers, "*")) /* "*" => always ask for name */
return true;
while ((sptr = strstri(genericusers, g.plname)) != NULL) {
while ((sptr = strstri(genericusers, gp.plname)) != NULL) {
/* check for full word: start of list or following a space */
if ((sptr == genericusers || sptr[-1] == ' ')
/* and also preceding a space or at end of list */
@@ -263,8 +263,8 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(
// if plname[] contains a generic user name, clear it
if (generic_plname())
*g.plname = '\0';
name->setText(g.plname);
*gp.plname = '\0';
name->setText(gp.plname);
connect(name, SIGNAL(textChanged(const QString&)),
this, SLOT(selectName(const QString&)));
name->setFocus();
@@ -545,7 +545,7 @@ void NetHackQtPlayerSelector::Randomize()
// if plname[] is empty, disable [Play], otherwise [Play] is the default
void NetHackQtPlayerSelector::plnamePlayVsQuit()
{
if (*g.plname) {
if (*gp.plname) {
play_btn->setEnabled(true);
play_btn->setDefault(true);
//quit_btn->setDefault(false);
@@ -564,7 +564,7 @@ void NetHackQtPlayerSelector::selectName(const QString& n)
// (it would be better to set up a validator that rejects leading spaces)
while (*name_str == ' ')
++name_str;
str_copy(g.plname, name_str, PL_NSIZ);
str_copy(gp.plname, name_str, PL_NSIZ);
// possibly enable or disable the [Play] button
plnamePlayVsQuit();
}
+5 -5
View File
@@ -817,17 +817,17 @@ void NetHackQtStatusWindow::updateStats()
buf = nh_capitalize_words(pmname(&mons[u.umonnum],
::flags.female ? FEMALE : MALE));
} else {
buf = rank_of(u.ulevel, g.pl_character[0], ::flags.female);
buf = rank_of(u.ulevel, gp.pl_character[0], ::flags.female);
}
QString buf2;
char buf3[BUFSZ];
buf2 = nh_qsprintf("%s the %s", upstart(strcpy(buf3, g.plname)),
buf2 = nh_qsprintf("%s the %s", upstart(strcpy(buf3, gp.plname)),
buf.toLatin1().constData());
name.setLabel(buf2, NetHackQtLabelledIcon::NoNum, u.ulevel);
if (!describe_level(buf3, 0)) {
Sprintf(buf3, "%s, level %d",
g.dungeons[u.uz.dnum].dname, ::depth(&u.uz));
gd.dungeons[u.uz.dnum].dname, ::depth(&u.uz));
}
dlevel.setLabel(buf3);
@@ -885,7 +885,7 @@ void NetHackQtStatusWindow::updateStats()
ac.setLabel("AC:", (long) u.uac);
// gold prefix used to be "Au:", tty uses "$:"; never too wide to fit;
// practical limit due to carrying capacity limit is less than 300K
long goldamt = money_cnt(g.invent);
long goldamt = money_cnt(gi.invent);
goldamt = std::max(goldamt, 0L); // sanity; core's botl() does likewise
goldamt = std::min(goldamt, 99999999L); // ditto
gold.setLabel("Gold:", goldamt);
@@ -925,7 +925,7 @@ void NetHackQtStatusWindow::updateStats()
if (::flags.time) {
// hypothetically Time could grow to enough digits to have trouble
// fitting, but it's not worth worrying about
time.setLabel("Time:", (long) g.moves);
time.setLabel("Time:", (long) gm.moves);
} else {
time.setLabel("");
}
+2 -2
View File
@@ -115,7 +115,7 @@ char NetHackQtYnDialog::Exec()
}
if ( question.indexOf("what direction") >= 0 ) {
// We replace this regardless, since sometimes you get choices.
const char* d = g.Cmd.dirchars;
const char* d = gc.Cmd.dirchars;
enable=ch;
ch="";
ch.append(d[1]);
@@ -220,7 +220,7 @@ char NetHackQtYnDialog::Exec()
// for "ynaq" (where "all" is a choice) it's "stop"
// and for end of game disclosure it really is "quit"
if (question.left(10) == QString("Dump core?")
|| (::g.program_state.gameover
|| (::gp.program_state.gameover
&& question.left(11) == QString("Do you want")))
button_name = "Quit";
else if (is_ynaq)
+13 -13
View File
@@ -957,8 +957,8 @@ X11_putstr(winid window, int attr, const char *str)
switch (wp->type) {
case NHW_MESSAGE:
(void) strncpy(g.toplines, str, TBUFSZ); /* for Norep(). */
g.toplines[TBUFSZ - 1] = 0;
(void) strncpy(gt.toplines, str, TBUFSZ); /* for Norep(). */
gt.toplines[TBUFSZ - 1] = 0;
append_message(wp, str);
break;
#ifndef STATUS_HILITES
@@ -1272,7 +1272,7 @@ X11_update_inventory(int arg)
if (iflags.perm_invent) {
/* skip any calls to update_inventory() before in_moveloop starts */
if (g.program_state.in_moveloop || g.program_state.gameover) {
if (gp.program_state.in_moveloop || gp.program_state.gameover) {
updated_inventory = 1; /* hack to avoid mapping&raising window */
if (!arg) {
(void) display_inventory((char *) 0, FALSE);
@@ -1754,7 +1754,7 @@ X11_hangup(Widget w, XEvent *event, String *params, Cardinal *num_params)
static void
X11_bail(const char *mesg)
{
g.program_state.something_worth_saving = 0;
gp.program_state.something_worth_saving = 0;
clearlocks();
X11_exit_nhwindows(mesg);
nh_terminate(EXIT_SUCCESS);
@@ -1771,7 +1771,7 @@ askname_delete(Widget w, XEvent *event, String *params, Cardinal *num_params)
nhUse(num_params);
nh_XtPopdown(w);
(void) strcpy(g.plname, "Mumbles"); /* give them a name... ;-) */
(void) strcpy(gp.plname, "Mumbles"); /* give them a name... ;-) */
exit_x_event = TRUE;
}
@@ -1796,11 +1796,11 @@ askname_done(Widget w, XtPointer client_data, XtPointer call_data)
}
/* Truncate name if necessary */
if (len >= sizeof g.plname - 1)
len = sizeof g.plname - 1;
if (len >= sizeof gp.plname - 1)
len = sizeof gp.plname - 1;
(void) strncpy(g.plname, s, len);
g.plname[len] = '\0';
(void) strncpy(gp.plname, s, len);
gp.plname[len] = '\0';
XtFree(s);
nh_XtPopdown(XtParent(dialog));
@@ -1848,7 +1848,7 @@ X11_askname(void)
(XtCallbackProc) 0);
SetDialogPrompt(dialog, nhStr("What is your name?")); /* set prompt */
SetDialogResponse(dialog, g.plname, PL_NSIZ); /* set default answer */
SetDialogResponse(dialog, gp.plname, PL_NSIZ); /* set default answer */
XtRealizeWidget(popup);
positionpopup(popup, TRUE); /* center,bottom */
@@ -1997,7 +1997,7 @@ X11_getlin(
/* we get here after the popup has exited;
put prompt and response into the message window (and into
core's dumplog history) unless play hasn't started yet */
if (g.program_state.in_moveloop || g.program_state.gameover) {
if (gp.program_state.in_moveloop || gp.program_state.gameover) {
/* single space has meaning (to remove a previously applied name) so
show it clearly; don't care about legibility of multiple spaces */
const char *visanswer = !input[0] ? "<empty>"
@@ -2511,12 +2511,12 @@ highlight_yn(boolean init)
Arg args[2];
XGCValues vals;
unsigned long fg_bg = (GCForeground | GCBackground);
GC gc = (xmap->map_information->is_tile
GC ggc = (xmap->map_information->is_tile
? xmap->map_information->tile_map.white_gc
: xmap->map_information->text_map.copy_gc);
(void) memset((genericptr_t) &vals, 0, sizeof vals);
if (XGetGCValues(XtDisplay(xmap->w), gc, fg_bg, &vals)) {
if (XGetGCValues(XtDisplay(xmap->w), ggc, fg_bg, &vals)) {
XtSetArg(args[0], XtNforeground, vals.foreground);
XtSetArg(args[1], XtNbackground, vals.background);
XtSetValues(yn_label, args, TWO);
+22 -22
View File
@@ -64,7 +64,7 @@ static void X11_free_gc(struct xwindow *wp, GC gc, X11_color color);
static void X11_set_map_font(struct xwindow *wp);
#endif
static void X11_draw_image_string(Display *display, Drawable d,
GC gc, int x, int y,
GC ggc, int x, int y,
const X11_map_symbol *string, int length);
static Font X11_get_map_font(struct xwindow *wp);
static XFontStruct *X11_get_map_font_struct(struct xwindow *wp);
@@ -1024,7 +1024,7 @@ static void
map_all_unexplored(struct map_info_t *map_info) /* [was map_all_stone()] */
{
int x, y;
glyph_info gi;
glyph_info ginfo;
short unexp_idx, nothg_idx;
/* unsigned short g_stone = cmap_to_glyph(S_stone); */
unsigned short g_unexp = GLYPH_UNEXPLORED, g_nothg = GLYPH_NOTHING;
@@ -1035,10 +1035,10 @@ map_all_unexplored(struct map_info_t *map_info) /* [was map_all_stone()] */
mgunexp = glyph2ttychar(GLYPH_UNEXPLORED);
mgnothg = glyph2ttychar(GLYPH_NOTHING);
map_glyphinfo(0, 0, g_unexp, 0, &gi);
unexp_idx = gi.gm.tileidx;
map_glyphinfo(0, 0, g_nothg, 0, &gi);
nothg_idx = gi.gm.tileidx;
map_glyphinfo(0, 0, g_unexp, 0, &ginfo);
unexp_idx = ginfo.gm.tileidx;
map_glyphinfo(0, 0, g_nothg, 0, &ginfo);
nothg_idx = ginfo.gm.tileidx;
/*
* Tiles map tracks glyphs.
@@ -1453,7 +1453,7 @@ map_update(struct xwindow *wp, int start_row, int stop_row, int start_col, int s
X11_map_symbol *t_ptr;
int cur_col, win_ystart;
X11_color color;
GC gc;
GC ggc;
for (row = start_row; row <= stop_row; row++) {
win_ystart =
@@ -1470,15 +1470,15 @@ map_update(struct xwindow *wp, int start_row, int stop_row, int start_col, int s
c_ptr++;
}
gc = X11_make_gc(wp, text_map, color, inverted);
ggc = X11_make_gc(wp, text_map, color, inverted);
X11_draw_image_string(XtDisplay(wp->w), XtWindow(wp->w),
gc,
ggc,
text_map->square_lbearing
+ (text_map->square_width
* (cur_col - COL0_OFFSET)),
win_ystart, t_ptr, count);
#ifdef ENHANCED_SYMBOLS
X11_free_gc(wp, gc, color);
X11_free_gc(wp, ggc, color);
#endif
/* move text pointer and column count */
@@ -1524,7 +1524,7 @@ X11_make_gc(struct xwindow *wp UNUSED, struct text_map_info_t *text_map,
X11_color color, boolean inverted)
{
boolean cur_inv = inverted;
GC gc;
GC ggc;
#ifdef ENHANCED_SYMBOLS
if ((color & 0x80000000) != 0) {
@@ -1551,11 +1551,11 @@ X11_make_gc(struct xwindow *wp UNUSED, struct text_map_info_t *text_map,
}
values.function = GXcopy;
values.font = X11_get_map_font(wp);
gc = XtGetGC(wp->w,
ggc = XtGetGC(wp->w,
GCFunction | GCForeground | GCBackground | GCFont,
&values);
} else {
gc = (cur_inv ? text_map->inv_copy_gc : text_map->copy_gc);
ggc = (cur_inv ? text_map->inv_copy_gc : text_map->copy_gc);
}
} else
#endif
@@ -1564,7 +1564,7 @@ X11_make_gc(struct xwindow *wp UNUSED, struct text_map_info_t *text_map,
color -= CLR_MAX;
cur_inv = !cur_inv;
}
gc = iflags.use_color
ggc = iflags.use_color
? (cur_inv
? text_map->inv_color_gcs[color]
: text_map->color_gcs[color])
@@ -1572,16 +1572,16 @@ X11_make_gc(struct xwindow *wp UNUSED, struct text_map_info_t *text_map,
? text_map->inv_copy_gc
: text_map->copy_gc);
}
return gc;
return ggc;
}
#ifdef ENHANCED_SYMBOLS
static void
X11_free_gc(struct xwindow *wp, GC gc, X11_color color)
X11_free_gc(struct xwindow *wp, GC ggc, X11_color color)
{
if ((color & 0x80000000) != 0 && iflags.use_color) {
/* X11_make_gc allocated a new GC */
XtReleaseGC(wp->w, gc);
XtReleaseGC(wp->w, ggc);
}
}
#endif
@@ -1589,7 +1589,7 @@ X11_free_gc(struct xwindow *wp, GC gc, X11_color color)
static void
X11_draw_image_string(Display *display, Drawable d,
GC gc, int x, int y,
GC ggc, int x, int y,
const X11_map_symbol *string, int length)
{
#ifdef ENHANCED_SYMBOLS
@@ -1610,9 +1610,9 @@ X11_draw_image_string(Display *display, Drawable d,
wstr[i].byte1 = ch >> 8;
wstr[i].byte2 = ch & 0xFF;
}
XDrawImageString16(display, d, gc, x, y, wstr, length);
XDrawImageString16(display, d, ggc, x, y, wstr, length);
#else /* !ENHANCED_SYMBOLS */
XDrawImageString(display, d, gc, x, y, (char *) string, length);
XDrawImageString(display, d, ggc, x, y, (char *) string, length);
#endif /* ?ENHANCED_SYMBOLS */
}
@@ -1988,7 +1988,7 @@ x_event(int exit_condition)
inptr = (inptr + 1) % INBUF_SIZE;
/* pkey(retval); */
keep_going = FALSE;
} else if (g.program_state.done_hup) {
} else if (gp.program_state.done_hup) {
retval = '\033';
inptr = (inptr + 1) % INBUF_SIZE;
keep_going = FALSE;
@@ -2007,7 +2007,7 @@ x_event(int exit_condition)
/* pkey(retval); */
}
keep_going = FALSE;
} else if (g.program_state.done_hup) {
} else if (gp.program_state.done_hup) {
retval = '\033';
inptr = (inptr + 1) % INBUF_SIZE;
keep_going = FALSE;
+23 -23
View File
@@ -349,11 +349,11 @@ plsel_dialog_acceptvalues(void)
XtSetArg(args[0], nhStr(XtNstring), &s);
XtGetValues(plsel_name_input, args, ONE);
(void) strncpy(g.plname, (char *) s, sizeof g.plname - 1);
g.plname[sizeof g.plname - 1] = '\0';
(void) mungspaces(g.plname);
if (strlen(g.plname) < 1)
(void) strcpy(g.plname, "Mumbles");
(void) strncpy(gp.plname, (char *) s, sizeof gp.plname - 1);
gp.plname[sizeof gp.plname - 1] = '\0';
(void) mungspaces(gp.plname);
if (strlen(gp.plname) < 1)
(void) strcpy(gp.plname, "Mumbles");
iflags.renameinprogress = FALSE;
}
@@ -473,7 +473,7 @@ X11_player_selection_randomize(void)
{
int nrole = plsel_n_roles;
int nrace = plsel_n_races;
int ro, ra, al, ge;
int ro, ra, al, gend;
boolean choose_race_first;
boolean picksomething = (flags.initrole == ROLE_NONE
|| flags.initrace == ROLE_NONE
@@ -520,12 +520,12 @@ X11_player_selection_randomize(void)
}
}
ge = flags.initgend;
if (ge == ROLE_NONE) {
ge = rn2(ROLE_GENDERS);
gend = flags.initgend;
if (gend == ROLE_NONE) {
gend = rn2(ROLE_GENDERS);
}
while (!validgend(ro, ra, ge)) {
ge = rn2(ROLE_GENDERS);
while (!validgend(ro, ra, gend)) {
gend = rn2(ROLE_GENDERS);
}
al = flags.initalign;
@@ -536,7 +536,7 @@ X11_player_selection_randomize(void)
al = rn2(ROLE_ALIGNS);
}
XawToggleSetCurrent(plsel_gend_radios[0], i2xtp(ge + 1));
XawToggleSetCurrent(plsel_gend_radios[0], i2xtp(gend + 1));
XawToggleSetCurrent(plsel_align_radios[0], i2xtp(al + 1));
XawToggleSetCurrent(plsel_race_radios[0], i2xtp(ra + 1));
XawToggleSetCurrent(plsel_role_radios[0], i2xtp(ro + 1));
@@ -776,8 +776,8 @@ X11_create_player_selection_name(Widget form)
XtSetArg(args[num_args], nhStr(XtNeditType),
!plsel_ask_name ? XawtextRead : XawtextEdit); num_args++;
XtSetArg(args[num_args], nhStr(XtNresize), XawtextResizeWidth); num_args++;
XtSetArg(args[num_args], nhStr(XtNstring), g.plname); num_args++;
XtSetArg(args[num_args], XtNinsertPosition, strlen(g.plname)); num_args++;
XtSetArg(args[num_args], nhStr(XtNstring), gp.plname); num_args++;
XtSetArg(args[num_args], XtNinsertPosition, strlen(gp.plname)); num_args++;
XtSetArg(args[num_args], nhStr(XtNaccelerators),
XtParseAcceleratorTable(plsel_input_accelerators)); num_args++;
plsel_name_input = XtCreateManagedWidget("name_input",
@@ -1217,7 +1217,7 @@ X11_player_selection_dialog(void)
if (plsel_align_radios)
free(plsel_align_radios);
if (ps_selected == PS_QUIT || g.program_state.done_hup) {
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
clearlocks();
X11_exit_nhwindows((char *) 0);
nh_terminate(0);
@@ -1291,7 +1291,7 @@ X11_player_selection_prompts(void)
XtDestroyWidget(popup);
free((genericptr_t) choices), choices = 0;
if (ps_selected == PS_QUIT || g.program_state.done_hup) {
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
clearlocks();
X11_exit_nhwindows((char *) 0);
nh_terminate(0);
@@ -1360,7 +1360,7 @@ X11_player_selection_prompts(void)
XtDestroyWidget(popup);
free((genericptr_t) choices), choices = 0;
if (ps_selected == PS_QUIT || g.program_state.done_hup) {
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
clearlocks();
X11_exit_nhwindows((char *) 0);
nh_terminate(0);
@@ -1428,7 +1428,7 @@ X11_player_selection_prompts(void)
XtDestroyWidget(popup);
free((genericptr_t) choices), choices = 0;
if (ps_selected == PS_QUIT || g.program_state.done_hup) {
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
clearlocks();
X11_exit_nhwindows((char *) 0);
nh_terminate(0);
@@ -1494,7 +1494,7 @@ X11_player_selection_prompts(void)
XtDestroyWidget(popup);
free((genericptr_t) choices), choices = 0;
if (ps_selected == PS_QUIT || g.program_state.done_hup) {
if (ps_selected == PS_QUIT || gp.program_state.done_hup) {
clearlocks();
X11_exit_nhwindows((char *) 0);
nh_terminate(0);
@@ -1516,15 +1516,15 @@ void
X11_player_selection(void)
{
if (iflags.wc_player_selection == VIA_DIALOG) {
if (!*g.plname) {
if (!*gp.plname) {
#ifdef UNIX
char *defplname = get_login_name();
#else
char *defplname = (char *)0;
#endif
(void) strncpy(g.plname, defplname ? defplname : "Mumbles",
sizeof g.plname - 1);
g.plname[sizeof g.plname - 1] = '\0';
(void) strncpy(gp.plname, defplname ? defplname : "Mumbles",
sizeof gp.plname - 1);
gp.plname[sizeof gp.plname - 1] = '\0';
iflags.renameinprogress = TRUE;
}
X11_player_selection_dialog();
+5 -5
View File
@@ -1463,7 +1463,7 @@ update_val(struct X_status_value *attr_rec, long new_value)
if (attr_rec->type == SV_LABEL) {
if (attr_rec == &shown_stats[F_NAME]) {
Strcpy(buf, g.plname);
Strcpy(buf, gp.plname);
buf[0] = highc(buf[0]);
Strcat(buf, " the ");
if (Upolyd) {
@@ -1478,11 +1478,11 @@ update_val(struct X_status_value *attr_rec, long new_value)
Strcat(buf, mnam);
} else
Strcat(buf,
rank_of(u.ulevel, g.pl_character[0], flags.female));
rank_of(u.ulevel, gp.pl_character[0], flags.female));
} else if (attr_rec == &shown_stats[F_DLEVEL]) {
if (!describe_level(buf, 0)) {
Strcpy(buf, g.dungeons[u.uz.dnum].dname);
Strcpy(buf, gd.dungeons[u.uz.dnum].dname);
Sprintf(eos(buf), ", level %d", depth(&u.uz));
}
} else {
@@ -1869,7 +1869,7 @@ update_fancy_status_field(int i, int color, int attributes)
break; /* special */
case F_GOLD:
val = money_cnt(g.invent);
val = money_cnt(gi.invent);
if (val < 0L)
val = 0L; /* ought to issue impossible() and discard gold */
break;
@@ -1899,7 +1899,7 @@ update_fancy_status_field(int i, int color, int attributes)
val = (long) u.ualign.type;
break;
case F_TIME:
val = flags.time ? (long) g.moves : 0L;
val = flags.time ? (long) gm.moves : 0L;
break;
case F_SCORE:
#ifdef SCORE_ON_BOTL
+8 -8
View File
@@ -293,7 +293,7 @@ create_text_window(struct xwindow *wp)
XtParseTranslationTable(text_translations));
num_args++;
wp->w = XtCreateManagedWidget(g.killer.name[0] && WIN_MAP == WIN_ERR
wp->w = XtCreateManagedWidget(gk.killer.name[0] && WIN_MAP == WIN_ERR
? "tombstone"
: "text_text", /* name */
asciiTextWidgetClass,
@@ -464,10 +464,10 @@ calculate_rip_text(int how, time_t when)
long cash;
/* Put name on stone */
Sprintf(rip_line[NAME_LINE], "%.16s", g.plname); /* STONE_LINE_LEN */
Sprintf(rip_line[NAME_LINE], "%.16s", gp.plname); /* STONE_LINE_LEN */
/* Put $ on stone */
cash = max(g.done_money, 0L);
cash = max(gd.done_money, 0L);
/* arbitrary upper limit; practical upper limit is quite a bit less */
if (cash > 999999999L)
cash = 999999999L;
@@ -517,7 +517,7 @@ rip_exposed(Widget w, XtPointer client_data UNUSED,
Arg args[8];
XGCValues values;
XtGCMask mask;
GC gc;
GC ggc;
static Pixmap rip_pixmap = None;
int i, x, y;
@@ -540,10 +540,10 @@ rip_exposed(Widget w, XtPointer client_data UNUSED,
XtGetValues(w, args, 1);
values.function = GXcopy;
values.font = WindowFont(w);
gc = XtGetGC(w, mask, &values);
ggc = XtGetGC(w, mask, &values);
if (rip_pixmap != None) {
XCopyArea(dpy, rip_pixmap, XtWindow(w), gc, event->x, event->y,
XCopyArea(dpy, rip_pixmap, XtWindow(w), ggc, event->x, event->y,
event->width, event->height, event->x, event->y);
}
@@ -554,12 +554,12 @@ rip_exposed(Widget w, XtPointer client_data UNUSED,
XFontStruct *font = WindowFontStruct(w);
int width = XTextWidth(font, rip_line[i], len);
XDrawString(dpy, XtWindow(w), gc, x - width / 2, y, rip_line[i], len);
XDrawString(dpy, XtWindow(w), ggc, x - width / 2, y, rip_line[i], len);
x += appResources.tombtext_dx;
y += appResources.tombtext_dy;
}
XtReleaseGC(w, gc);
XtReleaseGC(w, ggc);
}
/*
+3 -3
View File
@@ -220,7 +220,7 @@ curses_character_input_dialog(
re-activate them now that input is being requested */
curses_got_input();
if (g.invent || (g.moves > 1)) {
if (gi.invent || (gm.moves > 1)) {
curses_get_window_size(MAP_WIN, &map_height, &map_width);
} else {
map_height = term_rows;
@@ -775,7 +775,7 @@ curses_display_nhmenu(
menu_determine_pages(current_menu);
/* Display pre and post-game menus centered */
if ((g.moves <= 1 && !g.invent) || g.program_state.gameover) {
if ((gm.moves <= 1 && !gi.invent) || gp.program_state.gameover) {
win = curses_create_window(current_menu->width,
current_menu->height, CENTER);
} else { /* Display during-game menus on the right out of the way */
@@ -1018,7 +1018,7 @@ menu_win_size(nhmenu *menu)
int maxheaderwidth = menu->prompt ? (int) strlen(menu->prompt) : 0;
nhmenu_item *menu_item_ptr;
if (g.program_state.gameover) {
if (gp.program_state.gameover) {
/* for final inventory disclosure, use full width */
maxwidth = term_cols - 2; /* +2: borders assumed */
} else {
+2 -2
View File
@@ -742,9 +742,9 @@ curses_init_options(void)
set_option_mod_status("eight_bit_tty", set_in_config);
/* If we don't have a symset defined, load the curses symset by default */
if (!g.symset[PRIMARYSET].explicitly)
if (!gs.symset[PRIMARYSET].explicitly)
load_symset("curses", PRIMARYSET);
if (!g.symset[ROGUESET].explicitly)
if (!gs.symset[ROGUESET].explicitly)
load_symset("default", ROGUESET);
#ifdef PDCURSES
+4 -4
View File
@@ -297,9 +297,9 @@ curses_askname(void)
}
#endif /* SELECTSAVED */
curses_line_input_dialog("Who are you?", g.plname, PL_NSIZ);
(void) mungspaces(g.plname);
if (!g.plname[0] || g.plname[0] == '\033')
curses_line_input_dialog("Who are you?", gp.plname, PL_NSIZ);
(void) mungspaces(gp.plname);
if (!gp.plname[0] || gp.plname[0] == '\033')
goto bail;
iflags.renameallowed = TRUE; /* tty uses this, we don't [yet?] */
@@ -701,7 +701,7 @@ curses_update_inventory(int arg)
}
/* skip inventory updating during character initialization */
if (!g.program_state.in_moveloop && !g.program_state.gameover)
if (!gp.program_state.in_moveloop && !gp.program_state.gameover)
return;
if (!arg) {
+10 -10
View File
@@ -77,7 +77,7 @@ curses_message_win_puts(const char *message, boolean recursed)
}
#endif
if (curs_mesg_suppress_seq == g.hero_seq) {
if (curs_mesg_suppress_seq == gh.hero_seq) {
return; /* user has typed ESC to avoid seeing remaining messages. */
}
@@ -89,19 +89,19 @@ curses_message_win_puts(const char *message, boolean recursed)
my = border_space;
if (strcmp(message, "#") == 0) { /* Extended command or Count: */
if ((strcmp(g.toplines, "#") != 0)
if ((strcmp(gt.toplines, "#") != 0)
/* Bottom of message window */
&& (my >= (height - 1 + border_space)) && (height != 1)) {
scroll_window(MESSAGE_WIN);
mx = width;
my--;
Strcpy(g.toplines, message);
Strcpy(gt.toplines, message);
}
return;
}
if (!recursed) {
strcpy(g.toplines, message);
strcpy(gt.toplines, message);
mesg_add_line(message);
}
@@ -118,7 +118,7 @@ curses_message_win_puts(const char *message, boolean recursed)
this turn unless an urgent message is being delivered */
if (curses_more() == '\033'
&& !curs_mesg_no_suppress) {
curs_mesg_suppress_seq = g.hero_seq;
curs_mesg_suppress_seq = gh.hero_seq;
return;
}
/* turn_lines reset to 0 by more()->block()->got_input() */
@@ -321,7 +321,7 @@ curses_last_messages(void)
if (mesg && mesg->str && *mesg->str)
curses_message_win_puts(mesg->str, TRUE);
}
curses_message_win_puts(g.toplines, TRUE);
curses_message_win_puts(gt.toplines, TRUE);
--last_messages;
if (border)
@@ -681,7 +681,7 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer)
case '\n':
(void) strncpy(answer, p_answer, buffer);
answer[buffer - 1] = '\0';
Strcpy(g.toplines, tmpbuf);
Strcpy(gt.toplines, tmpbuf);
mesg_add_line(tmpbuf);
#if 1
/* position at end of current line so next message will be
@@ -818,7 +818,7 @@ mesg_add_line(const char *mline)
current_mesg->str = dupstr(mline);
}
}
current_mesg->turn = g.hero_seq;
current_mesg->turn = gh.hero_seq;
if (num_messages == 0) {
/* very first message; set up head */
@@ -934,7 +934,7 @@ curses_putmsghistory(const char *msg, boolean restoring_msghist)
initd = TRUE;
#ifdef DUMPLOG
/* this suffices; there's no need to scrub g.saved_pline[] pointers */
g.saved_pline_index = 0;
gs.saved_pline_index = 0;
#endif
}
@@ -944,7 +944,7 @@ curses_putmsghistory(const char *msg, boolean restoring_msghist)
however, we aren't only called when restoring history;
core uses putmsghistory() for other stuff during play
and those messages should have a normal turn value */
last_mesg->turn = restoring_msghist ? (1L << 3) : g.hero_seq;
last_mesg->turn = restoring_msghist ? (1L << 3) : gh.hero_seq;
#ifdef DUMPLOG
dumplogmsg(last_mesg->str);
#endif
+1 -1
View File
@@ -925,7 +925,7 @@ curses_convert_keys(int key)
if (iflags.num_pad) {
ret = '7';
} else {
ret = !g.Cmd.swap_yz ? 'y' : 'z';
ret = !gc.Cmd.swap_yz ? 'y' : 'z';
}
break;
#ifdef KEY_A3
+12 -12
View File
@@ -147,7 +147,7 @@ curses_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent,
if (fldidx != BL_FLUSH) {
if (fldidx < 0 || fldidx >= MAXBLSTATS) {
g.context.botlx = g.context.botl = FALSE; /* avoid another bot() */
gc.context.botlx = gc.context.botl = FALSE; /* avoid another bot() */
panic("curses_status_update(%d)", fldidx);
}
changed_fields |= (1 << fldidx);
@@ -1848,7 +1848,7 @@ draw_horizontal(int x, int y, int hp, int hpmax)
wmove(win, y, x);
get_playerrank(rank);
sprintf(buf, "%s the %s", g.plname, rank);
sprintf(buf, "%s the %s", gp.plname, rank);
/* Use the title as HP bar (similar to hitpointbar) */
draw_bar(TRUE, hp, hpmax, buf);
@@ -1878,7 +1878,7 @@ draw_horizontal(int x, int y, int hp, int hpmax)
wprintw(win, "%s", buf);
print_statdiff("$", &prevau, money_cnt(g.invent), STAT_GOLD);
print_statdiff("$", &prevau, money_cnt(gi.invent), STAT_GOLD);
/* HP/Pw use special coloring rules */
attr_t hpattr, pwattr;
@@ -1916,7 +1916,7 @@ draw_horizontal(int x, int y, int hp, int hpmax)
print_statdiff(" Exp:", &prevlevel, u.ulevel, STAT_OTHER);
if (flags.time)
print_statdiff(" T:", &prevtime, g.moves, STAT_TIME);
print_statdiff(" T:", &prevtime, gm.moves, STAT_TIME);
curses_add_statuses(win, FALSE, FALSE, NULL, NULL);
}
@@ -1933,9 +1933,9 @@ draw_horizontal_new(int x, int y, int hp, int hpmax)
get_playerrank(rank);
char race[BUFSZ];
Strcpy(race, g.urace.adj);
Strcpy(race, gu.urace.adj);
race[0] = highc(race[0]);
wprintw(win, "%s the %s %s%s%s", g.plname,
wprintw(win, "%s the %s %s%s%s", gp.plname,
(u.ualign.type == A_CHAOTIC ? "Chaotic" :
u.ualign.type == A_NEUTRAL ? "Neutral" : "Lawful"),
Upolyd ? "" : race, Upolyd ? "" : " ",
@@ -1989,7 +1989,7 @@ draw_horizontal_new(int x, int y, int hp, int hpmax)
wprintw(win, "Pw:");
draw_bar(FALSE, u.uen, u.uenmax, NULL);
print_statdiff(" $", &prevau, money_cnt(g.invent), STAT_GOLD);
print_statdiff(" $", &prevau, money_cnt(gi.invent), STAT_GOLD);
#ifdef SCORE_ON_BOTL
if (flags.showscore)
@@ -1997,7 +1997,7 @@ draw_horizontal_new(int x, int y, int hp, int hpmax)
#endif /* SCORE_ON_BOTL */
if (flags.time)
print_statdiff(" T:", &prevtime, g.moves, STAT_TIME);
print_statdiff(" T:", &prevtime, gm.moves, STAT_TIME);
curses_add_statuses(win, TRUE, FALSE, &x, &y);
@@ -2054,7 +2054,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
get_playerrank(rank);
int ranklen = strlen(rank);
int namelen = strlen(g.plname);
int namelen = strlen(gp.plname);
int maxlen = 19;
#ifdef STATUS_COLORS
if (!iflags.hitpointbar)
@@ -2071,7 +2071,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
while ((ranklen + namelen) > maxlen)
ranklen--; /* Still doesn't fit, strip rank */
}
sprintf(buf, "%-*s the %-*s", namelen, g.plname, ranklen, rank);
sprintf(buf, "%-*s the %-*s", namelen, gp.plname, ranklen, rank);
draw_bar(TRUE, hp, hpmax, buf);
wmove(win, y++, x);
wprintw(win, "%s", dungeons[u.uz.dnum].dname);
@@ -2105,7 +2105,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
wprintw(win, "%d", depth(&u.uz));
wmove(win, y++, x);
print_statdiff("Gold: ", &prevau, money_cnt(g.invent), STAT_GOLD);
print_statdiff("Gold: ", &prevau, money_cnt(gi.invent), STAT_GOLD);
wmove(win, y++, x);
/* HP/Pw use special coloring rules */
@@ -2150,7 +2150,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
wmove(win, y++, x);
if (flags.time) {
print_statdiff("Time: ", &prevtime, g.moves, STAT_TIME);
print_statdiff("Time: ", &prevtime, gm.moves, STAT_TIME);
wmove(win, y++, x);
}
+5 -5
View File
@@ -62,7 +62,7 @@ curses_create_window(int width, int height, orient orientation)
if ((orientation == UP) || (orientation == DOWN) ||
(orientation == LEFT) || (orientation == RIGHT)) {
if (g.invent || (g.moves > 1)) {
if (gi.invent || (gm.moves > 1)) {
map_border = curses_window_has_border(MAP_WIN);
curses_get_window_xy(MAP_WIN, &mapx, &mapy);
curses_get_window_size(MAP_WIN, &maph, &mapw);
@@ -97,7 +97,7 @@ curses_create_window(int width, int height, orient orientation)
starty = (term_rows / 2) - (height / 2);
break;
case UP:
if (g.invent || (g.moves > 1)) {
if (gi.invent || (gm.moves > 1)) {
startx = (mapw / 2) - (width / 2) + mapx + mapb_offset;
} else {
startx = 0;
@@ -106,7 +106,7 @@ curses_create_window(int width, int height, orient orientation)
starty = mapy + mapb_offset;
break;
case DOWN:
if (g.invent || (g.moves > 1)) {
if (gi.invent || (gm.moves > 1)) {
startx = (mapw / 2) - (width / 2) + mapx + mapb_offset;
} else {
startx = 0;
@@ -122,7 +122,7 @@ curses_create_window(int width, int height, orient orientation)
starty = term_rows - height;
break;
case RIGHT:
if (g.invent || (g.moves > 1)) {
if (gi.invent || (gm.moves > 1)) {
startx = (mapw + mapx + (mapb_offset * 2)) - width;
} else {
startx = term_cols - width;
@@ -174,7 +174,7 @@ curses_refresh_nethack_windows(void)
map_window = curses_get_nhwin(MAP_WIN);
inv_window = curses_get_nhwin(INV_WIN);
if ((g.moves <= 1) && !g.invent) {
if ((gm.moves <= 1) && !gi.invent) {
/* Main windows not yet displayed; refresh base window instead */
touchwin(stdscr);
refresh();
+6 -6
View File
@@ -66,7 +66,7 @@ hooked_tty_getlin(const char *query, register char *bufp, getlin_hook_proc hook)
for (;;) {
(void) fflush(stdout);
Strcat(strcat(strcpy(g.toplines, query), " "), obufp);
Strcat(strcat(strcpy(gt.toplines, query), " "), obufp);
c = pgetchar();
if (c == '\033' || c == EOF) {
if (c == '\033' && obufp[0] != '\0') {
@@ -194,11 +194,11 @@ hooked_tty_getlin(const char *query, register char *bufp, getlin_hook_proc hook)
if (suppress_history) {
/* prevent next message from pushing current query+answer into
tty message history */
*g.toplines = '\0';
*gt.toplines = '\0';
#ifdef DUMPLOG
} else {
/* needed because we've bypassed pline() */
dumplogmsg(g.toplines);
dumplogmsg(gt.toplines);
#endif
}
}
@@ -211,7 +211,7 @@ xwaitforspace(register const char *s) /* chars allowed besides return */
morc = 0;
while (
#ifdef HANGUPHANDLING
!g.program_state.done_hup &&
!gp.program_state.done_hup &&
#endif
(c = tty_nhgetch()) != EOF) {
if (c == '\n' || c == '\r')
@@ -280,14 +280,14 @@ tty_get_ext_cmd(void)
suppress_history = TRUE;
/* maybe a runtime option?
* hooked_tty_getlin("#", buf,
* (flags.cmd_comp && !g.in_doagain)
* (flags.cmd_comp && !gi.in_doagain)
* ? ext_cmd_getlin_hook
* : (getlin_hook_proc) 0);
*/
extcmd_char[0] = extcmd_initiator(), extcmd_char[1] = '\0';
buf[0] = '\0';
hooked_tty_getlin(extcmd_char, buf,
!g.in_doagain ? ext_cmd_getlin_hook : no_hook);
!gi.in_doagain ? ext_cmd_getlin_hook : no_hook);
(void) mungspaces(buf);
nmatches = (buf[0] == '\0' || buf[0] == '\033') ? -1
+1 -1
View File
@@ -489,7 +489,7 @@ tty_start_screen(void)
utf8graphics_mode_callback = tty_utf8graphics_fixup;
#endif
if (g.Cmd.num_pad)
if (gc.Cmd.num_pad)
tty_number_pad(1); /* make keypad send digits */
}
+26 -26
View File
@@ -36,7 +36,7 @@ tty_doprev_message(void)
putstr(prevmsg_win, 0, cw->data[i]);
i = (i + 1) % cw->rows;
} while (i != cw->maxcol);
putstr(prevmsg_win, 0, g.toplines);
putstr(prevmsg_win, 0, gt.toplines);
display_nhwindow(prevmsg_win, TRUE);
destroy_nhwindow(prevmsg_win);
} else if (iflags.prevmsg_window == 'c') { /* combination */
@@ -44,7 +44,7 @@ tty_doprev_message(void)
morc = 0;
if (cw->maxcol == cw->maxrow) {
ttyDisplay->dismiss_more = C('p'); /* ^P ok at --More-- */
redotoplin(g.toplines);
redotoplin(gt.toplines);
cw->maxcol--;
if (cw->maxcol < 0)
cw->maxcol = cw->rows - 1;
@@ -69,7 +69,7 @@ tty_doprev_message(void)
putstr(prevmsg_win, 0, cw->data[i]);
i = (i + 1) % cw->rows;
} while (i != cw->maxcol);
putstr(prevmsg_win, 0, g.toplines);
putstr(prevmsg_win, 0, gt.toplines);
display_nhwindow(prevmsg_win, TRUE);
destroy_nhwindow(prevmsg_win);
}
@@ -81,7 +81,7 @@ tty_doprev_message(void)
prevmsg_win = create_nhwindow(NHW_MENU);
putstr(prevmsg_win, 0, "Message History");
putstr(prevmsg_win, 0, "");
putstr(prevmsg_win, 0, g.toplines);
putstr(prevmsg_win, 0, gt.toplines);
cw->maxcol = cw->maxrow - 1;
if (cw->maxcol < 0)
cw->maxcol = cw->rows - 1;
@@ -104,7 +104,7 @@ tty_doprev_message(void)
do {
morc = 0;
if (cw->maxcol == cw->maxrow)
redotoplin(g.toplines);
redotoplin(gt.toplines);
else if (cw->data[cw->maxcol])
redotoplin(cw->data[cw->maxcol]);
cw->maxcol--;
@@ -171,9 +171,9 @@ remember_topl(void)
{
register struct WinDesc *cw = wins[WIN_MESSAGE];
int idx = cw->maxrow;
unsigned len = strlen(g.toplines) + 1;
unsigned len = strlen(gt.toplines) + 1;
if ((cw->flags & WIN_LOCKHISTORY) || !*g.toplines)
if ((cw->flags & WIN_LOCKHISTORY) || !*gt.toplines)
return;
if (len > (unsigned) cw->datlen[idx]) {
@@ -183,9 +183,9 @@ remember_topl(void)
cw->data[idx] = (char *) alloc(len);
cw->datlen[idx] = (short) len;
}
Strcpy(cw->data[idx], g.toplines);
if (!g.program_state.in_checkpoint) {
*g.toplines = '\0';
Strcpy(cw->data[idx], gt.toplines);
if (!gp.program_state.in_checkpoint) {
*gt.toplines = '\0';
cw->maxcol = cw->maxrow = (idx + 1) % cw->rows;
}
}
@@ -261,10 +261,10 @@ update_topl(register const char *bp)
n0 = strlen(bp);
if ((ttyDisplay->toplin == TOPLINE_NEED_MORE || skip)
&& cw->cury == 0
&& n0 + (int) strlen(g.toplines) + 3 < CO - 8 /* room for --More-- */
&& n0 + (int) strlen(gt.toplines) + 3 < CO - 8 /* room for --More-- */
&& (notdied = strncmp(bp, "You die", 7)) != 0) {
Strcat(g.toplines, " ");
Strcat(g.toplines, bp);
Strcat(gt.toplines, " ");
Strcat(gt.toplines, bp);
cw->curx += 2;
if (!skip)
addtopl(bp);
@@ -278,10 +278,10 @@ update_topl(register const char *bp)
}
}
remember_topl();
(void) strncpy(g.toplines, bp, TBUFSZ);
g.toplines[TBUFSZ - 1] = 0;
(void) strncpy(gt.toplines, bp, TBUFSZ);
gt.toplines[TBUFSZ - 1] = 0;
for (tl = g.toplines; n0 >= CO; ) {
for (tl = gt.toplines; n0 >= CO; ) {
otl = tl;
for (tl += CO - 1; tl != otl; --tl)
if (*tl == ' ')
@@ -298,7 +298,7 @@ update_topl(register const char *bp)
if (!notdied) /* double negative => "You die"; avoid suppressing mesg */
cw->flags &= ~WIN_STOP, skip = FALSE;
if (!skip)
redotoplin(g.toplines);
redotoplin(gt.toplines);
}
static void
@@ -532,10 +532,10 @@ tty_yn_function(
Sprintf(rtmp, "#%ld", yn_number);
else
(void) key2txt(q, rtmp);
/* addtopl(rtmp); -- rewrite g.toplines instead */
Sprintf(g.toplines, "%s%s", prompt, rtmp);
/* addtopl(rtmp); -- rewrite gt.toplines instead */
Sprintf(gt.toplines, "%s%s", prompt, rtmp);
#ifdef DUMPLOG
dumplogmsg(g.toplines);
dumplogmsg(gt.toplines);
#endif
ttyDisplay->inread--;
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
@@ -565,7 +565,7 @@ msghistory_snapshot(
return;
cw = wins[WIN_MESSAGE];
/* flush g.toplines[], moving most recent message to history */
/* flush gt.toplines[], moving most recent message to history */
remember_topl();
/* for a passive snapshot, we just copy pointers, so can't allow further
@@ -686,7 +686,7 @@ tty_putmsghistory(const char *msg, boolean restoring_msghist)
initd = TRUE;
#ifdef DUMPLOG
/* this suffices; there's no need to scrub saved_pline[] pointers */
g.saved_pline_index = 0;
gs.saved_pline_index = 0;
#endif
}
@@ -700,9 +700,9 @@ tty_putmsghistory(const char *msg, boolean restoring_msghist)
/* move most recent message to history, make this become most recent */
remember_topl();
Strcpy(g.toplines, msg);
Strcpy(gt.toplines, msg);
#ifdef DUMPLOG
dumplogmsg(g.toplines);
dumplogmsg(gt.toplines);
#endif
} else if (snapshot_mesgs) {
nhassert(ttyDisplay == NULL ||
@@ -711,9 +711,9 @@ tty_putmsghistory(const char *msg, boolean restoring_msghist)
/* done putting arbitrary messages in; put the snapshot ones back */
for (idx = 0; snapshot_mesgs[idx]; ++idx) {
remember_topl();
Strcpy(g.toplines, snapshot_mesgs[idx]);
Strcpy(gt.toplines, snapshot_mesgs[idx]);
#ifdef DUMPLOG
dumplogmsg(g.toplines);
dumplogmsg(gt.toplines);
#endif
}
/* now release the snapshot */
+27 -27
View File
@@ -80,7 +80,7 @@ extern void msmsg(const char *, ...);
*/
#define HUPSKIP() \
do { \
if (g.program_state.done_hup) { \
if (gp.program_state.done_hup) { \
morc = '\033'; \
return; \
} \
@@ -88,7 +88,7 @@ extern void msmsg(const char *, ...);
/* morc=ESC - in case we bypass xwaitforspace() which sets that */
#define HUPSKIP_RESULT(RES) \
do { \
if (g.program_state.done_hup) \
if (gp.program_state.done_hup) \
return (RES); \
} while (0)
#else /* !HANGUPHANDLING */
@@ -411,7 +411,7 @@ winch_handler(int sig_unused UNUSED)
ttyDisplay->toplin = i;
flush_screen(1);
if (i) {
addtopl(g.toplines);
addtopl(gt.toplines);
} else
for (i = WIN_INVEN; i < MAXWIN; i++)
if (wins[i] && wins[i]->active) {
@@ -1046,7 +1046,7 @@ tty_player_selection(void)
Sprintf(plbuf, " %s", genders[GEND].adj);
else
*plbuf = '\0'; /* omit redundant gender */
Snprintf(pbuf, sizeof(pbuf), "%s, %s%s %s %s", g.plname,
Snprintf(pbuf, sizeof(pbuf), "%s, %s%s %s %s", gp.plname,
aligns[ALGN].adj, plbuf, races[RACE].adj,
(GEND == 1 && roles[ROLE].name.f) ? roles[ROLE].name.f
: roles[ROLE].name.m);
@@ -1097,8 +1097,8 @@ tty_player_selection(void)
GEND, ALGN; we'll override that and honor only the name */
saveROLE = ROLE, saveRACE = RACE, saveGEND = GEND,
saveALGN = ALGN;
*g.plname = '\0';
plnamesuffix(); /* calls askname() when g.plname[] is empty */
*gp.plname = '\0';
plnamesuffix(); /* calls askname() when gp.plname[] is empty */
ROLE = saveROLE, RACE = saveRACE, GEND = saveGEND,
ALGN = saveALGN;
break; /* getconfirmation is still True */
@@ -1344,7 +1344,7 @@ setup_algnmenu(winid win, boolean filtering, int role, int race, int gend)
}
/*
* g.plname is filled either by an option (-u Player or -uPlayer) or
* gp.plname is filled either by an option (-u Player or -uPlayer) or
* explicitly (by being the wizard) or by askname.
* It may still contain a suffix denoting the role, etc.
* Always called after init_nhwindows() and before display_gamewindows().
@@ -1364,7 +1364,7 @@ tty_askname(void)
case 0:
break; /* no game chosen; start new game */
case 1:
return; /* g.plname[] has been set */
return; /* gp.plname[] has been set */
}
#endif /* SELECTSAVED */
@@ -1427,7 +1427,7 @@ tty_askname(void)
&& !(c >= '0' && c <= '9' && ct > 0))
c = '_';
#endif
if (ct < (int) (sizeof g.plname) - 1) {
if (ct < (int) (sizeof gp.plname) - 1) {
#if defined(MICRO)
#if defined(MSDOS)
if (iflags.grmode) {
@@ -1438,13 +1438,13 @@ tty_askname(void)
#else
(void) putchar(c);
#endif
g.plname[ct++] = c;
gp.plname[ct++] = c;
#ifdef WIN32CON
ttyDisplay->curx++;
#endif
}
}
g.plname[ct] = 0;
gp.plname[ct] = 0;
} while (ct == 0);
/* move to next line to simulate echo of user's <return> */
@@ -1757,11 +1757,11 @@ tty_clear_nhwindow(winid window)
cw->data[i][n - 1] = '\0';
/*finalx[i][NOW] = finalx[i][BEFORE] = 0;*/
}
g.context.botlx = 1;
gc.context.botlx = 1;
break;
case NHW_MAP:
/* cheap -- clear the whole thing and tell nethack to redraw botl */
g.context.botlx = 1;
gc.context.botlx = 1;
/*FALLTHRU*/
case NHW_BASE:
clear_screen();
@@ -2182,7 +2182,7 @@ process_menu_window(winid window, struct WinDesc *cw)
Strcat(resp, " "); /* next page or end */
Strcat(resp, "0123456789\033\n\r"); /* counts, quit */
Strcat(resp, gacc); /* group accelerators */
Strcat(resp, g.mapped_menu_cmds);
Strcat(resp, gm.mapped_menu_cmds);
if (cw->npages > 1)
Sprintf(cw->morestr, "(%d of %d)", curr_page + 1,
@@ -2919,7 +2919,7 @@ tty_putstr(winid window, int attr, const char *str)
#ifndef STATUS_HILITES
case NHW_STATUS:
ob = &cw->data[cw->cury][j = cw->curx];
if (g.context.botlx)
if (gc.context.botlx)
*ob = '\0';
if (!cw->cury && (int) strlen(str) >= CO) {
/* the characters before "St:" are unnecessary */
@@ -2930,7 +2930,7 @@ tty_putstr(winid window, int attr, const char *str)
nb = str;
for (i = cw->curx + 1, n0 = cw->cols; i < n0; i++, nb++) {
if (!*nb) {
if (*ob || g.context.botlx) {
if (*ob || gc.context.botlx) {
/* last char printed may be in middle of line */
tty_curs(WIN_STATUS, i, cw->cury);
cl_end();
@@ -3060,9 +3060,9 @@ tty_display_file(const char *fname, boolean complain)
if (complain)
raw_printf("Cannot open %s as stdin.", fname);
} else {
(void) execlp(g.catmore, "page", (char *) 0);
(void) execlp(gc.catmore, "page", (char *) 0);
if (complain)
raw_printf("Cannot exec %s.", g.catmore);
raw_printf("Cannot exec %s.", gc.catmore);
}
if (complain)
sleep(10); /* want to wait_synch() but stdin is gone */
@@ -3144,7 +3144,7 @@ tty_start_menu(winid window, unsigned long mbehavior)
}
if (mbehavior == MENU_BEHAVE_PERMINV
&& (iflags.perm_invent
|| g.perm_invent_toggling_direction == toggling_on)) {
|| gp.perm_invent_toggling_direction == toggling_on)) {
winid w = ttyinv_create_window(window, wins[window]);
if (w == WIN_ERR) {
/* something went wrong, so add clean up code here */
@@ -3274,9 +3274,9 @@ tty_end_menu(winid window, /* menu to use */
}
#ifdef TTY_PERM_INVENT
if (cw->mbehavior == MENU_BEHAVE_PERMINV
&& (iflags.perm_invent || g.perm_invent_toggling_direction == toggling_on)
&& (iflags.perm_invent || gp.perm_invent_toggling_direction == toggling_on)
&& window == WIN_INVEN) {
if (g.program_state.in_moveloop)
if (gp.program_state.in_moveloop)
ttyinv_render(window, cw);
return;
}
@@ -3610,7 +3610,7 @@ ttyinv_add_menu(winid window UNUSED, struct WinDesc *cw, char ch,
ignore = FALSE;
int row, side, slot = 0, rows_per_side = (!show_gold ? 26 : 27);
if (!g.program_state.in_moveloop)
if (!gp.program_state.in_moveloop)
return;
slot = selector_to_slot(ch, ttyinvmode, &ignore);
if (!ignore) {
@@ -3689,7 +3689,7 @@ ttyinv_render(winid window, struct WinDesc *cw)
int row, col, slot, side, filled_count = 0, slot_limit;
struct tty_perminvent_cell *cell;
char invbuf[BUFSZ], *text;
boolean force_redraw = g.program_state.in_docrt ? TRUE : FALSE,
boolean force_redraw = gp.program_state.in_docrt ? TRUE : FALSE,
show_gold = (ttyinvmode & InvShowGold) != 0,
inuse_only = (ttyinvmode & InvInUse) != 0;
int rows_per_side = (!show_gold ? 26 : 27);
@@ -3720,9 +3720,9 @@ ttyinv_render(winid window, struct WinDesc *cw)
ttyinv_populate_slot(cw, row, side, text, 0);
}
/* has there been a glyph reset since we last got here? */
if (g.glyph_reset_timestamp > last_glyph_reset_when) {
if (gg.glyph_reset_timestamp > last_glyph_reset_when) {
// tty_invent_box_glyph_init(wins[WIN_INVEN]);
last_glyph_reset_when = g.glyph_reset_timestamp;
last_glyph_reset_when = gg.glyph_reset_timestamp;
force_redraw = TRUE;
}
/* render to the display */
@@ -3984,7 +3984,7 @@ tty_wait_synch(void)
if (ttyDisplay->inmore) {
addtopl("--More--");
(void) fflush(stdout);
} else if (ttyDisplay->inread > g.program_state.gameover) {
} else if (ttyDisplay->inread > gp.program_state.gameover) {
/* this can only happen if we were reading and got interrupted */
ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT;
/* do this twice; 1st time gets the Quit? message again */
@@ -4062,7 +4062,7 @@ docorner(register int xmin, register int ymax, int ystart_between_menu_pages)
if (ymax >= (int) wins[WIN_STATUS]->offy
&& !ystart_between_menu_pages) {
/* we have wrecked the bottom line */
g.context.botlx = 1;
gc.context.botlx = 1;
bot();
}
}
+1 -1
View File
@@ -646,7 +646,7 @@ plselInitDialog(struct plsel_data * data)
/* set player name */
control_t * name_box = &data->controls[psc_name_box];
SetDlgItemText(data->dialog, name_box->id, NH_A2W(g.plname, wbuf, sizeof(wbuf)));
SetDlgItemText(data->dialog, name_box->id, NH_A2W(gp.plname, wbuf, sizeof(wbuf)));
plselRandomize(data);
+3 -3
View File
@@ -39,7 +39,7 @@ mswin_have_input(void)
return
#ifdef SAFERHANGUP
/* we always have input (ESC) if hangup was requested */
g.program_state.done_hup ||
gp.program_state.done_hup ||
#endif
(nhi_read_pos != nhi_write_pos);
}
@@ -69,7 +69,7 @@ mswin_input_pop(void)
#ifdef SAFERHANGUP
/* always return ESC when hangup was requested */
if (g.program_state.done_hup) {
if (gp.program_state.done_hup) {
static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR;
hangup_event.ei.kbd.ch = '\033';
@@ -98,7 +98,7 @@ mswin_input_peek(void)
#ifdef SAFERHANGUP
/* always return ESC when hangup was requested */
if (g.program_state.done_hup) {
if (gp.program_state.done_hup) {
static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR;
hangup_event.ei.kbd.ch = '\033';
+5 -5
View File
@@ -457,16 +457,16 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CLOSE: {
/* exit gracefully */
if (g.program_state.gameover) {
if (gp.program_state.gameover) {
/* assume the user really meant this, as the game is already
* over... */
/* to make sure we still save bones, just set stop printing flag
*/
g.program_state.stopprint++;
gp.program_state.stopprint++;
NHEVENT_KBD(
'\033'); /* and send keyboard input as if user pressed ESC */
/* additional code for this is done in menu and rip windows */
} else if (!g.program_state.something_worth_saving) {
} else if (!gp.program_state.something_worth_saving) {
/* User exited before the game started, e.g. during splash display
*/
/* Just get out. */
@@ -842,7 +842,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
case IDM_SAVE:
if (iflags.debug_fuzzer)
break;
if (!g.program_state.gameover && !g.program_state.done_hup)
if (!gp.program_state.gameover && !gp.program_state.done_hup)
dosave();
else
MessageBeep(0);
@@ -975,7 +975,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
ofn.nMaxFile = SIZE(filename);
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NH_A2W(g.hackdir, whackdir, MAX_PATH);
ofn.lpstrInitialDir = NH_A2W(gh.hackdir, whackdir, MAX_PATH);
ofn.lpstrTitle = NULL;
ofn.Flags = OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
ofn.nFileOffset = 0;
+2 -2
View File
@@ -349,10 +349,10 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
case WM_CLOSE:
if (g.program_state.gameover) {
if (gp.program_state.gameover) {
data->result = -1;
data->done = 1;
g.program_state.stopprint++;
gp.program_state.stopprint++;
return TRUE;
} else
return FALSE;
+1 -1
View File
@@ -227,7 +227,7 @@ NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
GetNHApp()->hMainWnd = NULL;
DestroyWindow(hWnd);
SetFocus(GetNHApp()->hMainWnd);
g.program_state.stopprint++;
gp.program_state.stopprint++;
return TRUE;
case WM_DESTROY:
+5 -5
View File
@@ -695,7 +695,7 @@ mswin_askname(void)
{
logDebug("mswin_askname()\n");
if (mswin_getlin_window("Who are you?", g.plname, PL_NSIZ) == IDCANCEL) {
if (mswin_getlin_window("Who are you?", gp.plname, PL_NSIZ) == IDCANCEL) {
bail("bye-bye");
/* not reached */
}
@@ -1243,7 +1243,7 @@ void
mswin_update_inventory(int arg)
{
logDebug("mswin_update_inventory(%d)\n", arg);
if (iflags.perm_invent && g.program_state.something_worth_saving
if (iflags.perm_invent && gp.program_state.something_worth_saving
&& iflags.window_inited && WIN_INVEN != WIN_ERR)
display_inventory(NULL, FALSE);
}
@@ -1937,12 +1937,12 @@ mswin_outrip(winid wid, int how, time_t when)
}
/* Put name on stone */
Sprintf(buf, "%s", g.plname);
Sprintf(buf, "%s", gp.plname);
buf[STONE_LINE_LEN] = 0;
putstr(wid, 0, buf);
/* Put $ on stone */
Sprintf(buf, "%ld Au", g.done_money);
Sprintf(buf, "%ld Au", gd.done_money);
buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
putstr(wid, 0, buf);
@@ -2829,7 +2829,7 @@ int
NHMessageBox(HWND hWnd, LPCTSTR text, UINT type)
{
TCHAR title[MAX_LOADSTRING];
if (g.program_state.exiting && !strcmp(text, "\n"))
if (gp.program_state.exiting && !strcmp(text, "\n"))
text = "Press Enter to exit";
LoadString(GetNHApp()->hApp, IDS_APP_TITLE_SHORT, title, MAX_LOADSTRING);