fix brace mismatch in winami.c

Reported directly to devteam, so no #H number.  Conditional code in
amii_get_ext_cmd() included an unmatched '{', which would break
compilation (at least if EXTMENU was enabled) and also resulted in
the remainder of winami.c being mis-formatted (the functions there
were treated as being inside a block rather than at file level).

This is completely untested.

There's some code suppressed via '#if 0' with a comment "fix for PL2".
We haven't used the patch-level nomenclature since version 3.0!
This commit is contained in:
PatR
2017-08-05 17:58:20 -07:00
parent 0d7101cd29
commit 1614f8f5ee
+72 -76
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 winami.c $NHDT-Date: 1432512794 2015/05/25 00:13:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.19 $ */ /* NetHack 3.6 winami.c $NHDT-Date: 1501981093 2017/08/06 00:58:13 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.20 $ */
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993,1996. /* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993,1996.
*/ */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -807,8 +807,8 @@ amii_get_ext_cmd(void)
} }
return (-1); return (-1);
} else { }
#else #endif
amii_clear_nhwindow(WIN_MESSAGE); /* Was NHW_MESSAGE */ amii_clear_nhwindow(WIN_MESSAGE); /* Was NHW_MESSAGE */
if (scrollmsg) { if (scrollmsg) {
@@ -932,13 +932,14 @@ amii_get_ext_cmd(void)
DisplayBeep(NULL); DisplayBeep(NULL);
} }
return (-1); return (-1);
#endif }
}
static int put_ext_cmd(obufp, colx, cw, bottom) char * obufp; static int
int colx, bottom; put_ext_cmd(obufp, colx, cw, bottom)
struct amii_WinDesc *cw; char * obufp;
{ int colx, bottom;
struct amii_WinDesc *cw;
{
struct Window *w = cw->win; struct Window *w = cw->win;
char *t; char *t;
@@ -953,8 +954,8 @@ amii_get_ext_cmd(void)
SetAPen(w->RPort, C_WHITE); SetAPen(w->RPort, C_WHITE);
Text(w->RPort, "># ", 3); Text(w->RPort, "># ", 3);
/* SetAPen( w->RPort, C_BLACK ); */ /* Black text on black /* SetAPen( w->RPort, C_BLACK ); */ /* Black text on black
screen doesn't look too * screen doesn't look
well ... -jhsa */ * too well ... -jhsa */
Text(w->RPort, t + 3, strlen(t) - 3); Text(w->RPort, t + 3, strlen(t) - 3);
} else { } else {
sprintf(t, "# %s", obufp); sprintf(t, "# %s", obufp);
@@ -977,13 +978,15 @@ amii_get_ext_cmd(void)
} }
amii_curs(WIN_MESSAGE, colx = strlen(obufp) + 3 + (scrollmsg != 0), amii_curs(WIN_MESSAGE, colx = strlen(obufp) + 3 + (scrollmsg != 0),
bottom); bottom);
return (colx); return colx;
} }
/* Ask a question and get a response */ /* Ask a question and get a response */
char
char amii_yn_function(query, resp, def) const char * query, *resp; amii_yn_function(query, resp, def)
char def; const char * query, *resp;
char def;
{
/* /*
* Generic yes/no function. 'def' is the default (returned by space or * Generic yes/no function. 'def' is the default (returned by space or
* return; 'esc' returns 'q', or 'n', or the default, depending on * return; 'esc' returns 'q', or 'n', or the default, depending on
@@ -995,7 +998,6 @@ amii_get_ext_cmd(void)
* are allowed); if it includes an <esc>, anything beyond that won't * are allowed); if it includes an <esc>, anything beyond that won't
* be shown in the prompt to the user but will be acceptable as input. * be shown in the prompt to the user but will be acceptable as input.
*/ */
{
register char q; register char q;
char rtmp[40]; char rtmp[40];
boolean digit_ok, allow_num; boolean digit_ok, allow_num;
@@ -1025,7 +1027,7 @@ amii_get_ext_cmd(void)
q = WindowGetchar(); q = WindowGetchar();
cursor_off(WIN_MESSAGE); cursor_off(WIN_MESSAGE);
*rtmp = q; *rtmp = q;
rtmp[1] = 0; rtmp[1] = '\0';
amii_addtopl(rtmp); amii_addtopl(rtmp);
goto clean_up; goto clean_up;
} }
@@ -1037,19 +1039,20 @@ amii_get_ext_cmd(void)
#if 0 #if 0
/* fix for PL2 */ /* fix for PL2 */
if (q == '\020') { /* ctrl-P */ if (q == '\020') { /* ctrl-P */
if(!doprev) (void) tty_doprev_message(); /* need two initially */ if(!doprev)
(void) tty_doprev_message(); /* need two initially */
(void) tty_doprev_message(); (void) tty_doprev_message();
q = (char)0; q = (char)0;
doprev = 1; doprev = 1;
continue; continue;
} else if(doprev) { } else if (doprev) {
tty_clear_nhwindow(WIN_MESSAGE); tty_clear_nhwindow(WIN_MESSAGE);
cw->maxcol = cw->maxrow; cw->maxcol = cw->maxrow;
doprev = 0; doprev = 0;
amii_addtopl(prompt); amii_addtopl(prompt);
continue; continue;
} }
#endif #endif /*0*/
digit_ok = allow_num && isdigit(q); digit_ok = allow_num && isdigit(q);
if (q == '\033') { if (q == '\033') {
if (index(resp, 'q')) if (index(resp, 'q'))
@@ -1070,6 +1073,7 @@ amii_get_ext_cmd(void)
char z, digit_string[2]; char z, digit_string[2];
int n_len = 0; int n_len = 0;
long value = 0; long value = 0;
amii_addtopl("#"), n_len++; amii_addtopl("#"), n_len++;
digit_string[1] = '\0'; digit_string[1] = '\0';
if (q != '#') { if (q != '#') {
@@ -1125,11 +1129,13 @@ amii_get_ext_cmd(void)
cursor_off(WIN_MESSAGE); cursor_off(WIN_MESSAGE);
clear_nhwindow(WIN_MESSAGE); clear_nhwindow(WIN_MESSAGE);
return q; return q;
} }
void amii_display_file(fn, complain) const char * fn; void
boolean complain; amii_display_file(fn, complain)
{ const char * fn;
boolean complain;
{
register struct amii_WinDesc *cw; register struct amii_WinDesc *cw;
register int win; register int win;
register dlb *fp; register dlb *fp;
@@ -1170,21 +1176,21 @@ amii_get_ext_cmd(void)
dlb_fclose(fp); dlb_fclose(fp);
/* If there were lines in the file, display those lines */ /* If there were lines in the file, display those lines */
if (amii_wins[win]->cury > 0) if (amii_wins[win]->cury > 0)
amii_display_nhwindow(win, TRUE); amii_display_nhwindow(win, TRUE);
amii_wins[win]->morestr = NULL; /* don't free title string */ amii_wins[win]->morestr = NULL; /* don't free title string */
amii_destroy_nhwindow(win); amii_destroy_nhwindow(win);
} }
/* Put a 3-D motif border around the gadget. String gadgets or those /* Put a 3-D motif border around the gadget. String gadgets or those
* which do not have highlighting are rendered down. Boolean gadgets * which do not have highlighting are rendered down. Boolean gadgets
* are rendered in the up position by default. * are rendered in the up position by default.
*/ */
void
void SetBorder(gd) register struct Gadget * gd; SetBorder(gd)
{ register struct Gadget * gd;
{
register struct Border *bp; register struct Border *bp;
register short *sp; register short *sp;
register int i, inc = -1, dec = -1; register int i, inc = -1, dec = -1;
@@ -1197,7 +1203,7 @@ amii_get_ext_cmd(void)
#ifdef INTUI_NEW_LOOK #ifdef INTUI_NEW_LOOK
if (IntuitionBase->LibNode.lib_Version >= 37) { if (IntuitionBase->LibNode.lib_Version >= 37) {
if (dip = GetScreenDrawInfo(HackScreen)) { if ((dip = GetScreenDrawInfo(HackScreen)) != 0) {
hipen = dip->dri_Pens[SHINEPEN]; hipen = dip->dri_Pens[SHINEPEN];
shadowpen = dip->dri_Pens[SHADOWPEN]; shadowpen = dip->dri_Pens[SHADOWPEN];
FreeScreenDrawInfo(HackScreen, dip); FreeScreenDrawInfo(HackScreen, dip);
@@ -1207,12 +1213,10 @@ amii_get_ext_cmd(void)
/* Allocate two border structures one for up image and one for down /* Allocate two border structures one for up image and one for down
* image, plus vector arrays for the border lines. * image, plus vector arrays for the border lines.
*/ */
if (gd->GadgetType == STRGADGET) if (gd->GadgetType == STRGADGET)
borders = 12; borders = 12;
if ((bp = (struct Border *) alloc(((sizeof (struct Border) * 2)
if ((bp = (struct Border *) alloc(((sizeof(struct Border) * 2) + (sizeof (short) * borders)) * 2))
+ (sizeof(short) * borders)) * 2))
== NULL) { == NULL) {
return; return;
} }
@@ -1221,9 +1225,7 @@ amii_get_ext_cmd(void)
* the text will be entered. * the text will be entered.
*/ */
/* Remove any special rendering flags to avoid confusing intuition /* Remove any special rendering flags to avoid confusing intuition */
*/
gd->Flags &= ~(GADGHIGHBITS | GADGIMAGE); gd->Flags &= ~(GADGHIGHBITS | GADGIMAGE);
sp = (short *) (bp + 4); sp = (short *) (bp + 4);
@@ -1280,7 +1282,6 @@ amii_get_ext_cmd(void)
/* Create the border vector values for up and left side, and /* Create the border vector values for up and left side, and
* also the lower and right side. * also the lower and right side.
*/ */
sp[0] = dec; sp[0] = dec;
sp[1] = gd->Height + inc; sp[1] = gd->Height + inc;
sp[2] = dec; sp[2] = dec;
@@ -1299,12 +1300,10 @@ amii_get_ext_cmd(void)
* rectangle share the border vectors with the opposite image, * rectangle share the border vectors with the opposite image,
* but specify different colors. * but specify different colors.
*/ */
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
bp[i].TopEdge = bp[i].LeftEdge = 0; bp[i].TopEdge = bp[i].LeftEdge = 0;
/* A GADGHNONE is always down */ /* A GADGHNONE is always down */
if (gd->GadgetType == BOOLGADGET if (gd->GadgetType == BOOLGADGET
&& (gd->Flags & GADGHIGHBITS) != GADGHNONE) { && (gd->Flags & GADGHIGHBITS) != GADGHNONE) {
bp[i].FrontPen = (i == 1 || i == 2) ? shadowpen : hipen; bp[i].FrontPen = (i == 1 || i == 2) ? shadowpen : hipen;
@@ -1327,13 +1326,13 @@ amii_get_ext_cmd(void)
gd->SelectRender = (APTR)(bp + 2); gd->SelectRender = (APTR)(bp + 2);
gd->Flags |= GADGHIMAGE; gd->Flags |= GADGHIMAGE;
} }
} }
/* Following function copied from wintty.c */ /* Following function copied from wintty.c;
/* Modified slightly to fit amiga needs */ Modified slightly to fit amiga needs */
void
void amii_player_selection() amii_player_selection()
{ {
int i, k, n; int i, k, n;
char pick4u = 'n', thisch, lastch = 0; char pick4u = 'n', thisch, lastch = 0;
char pbuf[QBUFSZ], plbuf[QBUFSZ], rolenamebuf[QBUFSZ]; char pbuf[QBUFSZ], plbuf[QBUFSZ], rolenamebuf[QBUFSZ];
@@ -1346,9 +1345,11 @@ amii_get_ext_cmd(void)
/* Should we randomly pick for the player? */ /* Should we randomly pick for the player? */
if (flags.initrole == ROLE_NONE || flags.initrace == ROLE_NONE if (flags.initrole == ROLE_NONE || flags.initrace == ROLE_NONE
|| flags.initgend == ROLE_NONE || flags.initalign == ROLE_NONE) { || flags.initgend == ROLE_NONE || flags.initalign == ROLE_NONE) {
char *prompt = build_plselection_prompt( char *prompt;
pbuf, QBUFSZ, flags.initrole, flags.initrace, flags.initgend,
flags.initalign); prompt = build_plselection_prompt(pbuf, QBUFSZ,
flags.initrole, flags.initrace,
flags.initgend, flags.initalign);
pline("%s", prompt); pline("%s", prompt);
do { /* loop until we get valid input */ do { /* loop until we get valid input */
cursor_on(WIN_MESSAGE); cursor_on(WIN_MESSAGE);
@@ -1373,9 +1374,9 @@ amii_get_ext_cmd(void)
} }
} }
(void) root_plselection_prompt(plbuf, QBUFSZ - 1, flags.initrole, (void) root_plselection_prompt(plbuf, QBUFSZ - 1,
flags.initrace, flags.initgend, flags.initrole, flags.initrace,
flags.initalign); flags.initgend, flags.initalign);
/* Select a role, if necessary */ /* Select a role, if necessary */
/* we'll try to be compatible with pre-selected race/gender/alignment, /* we'll try to be compatible with pre-selected race/gender/alignment,
@@ -1443,9 +1444,9 @@ amii_get_ext_cmd(void)
flags.initrole = selected[0].item.a_int - 1; flags.initrole = selected[0].item.a_int - 1;
free((genericptr_t) selected), selected = 0; free((genericptr_t) selected), selected = 0;
} }
(void) root_plselection_prompt(plbuf, QBUFSZ - 1, flags.initrole, (void) root_plselection_prompt(plbuf, QBUFSZ - 1,
flags.initrace, flags.initgend, flags.initrole, flags.initrace,
flags.initalign); flags.initgend, flags.initalign);
} }
/* Select a race, if necessary */ /* Select a race, if necessary */
@@ -1516,9 +1517,9 @@ amii_get_ext_cmd(void)
} }
flags.initrace = k; flags.initrace = k;
} }
(void) root_plselection_prompt(plbuf, QBUFSZ - 1, flags.initrole, (void) root_plselection_prompt(plbuf, QBUFSZ - 1,
flags.initrace, flags.initgend, flags.initrole, flags.initrace,
flags.initalign); flags.initgend, flags.initalign);
} }
/* Select a gender, if necessary */ /* Select a gender, if necessary */
@@ -1564,15 +1565,13 @@ amii_get_ext_cmd(void)
if (ok_gend(flags.initrole, flags.initrace, i, if (ok_gend(flags.initrole, flags.initrace, i,
flags.initalign)) { flags.initalign)) {
any.a_int = i + 1; any.a_int = i + 1;
add_menu(win, NO_GLYPH, &any, genders[i].adj[0], add_menu(win, NO_GLYPH, &any, genders[i].adj[0], 0,
0, ATR_NONE, genders[i].adj, ATR_NONE, genders[i].adj, MENU_UNSELECTED);
MENU_UNSELECTED);
} }
any.a_int = pick_gend(flags.initrole, flags.initrace, any.a_int = pick_gend(flags.initrole, flags.initrace,
flags.initalign, PICK_RANDOM) + 1; flags.initalign, PICK_RANDOM) + 1;
if (any.a_int == 0) /* must be non-zero */ if (any.a_int == 0) /* must be non-zero */
any.a_int = any.a_int = randgend(flags.initrole, flags.initrace) + 1;
randgend(flags.initrole, flags.initrace) + 1;
add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE, "Random", add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE, "Random",
MENU_UNSELECTED); MENU_UNSELECTED);
any.a_int = i + 1; /* must be non-zero */ any.a_int = i + 1; /* must be non-zero */
@@ -1590,9 +1589,9 @@ amii_get_ext_cmd(void)
} }
flags.initgend = k; flags.initgend = k;
} }
(void) root_plselection_prompt(plbuf, QBUFSZ - 1, flags.initrole, (void) root_plselection_prompt(plbuf, QBUFSZ - 1,
flags.initrace, flags.initgend, flags.initrole, flags.initrace,
flags.initalign); flags.initgend, flags.initalign);
} }
/* Select an alignment, if necessary */ /* Select an alignment, if necessary */
@@ -1606,8 +1605,7 @@ amii_get_ext_cmd(void)
flags.initgend, PICK_RANDOM); flags.initgend, PICK_RANDOM);
if (flags.initalign < 0) { if (flags.initalign < 0) {
amii_putstr(WIN_MESSAGE, 0, "Incompatible alignment!"); amii_putstr(WIN_MESSAGE, 0, "Incompatible alignment!");
flags.initalign = flags.initalign = randalign(flags.initrole, flags.initrace);
randalign(flags.initrole, flags.initrace);
} }
} else { /* pick4u == 'n' */ } else { /* pick4u == 'n' */
/* Count the number of valid alignments */ /* Count the number of valid alignments */
@@ -1639,14 +1637,12 @@ amii_get_ext_cmd(void)
flags.initgend, i)) { flags.initgend, i)) {
any.a_int = i + 1; any.a_int = i + 1;
add_menu(win, NO_GLYPH, &any, aligns[i].adj[0], 0, add_menu(win, NO_GLYPH, &any, aligns[i].adj[0], 0,
ATR_NONE, aligns[i].adj, ATR_NONE, aligns[i].adj, MENU_UNSELECTED);
MENU_UNSELECTED);
} }
any.a_int = pick_align(flags.initrole, flags.initrace, any.a_int = pick_align(flags.initrole, flags.initrace,
flags.initgend, PICK_RANDOM) + 1; flags.initgend, PICK_RANDOM) + 1;
if (any.a_int == 0) /* must be non-zero */ if (any.a_int == 0) /* must be non-zero */
any.a_int = any.a_int = randalign(flags.initrole, flags.initrace) + 1;
randalign(flags.initrole, flags.initrace) + 1;
add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE, "Random", add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE, "Random",
MENU_UNSELECTED); MENU_UNSELECTED);
any.a_int = i + 1; /* must be non-zero */ any.a_int = i + 1; /* must be non-zero */
@@ -1666,5 +1662,5 @@ amii_get_ext_cmd(void)
} }
} }
/* Success! */ /* Success! */
} }
#endif /* AMIGA_INTUITION */ #endif /* AMIGA_INTUITION */