Some Windows gcc fixes
This commit is contained in:
@@ -98,7 +98,7 @@ extern char *windows_exepath(void);
|
||||
*===============================================
|
||||
*/
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#ifdef __GNUC__
|
||||
#define MD_USE_TMPFILE_S
|
||||
#
|
||||
#ifdef strncasecmp
|
||||
@@ -110,10 +110,11 @@ extern char *windows_exepath(void);
|
||||
#ifdef __USE_MINGW_ANSI_STDIO
|
||||
#undef __USE_MINGW_ANSI_STDIO
|
||||
#endif
|
||||
#define __USE_MINGW_ANSI_STDIO 1
|
||||
/* with UCRT, we don't define this to 1 */
|
||||
#define __USE_MINGW_ANSI_STDIO 0
|
||||
#endif
|
||||
/* extern int getlock(void); */
|
||||
#endif /* __MINGW32__ */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define MD_USE_TMPFILE_S
|
||||
|
||||
@@ -55,14 +55,13 @@ windsound_init_nhsound(void)
|
||||
}
|
||||
|
||||
static void
|
||||
windsound_exit_nhsound(const char *reason)
|
||||
windsound_exit_nhsound(const char *reason UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
windsound_achievement(schar ach1, schar ach2, int32_t repeat)
|
||||
windsound_achievement(schar ach1, schar ach2, int32_t repeat UNUSED)
|
||||
{
|
||||
int reslt = 0;
|
||||
const char *filename;
|
||||
char resourcename[120], buf[PATHLEN];
|
||||
int findsound_approach = sff_base_only;
|
||||
@@ -108,27 +107,27 @@ windsound_achievement(schar ach1, schar ach2, int32_t repeat)
|
||||
filename = base_soundname_to_filename(resourcename,
|
||||
buf, sizeof buf, findsound_approach);
|
||||
if (filename) {
|
||||
reslt = PlaySound(filename, NULL, fdwsound);
|
||||
(void) PlaySound(filename, NULL, fdwsound);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
windsound_ambience(int32_t ambienceid, int32_t ambience_action,
|
||||
int32_t hero_proximity)
|
||||
windsound_ambience(int32_t ambienceid UNUSED, int32_t ambience_action UNUSED,
|
||||
int32_t hero_proximity UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
windsound_verbal(char *text, int32_t gender, int32_t tone,
|
||||
int32_t vol, int32_t moreinfo)
|
||||
windsound_verbal(char *text UNUSED, int32_t gender UNUSED, int32_t tone UNUSED,
|
||||
int32_t vol UNUSED, int32_t moreinfo UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
windsound_soundeffect(char *desc, int32_t seid, int32_t volume)
|
||||
windsound_soundeffect(char *desc UNUSED, int32_t seid, int32_t volume UNUSED)
|
||||
{
|
||||
#ifdef SND_SOUNDEFFECTS_AUTOMAP
|
||||
int reslt = 0;
|
||||
/* int reslt = 0; */
|
||||
int32_t findsound_approach = sff_base_only;
|
||||
char buf[PATHLEN];
|
||||
const char *filename;
|
||||
@@ -147,7 +146,7 @@ windsound_soundeffect(char *desc, int32_t seid, int32_t volume)
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
reslt = PlaySound(filename, NULL, fdwsound);
|
||||
(void) PlaySound(filename, NULL, fdwsound);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -155,7 +154,7 @@ windsound_soundeffect(char *desc, int32_t seid, int32_t volume)
|
||||
#define WAVEMUSIC_SOUNDS
|
||||
|
||||
static void
|
||||
windsound_hero_playnotes(int32_t instrument, const char *str, int32_t volume)
|
||||
windsound_hero_playnotes(int32_t instrument, const char *str, int32_t volume UNUSED)
|
||||
{
|
||||
#ifdef WAVEMUSIC_SOUNDS
|
||||
int reslt = 0;
|
||||
@@ -239,6 +238,8 @@ windsound_hero_playnotes(int32_t instrument, const char *str, int32_t volume)
|
||||
/* the final, or only, one is played ASYNC */
|
||||
maybe_preinsert_directory(findsound_approach, exedir, buf, sizeof buf);
|
||||
reslt = PlaySound(buf, NULL, fdwsound);
|
||||
nhUse(filename);
|
||||
nhUse(reslt);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -334,15 +334,19 @@ else
|
||||
DLBFLG =
|
||||
endif
|
||||
|
||||
|
||||
ifeq "$(GCC_EXTRA_WARNINGS)" "Y"
|
||||
#
|
||||
# These match the warnings enabled on the linux.370 and macOS.370 hints builds
|
||||
#
|
||||
CFLAGSXTRA = -Wall -Wextra -Wno-missing-field-initializers -Wreturn-type \
|
||||
-Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -pedantic \
|
||||
-Wmissing-declarations -Wformat-nonliteral -Wunreachable-code \
|
||||
-Wimplicit -Wimplicit-function-declaration -Wimplicit-int \
|
||||
-Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes
|
||||
CFLAGSXTRA = -Wall -Wextra -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow \
|
||||
-Wwrite-strings -pedantic -Wmissing-declarations \
|
||||
-Wformat-nonliteral -Wunreachable-code -Wimplicit \
|
||||
-Wimplicit-function-declaration -Wimplicit-int \
|
||||
-Wmissing-prototypes -Wold-style-definition \
|
||||
-Wstrict-prototypes -Wnonnull -Wformat-overflow \
|
||||
-Wmissing-parameter-type -Wimplicit-fallthrough
|
||||
|
||||
CPPFLAGSXTRA = -Wall -Wextra -Wno-missing-field-initializers -Wreturn-type \
|
||||
-Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -pedantic \
|
||||
-Wmissing-declarations -Wformat-nonliteral -Wunreachable-code
|
||||
|
||||
@@ -69,7 +69,7 @@ void windows_nhbell(void);
|
||||
int windows_nh_poskey(int *, int *, int *);
|
||||
void windows_raw_print(const char *);
|
||||
char windows_yn_function(const char *, const char *, char);
|
||||
static void windows_getlin(const char *, char *);
|
||||
/* static void windows_getlin(const char *, char *); */
|
||||
|
||||
#ifdef WIN32CON
|
||||
extern int windows_console_custom_nhgetch(void);
|
||||
@@ -116,6 +116,11 @@ void copy_sysconf_content(void);
|
||||
void copy_config_content(void);
|
||||
void copy_hack_content(void);
|
||||
void copy_symbols_content(void);
|
||||
void copy_file(const char *, const char *,
|
||||
const char *, const char *, boolean);
|
||||
void update_file(const char *, const char *,
|
||||
const char *, const char *, BOOL);
|
||||
void windows_raw_print_bold(const char *);
|
||||
|
||||
#ifdef PORT_HELP
|
||||
void port_help(void);
|
||||
@@ -150,6 +155,7 @@ DISABLE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
#if defined(MSWIN_GRAPHICS)
|
||||
#define MAIN nethackw_main
|
||||
int nethackw_main(int, char **);
|
||||
#else
|
||||
#define MAIN main
|
||||
#endif
|
||||
@@ -369,7 +375,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
(void) fname_encode(
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", '%',
|
||||
fnamebuf, encodedfnamebuf, BUFSZ);
|
||||
Sprintf(gl.lock, "%s", encodedfnamebuf);
|
||||
Snprintf(gl.lock, sizeof gl.lock, "%s", encodedfnamebuf);
|
||||
/* regularize(lock); */ /* we encode now, rather than substitute */
|
||||
if ((getlock_result = getlock()) == 0)
|
||||
nethack_exit(EXIT_SUCCESS);
|
||||
@@ -631,6 +637,7 @@ process_options(int argc, char * argv[])
|
||||
} else
|
||||
raw_printf("\nUnknown switch: %s", argv[0]);
|
||||
FALLTHROUGH;
|
||||
/* FALLTHRU */
|
||||
case '?':
|
||||
nhusage();
|
||||
nethack_exit(EXIT_SUCCESS);
|
||||
@@ -989,6 +996,7 @@ copy_symbols_content(void)
|
||||
copy_file(gf.fqn_prefix[SYSCONFPREFIX], SYMBOLS,
|
||||
gf.fqn_prefix[SYSCONFPREFIX], SYMBOLS_TEMPLATE, TRUE);
|
||||
}
|
||||
nhUse(no_template);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1107,10 +1115,10 @@ boolean
|
||||
fakeconsole(void)
|
||||
{
|
||||
if (!hStdOut) {
|
||||
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
HANDLE fkhStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
HANDLE fkhStdIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
|
||||
if (!hStdOut && !hStdIn) {
|
||||
if (!fkhStdOut && !fkhStdIn) {
|
||||
/* Bool rval; */
|
||||
AllocConsole();
|
||||
AttachConsole(GetCurrentProcessId());
|
||||
@@ -1277,11 +1285,13 @@ windows_yn_function(const char *query UNUSED, const char *resp UNUSED,
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
#if 0
|
||||
static void
|
||||
windows_getlin(const char *prompt UNUSED, char *outbuf)
|
||||
{
|
||||
Strcpy(outbuf, "\033");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PC_LOCKING
|
||||
static int
|
||||
|
||||
@@ -1022,7 +1022,8 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
pFile = _tfopen(filename, TEXT("wt+,ccs=UTF-8"));
|
||||
if (!pFile) {
|
||||
TCHAR buf[4096];
|
||||
_stprintf(buf, TEXT("Cannot open %s for writing!"), filename);
|
||||
nh_stprintf(buf, sizeof buf,
|
||||
TEXT("Cannot open %s for writing!"), filename);
|
||||
NHMessageBox(hWnd, buf, MB_OK | MB_ICONERROR);
|
||||
if (text)
|
||||
free(text);
|
||||
|
||||
@@ -1188,9 +1188,11 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
&& data->menui.menu.items[lpdis->itemID].count != 0
|
||||
&& item->glyphinfo.glyph != NO_GLYPH) {
|
||||
if (data->menui.menu.items[lpdis->itemID].count == -1) {
|
||||
_stprintf(wbuf, TEXT("Count: All"));
|
||||
nh_stprintf(wbuf, sizeof wbuf,
|
||||
TEXT("Count: All"));
|
||||
} else {
|
||||
_stprintf(wbuf, TEXT("Count: %d"),
|
||||
nh_stprintf(wbuf, sizeof wbuf,
|
||||
TEXT("Count: %d"),
|
||||
data->menui.menu.items[lpdis->itemID].count);
|
||||
}
|
||||
|
||||
|
||||
@@ -1061,7 +1061,8 @@ mswin_display_file(const char *filename, boolean must_exist)
|
||||
if (!f) {
|
||||
if (must_exist) {
|
||||
TCHAR message[90];
|
||||
_stprintf(message, TEXT("Warning! Could not find file: %s\n"),
|
||||
nh_stprintf(message, sizeof message,
|
||||
TEXT("Warning! Could not find file: %s\n"),
|
||||
NH_A2W(filename, wbuf, sizeof(wbuf)));
|
||||
NHMessageBox(GetNHApp()->hMainWnd, message,
|
||||
MB_OK | MB_ICONEXCLAMATION);
|
||||
|
||||
@@ -249,12 +249,14 @@ extern COLORREF message_fg_color;
|
||||
/* unicode stuff */
|
||||
#define NH_CODEPAGE (SYMHANDLING(H_IBM) ? GetOEMCP() : GetACP())
|
||||
#ifdef _UNICODE
|
||||
#define nh_stprintf swprintf
|
||||
#define NH_W2A(w, a, cb) \
|
||||
(WideCharToMultiByte(NH_CODEPAGE, 0, (w), -1, (a), (cb), NULL, NULL), (a))
|
||||
|
||||
#define NH_A2W(a, w, cb) \
|
||||
(MultiByteToWideChar(NH_CODEPAGE, 0, (a), -1, (w), (cb)), (w))
|
||||
#else
|
||||
#define nh_stprintf snprintf
|
||||
#define NH_W2A(w, a, cb) (strncpy((a), (w), (cb)))
|
||||
|
||||
#define NH_A2W(a, w, cb) (strncpy((w), (a), (cb)))
|
||||
|
||||
Reference in New Issue
Block a user