From c7276bcf6747a8449b4219cabf511ec469e97ce0 Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 12 Dec 2024 22:35:38 -0500 Subject: [PATCH] more MSYS2 warning clean-up --- sys/windows/GNUmakefile | 4 +- sys/windows/consoletty.c | 217 +++++++++++++++++++++++---------------- win/win32/NetHackW.c | 4 +- win/win32/mhdlg.c | 14 ++- win/win32/mhdlg.h | 2 +- win/win32/mhmain.c | 14 ++- win/win32/mhmap.c | 1 + win/win32/mhmenu.c | 5 +- win/win32/mhmsgwnd.c | 4 +- win/win32/mhrip.c | 1 + win/win32/mhsplash.c | 1 + win/win32/mhstatus.c | 8 +- win/win32/mhstatus.h | 2 + win/win32/mswproc.c | 93 +++++++++-------- win/win32/winMS.h | 13 ++- 15 files changed, 227 insertions(+), 156 deletions(-) diff --git a/sys/windows/GNUmakefile b/sys/windows/GNUmakefile index be037485a..f38aaf4f6 100644 --- a/sys/windows/GNUmakefile +++ b/sys/windows/GNUmakefile @@ -341,12 +341,12 @@ ifeq "$(GCC_EXTRA_WARNINGS)" "Y" # CFLAGSXTRA = -Wall -Wextra -Wreturn-type -Wunused -Wswitch -Wshadow \ -Wwrite-strings -pedantic -Wmissing-declarations \ - -Wformat-nonliteral -Wunreachable-code -Wimplicit \ + -Wunreachable-code -Wimplicit \ -Wimplicit-function-declaration -Wimplicit-int \ -Wmissing-prototypes -Wold-style-definition \ -Wstrict-prototypes -Wnonnull -Wformat-overflow \ -Wmissing-parameter-type -Wimplicit-fallthrough \ - -Wno-cast-function-type + -Wno-cast-function-type -Wno-format CPPFLAGSXTRA = -Wall -Wextra -Wno-missing-field-initializers -Wreturn-type \ -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -pedantic \ diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c index 772079deb..32892f864 100644 --- a/sys/windows/consoletty.c +++ b/sys/windows/consoletty.c @@ -97,11 +97,27 @@ cell_t clear_cell = { CONSOLE_CLEAR_CHARACTER, CONSOLE_CLEAR_ATTRIBUTE }; cell_t undefined_cell = { CONSOLE_UNDEFINED_CHARACTER, CONSOLE_UNDEFINED_ATTRIBUTE }; #else /* VIRTUAL_TERMINAL_SEQUENCES */ -cell_t clear_cell = { { CONSOLE_CLEAR_CHARACTER, 0, 0, 0, 0, 0, 0 }, - CONSOLE_CLEAR_CHARACTER, 0, 0L, 0, "\x1b[0m", 0 }; -cell_t undefined_cell = { { CONSOLE_UNDEFINED_CHARACTER, 0, 0, 0, 0, 0, 0 }, - CONSOLE_UNDEFINED_CHARACTER, 0, 0L, 0, (const char *) 0 }; +cell_t clear_cell = { + { CONSOLE_CLEAR_CHARACTER, 0, 0, 0, 0, 0, 0 }, + CONSOLE_CLEAR_CHARACTER, /* wcharacter */ + 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 }; +#endif #endif /* VIRTUAL_TERMINAL_SEQUENCES */ /* @@ -135,7 +151,9 @@ int process_keystroke(INPUT_RECORD *, boolean *, boolean numberpad, static void init_ttycolor(void); static void really_move_cursor(void); static void check_and_set_font(void); +#ifndef VIRTUAL_TERMINAL_SEQUENCES static boolean check_font_widths(void); +#endif static void set_known_good_console_font(void); static void restore_original_console_font(void); extern void safe_routines(void); @@ -150,7 +168,7 @@ static void free_custom_colors(void); /* Win32 Screen buffer,coordinate,console I/O information */ COORD ntcoord; -INPUT_RECORD ir; +INPUT_RECORD gbl_ir; static boolean orig_QuickEdit; /* Support for changing console font if existing glyph widths are too wide */ @@ -213,11 +231,11 @@ struct console_t { 0, /* current_nhcolor */ 0, /* current_nhbkcolor */ 0, /* current_colorflags */ - {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}, - {0, 0}, /* cursor */ + { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, + { 0, 0 }, /* cursor */ NULL, /* hConOut*/ NULL, /* hConIn */ - { 0 }, /* cbsi */ + { { 0, 0}, { 0, 0}, 0, { 0, 0, 0, 0 }, { 0, 0 } }, /* cbsi */ 0, /* width */ 0, /* height */ FALSE, /* has_unicode */ @@ -242,7 +260,9 @@ struct console_t { #endif /* VIRTUAL_TERMINAL_SEQUENCES */ }; +#if 0 static const char default_name[] = "default"; +#endif const char *const legal_key_handling[] = { "none", "default", @@ -282,7 +302,10 @@ struct keyboard_handling_t { default_checkinput }; -static DWORD ccount, acount; +static DWORD ccount; +#if 0 +static DWORD acount; +#endif #ifndef CLR_MAX #define CLR_MAX 16 #endif @@ -292,7 +315,9 @@ int ttycolors_inv[CLR_MAX]; #define MAX_OVERRIDES 256 unsigned char key_overrides[MAX_OVERRIDES]; +#if 0 static char nullstr[] = ""; +#endif char erase_char, kill_char; #define DEFTEXTCOLOR ttycolors[7] static INPUT_RECORD bogus_key; @@ -470,7 +495,17 @@ struct rgbvalues { { 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) { 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_return_to_default(void); void emit_hide_cursor(void); -void emit_show_curor(void); +void emit_show_cursor(void); void emit_hide_cursor(void) @@ -730,7 +765,7 @@ emit_stop_inverse(void) #define tcfmtstr24bit "\x1b[38:2:%ld:%ld:%ldm" #define tcfmtstr256 "\x1b[38:5:%dm" #endif - + void emit_start_256color(int u256coloridx) { @@ -773,12 +808,14 @@ emit_return_to_default(void) WriteConsoleA(console.hConOut, (LPCSTR) escseq, (int) strlen(escseq), &unused, NULL); } +#if 0 static boolean newattr_on = TRUE; +#endif static boolean color24_on = TRUE; /* for debugging */ WORD what_is_there_now; -BOOL success; +//BOOL success; DWORD error_result; #endif /* VIRTUAL_TERMINAL_SEQUENCES */ @@ -880,7 +917,7 @@ back_buffer_flip(void) (int) strlen(back->bkcolorseq), &unused, 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_colorseq; emit_default_color(); @@ -1050,7 +1087,7 @@ tty_startup(int *wid, int *hgt) } void -tty_number_pad(int state) +tty_number_pad(int state UNUSED) { // do nothing } @@ -1088,6 +1125,7 @@ CtrlHandler(DWORD ctrltype) case CTRL_BREAK_EVENT: term_clear_screen(); FALLTHROUGH; + /* FALLTHRU */ case CTRL_CLOSE_EVENT: case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: @@ -1106,7 +1144,7 @@ CtrlHandler(DWORD ctrltype) /* called by pcmain() and process_options() */ void -consoletty_open(int mode) +consoletty_open(int mode UNUSED) { int debugvar; @@ -1124,6 +1162,7 @@ consoletty_open(int mode) CO = console.width; really_move_cursor(); + nhUse(debugvar); } void @@ -1165,7 +1204,7 @@ process_keystroke( int consoletty_kbhit(void) { - return keyboard_handling.pNHkbhit(console.hConIn, &ir); + return keyboard_handling.pNHkbhit(console.hConIn, &gbl_ir); } int @@ -1174,20 +1213,20 @@ tgetch(void) int mod; coord cc; DWORD count; - boolean numpad = iflags.num_pad; + uchar numberpad = iflags.num_pad; really_move_cursor(); if (iflags.debug_fuzzer) return randomkey(); #ifdef QWERTZ_SUPPORT if (gc.Cmd.swap_yz) - numpad |= 0x10; + numberpad |= 0x10; #endif return (program_state.done_hup) ? '\033' : keyboard_handling.pCheckInput( - console.hConIn, &ir, &count, numpad, 0, &mod, &cc); + console.hConIn, &gbl_ir, &count, numberpad, 0, &mod, &cc); } int @@ -1196,7 +1235,7 @@ console_poskey(coordxy *x, coordxy *y, int *mod) int ch; coord cc = { 0, 0 }; DWORD count; - boolean numpad = iflags.num_pad; + boolean numberpad = iflags.num_pad; really_move_cursor(); if (iflags.debug_fuzzer) { @@ -1210,14 +1249,14 @@ console_poskey(coordxy *x, coordxy *y, int *mod) } #ifdef QWERTZ_SUPPORT if (gc.Cmd.swap_yz) - numpad |= 0x10; + numberpad |= 0x10; #endif ch = (program_state.done_hup) ? '\033' : keyboard_handling.pCheckInput( - console.hConIn, &ir, &count, numpad, 1, mod, &cc); + console.hConIn, &gbl_ir, &count, numberpad, 1, mod, &cc); #ifdef QWERTZ_SUPPORT - numpad &= ~0x10; + numberpad &= ~0x10; #endif if (!ch) { *x = cc.x; @@ -1245,9 +1284,11 @@ really_move_cursor(void) if (GetConsoleTitle(oldtitle, BUFSZ)) { oldtitle[39] = '\0'; } - Sprintf(newtitle, "%-55s tty=(%02d,%02d) consoletty=(%02d,%02d)", oldtitle, - ttyDisplay->curx, ttyDisplay->cury, - console.cursor.X, console.cursor.Y); + Snprintf(newtitle, sizeof newtitle, + "%-55s tty=(%02d,%02d) consoletty=(%02d,%02d)", + oldtitle, + ttyDisplay->curx, ttyDisplay->cury, + console.cursor.X, console.cursor.Y); (void) SetConsoleTitle(newtitle); } #endif @@ -1315,7 +1356,7 @@ xputc(int ch) #ifndef VIRTUAL_TERMINAL_SEQUENCES void -xputc_core(char ch) +xputc_core(char ch) #else void xputc_core(int ch) @@ -1423,27 +1464,25 @@ xputc_core(int ch) void g_putch(int in_ch) { + unsigned char ch; + cell_t cell; #ifndef VIRTUAL_TERMINAL_SEQUENCES boolean inverse = FALSE; #else /* VIRTUAL_TERMINAL_SEQUENCES */ - int ccount = 0; + ccount = 0; WCHAR wch[2]; + boolean usemap = (in_ch >= 0 && in_ch < SIZE(console.cpMap)); #endif /* VIRTUAL_TERMINAL_SEQUENCES */ - unsigned char ch = (unsigned char) in_ch; + ch = (unsigned char) in_ch; set_console_cursor(ttyDisplay->curx, ttyDisplay->cury); #ifndef VIRTUAL_TERMINAL_SEQUENCES - inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse); console.attr = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse) ? ttycolors_inv[console.current_nhcolor] : ttycolors[console.current_nhcolor]; if (console.current_nhattr[ATR_BOLD]) console.attr |= (inverse) ? BACKGROUND_INTENSITY : FOREGROUND_INTENSITY; - -#endif /* ! VIRTUAL_TERMINAL_SEQUENCES */ - cell_t cell; -#ifndef VIRTUAL_TERMINAL_SEQUENCES cell.attribute = console.attr; cell.character = (console.has_unicode ? cp437[ch] : ch); #else @@ -1454,7 +1493,7 @@ g_putch(int in_ch) cell.color256idx = 0; wch[1] = 0; 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 if (SYMHANDLING(H_UTF8)) { /* we have to convert it to UTF-8 for cell.utf8str */ @@ -1476,7 +1515,7 @@ g_putch(int in_ch) cell.utf8str[1] = 0; ccount = 2; } -#endif +#endif /* VIRTUAL_TERMINAL_SEQUENCES */ 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); #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 cl_end(void) { - if (ttyDisplay->curx < console.width + if (ttyDisplay->curx < console.width && ttyDisplay->cury < console.height) { set_console_cursor(ttyDisplay->curx, ttyDisplay->cury); buffer_clear_to_end_of_line(console.back_buffer, console.cursor.X, @@ -1652,6 +1691,7 @@ tty_delay_output(void) while (goal > clock()) { k = junk; /* Do nothing */ } + nhUse(k); } /* @@ -2044,9 +2084,9 @@ win32con_debug_keystrokes(void) xputs("\n"); while (!valid || ch != 27) { nocmov(ttyDisplay->curx, ttyDisplay->cury); - ReadConsoleInput(console.hConIn, &ir, 1, &count); - if ((ir.EventType == KEY_EVENT) && ir.Event.KeyEvent.bKeyDown) - ch = process_keystroke(&ir, &valid, iflags.num_pad, 1); + ReadConsoleInput(console.hConIn, &gbl_ir, 1, &count); + if ((gbl_ir.EventType == KEY_EVENT) && gbl_ir.Event.KeyEvent.bKeyDown) + ch = process_keystroke(&gbl_ir, &valid, iflags.num_pad, 1); } (void) doredraw(); } @@ -2090,7 +2130,7 @@ map_subkeyvalue(char *op) key_overrides[idx] = val; } - +#if 0 /* fatal error */ /*VARARGS1*/ void consoletty_error @@ -2109,6 +2149,7 @@ VA_DECL(const char *, s) VA_END(); exit(EXIT_FAILURE); } +#endif void synch_cursor(void) @@ -2116,13 +2157,16 @@ synch_cursor(void) really_move_cursor(); } +#ifndef VIRTUAL_TERMINAL_SEQUENCES 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; *lf_ptr = *lf; return 0; } +#endif /* 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 @@ -2147,15 +2191,12 @@ check_and_set_font(void) #endif } +#ifndef VIRTUAL_TERMINAL_SEQUENCES /* check_font_widths returns TRUE if all glyphs in current console font * fit within the width of a single console cell. */ boolean -#ifndef VIRTUAL_TERMINAL_SEQUENCES check_font_widths(void) -#else /* VIRTUAL_TERMINAL_SEQUENCES */ -check_font_widths(void) -#endif /* VIRTUAL_TERMINAL_SEQUENCES */ { CONSOLE_FONT_INFOEX console_font_info; console_font_info.cbSize = sizeof(console_font_info); @@ -2223,7 +2264,7 @@ check_font_widths(void) int wcUsedCount = 0; wchar_t wcUsed[256]; - for (int i = 0; i < sizeof(used); i++) + for (int i = 0; i < (int) sizeof(used); i++) if (used[i]) wcUsed[wcUsedCount++] = cp437[i]; @@ -2252,6 +2293,7 @@ clean_up: return all_glyphs_fit; } +#endif /* 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 @@ -2465,7 +2507,7 @@ void nethack_enter_consoletty(void) { #ifdef VIRTUAL_TERMINAL_SEQUENCES char buf[BUFSZ], *bp, *localestr; - BOOL success; + BOOL apisuccess; #endif /* VIRTUAL_TERMINAL_SEQUENCES */ #if 0 /* set up state needed by early_raw_print() */ @@ -2559,7 +2601,7 @@ void nethack_enter_consoletty(void) /* store the original font */ console.orig_font_info.cbSize = sizeof(console.orig_font_info); - success = GetCurrentConsoleFontEx(console.hConOut, + apisuccess = GetCurrentConsoleFontEx(console.hConOut, FALSE, &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; if (console.has_unicode) { if (console.code_page != 437) - success = SetConsoleOutputCP(437); + apisuccess = SetConsoleOutputCP(437); } else if (console.code_page != 1252) { - success = SetConsoleOutputCP(1252); + apisuccess = SetConsoleOutputCP(1252); } console.code_page = GetConsoleOutputCP(); #endif /* VIRTUAL_TERMINAL_SEQUENCES */ @@ -2660,6 +2702,7 @@ void nethack_enter_consoletty(void) #endif /* VIRTUAL_TERMINAL_SEQUENCES */ console.current_nhcolor = NO_COLOR; console.is_ready = TRUE; + nhUse(apisuccess); } #endif /* TTY_GRAPHICS */ @@ -2718,7 +2761,7 @@ VA_DECL(const char *, fmt) #ifdef QWERTZ_SUPPORT /* 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' */ static boolean qwertz = FALSE; #endif @@ -2939,7 +2982,7 @@ set_keyhandling_via_option(void) int default_processkeystroke( - HANDLE hConIn, + HANDLE hConIn UNUSED, INPUT_RECORD *ir, boolean *valid, boolean numberpad, @@ -3104,12 +3147,12 @@ default_kbhit(HANDLE hConIn, INPUT_RECORD *ir) return retval; } -int +int default_checkinput( HANDLE hConIn, INPUT_RECORD *ir, DWORD *count, - boolean numpad, + uchar numberpad, int mode, int *mod, coord *cc) @@ -3121,8 +3164,8 @@ default_checkinput( boolean valid = 0, done = 0; #ifdef QWERTZ_SUPPORT - if (numpad & 0x10) { - numpad &= ~0x10; + if (numberpad & 0x10) { + numberpad &= ~0x10; qwertz = TRUE; } else { qwertz = FALSE; @@ -3139,21 +3182,21 @@ default_checkinput( ReadConsoleInput(hConIn, ir, 1, count); if (mode == 0) { 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; } } else { - if (count > 0) { + if (*count > 0) { if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { #ifdef QWERTZ_SUPPORT if (qwertz) - numpad |= 0x10; + numberpad |= 0x10; #endif - ch = default_processkeystroke(hConIn, ir, &valid, numpad, 0); + ch = default_processkeystroke(hConIn, ir, &valid, numberpad, 0); #ifdef QWERTZ_SUPPORT - numpad &= ~0x10; -#endif + numberpad &= ~0x10; +#endif if (valid) return ch; } else if (ir->EventType == MOUSE_EVENT) { @@ -3565,7 +3608,7 @@ ray_checkinput( HANDLE hConIn, INPUT_RECORD *ir, DWORD *count, - boolean numpad, + uchar numberpad, int mode, int *mod, coord *cc) @@ -3577,8 +3620,8 @@ ray_checkinput( boolean valid = 0, done = 0; #ifdef QWERTZ_SUPPORT - if (numpad & 0x10) { - numpad &= ~0x10; + if (numberpad & 0x10) { + numberpad &= ~0x10; qwertz = TRUE; } else { qwertz = FALSE; @@ -3600,22 +3643,22 @@ ray_checkinput( ReadConsoleInput(hConIn, ir, 1, count); } else { ch = 0; - if (count > 0) { + if (*count > 0) { if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { #ifdef QWERTZ_SUPPORT if (qwertz) - numpad |= 0x10; + numberpad |= 0x10; #endif - ch = ray_processkeystroke(hConIn, ir, &valid, numpad, + ch = ray_processkeystroke(hConIn, ir, &valid, numberpad, #ifdef PORTDEBUG 1); #else 0); #endif #ifdef QWERTZ_SUPPORT - numpad &= ~0x10; -#endif + numberpad &= ~0x10; +#endif if (valid) return ch; } else { @@ -3635,7 +3678,7 @@ ray_checkinput( else if (ir->Event.MouseEvent.dwButtonState & RIGHTBUTTON) *mod = CLICK_2; -#if 0 /* middle button */ +#if 0 /* middle button */ else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON) *mod = CLICK_3; #endif @@ -3733,12 +3776,12 @@ ray_kbhit( * shift values below. */ -int +int nh340_processkeystroke( - HANDLE hConIn, + HANDLE hConIn UNUSED, INPUT_RECORD *ir, boolean *valid, - boolean numberpad, + uchar numberpad, int portdebug) { int keycode, vk; @@ -3884,7 +3927,7 @@ nh340_checkinput( HANDLE hConIn, INPUT_RECORD *ir, DWORD *count, - boolean numpad, + uchar numberpad, int mode, int *mod, coord *cc) @@ -3896,8 +3939,8 @@ nh340_checkinput( boolean valid = 0, done = 0; #ifdef QWERTZ_SUPPORT - if (numpad & 0x10) { - numpad &= ~0x10; + if (numberpad & 0x10) { + numberpad &= ~0x10; qwertz = TRUE; } else { qwertz = FALSE; @@ -3916,19 +3959,19 @@ nh340_checkinput( if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { #ifdef QWERTZ_SUPPORT if (qwertz) - numpad |= 0x10; + numberpad |= 0x10; #endif - ch = nh340_processkeystroke(hConIn, ir, &valid, numpad, 0); + ch = nh340_processkeystroke(hConIn, ir, &valid, numberpad, 0); #ifdef QWERTZ_SUPPORT - numpad &= ~0x10; -#endif + numberpad &= ~0x10; +#endif done = valid; } } else { - if (count > 0) { + if (*count > 0) { if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { - ch = nh340_processkeystroke(hConIn, ir, &valid, numpad, 0); + ch = nh340_processkeystroke(hConIn, ir, &valid, numberpad, 0); if (valid) return ch; } else if (ir->EventType == MOUSE_EVENT) { diff --git a/win/win32/NetHackW.c b/win/win32/NetHackW.c index 2eee75939..02b537cbd 100644 --- a/win/win32/NetHackW.c +++ b/win/win32/NetHackW.c @@ -73,7 +73,7 @@ int GUILaunched = TRUE; /* We tell shared startup code in windmain.c // Forward declarations of functions included in this code module: extern boolean main(int, char **); -static void __cdecl mswin_moveloop(void *); +//static void __cdecl mswin_moveloop(void *); #define MAX_CMDLINE_PARAM 255 @@ -327,7 +327,7 @@ _get_cmd_arg(TCHAR *pCmdLine) } else { pArgs = NULL; } - + nhUse(bQuoted); return pRetArg; } diff --git a/win/win32/mhdlg.c b/win/win32/mhdlg.c index f190f000d..94a7ecf3e 100644 --- a/win/win32/mhdlg.c +++ b/win/win32/mhdlg.c @@ -12,7 +12,10 @@ #include "mhdlg.h" #include - +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 */ @@ -346,6 +349,11 @@ INT_PTR CALLBACK PlayerSelectorDlgProc(HWND, UINT, WPARAM, LPARAM); static void plselAdjustSelections(HWND hWnd); static boolean plselRandomize(plsel_data_t * data); 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 mswin_player_selection_window(void) @@ -874,7 +882,7 @@ plselAdjustSelections(HWND hWnd) /* player made up his mind - get final selection here */ int -plselFinalSelection(HWND hWnd) +plselFinalSelection(HWND hWnd UNUSED) { 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); /* If there are no list box items, skip this message. */ - if (lpdis->itemID < 0) + if (lpdis->itemID == (UINT) -1) return FALSE; HWND control = GetDlgItem(hWnd, (int) wParam); diff --git a/win/win32/mhdlg.h b/win/win32/mhdlg.h index 0b08e8fcb..7eb0b8eb9 100644 --- a/win/win32/mhdlg.h +++ b/win/win32/mhdlg.h @@ -12,6 +12,6 @@ int mswin_getlin_window(const char *question, char *result, size_t result_size); int mswin_ext_cmd_window(int *selection); -boolean mswin_player_selection_window(); +boolean mswin_player_selection_window(void); #endif /* MSWINDlgWindow_h */ diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index c0a6cd0b1..f3eae350c 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -544,6 +544,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) mswin_select_map_mode(iflags.wc_map_mode); child = GetNHApp()->windowlist[msg_param->wid].win; + nhUse(child); } break; case MSNH_MSG_RANDOM_INPUT: { @@ -753,14 +754,18 @@ mswin_layout_main_window(HWND changed_child) } if (IsWindow(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( _In_ HWND hwnd, - _In_ UINT uMsg, - _In_ UINT_PTR idEvent, - _In_ DWORD dwTime - ) + _In_ UINT uMsg UNUSED, + _In_ UINT_PTR idEvent UNUSED, + _In_ DWORD dwTime UNUSED) { INPUT input[16]; int i_pos = 0; @@ -1114,6 +1119,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) default: return 1; } + nhUse(wmEvent); return 0; } diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index 6a5914cc6..a3f46c39d 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -764,6 +764,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) msg_data->buffer[index++] = '\r'; msg_data->buffer[index++] = '\n'; } + nhUse(mgch); } break; #ifdef ENHANCED_SYMBOLS diff --git a/win/win32/mhmenu.c b/win/win32/mhmenu.c index 121704b0d..d39bdc1b4 100644 --- a/win/win32/mhmenu.c +++ b/win/win32/mhmenu.c @@ -923,7 +923,7 @@ SetMenuListType(HWND hWnd, int how) for (i = 0; i < data->menui.menu.size; i++) { LVITEM 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); lvitem.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT; @@ -940,6 +940,7 @@ SetMenuListType(HWND hWnd, int how) } if (data->is_active) SetFocus(control); + nhUse(nItem); } /*-----------------------------------------------------------------------------*/ HWND @@ -1036,7 +1037,7 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam) lpdis = (LPDRAWITEMSTRUCT) lParam; /* If there are no list box items, skip this message. */ - if (lpdis->itemID == -1) + if (lpdis->itemID == (UINT) -1) return FALSE; data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA); diff --git a/win/win32/mhmsgwnd.c b/win/win32/mhmsgwnd.c index 864df34aa..e4d62b5ab 100644 --- a/win/win32/mhmsgwnd.c +++ b/win/win32/mhmsgwnd.c @@ -481,8 +481,8 @@ onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam) // of the scroll box, and update the window. UpdateWindow // sends the WM_PAINT message. - if (yInc = max(MSG_VISIBLE_LINES - data->yPos, - min(yInc, data->yMax - data->yPos))) { + if ((yInc = max(MSG_VISIBLE_LINES - data->yPos, + min(yInc, data->yMax - data->yPos)))) { data->yPos += yInc; /* ScrollWindowEx(hWnd, 0, -data->yChar * yInc, (CONST RECT *) NULL, (CONST RECT *) NULL, diff --git a/win/win32/mhrip.c b/win/win32/mhrip.c index 912bbd9db..28036307b 100644 --- a/win/win32/mhrip.c +++ b/win/win32/mhrip.c @@ -297,6 +297,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) break; } + nhUse(InRipText); } void diff --git a/win/win32/mhsplash.c b/win/win32/mhsplash.c index f928cbfc6..5c5ef6328 100644 --- a/win/win32/mhsplash.c +++ b/win/win32/mhsplash.c @@ -259,6 +259,7 @@ NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) DrawText(hdc, VersionString, strlen(VersionString), &rt, DT_LEFT | DT_NOPREFIX); EndPaint(hWnd, &ps); + nhUse(OldFont); } break; case WM_COMMAND: diff --git a/win/win32/mhstatus.c b/win/win32/mhstatus.c index fffbc5100..eee9047f8 100644 --- a/win/win32/mhstatus.c +++ b/win/win32/mhstatus.c @@ -19,7 +19,6 @@ extern COLORREF nhcolor_to_RGB(int c); /* from mhmap */ - typedef struct back_buffer { HWND hWnd; HDC hdc; @@ -29,6 +28,11 @@ typedef struct back_buffer { int height; } 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) { if (back_buffer->bm != NULL) { @@ -274,7 +278,7 @@ StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } static LRESULT -onWMPaint(HWND hWnd, WPARAM wParam, LPARAM lParam) +onWMPaint(HWND hWnd, WPARAM wParam UNUSED, LPARAM lParam UNUSED) { SIZE sz; WCHAR wbuf[BUFSZ]; diff --git a/win/win32/mhstatus.h b/win/win32/mhstatus.h index a70a90f6e..ec3473334 100644 --- a/win/win32/mhstatus.h +++ b/win/win32/mhstatus.h @@ -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_EXP, BL_HD, BL_TIME, BL_HUNGER, BL_CAP, BL_CONDITION, -1 }; +#ifdef MSWPROC_C static const int *fieldorders[] = { fieldorder1, fieldorder2, NULL }; +#endif static const int fieldcounts[NHSW_LINES] = { SIZE(fieldorder1) - 1, SIZE(fieldorder2) - 1}; #define MSWIN_MAX_LINE1_STRINGS (SIZE(fieldorder1) - 1) diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index cf4f63a44..1103233c2 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -7,6 +7,7 @@ * code in the mswin port and the rest of the nethack game engine. */ +#define MSWPROC_C #include "hack.h" #include "color.h" #include "dlb.h" @@ -28,6 +29,7 @@ #include "mhmain.h" #include "mhfont.h" #include "resource.h" +#undef MSWPROC_C #define LLEN 128 @@ -371,14 +373,15 @@ prompt_for_player_selection(void) /* tty_putsym(BASE_WINDOW, (int)strlen(prompt)+1, echoline, * pick4u); */ /* tty_putstr(BASE_WINDOW, 0, ""); */ - } else + } else { /* Otherwise it's hard to tell where to echo, and things are * wrapping a bit messily anyway, so (try to) make sure the next * question shows up well and doesn't get wrapped at the * bottom of the window. */ - /* tty_clear_nhwindow(BASE_WINDOW) */; - + /* tty_clear_nhwindow(BASE_WINDOW) */ + ; + } if (pick4u != 'y' && pick4u != 'n') { give_up: /* Quit */ if (selected) @@ -450,7 +453,7 @@ prompt_for_player_selection(void) any.a_int = i + 1; /* must be non-zero */ add_menu(win, &nul_glyphinfo, &any, 'q', 0, 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); n = select_menu(win, PICK_ONE, &selected); destroy_nhwindow(win); @@ -524,7 +527,7 @@ prompt_for_player_selection(void) any.a_int = i + 1; /* must be non-zero */ add_menu(win, &nul_glyphinfo, &any, 'q', 0, 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); n = select_menu(win, PICK_ONE, &selected); destroy_nhwindow(win); @@ -599,7 +602,7 @@ prompt_for_player_selection(void) any.a_int = i + 1; /* must be non-zero */ add_menu(win, &nul_glyphinfo, &any, 'q', 0, 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); n = select_menu(win, PICK_ONE, &selected); destroy_nhwindow(win); @@ -673,7 +676,7 @@ prompt_for_player_selection(void) any.a_int = i + 1; /* must be non-zero */ add_menu(win, &nul_glyphinfo, &any, 'q', 0, 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); n = select_menu(win, PICK_ONE, &selected); destroy_nhwindow(win); @@ -1260,7 +1263,7 @@ mswin_update_inventory(int arg) win_request_info * mswin_ctrl_nhwindow( - winid window, + winid window UNUSED, int request, 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 * raw_print_strbuf. */ +void mswin_raw_print_accumulate(const char * str, boolean bold); + void 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"); 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'; mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, res_ch, 1); } - + nhUse(yn_esc_map); return ch; } @@ -1916,7 +1921,7 @@ char * mswin_get_color_string(void) { 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) != ERROR_SUCCESS) { - RegCreateKeyEx(HKEY_CURRENT_USER, keystring, 0, "", + RegCreateKeyEx(HKEY_CURRENT_USER, keystring, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, &disposition); } @@ -2694,7 +2699,7 @@ static color_table_value color_table[] = { }; typedef struct ctbv { - char *colorstring; + const char *colorstring; int syscolorvalue; } 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_brush_value *ctbv_ptr = color_table_brush; int red_value, blue_value, green_value; - static char *hexadecimals = "0123456789abcdef"; + static const char *hexadecimals = "0123456789abcdef"; if (colorstring == NULL) return; @@ -2880,36 +2885,36 @@ static mswin_status_string _condition_strings[CONDITION_COUNT]; static mswin_status_field _status_fields[MAXBLSTATS]; static mswin_condition_field _condition_fields[CONDITION_COUNT] = { - { BL_MASK_BAREH, "Bare" }, - { BL_MASK_BLIND, "Blind" }, - { BL_MASK_BUSY, "Busy" }, - { BL_MASK_CONF, "Conf" }, - { BL_MASK_DEAF, "Deaf" }, - { BL_MASK_ELF_IRON, "Iron" }, - { BL_MASK_FLY, "Fly" }, - { BL_MASK_FOODPOIS, "FoodPois" }, - { BL_MASK_GLOWHANDS, "Glow" }, - { BL_MASK_GRAB, "Grab" }, - { BL_MASK_HALLU, "Hallu" }, - { BL_MASK_HELD, "Held" }, - { BL_MASK_ICY, "Icy" }, - { BL_MASK_INLAVA, "Lava" }, - { BL_MASK_LEV, "Lev" }, - { BL_MASK_PARLYZ, "Parlyz" }, - { BL_MASK_RIDE, "Ride" }, - { BL_MASK_SLEEPING, "Zzz" }, - { BL_MASK_SLIME, "Slime" }, - { BL_MASK_SLIPPERY, "Slip" }, - { BL_MASK_STONE, "Stone" }, - { BL_MASK_STRNGL, "Strngl" }, - { BL_MASK_STUN, "Stun" }, - { BL_MASK_SUBMERGED, "Sub" }, - { BL_MASK_TERMILL, "TermIll" }, - { BL_MASK_TETHERED, "Teth" }, - { BL_MASK_TRAPPED, "Trap" }, - { BL_MASK_UNCONSC, "Out" }, - { BL_MASK_WOUNDEDL, "Legs" }, - { BL_MASK_HOLDING, "Uhold" }, + { BL_MASK_BAREH, "Bare", 0}, + { BL_MASK_BLIND, "Blind", 0 }, + { BL_MASK_BUSY, "Busy", 0 }, + { BL_MASK_CONF, "Conf", 0 }, + { BL_MASK_DEAF, "Deaf", 0 }, + { BL_MASK_ELF_IRON, "Iron", 0 }, + { BL_MASK_FLY, "Fly", 0 }, + { BL_MASK_FOODPOIS, "FoodPois", 0 }, + { BL_MASK_GLOWHANDS, "Glow", 0 }, + { BL_MASK_GRAB, "Grab", 0 }, + { BL_MASK_HALLU, "Hallu", 0 }, + { BL_MASK_HELD, "Held", 0 }, + { BL_MASK_ICY, "Icy", 0 }, + { BL_MASK_INLAVA, "Lava", 0 }, + { BL_MASK_LEV, "Lev", 0 }, + { BL_MASK_PARLYZ, "Parlyz", 0 }, + { BL_MASK_RIDE, "Ride", 0 }, + { BL_MASK_SLEEPING, "Zzz", 0 }, + { BL_MASK_SLIME, "Slime", 0 }, + { BL_MASK_SLIPPERY, "Slip", 0 }, + { BL_MASK_STONE, "Stone", 0 }, + { BL_MASK_STRNGL, "Strngl", 0 }, + { BL_MASK_STUN, "Stun", 0 }, + { BL_MASK_SUBMERGED, "Sub", 0 }, + { BL_MASK_TERMILL, "TermIll", 0 }, + { BL_MASK_TETHERED, "Teth", 0 }, + { BL_MASK_TRAPPED, "Trap", 0 }, + { BL_MASK_UNCONSC, "Out", 0 }, + { BL_MASK_WOUNDEDL, "Legs", 0 }, + { BL_MASK_HOLDING, "Uhold", 0 }, }; extern winid WIN_STATUS; diff --git a/win/win32/winMS.h b/win/win32/winMS.h index ed7e24e8f..682fbc3ee 100644 --- a/win/win32/winMS.h +++ b/win/win32/winMS.h @@ -142,12 +142,9 @@ typedef struct mswin_nhwindow_app { LPTRANSPARENTBLT lpfnTransparentBlt; /* transparent blt function */ } NHWinApp, *PNHWinApp; -#define E extern - -E PNHWinApp GetNHApp(void); -E struct window_procs mswin_procs; - -#undef E +extern PNHWinApp GetNHApp(void); +extern struct window_procs mswin_procs; +extern void free_winmain_stuff(void); /* Some prototypes */ 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); void mswin_raw_print(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_nh_poskey(coordxy *x, coordxy *y, int *mod); 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_apply_window_style(HWND hwnd); +//boolean mswin_player_selection_window(void); + int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type); extern HBRUSH menu_bg_brush;