diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 406efda73..43e4011a8 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -539,7 +539,7 @@ endif() set( PLAT_WIN32_SOURCES audiolib/src/driver_directsound.cpp glad/src/glad_wgl.c - build/src/winbits.cpp + platform/win32/winbits.cpp duke3d/src/startwin.game.cpp rr/src/startwin.game.cpp @@ -689,7 +689,6 @@ file( GLOB HEADER_FILES # without being compiled. set( NOT_COMPILED_SOURCE_FILES ${OTHER_SYSTEM_SOURCES} - build/src/mingw_main.cpp build/src/sdlkeytrans.cpp duke3d/src/gamestructures.cpp rr/src/gamestructures.cpp @@ -828,7 +827,6 @@ set (PCH_SOURCES build/src/textfont.cpp build/src/tiles.cpp build/src/timer.cpp - build/src/vfs.cpp build/src/voxmodel.cpp duke3d/src/actors.cpp @@ -1024,6 +1022,7 @@ include_directories( libsmackerdec/include thirdparty/include common/utility + platform ${CMAKE_BINARY_DIR}/libraries/gdtoa ${CMAKE_BINARY_DIR}/libraries/enet diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 2bf999b0e..9bc5186cd 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -72,7 +72,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifdef _WIN32 # include # define UPDATEINTERVAL 604800 // 1w -# include "winbits.h" +# include "win32/winbits.h" #else # ifndef GEKKO # include @@ -1440,8 +1440,6 @@ int app_main(int argc, char const * const * argv) margv = argv; #ifdef _WIN32 - backgroundidle = 0; - G_ExtPreInit(argc, argv); #ifdef DEBUGGINGAIDS diff --git a/source/blood/src/common.cpp b/source/blood/src/common.cpp index 2c5b62075..b31aa15dc 100644 --- a/source/blood/src/common.cpp +++ b/source/blood/src/common.cpp @@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifdef _WIN32 # define NEED_SHLWAPI_H # include "windows_inc.h" -# include "winbits.h" +# include "win32/winbits.h" # ifndef KEY_WOW64_64KEY # define KEY_WOW64_64KEY 0x0100 # endif diff --git a/source/build/include/winbits.h b/source/build/include/winbits.h deleted file mode 100644 index e21e99516..000000000 --- a/source/build/include/winbits.h +++ /dev/null @@ -1,23 +0,0 @@ -// Windows layer-independent code - -#include "compat.h" - -#ifdef APPNAME -# define WindowClass APPNAME -#else -# define WindowClass "buildapp" -#endif - -extern int32_t backgroundidle; // set to 1 to tell winlayer to go to idle priority when inactive - -extern int64_t win_timerfreq; - -extern char silentvideomodeswitch; - -extern void win_init(void); -extern void win_setvideomode(int32_t c); -extern void win_uninit(void); - -extern int32_t addsearchpath_ProgramFiles(const char *p); - -extern int32_t win_buildargs(char **argvbuf); \ No newline at end of file diff --git a/source/build/src/mingw_main.cpp b/source/build/src/mingw_main.cpp deleted file mode 100644 index 4e5548ce0..000000000 --- a/source/build/src/mingw_main.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @file main.c - * Copyright 2012, 2013 MinGW.org project - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* - * Extra startup code for applications which do not have a main function - * of their own (but do have a WinMain). Generally these are GUI - * applications, but they don't *have* to be. - */ - -// Taken from mingwrt-4.0.0 src/libcrt/crt/main.c. - -#include "compat.h" - -#define ISSPACE(a) (a == ' ' || a == '\t') - -extern int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, - LPSTR szCmdLine, int nShow); - -int -main (int argc ATTRIBUTE((unused)), char *argv[] ATTRIBUTE((unused)), char **environment ATTRIBUTE((unused))) -{ - char *szCmd; - STARTUPINFO startinfo; - int nRet; - - /* Get the command line passed to the process. */ - szCmd = GetCommandLineA (); - GetStartupInfoA (&startinfo); - - /* Strip off the name of the application and any leading - * whitespace. */ - if (szCmd) - { - while (ISSPACE (*szCmd)) - { - szCmd++; - } - - /* On my system I always get the app name enclosed - * in quotes... */ - if (*szCmd == '\"') - { - do - { - szCmd++; - } - while (*szCmd != '\"' && *szCmd != '\0'); - - if (*szCmd == '\"') - { - szCmd++; - } - } - else - { - /* If no quotes then assume first token is program - * name. */ - while (!ISSPACE (*szCmd) && *szCmd != '\0') - { - szCmd++; - } - } - - while (ISSPACE (*szCmd)) - { - szCmd++; - } - } - - nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd, - (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? - startinfo.wShowWindow : SW_SHOWDEFAULT); - - return nRet; -} - diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 5d59d1b5f..b3d1c6e42 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -34,7 +34,7 @@ # include # include #elif defined _WIN32 -# include "winbits.h" +# include "win32/winbits.h" #endif #include "vfs.h" @@ -445,7 +445,7 @@ int main(int argc, char *argv[]) #ifdef _WIN32 char* argvbuf; - int32_t buildargc = win_buildargs(&argvbuf); + int32_t buildargc = win_buildargs(&argvbuf); const char** buildargv = (const char**)Xmalloc(sizeof(char*) * (buildargc + 1)); char* wp = argvbuf; @@ -691,10 +691,6 @@ void uninitsystem(void) SDL_Quit(); -#ifdef _WIN32 - win_uninit(); -#endif - #ifdef USE_OPENGL # if SDL_MAJOR_VERSION!=1 SDL_GL_UnloadLibrary(); @@ -2261,10 +2257,6 @@ int32_t handleevents_pollsdl(void) appactive = (ev.window.event == SDL_WINDOWEVENT_FOCUS_GAINED); if (g_mouseGrabbed && g_mouseEnabled) grabmouse_low(appactive); -#ifdef _WIN32 - if (backgroundidle) - SetPriorityClass(GetCurrentProcess(), appactive ? NORMAL_PRIORITY_CLASS : IDLE_PRIORITY_CLASS); -#endif break; case SDL_WINDOWEVENT_MOVED: diff --git a/source/build/src/vfs.cpp b/source/build/src/vfs.cpp deleted file mode 100644 index 83d035f35..000000000 --- a/source/build/src/vfs.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -#include "vfs.h" -#include "cache1d.h" - -#ifdef USE_PHYSFS - -int32_t numgroupfiles; - -void uninitgroupfile(void) -{ - PHYSFS_deinit(); -} - -#include - -int32_t klseek(buildvfs_kfd handle, int32_t offset, int32_t whence) -{ - // TODO: replace klseek calls with _{abs,cur,end} versions - - if (whence == SEEK_CUR) - offset += PHYSFS_tell(handle); - else if (whence == SEEK_END) - offset += PHYSFS_fileLength(handle); - - PHYSFS_seek(handle, offset); - return PHYSFS_tell(handle); -} - -#endif diff --git a/source/duke3d/src/common.cpp b/source/duke3d/src/common.cpp index c4ce9a888..93b932669 100644 --- a/source/duke3d/src/common.cpp +++ b/source/duke3d/src/common.cpp @@ -16,7 +16,7 @@ #ifdef _WIN32 # define NEED_SHLWAPI_H # include "windows_inc.h" -# include "winbits.h" +# include "win32/winbits.h" # ifndef KEY_WOW64_64KEY # define KEY_WOW64_64KEY 0x0100 # endif diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index b12ae2633..b5c97e423 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -60,7 +60,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifdef _WIN32 # include # define UPDATEINTERVAL 604800 // 1w -# include "winbits.h" +# include "win32/winbits.h" #else # ifndef GEKKO # include @@ -6370,8 +6370,6 @@ int app_main(int argc, char const * const * argv) #ifdef _WIN32 - backgroundidle = 0; - #ifndef USE_PHYSFS #ifdef DEBUGGINGAIDS extern int32_t (*check_filename_casing_fn)(void); diff --git a/source/build/src/winbits.cpp b/source/platform/win32/winbits.cpp similarity index 59% rename from source/build/src/winbits.cpp rename to source/platform/win32/winbits.cpp index 83b7cbe9f..02bc08f53 100644 --- a/source/build/src/winbits.cpp +++ b/source/platform/win32/winbits.cpp @@ -5,54 +5,26 @@ #include "baselayer.h" #include "osd.h" #include "cache1d.h" - - - +#include "zstring.h" #include "winbits.h" -int32_t backgroundidle = 1; - -char silentvideomodeswitch = 0; - -static char taskswitching = 1; - -static OSVERSIONINFOEXA osv; - -static int32_t togglecomp = 0; - -FARPROC pwinever; - // -// CheckWinVersion() -- check to see what version of Windows we happen to be running under +// CheckWinVersion() -- check to see what version of Windows we happen to be running under (stripped down to what is actually still supported.) // -static void win_printversion(void) +void win_init(void) { const char *ver = ""; + OSVERSIONINFOEXA osv; + osv.dwOSVersionInfoSize = sizeof(osv); + GetVersionExA((LPOSVERSIONINFOA)&osv); + switch (osv.dwPlatformId) { - case VER_PLATFORM_WIN32_WINDOWS: - if (osv.dwMinorVersion < 10) - ver = "95"; - else if (osv.dwMinorVersion < 90) - ver = "98"; - else - ver = "ME"; - break; - case VER_PLATFORM_WIN32_NT: switch (osv.dwMajorVersion) { - case 5: - switch (osv.dwMinorVersion) - { - case 0: ver = "2000"; break; - case 1: ver = "XP"; break; - case 2: ver = osv.wProductType == VER_NT_WORKSTATION ? "XP x64" : "Server 2003"; break; - } - break; - case 6: switch (osv.dwMinorVersion) { @@ -73,101 +45,33 @@ static void win_printversion(void) break; } - char *str = (char *)Xcalloc(1, 256); - int l; - - if (pwinever) - l = Bsprintf(str, "Wine %s, identifying as Windows %s", (char *)pwinever(), ver); - else - l = Bsprintf(str, "Windows %s", ver); + FStringf str("Windows %s", ver); // service packs if (osv.szCSDVersion[0]) { - str[l] = 32; - Bstrcat(&str[l], osv.szCSDVersion); + str.AppendFormat(" %s", osv.szCSDVersion); } - initprintf("Running on %s (build %lu.%lu.%lu)\n", str, osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber); - Xfree(str); + initprintf("Running on %s (build %lu.%lu.%lu)\n", str.GetChars(), osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber); } - -static void ToggleDesktopComposition(BOOL compEnable) -{ - static HMODULE hDWMApiDLL = NULL; - static HRESULT(WINAPI *aDwmEnableComposition)(UINT); - - if (!hDWMApiDLL && (hDWMApiDLL = LoadLibraryA("DWMAPI.DLL"))) - aDwmEnableComposition = (HRESULT(WINAPI *)(UINT))(void (*)(void))GetProcAddress(hDWMApiDLL, "DwmEnableComposition"); - - if (aDwmEnableComposition) - { - aDwmEnableComposition(compEnable); - if (!silentvideomodeswitch) - initprintf("%sabling desktop composition...\n", (compEnable) ? "En" : "Dis"); - } -} - -typedef void (*dllSetString)(const char*); - -void win_init(void) -{ - uint32_t i; - - static osdcvardata_t cvars_win[] = - { - { "r_togglecomposition","enable/disable toggle of desktop composition when initializing screen modes",(void *) &togglecomp, CVAR_BOOL, 0, 1 }, - }; - - for (i=0; i # define UPDATEINTERVAL 604800 // 1w -# include "winbits.h" +# include "win32/winbits.h" #else # ifndef GEKKO # include @@ -7751,8 +7751,6 @@ int app_main(int argc, char const * const * argv) #ifdef _WIN32 - backgroundidle = 0; - #ifdef DEBUGGINGAIDS extern int32_t (*check_filename_casing_fn)(void); check_filename_casing_fn = check_filename_casing;