From a90185bea9058051aac0abbaf02eccff1750da88 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 3 Feb 2020 21:30:57 +0100 Subject: [PATCH] - cleaned up the remaining dependencies on windows.h This file now only gets included by code that really needs it. --- source/blood/src/blood.cpp | 9 -- source/blood/src/network.cpp | 6 +- source/build/include/compat.h | 4 - source/build/include/windows_inc.h | 144 --------------------- source/common/filesystem/filesystem.cpp | 4 +- source/common/gamecontrol.cpp | 8 +- source/common/utility/files_decompress.cpp | 1 + source/duke3d/src/game.cpp | 9 -- source/duke3d/src/mdump.h | 26 ---- source/duke3d/src/network.cpp | 5 +- source/duke3d/src/player.cpp | 4 +- source/g_pch.h | 19 +-- source/rr/src/game.cpp | 9 -- source/rr/src/mdump.h | 26 ---- source/rr/src/net.cpp | 6 +- source/rr/src/player.cpp | 1 - source/sw/src/common.cpp | 4 - 17 files changed, 20 insertions(+), 265 deletions(-) delete mode 100644 source/build/include/windows_inc.h delete mode 100644 source/duke3d/src/mdump.h delete mode 100644 source/rr/src/mdump.h diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index cbc374bd6..937251eff 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -73,15 +73,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "menu/menu.h" #include "sound/s_soundinternal.h" -#ifdef _WIN32 -# include -# define UPDATEINTERVAL 604800 // 1w -#else -# ifndef GEKKO -# include -# endif -#endif /* _WIN32 */ - BEGIN_BLD_NS diff --git a/source/blood/src/network.cpp b/source/blood/src/network.cpp index b81ae717c..76dab0cd7 100644 --- a/source/blood/src/network.cpp +++ b/source/blood/src/network.cpp @@ -21,13 +21,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #include "ns.h" // Must come before everything else! +#ifndef NETCODE_DISABLE +#include "enet.h" +#endif #include "build.h" #include "mmulti.h" #include "pragmas.h" -#ifndef NETCODE_DISABLE -#include "enet.h" -#endif #include "compat.h" #include "config.h" #include "controls.h" diff --git a/source/build/include/compat.h b/source/build/include/compat.h index f03324229..36ac8e7f0 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -7,10 +7,6 @@ #pragma once -#ifdef _WIN32 -# include "windows_inc.h" -#endif - #include "xs_Float.h" ////////// Compiler detection ////////// diff --git a/source/build/include/windows_inc.h b/source/build/include/windows_inc.h deleted file mode 100644 index 2cc281ab3..000000000 --- a/source/build/include/windows_inc.h +++ /dev/null @@ -1,144 +0,0 @@ -// Wrapper for all Windows headers. -// No include guard for this file. - -#ifndef _WIN32_IE -# define _WIN32_IE 0x0501 -#endif - -#ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0501 -#endif - -#ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif - -#ifndef NOMINMAX -# define NOMINMAX -#endif - -#ifdef UNREFERENCED_PARAMETER -# undef UNREFERENCED_PARAMETER -#endif - -#ifdef NEED_WINSOCK2_H -# include -# undef NEED_WINSOCK2_H -#endif - -#include - -#ifdef NEED_WINDOWSX_H -# include -# undef NEED_WINDOWSX_H -#endif - -#ifdef NEED_PROCESS_H -# include -# undef NEED_PROCESS_H -#endif - -#ifdef NEED_SHELLAPI_H -# include -# undef NEED_SHELLAPI_H -#endif - -#ifdef NEED_SHLWAPI_H -# include -# undef NEED_SHLWAPI_H -#endif - -#ifdef NEED_SHLOBJ_H -# include -# undef NEED_SHLOBJ_H -#endif - -#ifdef NEED_WS2TCPIP_H -# include -# undef NEED_WS2TCPIP_H -#endif - -#ifdef NEED_COMMCTRL_H -# include -# undef NEED_COMMCTRL_H -#endif - -#ifdef NEED_MMSYSTEM_H -# include -# undef NEED_MMSYSTEM_H -#endif - -#ifdef NEED_DDRAW_H -# define DIRECTDRAW_VERSION 0x0600 -# ifndef CINTERFACE -# define CINTERFACE -# endif -# include -# undef NEED_DDRAW_H -#endif - -#ifdef NEED_DINPUT_H -# define INITGUID -# define DIRECTINPUT_VERSION 0x0700 -# ifndef CINTERFACE -# define CINTERFACE -# endif -# include -# undef NEED_DINPUT_H - -# if defined (_MSC_VER) || !defined(__cplusplus) -# define bDIPROP_BUFFERSIZE MAKEDIPROP(1) -# define bDIPROP_DEADZONE MAKEDIPROP(5) -# define bDIPROP_SATURATION MAKEDIPROP(6) -# else -# define bMAKEDIPROP(prop) ((REFGUID)(prop)) -# define bDIPROP_BUFFERSIZE bMAKEDIPROP(1) -# define bDIPROP_DEADZONE bMAKEDIPROP(5) -# define bDIPROP_SATURATION bMAKEDIPROP(6) -# endif - -# if defined (_MSC_VER) && defined(__cplusplus) -# define bREFGUID (REFGUID) -# define bREFIID (REFIID) -# else -# define bREFGUID & -# define bREFIID & -# endif - -# ifndef DIK_PAUSE -# define DIK_PAUSE 0xC5 -# endif - -#endif - -#ifdef NEED_DSOUND_H -# define DIRECTSOUND_VERSION 0x0800 -# ifndef CINTERFACE -# define CINTERFACE -# endif -# include -# undef NEED_DSOUND_H -#endif - -#ifdef NEED_CRTDBG_H -# include -# undef NEED_CRTDBG_H -#endif - -#ifdef NEED_DBGHELP_H -# if defined _MSC_VER && _MSC_VER < 1300 -# define DECLSPEC_DEPRECATED -// VC6: change this path to your Platform SDK headers. -// must be XP version of file -// # include "M:\\dev7\\vs\\devtools\\common\\win32sdk\\include\\dbghelp.h" -# error "VC6 needs an updated dbghelp.h; see source" -# else -// VC7: ships with updated headers -# include -# endif -# undef NEED_DBGHELP_H -#endif - -#ifndef UNREFERENCED_PARAMETER -# define UNREFERENCED_PARAMETER(x) (x) = (x) -#endif diff --git a/source/common/filesystem/filesystem.cpp b/source/common/filesystem/filesystem.cpp index 5594966ed..5d31560ed 100644 --- a/source/common/filesystem/filesystem.cpp +++ b/source/common/filesystem/filesystem.cpp @@ -1102,7 +1102,6 @@ FString::FString (ELumpNum lumpnum) //#define WIN32_LEAN_AND_MEAN //#include -#if 0 extern "C" { __declspec(dllimport) unsigned long __stdcall FormatMessageA( unsigned long dwFlags, @@ -1116,7 +1115,6 @@ __declspec(dllimport) unsigned long __stdcall FormatMessageA( __declspec(dllimport) void * __stdcall LocalFree (void *); __declspec(dllimport) unsigned long __stdcall GetLastError (); } -#endif static void PrintLastError () { @@ -1127,7 +1125,7 @@ static void PrintLastError () NULL, GetLastError(), 1 << 10 /*MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)*/, // Default language - (LPSTR)&lpMsgBuf, + (char **)&lpMsgBuf, 0, NULL ); diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index c925e72ef..fd38c2fdf 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -835,9 +835,7 @@ void I_Error(const char* error, ...) va_start(argptr, error); vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); va_end(argptr); -#ifdef _WIN32 - OutputDebugStringA(errortext); -#endif + I_DebugPrint(errortext); throw std::runtime_error(errortext); } @@ -850,9 +848,7 @@ void I_FatalError(const char* error, ...) va_start(argptr, error); vsnprintf(errortext, MAX_ERRORTEXT, error, argptr); va_end(argptr); -#ifdef _WIN32 - OutputDebugStringA(errortext); -#endif + I_DebugPrint(errortext); throw std::runtime_error(errortext); } diff --git a/source/common/utility/files_decompress.cpp b/source/common/utility/files_decompress.cpp index c6707a283..5cdf69af1 100644 --- a/source/common/utility/files_decompress.cpp +++ b/source/common/utility/files_decompress.cpp @@ -34,6 +34,7 @@ */ // Caution: LzmaDec also pulls in windows.h! +#define NOMINMAX #include "LzmaDec.h" #include #include diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index fae055351..c31a87189 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -64,15 +64,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # define GAME_STATIC static #endif -#ifdef _WIN32 -# include -# define UPDATEINTERVAL 604800 // 1w -#else -# ifndef GEKKO -# include -# endif -#endif /* _WIN32 */ - BEGIN_DUKE_NS int32_t g_quitDeadline = 0; diff --git a/source/duke3d/src/mdump.h b/source/duke3d/src/mdump.h deleted file mode 100644 index be6463b55..000000000 --- a/source/duke3d/src/mdump.h +++ /dev/null @@ -1,26 +0,0 @@ - -#define NEED_DBGHELP_H -#define NEED_MMSYSTEM_H -#include "windows_inc.h" - -BEGIN_DUKE_NS - -// based on dbghelp.h -typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, - CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, - CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, - CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam - ); - -class MiniDumper -{ -private: - static LPCSTR m_szAppName; - - static LONG WINAPI TopLevelFilter( struct _EXCEPTION_POINTERS *pExceptionInfo ); - -public: - MiniDumper( LPCSTR szAppName ); -}; - -END_DUKE_NS diff --git a/source/duke3d/src/network.cpp b/source/duke3d/src/network.cpp index b45f0a86a..ab83926d1 100644 --- a/source/duke3d/src/network.cpp +++ b/source/duke3d/src/network.cpp @@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! +#ifndef NETWORK_DISABLE +#include "enet.h" +#endif + /// Preprocessor directives: /// /// ITERATE_ON_UPDATE: Every time the netcode updates the sprite linked lists, attempt to iterate through all of them. @@ -39,7 +43,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecvars.h" #include "mapinfo.h" -#include "enet.h" #include "m_crc32.h" BEGIN_DUKE_NS diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index 12887f4c3..b7e8044a6 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -21,10 +21,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" // Must come before everything else! +#ifndef NETWORK_DISABLE +#include "enet.h" +#endif #include "duke3d.h" #include "demo.h" -#include "enet.h" #include "sjson.h" #include "gamecvars.h" #include "d_event.h" diff --git a/source/g_pch.h b/source/g_pch.h index 1894bff17..db20b29f9 100644 --- a/source/g_pch.h +++ b/source/g_pch.h @@ -1,14 +1,3 @@ -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#include // Ugh... This needs to go away but since some of the headers pull it in the compilation is creepingly slow without this. - -#ifdef min -#undef min -#undef max -#endif -#endif - #include #include #include @@ -26,10 +15,6 @@ #include #include #include -#ifdef _MSC_VER -#include -#include -#endif // _MSC_VER #include #include #include @@ -40,5 +25,5 @@ // These two headers get included nearly everywhere so it doesn't matter if changing them forces a few more recompiles. // The overall savings from PCHing them are more significant. -//#include "tarray.h" -//#include "zstring.h" +#include "tarray.h" +#include "zstring.h" diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 65a5d600d..e291cefaf 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -61,15 +61,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # define GAME_STATIC static #endif -#ifdef _WIN32 -# include -# define UPDATEINTERVAL 604800 // 1w -#else -# ifndef GEKKO -# include -# endif -#endif /* _WIN32 */ - BEGIN_RR_NS diff --git a/source/rr/src/mdump.h b/source/rr/src/mdump.h deleted file mode 100644 index 0b4e0fd1a..000000000 --- a/source/rr/src/mdump.h +++ /dev/null @@ -1,26 +0,0 @@ - -#define NEED_DBGHELP_H -#define NEED_MMSYSTEM_H -#include "windows_inc.h" - -BEGIN_RR_NS - -// based on dbghelp.h -typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, - CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, - CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, - CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam - ); - -class MiniDumper -{ -private: - static LPCSTR m_szAppName; - - static LONG WINAPI TopLevelFilter( struct _EXCEPTION_POINTERS *pExceptionInfo ); - -public: - MiniDumper( LPCSTR szAppName ); -}; - -END_RR_NS diff --git a/source/rr/src/net.cpp b/source/rr/src/net.cpp index 27881aef8..e89bcab01 100644 --- a/source/rr/src/net.cpp +++ b/source/rr/src/net.cpp @@ -21,6 +21,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" // Must come before everything else! +#ifndef NETWORK_DISABLE +#include "enet.h" +#endif + #include "duke3d.h" #include "game.h" #include "gamedef.h" @@ -31,8 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "m_crc32.h" #include "mapinfo.h" -#include "enet.h" - BEGIN_RR_NS #define TIMERUPDATESIZ 32 diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index 20a092a9c..71870ea0e 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "duke3d.h" #include "demo.h" -#include "enet.h" #include "d_event.h" BEGIN_RR_NS diff --git a/source/sw/src/common.cpp b/source/sw/src/common.cpp index 00877fbec..5ee30c35c 100644 --- a/source/sw/src/common.cpp +++ b/source/sw/src/common.cpp @@ -2,10 +2,6 @@ #include "build.h" -#ifdef _WIN32 -# include "windows_inc.h" -#endif - #include "common.h" #include "common_game.h"