From 3aa4d145ab3a3100f5c18890e398a38725c23fa7 Mon Sep 17 00:00:00 2001 From: Hourier Date: Sun, 22 Mar 2020 14:47:31 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#40274=20WIN32=E3=81=AE=E3=83=97?= =?utf8?q?=E3=83=AA=E3=83=97=E3=83=AD=E3=81=8C=E6=9C=89=E5=8A=B9=E3=81=A7?= =?utf8?q?=E3=81=82=E3=82=8B=E3=81=93=E3=81=A8=E3=82=92=E5=89=8D=E6=8F=90?= =?utf8?q?=E3=81=A8=E3=81=97=E3=80=81main-win.c=20=E3=81=8B=E3=82=89?= =?utf8?q?=E3=83=97=E3=83=AA=E3=83=97=E3=83=AD=E8=87=AA=E4=BD=93=E3=82=92?= =?utf8?q?=E5=89=8A=E9=99=A4=20/=20Removed=20WIN32=20but=20existing=20code?= =?utf8?q?s=20are=20as-is=20in=20main-win.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main-win.c | 114 ++------------------------------------------------------- src/readdib.c | 9 ----- 2 files changed, 3 insertions(+), 120 deletions(-) diff --git a/src/main-win.c b/src/main-win.c index 0faa3df3c..d81d3cde7 100644 --- a/src/main-win.c +++ b/src/main-win.c @@ -123,15 +123,6 @@ #include "dungeon.h" /* - * Extract the "WIN32" flag from the compiler - */ -#if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__) -# ifndef WIN32 -# define WIN32 -# endif -#endif - -/* * Available graphic modes */ #define GRAPHICS_NONE 0 @@ -294,6 +285,8 @@ #define MMNOMMIO /* Multimedia file I/O support */ #define MMNOMMSYSTEM /* General MMSYSTEM functions */ +#define INVALID_FILE_NAME (DWORD)0xFFFFFFFF + /* * Standard sound names */ @@ -409,23 +402,7 @@ const concptr angband_music_basic_name[MUSIC_BASIC_MAX] = */ #include "readdib.h" - /* - * Hack -- Fake declarations from "dos.h" - */ -#ifdef WIN32 -#define INVALID_FILE_NAME (DWORD)0xFFFFFFFF -#else /* WIN32 */ -#define FA_LABEL 0x08 /* Volume label */ -#define FA_DIREC 0x10 /* Directory */ -unsigned _cdecl _dos_getfileattr(concptr, unsigned *); -#endif /* WIN32 */ - -/* - * Silliness in WIN32 drawing routine - */ -#ifdef WIN32 -# define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL) -#endif /* WIN32 */ +#define MoveTo(H,X,Y) MoveToEx(H, X, Y, NULL) /* * Silliness for Windows 95 @@ -825,22 +802,11 @@ static void DrawBG(HDC hdc, RECT *r) static bool check_file(concptr s) { char path[1024]; - -#ifdef WIN32 - DWORD attrib; -#else /* WIN32 */ - - unsigned int attrib; - -#endif /* WIN32 */ - /* Copy it */ strcpy(path, s); -#ifdef WIN32 - /* Examine */ attrib = GetFileAttributes(path); @@ -850,19 +816,6 @@ static bool check_file(concptr s) /* Prohibit directory */ if (attrib & FILE_ATTRIBUTE_DIRECTORY) return FALSE; -#else /* WIN32 */ - - /* Examine and verify */ - if (_dos_getfileattr(path, &attrib)) return FALSE; - - /* Prohibit something */ - if (attrib & FA_LABEL) return FALSE; - - /* Prohibit directory */ - if (attrib & FA_DIREC) return FALSE; - -#endif /* WIN32 */ - /* Success */ return TRUE; } @@ -876,17 +829,8 @@ static bool check_dir(concptr s) int i; char path[1024]; - -#ifdef WIN32 - DWORD attrib; -#else /* WIN32 */ - - unsigned int attrib; - -#endif /* WIN32 */ - /* Copy it */ strcpy(path, s); @@ -896,8 +840,6 @@ static bool check_dir(concptr s) /* Remove trailing backslash */ if (i && (path[i - 1] == '\\')) path[--i] = '\0'; -#ifdef WIN32 - /* Examine */ attrib = GetFileAttributes(path); @@ -907,19 +849,6 @@ static bool check_dir(concptr s) /* Require directory */ if (!(attrib & FILE_ATTRIBUTE_DIRECTORY)) return FALSE; -#else /* WIN32 */ - - /* Examine and verify */ - if (_dos_getfileattr(path, &attrib)) return FALSE; - - /* Prohibit something */ - if (attrib & FA_LABEL) return FALSE; - - /* Require directory */ - if (!(attrib & FA_DIREC)) return FALSE; - -#endif /* WIN32 */ - /* Success */ return TRUE; } @@ -2152,17 +2081,8 @@ static errr term_xtra_win_sound(int v) /* Build the path */ path_build(buf, 1024, ANGBAND_DIR_XTRA_SOUND, sound_file[v][Rand_external(i)]); -#ifdef WIN32 - /* Play the sound, catch errors */ return (PlaySound(buf, 0, SND_FILENAME | SND_ASYNC)); - -#else /* WIN32 */ - - /* Play the sound, catch errors */ - return (sndPlaySound(buf, SND_ASYNC)); - -#endif /* WIN32 */ } /* @@ -2230,8 +2150,6 @@ static errr term_xtra_win_music(int n, int v) current_music_type = n; current_music_id = v; -#ifdef WIN32 - mop.lpstrDeviceType = mci_device_type; mop.lpstrElementName = buf; mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0); @@ -2240,8 +2158,6 @@ static errr term_xtra_win_music(int n, int v) mciSendCommand(mop.wDeviceID, MCI_SEEK, MCI_SEEK_TO_START, 0); mciSendCommand(mop.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mop); return 0; - -#endif /* WIN32 */ } @@ -2250,33 +2166,9 @@ static errr term_xtra_win_music(int n, int v) */ static int term_xtra_win_delay(int v) { - -#ifdef WIN32 - /* Sleep */ Sleep(v); -#else /* WIN32 */ - - DWORD t; - MSG msg; - - /* Final count */ - t = GetTickCount() + v; - - /* Wait for it */ - while (GetTickCount() < t) - { - /* Handle messages */ - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - -#endif /* WIN32 */ - /* Success */ return 0; } diff --git a/src/readdib.c b/src/readdib.c index b7ad98ffc..e5e7b0380 100644 --- a/src/readdib.c +++ b/src/readdib.c @@ -25,15 +25,6 @@ #include "readdib.h" /* - * Extract the "WIN32" flag from the compiler - */ -#if defined(__WIN32__) || defined(__WINNT__) || defined(__NT__) -# ifndef WIN32 -# define WIN32 -# endif -#endif - -/* * Needed for lcc-win32 */ #ifndef SEEK_SET -- 2.11.0