more MSYS2 warning clean-up

This commit is contained in:
nhmall
2024-12-12 22:35:38 -05:00
parent 8bb764e624
commit c7276bcf67
15 changed files with 227 additions and 156 deletions
+2 -2
View File
@@ -341,12 +341,12 @@ ifeq "$(GCC_EXTRA_WARNINGS)" "Y"
# #
CFLAGSXTRA = -Wall -Wextra -Wreturn-type -Wunused -Wswitch -Wshadow \ CFLAGSXTRA = -Wall -Wextra -Wreturn-type -Wunused -Wswitch -Wshadow \
-Wwrite-strings -pedantic -Wmissing-declarations \ -Wwrite-strings -pedantic -Wmissing-declarations \
-Wformat-nonliteral -Wunreachable-code -Wimplicit \ -Wunreachable-code -Wimplicit \
-Wimplicit-function-declaration -Wimplicit-int \ -Wimplicit-function-declaration -Wimplicit-int \
-Wmissing-prototypes -Wold-style-definition \ -Wmissing-prototypes -Wold-style-definition \
-Wstrict-prototypes -Wnonnull -Wformat-overflow \ -Wstrict-prototypes -Wnonnull -Wformat-overflow \
-Wmissing-parameter-type -Wimplicit-fallthrough \ -Wmissing-parameter-type -Wimplicit-fallthrough \
-Wno-cast-function-type -Wno-cast-function-type -Wno-format
CPPFLAGSXTRA = -Wall -Wextra -Wno-missing-field-initializers -Wreturn-type \ CPPFLAGSXTRA = -Wall -Wextra -Wno-missing-field-initializers -Wreturn-type \
-Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -pedantic \ -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -pedantic \
+130 -87
View File
@@ -97,11 +97,27 @@ cell_t clear_cell = { CONSOLE_CLEAR_CHARACTER, CONSOLE_CLEAR_ATTRIBUTE };
cell_t undefined_cell = { CONSOLE_UNDEFINED_CHARACTER, cell_t undefined_cell = { CONSOLE_UNDEFINED_CHARACTER,
CONSOLE_UNDEFINED_ATTRIBUTE }; CONSOLE_UNDEFINED_ATTRIBUTE };
#else /* VIRTUAL_TERMINAL_SEQUENCES */ #else /* VIRTUAL_TERMINAL_SEQUENCES */
cell_t clear_cell = { { CONSOLE_CLEAR_CHARACTER, 0, 0, 0, 0, 0, 0 }, cell_t clear_cell = {
CONSOLE_CLEAR_CHARACTER, 0, 0L, 0, "\x1b[0m", 0 }; { CONSOLE_CLEAR_CHARACTER, 0, 0, 0, 0, 0, 0 },
cell_t undefined_cell = { { CONSOLE_UNDEFINED_CHARACTER, 0, 0, 0, 0, 0, 0 }, CONSOLE_CLEAR_CHARACTER, /* wcharacter */
CONSOLE_UNDEFINED_CHARACTER, 0, 0L, 0, (const char *) 0 }; 0, /* attr */
0L, /* color24 */
0, /* color256idx */
"\x1b[0m", /* bkcolorseq */
0 /* colorseq */
};
cell_t undefined_cell = {
{ CONSOLE_UNDEFINED_CHARACTER, 0, 0, 0, 0, 0, 0 },
CONSOLE_UNDEFINED_CHARACTER, /* wcharacter */
0, /* attr */
0L, /* color24 */
0, /* color256idx */
(const char *) 0, /* bkcolorseq */
(const char *) 0 /* colorseq */
};
#if 0
static const uint8 empty_utf8str[MAX_UTF8_SEQUENCE] = { 0 }; static const uint8 empty_utf8str[MAX_UTF8_SEQUENCE] = { 0 };
#endif
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
/* /*
@@ -135,7 +151,9 @@ int process_keystroke(INPUT_RECORD *, boolean *, boolean numberpad,
static void init_ttycolor(void); static void init_ttycolor(void);
static void really_move_cursor(void); static void really_move_cursor(void);
static void check_and_set_font(void); static void check_and_set_font(void);
#ifndef VIRTUAL_TERMINAL_SEQUENCES
static boolean check_font_widths(void); static boolean check_font_widths(void);
#endif
static void set_known_good_console_font(void); static void set_known_good_console_font(void);
static void restore_original_console_font(void); static void restore_original_console_font(void);
extern void safe_routines(void); extern void safe_routines(void);
@@ -150,7 +168,7 @@ static void free_custom_colors(void);
/* Win32 Screen buffer,coordinate,console I/O information */ /* Win32 Screen buffer,coordinate,console I/O information */
COORD ntcoord; COORD ntcoord;
INPUT_RECORD ir; INPUT_RECORD gbl_ir;
static boolean orig_QuickEdit; static boolean orig_QuickEdit;
/* Support for changing console font if existing glyph widths are too wide */ /* Support for changing console font if existing glyph widths are too wide */
@@ -213,11 +231,11 @@ struct console_t {
0, /* current_nhcolor */ 0, /* current_nhcolor */
0, /* current_nhbkcolor */ 0, /* current_nhbkcolor */
0, /* current_colorflags */ 0, /* current_colorflags */
{FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}, { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE },
{0, 0}, /* cursor */ { 0, 0 }, /* cursor */
NULL, /* hConOut*/ NULL, /* hConOut*/
NULL, /* hConIn */ NULL, /* hConIn */
{ 0 }, /* cbsi */ { { 0, 0}, { 0, 0}, 0, { 0, 0, 0, 0 }, { 0, 0 } }, /* cbsi */
0, /* width */ 0, /* width */
0, /* height */ 0, /* height */
FALSE, /* has_unicode */ FALSE, /* has_unicode */
@@ -242,7 +260,9 @@ struct console_t {
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
}; };
#if 0
static const char default_name[] = "default"; static const char default_name[] = "default";
#endif
const char *const legal_key_handling[] = { const char *const legal_key_handling[] = {
"none", "none",
"default", "default",
@@ -282,7 +302,10 @@ struct keyboard_handling_t {
default_checkinput default_checkinput
}; };
static DWORD ccount, acount; static DWORD ccount;
#if 0
static DWORD acount;
#endif
#ifndef CLR_MAX #ifndef CLR_MAX
#define CLR_MAX 16 #define CLR_MAX 16
#endif #endif
@@ -292,7 +315,9 @@ int ttycolors_inv[CLR_MAX];
#define MAX_OVERRIDES 256 #define MAX_OVERRIDES 256
unsigned char key_overrides[MAX_OVERRIDES]; unsigned char key_overrides[MAX_OVERRIDES];
#if 0
static char nullstr[] = ""; static char nullstr[] = "";
#endif
char erase_char, kill_char; char erase_char, kill_char;
#define DEFTEXTCOLOR ttycolors[7] #define DEFTEXTCOLOR ttycolors[7]
static INPUT_RECORD bogus_key; static INPUT_RECORD bogus_key;
@@ -470,7 +495,17 @@ struct rgbvalues {
{ 138, "white", "#FFFFFF", 255, 255, 255 }, { 138, "white", "#FFFFFF", 255, 255, 255 },
}; };
long void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y);
void buffer_write(cell_t * buffer, cell_t * cell, COORD pos);
static long rgbtable_to_long(struct rgbvalues *);
void term_start_256color(int idx);
void set_cp_map(void);
#ifdef PORT_DEBUG
void win32con_debug_keystrokes(void);
void win32con_toggle_cursor_info(void);
#endif
static long
rgbtable_to_long(struct rgbvalues *tbl) rgbtable_to_long(struct rgbvalues *tbl)
{ {
long rgblong = (tbl->r << 0) | (tbl->gn << 8) | (tbl->b << 16); long rgblong = (tbl->r << 0) | (tbl->gn << 8) | (tbl->b << 16);
@@ -595,7 +630,7 @@ void emit_start_256color(int u256coloridx);
void emit_default_color(void); void emit_default_color(void);
void emit_return_to_default(void); void emit_return_to_default(void);
void emit_hide_cursor(void); void emit_hide_cursor(void);
void emit_show_curor(void); void emit_show_cursor(void);
void void
emit_hide_cursor(void) emit_hide_cursor(void)
@@ -730,7 +765,7 @@ emit_stop_inverse(void)
#define tcfmtstr24bit "\x1b[38:2:%ld:%ld:%ldm" #define tcfmtstr24bit "\x1b[38:2:%ld:%ld:%ldm"
#define tcfmtstr256 "\x1b[38:5:%dm" #define tcfmtstr256 "\x1b[38:5:%dm"
#endif #endif
void void
emit_start_256color(int u256coloridx) emit_start_256color(int u256coloridx)
{ {
@@ -773,12 +808,14 @@ emit_return_to_default(void)
WriteConsoleA(console.hConOut, (LPCSTR) escseq, (int) strlen(escseq), WriteConsoleA(console.hConOut, (LPCSTR) escseq, (int) strlen(escseq),
&unused, NULL); &unused, NULL);
} }
#if 0
static boolean newattr_on = TRUE; static boolean newattr_on = TRUE;
#endif
static boolean color24_on = TRUE; static boolean color24_on = TRUE;
/* for debugging */ /* for debugging */
WORD what_is_there_now; WORD what_is_there_now;
BOOL success; //BOOL success;
DWORD error_result; DWORD error_result;
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
@@ -880,7 +917,7 @@ back_buffer_flip(void)
(int) strlen(back->bkcolorseq), &unused, (int) strlen(back->bkcolorseq), &unused,
NULL); NULL);
} }
if ((did_anything | (did_colorseq | did_bkcolorseq | did_color24)) == 0) { if ((did_anything & (did_colorseq | did_bkcolorseq | did_color24)) == 0) {
did_anything &= ~(did_bkcolorseq | did_color24); did_anything &= ~(did_bkcolorseq | did_color24);
did_anything |= did_colorseq; did_anything |= did_colorseq;
emit_default_color(); emit_default_color();
@@ -1050,7 +1087,7 @@ tty_startup(int *wid, int *hgt)
} }
void void
tty_number_pad(int state) tty_number_pad(int state UNUSED)
{ {
// do nothing // do nothing
} }
@@ -1088,6 +1125,7 @@ CtrlHandler(DWORD ctrltype)
case CTRL_BREAK_EVENT: case CTRL_BREAK_EVENT:
term_clear_screen(); term_clear_screen();
FALLTHROUGH; FALLTHROUGH;
/* FALLTHRU */
case CTRL_CLOSE_EVENT: case CTRL_CLOSE_EVENT:
case CTRL_LOGOFF_EVENT: case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT: case CTRL_SHUTDOWN_EVENT:
@@ -1106,7 +1144,7 @@ CtrlHandler(DWORD ctrltype)
/* called by pcmain() and process_options() */ /* called by pcmain() and process_options() */
void void
consoletty_open(int mode) consoletty_open(int mode UNUSED)
{ {
int debugvar; int debugvar;
@@ -1124,6 +1162,7 @@ consoletty_open(int mode)
CO = console.width; CO = console.width;
really_move_cursor(); really_move_cursor();
nhUse(debugvar);
} }
void void
@@ -1165,7 +1204,7 @@ process_keystroke(
int int
consoletty_kbhit(void) consoletty_kbhit(void)
{ {
return keyboard_handling.pNHkbhit(console.hConIn, &ir); return keyboard_handling.pNHkbhit(console.hConIn, &gbl_ir);
} }
int int
@@ -1174,20 +1213,20 @@ tgetch(void)
int mod; int mod;
coord cc; coord cc;
DWORD count; DWORD count;
boolean numpad = iflags.num_pad; uchar numberpad = iflags.num_pad;
really_move_cursor(); really_move_cursor();
if (iflags.debug_fuzzer) if (iflags.debug_fuzzer)
return randomkey(); return randomkey();
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
if (gc.Cmd.swap_yz) if (gc.Cmd.swap_yz)
numpad |= 0x10; numberpad |= 0x10;
#endif #endif
return (program_state.done_hup) return (program_state.done_hup)
? '\033' ? '\033'
: keyboard_handling.pCheckInput( : keyboard_handling.pCheckInput(
console.hConIn, &ir, &count, numpad, 0, &mod, &cc); console.hConIn, &gbl_ir, &count, numberpad, 0, &mod, &cc);
} }
int int
@@ -1196,7 +1235,7 @@ console_poskey(coordxy *x, coordxy *y, int *mod)
int ch; int ch;
coord cc = { 0, 0 }; coord cc = { 0, 0 };
DWORD count; DWORD count;
boolean numpad = iflags.num_pad; boolean numberpad = iflags.num_pad;
really_move_cursor(); really_move_cursor();
if (iflags.debug_fuzzer) { if (iflags.debug_fuzzer) {
@@ -1210,14 +1249,14 @@ console_poskey(coordxy *x, coordxy *y, int *mod)
} }
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
if (gc.Cmd.swap_yz) if (gc.Cmd.swap_yz)
numpad |= 0x10; numberpad |= 0x10;
#endif #endif
ch = (program_state.done_hup) ch = (program_state.done_hup)
? '\033' ? '\033'
: keyboard_handling.pCheckInput( : keyboard_handling.pCheckInput(
console.hConIn, &ir, &count, numpad, 1, mod, &cc); console.hConIn, &gbl_ir, &count, numberpad, 1, mod, &cc);
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
numpad &= ~0x10; numberpad &= ~0x10;
#endif #endif
if (!ch) { if (!ch) {
*x = cc.x; *x = cc.x;
@@ -1245,9 +1284,11 @@ really_move_cursor(void)
if (GetConsoleTitle(oldtitle, BUFSZ)) { if (GetConsoleTitle(oldtitle, BUFSZ)) {
oldtitle[39] = '\0'; oldtitle[39] = '\0';
} }
Sprintf(newtitle, "%-55s tty=(%02d,%02d) consoletty=(%02d,%02d)", oldtitle, Snprintf(newtitle, sizeof newtitle,
ttyDisplay->curx, ttyDisplay->cury, "%-55s tty=(%02d,%02d) consoletty=(%02d,%02d)",
console.cursor.X, console.cursor.Y); oldtitle,
ttyDisplay->curx, ttyDisplay->cury,
console.cursor.X, console.cursor.Y);
(void) SetConsoleTitle(newtitle); (void) SetConsoleTitle(newtitle);
} }
#endif #endif
@@ -1315,7 +1356,7 @@ xputc(int ch)
#ifndef VIRTUAL_TERMINAL_SEQUENCES #ifndef VIRTUAL_TERMINAL_SEQUENCES
void void
xputc_core(char ch) xputc_core(char ch)
#else #else
void void
xputc_core(int ch) xputc_core(int ch)
@@ -1423,27 +1464,25 @@ xputc_core(int ch)
void void
g_putch(int in_ch) g_putch(int in_ch)
{ {
unsigned char ch;
cell_t cell;
#ifndef VIRTUAL_TERMINAL_SEQUENCES #ifndef VIRTUAL_TERMINAL_SEQUENCES
boolean inverse = FALSE; boolean inverse = FALSE;
#else /* VIRTUAL_TERMINAL_SEQUENCES */ #else /* VIRTUAL_TERMINAL_SEQUENCES */
int ccount = 0; ccount = 0;
WCHAR wch[2]; WCHAR wch[2];
boolean usemap = (in_ch >= 0 && in_ch < SIZE(console.cpMap));
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
unsigned char ch = (unsigned char) in_ch; ch = (unsigned char) in_ch;
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury); set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
#ifndef VIRTUAL_TERMINAL_SEQUENCES #ifndef VIRTUAL_TERMINAL_SEQUENCES
inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse); inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse);
console.attr = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse) ? console.attr = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse) ?
ttycolors_inv[console.current_nhcolor] : ttycolors_inv[console.current_nhcolor] :
ttycolors[console.current_nhcolor]; ttycolors[console.current_nhcolor];
if (console.current_nhattr[ATR_BOLD]) if (console.current_nhattr[ATR_BOLD])
console.attr |= (inverse) ? BACKGROUND_INTENSITY : FOREGROUND_INTENSITY; console.attr |= (inverse) ? BACKGROUND_INTENSITY : FOREGROUND_INTENSITY;
#endif /* ! VIRTUAL_TERMINAL_SEQUENCES */
cell_t cell;
#ifndef VIRTUAL_TERMINAL_SEQUENCES
cell.attribute = console.attr; cell.attribute = console.attr;
cell.character = (console.has_unicode ? cp437[ch] : ch); cell.character = (console.has_unicode ? cp437[ch] : ch);
#else #else
@@ -1454,7 +1493,7 @@ g_putch(int in_ch)
cell.color256idx = 0; cell.color256idx = 0;
wch[1] = 0; wch[1] = 0;
if (console.has_unicode) { if (console.has_unicode) {
wch[0] = (ch >= 0 && ch < SIZE(console.cpMap)) ? console.cpMap[ch] : ch; wch[0] = (usemap) ? console.cpMap[ch] : ch;
#ifdef UTF8_FROM_CORE #ifdef UTF8_FROM_CORE
if (SYMHANDLING(H_UTF8)) { if (SYMHANDLING(H_UTF8)) {
/* we have to convert it to UTF-8 for cell.utf8str */ /* we have to convert it to UTF-8 for cell.utf8str */
@@ -1476,7 +1515,7 @@ g_putch(int in_ch)
cell.utf8str[1] = 0; cell.utf8str[1] = 0;
ccount = 2; ccount = 2;
} }
#endif #endif /* VIRTUAL_TERMINAL_SEQUENCES */
buffer_write(console.back_buffer, &cell, console.cursor); buffer_write(console.back_buffer, &cell, console.cursor);
} }
@@ -1522,10 +1561,10 @@ term_start_extracolor(uint32 nhcolor, uint16 color256idx)
term_start_color(console.current_nhcolor); term_start_color(console.current_nhcolor);
#ifdef VIRTUAL_TERMINAL_SEQUENCES #ifdef VIRTUAL_TERMINAL_SEQUENCES
} }
#endif #endif
} }
void term_start_256color(int idx) void term_start_256color(int idx UNUSED)
{ {
} }
@@ -1542,7 +1581,7 @@ term_end_extracolor(void)
void void
cl_end(void) cl_end(void)
{ {
if (ttyDisplay->curx < console.width if (ttyDisplay->curx < console.width
&& ttyDisplay->cury < console.height) { && ttyDisplay->cury < console.height) {
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury); set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
buffer_clear_to_end_of_line(console.back_buffer, console.cursor.X, buffer_clear_to_end_of_line(console.back_buffer, console.cursor.X,
@@ -1652,6 +1691,7 @@ tty_delay_output(void)
while (goal > clock()) { while (goal > clock()) {
k = junk; /* Do nothing */ k = junk; /* Do nothing */
} }
nhUse(k);
} }
/* /*
@@ -2044,9 +2084,9 @@ win32con_debug_keystrokes(void)
xputs("\n"); xputs("\n");
while (!valid || ch != 27) { while (!valid || ch != 27) {
nocmov(ttyDisplay->curx, ttyDisplay->cury); nocmov(ttyDisplay->curx, ttyDisplay->cury);
ReadConsoleInput(console.hConIn, &ir, 1, &count); ReadConsoleInput(console.hConIn, &gbl_ir, 1, &count);
if ((ir.EventType == KEY_EVENT) && ir.Event.KeyEvent.bKeyDown) if ((gbl_ir.EventType == KEY_EVENT) && gbl_ir.Event.KeyEvent.bKeyDown)
ch = process_keystroke(&ir, &valid, iflags.num_pad, 1); ch = process_keystroke(&gbl_ir, &valid, iflags.num_pad, 1);
} }
(void) doredraw(); (void) doredraw();
} }
@@ -2090,7 +2130,7 @@ map_subkeyvalue(char *op)
key_overrides[idx] = val; key_overrides[idx] = val;
} }
#if 0
/* fatal error */ /* fatal error */
/*VARARGS1*/ /*VARARGS1*/
void consoletty_error void consoletty_error
@@ -2109,6 +2149,7 @@ VA_DECL(const char *, s)
VA_END(); VA_END();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif
void void
synch_cursor(void) synch_cursor(void)
@@ -2116,13 +2157,16 @@ synch_cursor(void)
really_move_cursor(); really_move_cursor();
} }
#ifndef VIRTUAL_TERMINAL_SEQUENCES
static int CALLBACK EnumFontCallback( static int CALLBACK EnumFontCallback(
const LOGFONTW * lf, const TEXTMETRICW * tm, DWORD fontType, LPARAM lParam) const LOGFONTW * lf, const TEXTMETRICW * tm UNUSED,
DWORD fontType UNUSED, LPARAM lParam)
{ {
LOGFONTW * lf_ptr = (LOGFONTW *) lParam; LOGFONTW * lf_ptr = (LOGFONTW *) lParam;
*lf_ptr = *lf; *lf_ptr = *lf;
return 0; return 0;
} }
#endif
/* check_and_set_font ensures that the current font will render the symbols /* check_and_set_font ensures that the current font will render the symbols
* that are currently being used correctly. If they will not be rendered * that are currently being used correctly. If they will not be rendered
@@ -2147,15 +2191,12 @@ check_and_set_font(void)
#endif #endif
} }
#ifndef VIRTUAL_TERMINAL_SEQUENCES
/* check_font_widths returns TRUE if all glyphs in current console font /* check_font_widths returns TRUE if all glyphs in current console font
* fit within the width of a single console cell. * fit within the width of a single console cell.
*/ */
boolean boolean
#ifndef VIRTUAL_TERMINAL_SEQUENCES
check_font_widths(void) check_font_widths(void)
#else /* VIRTUAL_TERMINAL_SEQUENCES */
check_font_widths(void)
#endif /* VIRTUAL_TERMINAL_SEQUENCES */
{ {
CONSOLE_FONT_INFOEX console_font_info; CONSOLE_FONT_INFOEX console_font_info;
console_font_info.cbSize = sizeof(console_font_info); console_font_info.cbSize = sizeof(console_font_info);
@@ -2223,7 +2264,7 @@ check_font_widths(void)
int wcUsedCount = 0; int wcUsedCount = 0;
wchar_t wcUsed[256]; wchar_t wcUsed[256];
for (int i = 0; i < sizeof(used); i++) for (int i = 0; i < (int) sizeof(used); i++)
if (used[i]) if (used[i])
wcUsed[wcUsedCount++] = cp437[i]; wcUsed[wcUsedCount++] = cp437[i];
@@ -2252,6 +2293,7 @@ clean_up:
return all_glyphs_fit; return all_glyphs_fit;
} }
#endif
/* set_known_good_console_font sets the code page and font used by the console /* set_known_good_console_font sets the code page and font used by the console
* to settings know to work well with NetHack. It also saves the original * to settings know to work well with NetHack. It also saves the original
@@ -2465,7 +2507,7 @@ void nethack_enter_consoletty(void)
{ {
#ifdef VIRTUAL_TERMINAL_SEQUENCES #ifdef VIRTUAL_TERMINAL_SEQUENCES
char buf[BUFSZ], *bp, *localestr; char buf[BUFSZ], *bp, *localestr;
BOOL success; BOOL apisuccess;
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
#if 0 #if 0
/* set up state needed by early_raw_print() */ /* set up state needed by early_raw_print() */
@@ -2559,7 +2601,7 @@ void nethack_enter_consoletty(void)
/* store the original font */ /* store the original font */
console.orig_font_info.cbSize = sizeof(console.orig_font_info); console.orig_font_info.cbSize = sizeof(console.orig_font_info);
success = GetCurrentConsoleFontEx(console.hConOut, apisuccess = GetCurrentConsoleFontEx(console.hConOut,
FALSE, &console.orig_font_info); FALSE, &console.orig_font_info);
console.font_info = console.orig_font_info; console.font_info = console.orig_font_info;
@@ -2576,9 +2618,9 @@ void nethack_enter_consoletty(void)
console.code_page = console.orig_code_page; console.code_page = console.orig_code_page;
if (console.has_unicode) { if (console.has_unicode) {
if (console.code_page != 437) if (console.code_page != 437)
success = SetConsoleOutputCP(437); apisuccess = SetConsoleOutputCP(437);
} else if (console.code_page != 1252) { } else if (console.code_page != 1252) {
success = SetConsoleOutputCP(1252); apisuccess = SetConsoleOutputCP(1252);
} }
console.code_page = GetConsoleOutputCP(); console.code_page = GetConsoleOutputCP();
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
@@ -2660,6 +2702,7 @@ void nethack_enter_consoletty(void)
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
console.current_nhcolor = NO_COLOR; console.current_nhcolor = NO_COLOR;
console.is_ready = TRUE; console.is_ready = TRUE;
nhUse(apisuccess);
} }
#endif /* TTY_GRAPHICS */ #endif /* TTY_GRAPHICS */
@@ -2718,7 +2761,7 @@ VA_DECL(const char *, fmt)
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
/* when 'numberpad' is 0 and Cmd.swap_yz is True /* when 'numberpad' is 0 and Cmd.swap_yz is True
(signaled by setting 0x10 on boolean numpad argument) (signaled by setting 0x10 on uchar numberpad argument)
treat keypress of numpad 7 as 'z' rather than 'y' */ treat keypress of numpad 7 as 'z' rather than 'y' */
static boolean qwertz = FALSE; static boolean qwertz = FALSE;
#endif #endif
@@ -2939,7 +2982,7 @@ set_keyhandling_via_option(void)
int int
default_processkeystroke( default_processkeystroke(
HANDLE hConIn, HANDLE hConIn UNUSED,
INPUT_RECORD *ir, INPUT_RECORD *ir,
boolean *valid, boolean *valid,
boolean numberpad, boolean numberpad,
@@ -3104,12 +3147,12 @@ default_kbhit(HANDLE hConIn, INPUT_RECORD *ir)
return retval; return retval;
} }
int int
default_checkinput( default_checkinput(
HANDLE hConIn, HANDLE hConIn,
INPUT_RECORD *ir, INPUT_RECORD *ir,
DWORD *count, DWORD *count,
boolean numpad, uchar numberpad,
int mode, int mode,
int *mod, int *mod,
coord *cc) coord *cc)
@@ -3121,8 +3164,8 @@ default_checkinput(
boolean valid = 0, done = 0; boolean valid = 0, done = 0;
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
if (numpad & 0x10) { if (numberpad & 0x10) {
numpad &= ~0x10; numberpad &= ~0x10;
qwertz = TRUE; qwertz = TRUE;
} else { } else {
qwertz = FALSE; qwertz = FALSE;
@@ -3139,21 +3182,21 @@ default_checkinput(
ReadConsoleInput(hConIn, ir, 1, count); ReadConsoleInput(hConIn, ir, 1, count);
if (mode == 0) { if (mode == 0) {
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
ch = default_processkeystroke(hConIn, ir, &valid, numpad, 0); ch = default_processkeystroke(hConIn, ir, &valid, numberpad, 0);
done = valid; done = valid;
} }
} else { } else {
if (count > 0) { if (*count > 0) {
if (ir->EventType == KEY_EVENT if (ir->EventType == KEY_EVENT
&& ir->Event.KeyEvent.bKeyDown) { && ir->Event.KeyEvent.bKeyDown) {
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
if (qwertz) if (qwertz)
numpad |= 0x10; numberpad |= 0x10;
#endif #endif
ch = default_processkeystroke(hConIn, ir, &valid, numpad, 0); ch = default_processkeystroke(hConIn, ir, &valid, numberpad, 0);
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
numpad &= ~0x10; numberpad &= ~0x10;
#endif #endif
if (valid) if (valid)
return ch; return ch;
} else if (ir->EventType == MOUSE_EVENT) { } else if (ir->EventType == MOUSE_EVENT) {
@@ -3565,7 +3608,7 @@ ray_checkinput(
HANDLE hConIn, HANDLE hConIn,
INPUT_RECORD *ir, INPUT_RECORD *ir,
DWORD *count, DWORD *count,
boolean numpad, uchar numberpad,
int mode, int mode,
int *mod, int *mod,
coord *cc) coord *cc)
@@ -3577,8 +3620,8 @@ ray_checkinput(
boolean valid = 0, done = 0; boolean valid = 0, done = 0;
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
if (numpad & 0x10) { if (numberpad & 0x10) {
numpad &= ~0x10; numberpad &= ~0x10;
qwertz = TRUE; qwertz = TRUE;
} else { } else {
qwertz = FALSE; qwertz = FALSE;
@@ -3600,22 +3643,22 @@ ray_checkinput(
ReadConsoleInput(hConIn, ir, 1, count); ReadConsoleInput(hConIn, ir, 1, count);
} else { } else {
ch = 0; ch = 0;
if (count > 0) { if (*count > 0) {
if (ir->EventType == KEY_EVENT if (ir->EventType == KEY_EVENT
&& ir->Event.KeyEvent.bKeyDown) { && ir->Event.KeyEvent.bKeyDown) {
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
if (qwertz) if (qwertz)
numpad |= 0x10; numberpad |= 0x10;
#endif #endif
ch = ray_processkeystroke(hConIn, ir, &valid, numpad, ch = ray_processkeystroke(hConIn, ir, &valid, numberpad,
#ifdef PORTDEBUG #ifdef PORTDEBUG
1); 1);
#else #else
0); 0);
#endif #endif
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
numpad &= ~0x10; numberpad &= ~0x10;
#endif #endif
if (valid) if (valid)
return ch; return ch;
} else { } else {
@@ -3635,7 +3678,7 @@ ray_checkinput(
else if (ir->Event.MouseEvent.dwButtonState else if (ir->Event.MouseEvent.dwButtonState
& RIGHTBUTTON) & RIGHTBUTTON)
*mod = CLICK_2; *mod = CLICK_2;
#if 0 /* middle button */ #if 0 /* middle button */
else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON) else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON)
*mod = CLICK_3; *mod = CLICK_3;
#endif #endif
@@ -3733,12 +3776,12 @@ ray_kbhit(
* shift values below. * shift values below.
*/ */
int int
nh340_processkeystroke( nh340_processkeystroke(
HANDLE hConIn, HANDLE hConIn UNUSED,
INPUT_RECORD *ir, INPUT_RECORD *ir,
boolean *valid, boolean *valid,
boolean numberpad, uchar numberpad,
int portdebug) int portdebug)
{ {
int keycode, vk; int keycode, vk;
@@ -3884,7 +3927,7 @@ nh340_checkinput(
HANDLE hConIn, HANDLE hConIn,
INPUT_RECORD *ir, INPUT_RECORD *ir,
DWORD *count, DWORD *count,
boolean numpad, uchar numberpad,
int mode, int mode,
int *mod, int *mod,
coord *cc) coord *cc)
@@ -3896,8 +3939,8 @@ nh340_checkinput(
boolean valid = 0, done = 0; boolean valid = 0, done = 0;
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
if (numpad & 0x10) { if (numberpad & 0x10) {
numpad &= ~0x10; numberpad &= ~0x10;
qwertz = TRUE; qwertz = TRUE;
} else { } else {
qwertz = FALSE; qwertz = FALSE;
@@ -3916,19 +3959,19 @@ nh340_checkinput(
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
if (qwertz) if (qwertz)
numpad |= 0x10; numberpad |= 0x10;
#endif #endif
ch = nh340_processkeystroke(hConIn, ir, &valid, numpad, 0); ch = nh340_processkeystroke(hConIn, ir, &valid, numberpad, 0);
#ifdef QWERTZ_SUPPORT #ifdef QWERTZ_SUPPORT
numpad &= ~0x10; numberpad &= ~0x10;
#endif #endif
done = valid; done = valid;
} }
} else { } else {
if (count > 0) { if (*count > 0) {
if (ir->EventType == KEY_EVENT if (ir->EventType == KEY_EVENT
&& ir->Event.KeyEvent.bKeyDown) { && ir->Event.KeyEvent.bKeyDown) {
ch = nh340_processkeystroke(hConIn, ir, &valid, numpad, 0); ch = nh340_processkeystroke(hConIn, ir, &valid, numberpad, 0);
if (valid) if (valid)
return ch; return ch;
} else if (ir->EventType == MOUSE_EVENT) { } else if (ir->EventType == MOUSE_EVENT) {
+2 -2
View File
@@ -73,7 +73,7 @@ int GUILaunched = TRUE; /* We tell shared startup code in windmain.c
// Forward declarations of functions included in this code module: // Forward declarations of functions included in this code module:
extern boolean main(int, char **); extern boolean main(int, char **);
static void __cdecl mswin_moveloop(void *); //static void __cdecl mswin_moveloop(void *);
#define MAX_CMDLINE_PARAM 255 #define MAX_CMDLINE_PARAM 255
@@ -327,7 +327,7 @@ _get_cmd_arg(TCHAR *pCmdLine)
} else { } else {
pArgs = NULL; pArgs = NULL;
} }
nhUse(bQuoted);
return pRetArg; return pRetArg;
} }
+11 -3
View File
@@ -12,7 +12,10 @@
#include "mhdlg.h" #include "mhdlg.h"
#include <assert.h> #include <assert.h>
int list_view_height(HWND hWnd, int count);
void get_rect_size(RECT *rect, SIZE *size);
void center_dialog(HWND dialog);
void size_dialog(HWND dialog, SIZE new_client_size);
/*---------------------------------------------------------------*/ /*---------------------------------------------------------------*/
/* data for getlin dialog */ /* data for getlin dialog */
@@ -346,6 +349,11 @@ INT_PTR CALLBACK PlayerSelectorDlgProc(HWND, UINT, WPARAM, LPARAM);
static void plselAdjustSelections(HWND hWnd); static void plselAdjustSelections(HWND hWnd);
static boolean plselRandomize(plsel_data_t * data); static boolean plselRandomize(plsel_data_t * data);
static BOOL plselDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam); static BOOL plselDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam);
void calculate_player_selector_layout(plsel_data_t * data);
void move_controls(control_t * controls, int count);
void do_player_selector_layout(plsel_data_t * data);
void plselInitDialog(struct plsel_data * data);
int plselFinalSelection(HWND hWnd);
boolean boolean
mswin_player_selection_window(void) mswin_player_selection_window(void)
@@ -874,7 +882,7 @@ plselAdjustSelections(HWND hWnd)
/* player made up his mind - get final selection here */ /* player made up his mind - get final selection here */
int int
plselFinalSelection(HWND hWnd) plselFinalSelection(HWND hWnd UNUSED)
{ {
int role, race, gender, alignment; int role, race, gender, alignment;
@@ -984,7 +992,7 @@ plselDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
struct plsel_data * data = (plsel_data_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); struct plsel_data * data = (plsel_data_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
/* If there are no list box items, skip this message. */ /* If there are no list box items, skip this message. */
if (lpdis->itemID < 0) if (lpdis->itemID == (UINT) -1)
return FALSE; return FALSE;
HWND control = GetDlgItem(hWnd, (int) wParam); HWND control = GetDlgItem(hWnd, (int) wParam);
+1 -1
View File
@@ -12,6 +12,6 @@
int mswin_getlin_window(const char *question, char *result, int mswin_getlin_window(const char *question, char *result,
size_t result_size); size_t result_size);
int mswin_ext_cmd_window(int *selection); int mswin_ext_cmd_window(int *selection);
boolean mswin_player_selection_window(); boolean mswin_player_selection_window(void);
#endif /* MSWINDlgWindow_h */ #endif /* MSWINDlgWindow_h */
+10 -4
View File
@@ -544,6 +544,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
mswin_select_map_mode(iflags.wc_map_mode); mswin_select_map_mode(iflags.wc_map_mode);
child = GetNHApp()->windowlist[msg_param->wid].win; child = GetNHApp()->windowlist[msg_param->wid].win;
nhUse(child);
} break; } break;
case MSNH_MSG_RANDOM_INPUT: { case MSNH_MSG_RANDOM_INPUT: {
@@ -753,14 +754,18 @@ mswin_layout_main_window(HWND changed_child)
} }
if (IsWindow(changed_child)) if (IsWindow(changed_child))
SetForegroundWindow(changed_child); SetForegroundWindow(changed_child);
nhUse(data);
} }
VOID CALLBACK FuzzTimerProc( _In_ HWND hwnd,
_In_ UINT uMsg, _In_ UINT_PTR idEvent,
_In_ DWORD dwTime);
VOID CALLBACK FuzzTimerProc( VOID CALLBACK FuzzTimerProc(
_In_ HWND hwnd, _In_ HWND hwnd,
_In_ UINT uMsg, _In_ UINT uMsg UNUSED,
_In_ UINT_PTR idEvent, _In_ UINT_PTR idEvent UNUSED,
_In_ DWORD dwTime _In_ DWORD dwTime UNUSED)
)
{ {
INPUT input[16]; INPUT input[16];
int i_pos = 0; int i_pos = 0;
@@ -1114,6 +1119,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
default: default:
return 1; return 1;
} }
nhUse(wmEvent);
return 0; return 0;
} }
+1
View File
@@ -764,6 +764,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
msg_data->buffer[index++] = '\r'; msg_data->buffer[index++] = '\r';
msg_data->buffer[index++] = '\n'; msg_data->buffer[index++] = '\n';
} }
nhUse(mgch);
} break; } break;
#ifdef ENHANCED_SYMBOLS #ifdef ENHANCED_SYMBOLS
+3 -2
View File
@@ -923,7 +923,7 @@ SetMenuListType(HWND hWnd, int how)
for (i = 0; i < data->menui.menu.size; i++) { for (i = 0; i < data->menui.menu.size; i++) {
LVITEM lvitem; LVITEM lvitem;
ZeroMemory(&lvitem, sizeof(lvitem)); ZeroMemory(&lvitem, sizeof(lvitem));
sprintf(buf, "%c - %s", max(data->menui.menu.items[i].accelerator, ' '), Snprintf(buf, sizeof buf, "%c - %s", max(data->menui.menu.items[i].accelerator, ' '),
data->menui.menu.items[i].str); data->menui.menu.items[i].str);
lvitem.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT; lvitem.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;
@@ -940,6 +940,7 @@ SetMenuListType(HWND hWnd, int how)
} }
if (data->is_active) if (data->is_active)
SetFocus(control); SetFocus(control);
nhUse(nItem);
} }
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
HWND HWND
@@ -1036,7 +1037,7 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
lpdis = (LPDRAWITEMSTRUCT) lParam; lpdis = (LPDRAWITEMSTRUCT) lParam;
/* If there are no list box items, skip this message. */ /* If there are no list box items, skip this message. */
if (lpdis->itemID == -1) if (lpdis->itemID == (UINT) -1)
return FALSE; return FALSE;
data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA); data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+2 -2
View File
@@ -481,8 +481,8 @@ onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
// of the scroll box, and update the window. UpdateWindow // of the scroll box, and update the window. UpdateWindow
// sends the WM_PAINT message. // sends the WM_PAINT message.
if (yInc = max(MSG_VISIBLE_LINES - data->yPos, if ((yInc = max(MSG_VISIBLE_LINES - data->yPos,
min(yInc, data->yMax - data->yPos))) { min(yInc, data->yMax - data->yPos)))) {
data->yPos += yInc; data->yPos += yInc;
/* ScrollWindowEx(hWnd, 0, -data->yChar * yInc, /* ScrollWindowEx(hWnd, 0, -data->yChar * yInc,
(CONST RECT *) NULL, (CONST RECT *) NULL, (CONST RECT *) NULL, (CONST RECT *) NULL,
+1
View File
@@ -297,6 +297,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
break; break;
} }
nhUse(InRipText);
} }
void void
+1
View File
@@ -259,6 +259,7 @@ NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
DrawText(hdc, VersionString, strlen(VersionString), &rt, DrawText(hdc, VersionString, strlen(VersionString), &rt,
DT_LEFT | DT_NOPREFIX); DT_LEFT | DT_NOPREFIX);
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
nhUse(OldFont);
} break; } break;
case WM_COMMAND: case WM_COMMAND:
+6 -2
View File
@@ -19,7 +19,6 @@
extern COLORREF nhcolor_to_RGB(int c); /* from mhmap */ extern COLORREF nhcolor_to_RGB(int c); /* from mhmap */
typedef struct back_buffer { typedef struct back_buffer {
HWND hWnd; HWND hWnd;
HDC hdc; HDC hdc;
@@ -29,6 +28,11 @@ typedef struct back_buffer {
int height; int height;
} back_buffer_t; } back_buffer_t;
void back_buffer_free(back_buffer_t * back_buffer);
void back_buffer_allocate(back_buffer_t * back_buffer, int width, int height);
void back_buffer_size(back_buffer_t * back_buffer, int width, int height);
void back_buffer_init(back_buffer_t * back_buffer, HWND hWnd, int width, int height);
void back_buffer_free(back_buffer_t * back_buffer) void back_buffer_free(back_buffer_t * back_buffer)
{ {
if (back_buffer->bm != NULL) { if (back_buffer->bm != NULL) {
@@ -274,7 +278,7 @@ StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
static LRESULT static LRESULT
onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam) onWMPaint(HWND hWnd, WPARAM wParam UNUSED, LPARAM lParam UNUSED)
{ {
SIZE sz; SIZE sz;
WCHAR wbuf[BUFSZ]; WCHAR wbuf[BUFSZ];
+2
View File
@@ -17,7 +17,9 @@ static const int fieldorder2[] = { BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX
BL_ENE, BL_ENEMAX, BL_AC, BL_XP, BL_ENE, BL_ENEMAX, BL_AC, BL_XP,
BL_EXP, BL_HD, BL_TIME, BL_HUNGER, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
BL_CAP, BL_CONDITION, -1 }; BL_CAP, BL_CONDITION, -1 };
#ifdef MSWPROC_C
static const int *fieldorders[] = { fieldorder1, fieldorder2, NULL }; static const int *fieldorders[] = { fieldorder1, fieldorder2, NULL };
#endif
static const int fieldcounts[NHSW_LINES] = { SIZE(fieldorder1) - 1, SIZE(fieldorder2) - 1}; static const int fieldcounts[NHSW_LINES] = { SIZE(fieldorder1) - 1, SIZE(fieldorder2) - 1};
#define MSWIN_MAX_LINE1_STRINGS (SIZE(fieldorder1) - 1) #define MSWIN_MAX_LINE1_STRINGS (SIZE(fieldorder1) - 1)
+49 -44
View File
@@ -7,6 +7,7 @@
* code in the mswin port and the rest of the nethack game engine. * code in the mswin port and the rest of the nethack game engine.
*/ */
#define MSWPROC_C
#include "hack.h" #include "hack.h"
#include "color.h" #include "color.h"
#include "dlb.h" #include "dlb.h"
@@ -28,6 +29,7 @@
#include "mhmain.h" #include "mhmain.h"
#include "mhfont.h" #include "mhfont.h"
#include "resource.h" #include "resource.h"
#undef MSWPROC_C
#define LLEN 128 #define LLEN 128
@@ -371,14 +373,15 @@ prompt_for_player_selection(void)
/* tty_putsym(BASE_WINDOW, (int)strlen(prompt)+1, echoline, /* tty_putsym(BASE_WINDOW, (int)strlen(prompt)+1, echoline,
* pick4u); */ * pick4u); */
/* tty_putstr(BASE_WINDOW, 0, ""); */ /* tty_putstr(BASE_WINDOW, 0, ""); */
} else } else {
/* Otherwise it's hard to tell where to echo, and things are /* Otherwise it's hard to tell where to echo, and things are
* wrapping a bit messily anyway, so (try to) make sure the next * wrapping a bit messily anyway, so (try to) make sure the next
* question shows up well and doesn't get wrapped at the * question shows up well and doesn't get wrapped at the
* bottom of the window. * bottom of the window.
*/ */
/* tty_clear_nhwindow(BASE_WINDOW) */; /* tty_clear_nhwindow(BASE_WINDOW) */
;
}
if (pick4u != 'y' && pick4u != 'n') { if (pick4u != 'y' && pick4u != 'n') {
give_up: /* Quit */ give_up: /* Quit */
if (selected) if (selected)
@@ -450,7 +453,7 @@ prompt_for_player_selection(void)
any.a_int = i + 1; /* must be non-zero */ any.a_int = i + 1; /* must be non-zero */
add_menu(win, &nul_glyphinfo, &any, 'q', 0, add_menu(win, &nul_glyphinfo, &any, 'q', 0,
ATR_NONE, clr, "Quit", MENU_ITEMFLAGS_NONE); ATR_NONE, clr, "Quit", MENU_ITEMFLAGS_NONE);
Sprintf(pbuf, "Pick a role for your %s", plbuf); Snprintf(pbuf, sizeof pbuf, "Pick a role for your %s", plbuf);
end_menu(win, pbuf); end_menu(win, pbuf);
n = select_menu(win, PICK_ONE, &selected); n = select_menu(win, PICK_ONE, &selected);
destroy_nhwindow(win); destroy_nhwindow(win);
@@ -524,7 +527,7 @@ prompt_for_player_selection(void)
any.a_int = i + 1; /* must be non-zero */ any.a_int = i + 1; /* must be non-zero */
add_menu(win, &nul_glyphinfo, &any, 'q', 0, add_menu(win, &nul_glyphinfo, &any, 'q', 0,
ATR_NONE, clr, "Quit", MENU_ITEMFLAGS_NONE); ATR_NONE, clr, "Quit", MENU_ITEMFLAGS_NONE);
Sprintf(pbuf, "Pick the race of your %s", plbuf); Snprintf(pbuf, sizeof pbuf, "Pick the race of your %s", plbuf);
end_menu(win, pbuf); end_menu(win, pbuf);
n = select_menu(win, PICK_ONE, &selected); n = select_menu(win, PICK_ONE, &selected);
destroy_nhwindow(win); destroy_nhwindow(win);
@@ -599,7 +602,7 @@ prompt_for_player_selection(void)
any.a_int = i + 1; /* must be non-zero */ any.a_int = i + 1; /* must be non-zero */
add_menu(win, &nul_glyphinfo, &any, 'q', 0, add_menu(win, &nul_glyphinfo, &any, 'q', 0,
ATR_NONE, clr, "Quit", MENU_ITEMFLAGS_NONE); ATR_NONE, clr, "Quit", MENU_ITEMFLAGS_NONE);
Sprintf(pbuf, "Pick the gender of your %s", plbuf); Snprintf(pbuf, sizeof pbuf, "Pick the gender of your %s", plbuf);
end_menu(win, pbuf); end_menu(win, pbuf);
n = select_menu(win, PICK_ONE, &selected); n = select_menu(win, PICK_ONE, &selected);
destroy_nhwindow(win); destroy_nhwindow(win);
@@ -673,7 +676,7 @@ prompt_for_player_selection(void)
any.a_int = i + 1; /* must be non-zero */ any.a_int = i + 1; /* must be non-zero */
add_menu(win, &nul_glyphinfo, &any, 'q', 0, add_menu(win, &nul_glyphinfo, &any, 'q', 0,
ATR_NONE, clr, "Quit", MENU_ITEMFLAGS_NONE); ATR_NONE, clr, "Quit", MENU_ITEMFLAGS_NONE);
Sprintf(pbuf, "Pick the alignment of your %s", plbuf); Snprintf(pbuf, sizeof pbuf, "Pick the alignment of your %s", plbuf);
end_menu(win, pbuf); end_menu(win, pbuf);
n = select_menu(win, PICK_ONE, &selected); n = select_menu(win, PICK_ONE, &selected);
destroy_nhwindow(win); destroy_nhwindow(win);
@@ -1260,7 +1263,7 @@ mswin_update_inventory(int arg)
win_request_info * win_request_info *
mswin_ctrl_nhwindow( mswin_ctrl_nhwindow(
winid window, winid window UNUSED,
int request, int request,
win_request_info *wri) win_request_info *wri)
{ {
@@ -1365,10 +1368,12 @@ mswin_print_glyph(winid wid, coordxy x, coordxy y,
* mswin_raw_print_accumulate() accumulate the given text into * mswin_raw_print_accumulate() accumulate the given text into
* raw_print_strbuf. * raw_print_strbuf.
*/ */
void mswin_raw_print_accumulate(const char * str, boolean bold);
void void
mswin_raw_print_accumulate(const char * str, boolean bold) mswin_raw_print_accumulate(const char * str, boolean bold)
{ {
bold; // ignored for now nhUse(bold); // ignored for now
if (raw_print_strbuf.str != NULL) strbuf_append(&raw_print_strbuf, "\n"); if (raw_print_strbuf.str != NULL) strbuf_append(&raw_print_strbuf, "\n");
strbuf_append(&raw_print_strbuf, str); strbuf_append(&raw_print_strbuf, str);
@@ -1704,7 +1709,7 @@ mswin_yn_function(const char *question, const char *choices, char def)
res_ch[1] = '\x0'; res_ch[1] = '\x0';
mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, res_ch, 1); mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, res_ch, 1);
} }
nhUse(yn_esc_map);
return ch; return ch;
} }
@@ -1916,7 +1921,7 @@ char *
mswin_get_color_string(void) mswin_get_color_string(void)
{ {
logDebug("mswin_get_color_string()\n"); logDebug("mswin_get_color_string()\n");
return (""); return (char *) "";
} }
/* /*
@@ -2557,7 +2562,7 @@ mswin_write_reg(void)
if (RegOpenKeyEx(HKEY_CURRENT_USER, keystring, 0, KEY_WRITE, &key) if (RegOpenKeyEx(HKEY_CURRENT_USER, keystring, 0, KEY_WRITE, &key)
!= ERROR_SUCCESS) { != ERROR_SUCCESS) {
RegCreateKeyEx(HKEY_CURRENT_USER, keystring, 0, "", RegCreateKeyEx(HKEY_CURRENT_USER, keystring, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
&key, &disposition); &key, &disposition);
} }
@@ -2694,7 +2699,7 @@ static color_table_value color_table[] = {
}; };
typedef struct ctbv { typedef struct ctbv {
char *colorstring; const char *colorstring;
int syscolorvalue; int syscolorvalue;
} color_table_brush_value; } color_table_brush_value;
@@ -2729,7 +2734,7 @@ mswin_color_from_string(char *colorstring, HBRUSH *brushptr,
color_table_value *ctv_ptr = color_table; color_table_value *ctv_ptr = color_table;
color_table_brush_value *ctbv_ptr = color_table_brush; color_table_brush_value *ctbv_ptr = color_table_brush;
int red_value, blue_value, green_value; int red_value, blue_value, green_value;
static char *hexadecimals = "0123456789abcdef"; static const char *hexadecimals = "0123456789abcdef";
if (colorstring == NULL) if (colorstring == NULL)
return; return;
@@ -2880,36 +2885,36 @@ static mswin_status_string _condition_strings[CONDITION_COUNT];
static mswin_status_field _status_fields[MAXBLSTATS]; static mswin_status_field _status_fields[MAXBLSTATS];
static mswin_condition_field _condition_fields[CONDITION_COUNT] = { static mswin_condition_field _condition_fields[CONDITION_COUNT] = {
{ BL_MASK_BAREH, "Bare" }, { BL_MASK_BAREH, "Bare", 0},
{ BL_MASK_BLIND, "Blind" }, { BL_MASK_BLIND, "Blind", 0 },
{ BL_MASK_BUSY, "Busy" }, { BL_MASK_BUSY, "Busy", 0 },
{ BL_MASK_CONF, "Conf" }, { BL_MASK_CONF, "Conf", 0 },
{ BL_MASK_DEAF, "Deaf" }, { BL_MASK_DEAF, "Deaf", 0 },
{ BL_MASK_ELF_IRON, "Iron" }, { BL_MASK_ELF_IRON, "Iron", 0 },
{ BL_MASK_FLY, "Fly" }, { BL_MASK_FLY, "Fly", 0 },
{ BL_MASK_FOODPOIS, "FoodPois" }, { BL_MASK_FOODPOIS, "FoodPois", 0 },
{ BL_MASK_GLOWHANDS, "Glow" }, { BL_MASK_GLOWHANDS, "Glow", 0 },
{ BL_MASK_GRAB, "Grab" }, { BL_MASK_GRAB, "Grab", 0 },
{ BL_MASK_HALLU, "Hallu" }, { BL_MASK_HALLU, "Hallu", 0 },
{ BL_MASK_HELD, "Held" }, { BL_MASK_HELD, "Held", 0 },
{ BL_MASK_ICY, "Icy" }, { BL_MASK_ICY, "Icy", 0 },
{ BL_MASK_INLAVA, "Lava" }, { BL_MASK_INLAVA, "Lava", 0 },
{ BL_MASK_LEV, "Lev" }, { BL_MASK_LEV, "Lev", 0 },
{ BL_MASK_PARLYZ, "Parlyz" }, { BL_MASK_PARLYZ, "Parlyz", 0 },
{ BL_MASK_RIDE, "Ride" }, { BL_MASK_RIDE, "Ride", 0 },
{ BL_MASK_SLEEPING, "Zzz" }, { BL_MASK_SLEEPING, "Zzz", 0 },
{ BL_MASK_SLIME, "Slime" }, { BL_MASK_SLIME, "Slime", 0 },
{ BL_MASK_SLIPPERY, "Slip" }, { BL_MASK_SLIPPERY, "Slip", 0 },
{ BL_MASK_STONE, "Stone" }, { BL_MASK_STONE, "Stone", 0 },
{ BL_MASK_STRNGL, "Strngl" }, { BL_MASK_STRNGL, "Strngl", 0 },
{ BL_MASK_STUN, "Stun" }, { BL_MASK_STUN, "Stun", 0 },
{ BL_MASK_SUBMERGED, "Sub" }, { BL_MASK_SUBMERGED, "Sub", 0 },
{ BL_MASK_TERMILL, "TermIll" }, { BL_MASK_TERMILL, "TermIll", 0 },
{ BL_MASK_TETHERED, "Teth" }, { BL_MASK_TETHERED, "Teth", 0 },
{ BL_MASK_TRAPPED, "Trap" }, { BL_MASK_TRAPPED, "Trap", 0 },
{ BL_MASK_UNCONSC, "Out" }, { BL_MASK_UNCONSC, "Out", 0 },
{ BL_MASK_WOUNDEDL, "Legs" }, { BL_MASK_WOUNDEDL, "Legs", 0 },
{ BL_MASK_HOLDING, "Uhold" }, { BL_MASK_HOLDING, "Uhold", 0 },
}; };
extern winid WIN_STATUS; extern winid WIN_STATUS;
+6 -7
View File
@@ -142,12 +142,9 @@ typedef struct mswin_nhwindow_app {
LPTRANSPARENTBLT lpfnTransparentBlt; /* transparent blt function */ LPTRANSPARENTBLT lpfnTransparentBlt; /* transparent blt function */
} NHWinApp, *PNHWinApp; } NHWinApp, *PNHWinApp;
#define E extern extern PNHWinApp GetNHApp(void);
extern struct window_procs mswin_procs;
E PNHWinApp GetNHApp(void); extern void free_winmain_stuff(void);
E struct window_procs mswin_procs;
#undef E
/* Some prototypes */ /* Some prototypes */
void mswin_init_nhwindows(int *argc, char **argv); void mswin_init_nhwindows(int *argc, char **argv);
@@ -179,7 +176,7 @@ void mswin_print_glyph(winid wid, coordxy x, coordxy y,
const glyph_info *glyph, const glyph_info *bkglyph); const glyph_info *glyph, const glyph_info *bkglyph);
void mswin_raw_print(const char *str); void mswin_raw_print(const char *str);
void mswin_raw_print_bold(const char *str); void mswin_raw_print_bold(const char *str);
void mswin_raw_print_flush(); void mswin_raw_print_flush(void);
int mswin_nhgetch(void); int mswin_nhgetch(void);
int mswin_nh_poskey(coordxy *x, coordxy *y, int *mod); int mswin_nh_poskey(coordxy *x, coordxy *y, int *mod);
void mswin_nhbell(void); void mswin_nhbell(void);
@@ -224,6 +221,8 @@ void mswin_get_window_placement(int type, LPRECT rt);
void mswin_update_window_placement(int type, LPRECT rt); void mswin_update_window_placement(int type, LPRECT rt);
void mswin_apply_window_style(HWND hwnd); void mswin_apply_window_style(HWND hwnd);
//boolean mswin_player_selection_window(void);
int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type); int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type);
extern HBRUSH menu_bg_brush; extern HBRUSH menu_bg_brush;