diff --git a/mk/windoze/NetworkThrottleFix.reg b/mk/windoze/NetworkThrottleFix.reg new file mode 100644 index 000000000..f84ae2cec --- /dev/null +++ b/mk/windoze/NetworkThrottleFix.reg @@ -0,0 +1,5 @@ +REGEDIT4 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile] +"NetworkThrottlingIndex"=dword:ffffffff + diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 9be50e0dc..474a4482a 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -4138,6 +4138,10 @@ int glestMain(int argc, char** argv) { setGameVersion(glestVersionString); setGameGITVersion(getRAWGITRevisionString()); +#ifdef WIN32 + CheckPacketThrottling(); +#endif + if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true || diff --git a/source/shared_lib/include/platform/sdl/platform_util.h b/source/shared_lib/include/platform/sdl/platform_util.h index 6a6125d06..9b7a41ca6 100644 --- a/source/shared_lib/include/platform/sdl/platform_util.h +++ b/source/shared_lib/include/platform/sdl/platform_util.h @@ -109,6 +109,8 @@ void init_win32(); void done_win32(); void ontop_win32(int width, int height); +void CheckPacketThrottling(); + // The following is used for stacking tracing for windows based exceptions #if !defined(_DEBUG) && !defined(__GNUC__) diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 029e5163a..e7e6954f7 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -33,6 +33,7 @@ #include #include #include + #include #define MSG_NOSIGNAL 0 #define MSG_DONTWAIT 0 @@ -89,21 +90,6 @@ Mutex UPNP_Tools::mutexUPNP; #ifdef WIN32 -void DisablePacketThrottling() { - //Open the registry key. - wstring subKey = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Multimedia\\SystemProfile"; - HKEY keyHandle; - DWORD dwDisposition; - RegCreateKeyEx(HKEY_LOCAL_MACHINE,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition); - //Set the value. - - DWORD disableThrottle = 0xffffffff; - DWORD len = sizeof(disableThrottle); - RegSetValueEx(keyHandle, L"NetworkThrottlingIndex", 0, REG_DWORD, (const BYTE*)&disableThrottle, len); - RegCloseKey(keyHandle); -} - - #define socklen_t int #define MAXHOSTNAME 254 @@ -242,7 +228,6 @@ void DisablePacketThrottling() { SocketManager Socket::wsaManager; SocketManager::SocketManager() { - DisablePacketThrottling(); WSADATA wsaData; WORD wVersionRequested = MAKEWORD(2, 0); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("SocketManager calling WSAStartup...\n"); diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index c906c9dd2..9c1fc6fa5 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -436,4 +436,47 @@ void done_win32() { ::DestroyIcon(icon); } +void CheckPacketThrottling() { + static bool alreadyChecked = false; + if(alreadyChecked == true) { + return; + } + alreadyChecked = true; + //printf("Checking Windows Network Packet Throttle Setting...\n"); + //Open the registry key. + wstring subKey = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Multimedia\\SystemProfile"; + wstring Key = L"NetworkThrottlingIndex"; + HKEY keyHandle; + DWORD dwDesiredThrottle = 0xffffffff; + //LONG reg_result = RegCreateKeyEx(HKEY_LOCAL_MACHINE,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition); + //LONG reg_result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey.c_str(),0, KEY_ALL_ACCESS, &keyHandle); + LONG reg_result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey.c_str(),0, KEY_QUERY_VALUE, &keyHandle); + + if(reg_result != ERROR_SUCCESS) { + printf("\nError opening network throttle registry hive: %d\n",reg_result); + } + //Set the value. + + DWORD disableThrottle = 0; + DWORD len = sizeof(DWORD); + + reg_result = RegQueryValueEx(keyHandle, Key.c_str(), 0, 0, (LPBYTE) &disableThrottle, &len); + if(reg_result != ERROR_SUCCESS) { + printf("\nError opening network throttle registry key: %d\n",reg_result); + } + + if(disableThrottle != dwDesiredThrottle) { + printf("\n***WARNING*** Windows network throttling is enabled, value: %d\n",disableThrottle); + wprintf(L"Please set: HKEY_LOCAL_MACHINE\\%s\nKey: %s to the value: %X\n",subKey.c_str(),Key.c_str(),dwDesiredThrottle); + +// disableThrottle = 0xffffffff; +// reg_result = RegSetValueEx(keyHandle, L"NetworkThrottlingIndex", 0, REG_DWORD, (LPBYTE) &disableThrottle, len); +// if(reg_result != ERROR_SUCCESS) { +// printf("Error setting network throttle registry key: %d [%s]\n",reg_result,getWindowsAPIError(reg_result).c_str()); +// } + } + RegCloseKey(keyHandle); +} + + }}//end namespace