diff --git a/doc/changelog.txt b/doc/changelog.txt index b7b270a40ce..f9d29a0a2d1 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -12,6 +12,8 @@ Sim: - allow CEG trails for crashing aircraft (engine will randomly select from any generators listed in sfxTypes.crashExplosionGenerators) Lua: + - add Platform.osVersion; complements Platform.osName + - add Platform.hwConfig ! remove Game.mapHumanName ! remove UnitDefs[i].moveDef.{family,type} - let Spring.SelectUnitArray select enemy units with godmode enabled @@ -112,8 +114,61 @@ Misc: by either nested tables or 'parent' key. - IME editing support for those with the proper SDL2 version/IME tool combination ! Made lockluaui.txt obsolete: no longer necessary for it to exists in order to enable VFS for LuaUI + - use SHA2 content hashes rather than CRC32 Fixes: + - fix #6059 (units with high turnRate/brakeRate/acceleration moving unexpectedly) + - fix #4268 (add Spring.AddObjectDecal) + - fix #4755 (wrong usage of addr2line on FreeBSD) + - fix #4945 (add Spring.GetMapStartPositions) + - fix #4724 (Spring.SetUnitNeutral not informing any attackers) + - fix #5864 (gunships not limited by maxVelocity when climbing) + - fix #4515 (aircraft jitter when moving and turning) + - fix #6048 (falling features shaking on the ground instead of fully stopping) + - fix #6046 #5326 #5222 #4663 (false camera movement if entering MMB mode while moving cursor) + - fix #6019 (Spring.IsAABBInView bug) + - fix #6038 (noExplode weapons not obeying SetUnitWeaponState("range")) + - fix #6036 (no method to detect MMB camera-pan mode) + - fix #5956 (inverted mouse camera panning for Windows 10 Pro users) + - fix #6022 (uniformArray not initializing array-uniforms in gl.CreateShader) + - fix #6012 (air-transports not unloading properly) + - fix #6010 (HoverAirMoveType aircraft ignoring smooth-mesh when idle) + - fix #6009 (aircraft landing on damage-dealing water when idle) + - fix #6007 / #5989 (desyncs on CMD_UNLOAD_UNITS) + - fix #5993 (voidwater triggering water explosion effects) + - fix #5247 (maximized minimap producing graphical glitches) + - fix #5962 (minimap viewport rectangle larger than what actual screen shows) + - fix #5965 + - fix #5977 (log-system memory corruption) + - fix #5964 (shields occasionally letting projectiles pass) + - fix #5948 (memory corruption with LoadingMT=1) + - fix #5947 (PFS failure if starting square inside concave corner) + - fix #5934 (crash on malformed build-commands) + - fix #5923 (wrong external format passed to gl{BuildMipmaps,TexImage2D}) + - fix #5927 (memory corruption in text-wrapping) + - fix #2127 (units chasing after full transports) + - fix #4972 (builders doing redundant movement to clear build-sites) + - fix #5207 (units not following waypoints) + - fix #2354 (Spring.GetUnitWeaponState not matching Spring.SetUnitWeaponState due to experience) + - fix #5841 (allow setting colour of area selection for custom commands) + - fix #5884 (treat collidee as attacker on unit <-> unit collisions for UnitPreDamaged) + - fix #5716 (add Weapon::{avoid,collision}Flags to Spring.{Get,Set}UnitWeaponState) + - fix #5652 (maneuverBlockTime aircraft control parameter) + - fix #1225 (inaccurate preview range-rings) + - fix #5870 (zero-based months in rotating infolog filenames) + - fix #5862 (Spring.DestroyUnit + Spring.CreateUnit not supporting persistent ID's) + - fix #5860 (units failing to aim uphill at targets near cliff edges) + - fix #5863 (too strict matrix orthonormality check) + - fix #5855 (memory corruption when loading models) + - fix #5852 (units chasing after auto-generated targets going out of range even on hold-pos) + - fix #5854 (broken default formation-move visualization) + - fix #5851 (DynamicWater crash if foamTexture specified as .dds file) + - fix #5850 (squished loadscreens with BumpWater enabled) + - fix #5806 (CEG spikes from underwater explosions drawn on water surface) + - fix #5820 (broken by 3bd78acb00cab732af4278ed324c7ee5dbc7c517) + - fix #5805 (broken water reflections in FPS camera mode) + - fix infinite backtracking loop in PFS + - fix #5814 (broken slopemap indexing for terrain buildability tests) - fix #5803 (move goals cancelled when issued onto blocked terrain) - fix Spring.{G,S}etConfigFloat not being callable - fix Spring.GetPlayerRoster sometimes excluding active players diff --git a/rts/Lua/LuaConstPlatform.cpp b/rts/Lua/LuaConstPlatform.cpp index 5149a2c6ee2..7244269a4d2 100644 --- a/rts/Lua/LuaConstPlatform.cpp +++ b/rts/Lua/LuaConstPlatform.cpp @@ -34,10 +34,10 @@ bool LuaConstPlatform::PushEntries(lua_State* L) LuaPushNamedBool(L, "glSupportClipSpaceControl", globalRendering->supportClipSpaceControl); LuaPushNamedBool(L, "glSupportFragDepthLayout" , globalRendering->supportFragDepthLayout); - LuaPushNamedString(L, "osName", Platform::GetOSVersionStr()); + LuaPushNamedString(L, "osName", Platform::GetOSNameStr()); LuaPushNamedString(L, "osVersion", Platform::GetOSVersionStr()); LuaPushNamedString(L, "osFamily", Platform::GetOSFamilyStr()); - LuaPushNamedString(L, "hwInfo", Platform::GetHardwareStr()); + LuaPushNamedString(L, "hwConfig", Platform::GetHardwareStr()); return true; } diff --git a/rts/System/LogOutput.cpp b/rts/System/LogOutput.cpp index 37b803c2b8e..1810a3d3096 100644 --- a/rts/System/LogOutput.cpp +++ b/rts/System/LogOutput.cpp @@ -281,8 +281,8 @@ void CLogOutput::LogSystemInfo() LOG(" Spring %s", SpringVersion::GetFull().c_str()); LOG(" Build Environment: %s", SpringVersion::GetBuildEnvironment().c_str()); LOG(" Compiler Version: %s", SpringVersion::GetCompiler().c_str()); - LOG(" Operating System: %s", Platform::GetOSVersionStr().c_str()); - LOG(" Platform Hardware: %s", Platform::GetHardwareStr().c_str()); + LOG(" Operating System: %s", Platform::GetOSDisplayStr().c_str()); + LOG(" Hardware Config: %s", Platform::GetHardwareStr().c_str()); LOG(" Binary Word Size: %s", Platform::GetWordSizeStr().c_str()); LOG(" Process Clock: %s", spring_clock::GetName()); LOG(" Physical CPU Cores: %d", Threading::GetPhysicalCpuCores()); diff --git a/rts/System/Platform/Misc.cpp b/rts/System/Platform/Misc.cpp index cc462dc8a33..65085ce1ff6 100644 --- a/rts/System/Platform/Misc.cpp +++ b/rts/System/Platform/Misc.cpp @@ -340,28 +340,39 @@ namespace Platform - std::string GetOSVersionStr() + std::string GetOSNameStr() { - #if defined(WIN32) - return (GetOSDisplayString()); - #else + #if defined(WIN32) + // "Windows Vista" + return (windows::GetDisplayString(true, false, false)); + #else + // "Linux 3.16.0-45-generic" + // "Darwin 17.7.0" struct utsname info; if (uname(&info) == 0) - return (std::string(info.sysname) + " " + info.release + " " + info.version + " " + info.machine); + return (std::string(info.sysname) + " " + info.release); + #endif - #if defined(__linux__) - return "Linux"; - #elif defined(__FreeBSD__) - return "FreeBSD"; - #elif defined(__APPLE__) - return "Mac OS X"; + return {}; + } + + std::string GetOSVersionStr() + { + #if defined(WIN32) + // "Ultimate Edition, 32-bit Service Pack 1 (build 7601)" + return (windows::GetDisplayString(false, true, true)); #else - #warning improve this - return "unknown OS"; + struct utsname info; + // "#60~14.04.1-Ubuntu SMP Fri Jul 24 21:16:23 UTC 2015 (x86_64)" + // "Darwin Kernel Version 17.7.0: Wed Sep 19 21:20:59 PDT 2018; root:xnu-4570.71.8~4/RELEASE_X86_64 (x86_64)" + if (uname(&info) == 0) + return (std::string(info.version) + " (" + info.machine + ")"); + + return {}; #endif - #endif } + std::string GetOSDisplayStr() { return (GetOSNameStr() + " " + GetOSVersionStr()); } std::string GetOSFamilyStr() { #if defined(WIN32) @@ -371,7 +382,7 @@ namespace Platform #elif defined(__FreeBSD__) return "FreeBSD"; #elif defined(__APPLE__) - return "MacOSX"; + return "MacOS"; #else return "Unknown"; #endif @@ -391,7 +402,7 @@ namespace Platform } #if (defined(WIN32)) - std::string GetHardwareStr() { return (GetHardwareInfoString()); } + std::string GetHardwareStr() { return (windows::GetHardwareString()); } #else std::string GetHardwareStr() { std::string ret; diff --git a/rts/System/Platform/Misc.h b/rts/System/Platform/Misc.h index 0fe1932c5d6..f99421a17f6 100644 --- a/rts/System/Platform/Misc.h +++ b/rts/System/Platform/Misc.h @@ -79,7 +79,9 @@ std::string GetModuleFile(std::string moduleName = ""); */ std::string GetModulePath(const std::string& moduleName = ""); +std::string GetOSNameStr(); std::string GetOSVersionStr(); +std::string GetOSDisplayStr(); // name + version std::string GetOSFamilyStr(); std::string GetWordSizeStr(); std::string GetPlatformStr(); // OS family + wordsize diff --git a/rts/System/Platform/Win/WinVersion.cpp b/rts/System/Platform/Win/WinVersion.cpp index d4c67817b5f..ded7e312579 100644 --- a/rts/System/Platform/Win/WinVersion.cpp +++ b/rts/System/Platform/Win/WinVersion.cpp @@ -61,248 +61,236 @@ typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD); #define SM_SERVERR2 89 #endif -// this is a modified version of http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx -// always provide a long enough buffer -std::string GetOSDisplayString() + +// from http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx +// Windows version table mapping (as of november 2018) is as follows: +// Windows 10 : 10.0* +// Windows Server 2016 : 10.0* +// Windows 8.1 : 6.3* +// Windows Server 2012 R2 : 6.3* +// Windows 8 : 6.2 +// Windows Server 2012 : 6.2 +// Windows 7 : 6.1 +// Windows Server 2008 R2 : 6.1 +// Windows Server 2008 : 6.0 +// Windows Vista : 6.0 +// Windows Server 2003 R2 : 5.2 +// Windows Server 2003 : 5.2 +// Windows XP 64-Bit Edition: 5.2 +// Windows XP : 5.1 +// Windows 2000 : 5.0 +// +std::string windows::GetDisplayString(bool getName, bool getVersion, bool getExtra) { - OSVERSIONINFOEX osvi; - SYSTEM_INFO si; - PGNSI pGNSI; - BOOL bOsVersionInfoEx; - DWORD dwType; - - ZeroMemory(&si, sizeof(SYSTEM_INFO)); - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - if ( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) ) - return std::string("error getting Windows version"); - - // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. - - pGNSI = (PGNSI) GetProcAddress( - GetModuleHandle(TEXT("kernel32.dll")), - "GetNativeSystemInfo"); - if (NULL != pGNSI) - pGNSI(&si); - else GetSystemInfo(&si); - - if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && - osvi.dwMajorVersion > 4 ) - { - std::ostringstream oss; - oss << "Microsoft "; - - // Test for the specific product. - - if ( osvi.dwMajorVersion == 6) - { - if (osvi.dwMinorVersion == 0) { - if ( osvi.wProductType == VER_NT_WORKSTATION ) - oss << "Windows Vista "; - else oss << "Windows Server 2008 "; - } else if (osvi.dwMinorVersion == 1) { - if( osvi.wProductType == VER_NT_WORKSTATION ) - oss << "Windows 7 "; - else oss << "Windows Server 2008 R2 "; - } - - PGPI pGPI = (PGPI) GetProcAddress( - GetModuleHandle(TEXT("kernel32.dll")), - "GetProductInfo"); - - pGPI( 6, 0, 0, 0, &dwType); - - switch ( dwType ) - { - case PRODUCT_ULTIMATE: - oss << "Ultimate Edition"; - break; - case PRODUCT_HOME_PREMIUM: - oss << "Home Premium Edition"; - break; - case PRODUCT_HOME_BASIC: - oss << "Home Basic Edition"; - break; - case PRODUCT_ENTERPRISE: - oss << "Enterprise Edition"; - break; - case PRODUCT_BUSINESS: - oss << "Business Edition"; - break; - case PRODUCT_STARTER: - oss << "Starter Edition"; - break; - case PRODUCT_CLUSTER_SERVER: - oss << "Cluster Server Edition"; - break; - case PRODUCT_DATACENTER_SERVER: - oss << "Datacenter Edition"; - break; - case PRODUCT_DATACENTER_SERVER_CORE: - oss << "Datacenter Edition (core installation)"; - break; - case PRODUCT_ENTERPRISE_SERVER: - oss << "Enterprise Edition"; - break; - case PRODUCT_ENTERPRISE_SERVER_CORE: - oss << "Enterprise Edition (core installation)"; - break; - case PRODUCT_ENTERPRISE_SERVER_IA64: - oss << "Enterprise Edition for Itanium-based Systems"; - break; - case PRODUCT_SMALLBUSINESS_SERVER: - oss << "Small Business Server"; - break; - /* undocumented? - case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: - oss << "Small Business Server Premium Edition"; - break; */ - case PRODUCT_STANDARD_SERVER: - oss << "Standard Edition"; - break; - case PRODUCT_STANDARD_SERVER_CORE: - oss << "Standard Edition (core installation)"; - break; - case PRODUCT_WEB_SERVER: - oss << "Web Server Edition"; - break; - } - if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 ) - oss << ", 64-bit"; - else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL ) - oss << ", 32-bit"; - } - - if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) - { - if ( GetSystemMetrics(SM_SERVERR2) ) - oss << "Windows Server 2003 R2, "; - else if ( osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER ) - oss << "Windows Storage Server 2003"; - else if ( osvi.wProductType == VER_NT_WORKSTATION && - si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) - { - oss << "Windows XP Professional x64 Edition"; - } - else oss << "Windows Server 2003, "; - - // Test for the server type. - if ( osvi.wProductType != VER_NT_WORKSTATION ) - { - if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 ) - { - if ( osvi.wSuiteMask & VER_SUITE_DATACENTER ) - oss << "Datacenter Edition for Itanium-based Systems"; - else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) - oss << "Enterprise Edition for Itanium-based Systems"; - } - - else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 ) - { - if ( osvi.wSuiteMask & VER_SUITE_DATACENTER ) - oss << "Datacenter x64 Edition"; - else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) - oss << "Enterprise x64 Edition"; - else oss << "Standard x64 Edition"; - } - - else - { - if ( osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER ) - oss << "Compute Cluster Edition"; - else if ( osvi.wSuiteMask & VER_SUITE_DATACENTER ) - oss << "Datacenter Edition"; - else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) - oss << "Enterprise Edition" ; - else if ( osvi.wSuiteMask & VER_SUITE_BLADE ) - oss << "Web Edition"; - else oss << "Standard Edition"; - } - } - } - - if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) - { - oss << "Windows XP "; - if ( osvi.wSuiteMask & VER_SUITE_PERSONAL ) - oss << "Home Edition"; - else oss << "Professional"; - } - - if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) - { - oss << "Windows 2000 "; - - if ( osvi.wProductType == VER_NT_WORKSTATION ) - { - oss << "Professional"; - } - else - { - if ( osvi.wSuiteMask & VER_SUITE_DATACENTER ) - oss << "Datacenter Server"; - else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) - oss << "Advanced Server"; - else oss << "Server"; - } - } - - // Include service pack (if any) and build number. - - if (strlen(osvi.szCSDVersion) > 0 ) - { - oss << " " << osvi.szCSDVersion; - } - - oss << " (build " << osvi.dwBuildNumber << ")"; - - return oss.str(); - } - - else - { - return std::string("unsupported version of Windows"); - } + OSVERSIONINFOEX osvi; + SYSTEM_INFO si; + PGNSI pGNSI; + BOOL bOsVersionInfoEx; + DWORD dwType; + + ZeroMemory(&si, sizeof(SYSTEM_INFO)); + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi))) + return "error getting Windows version"; + + // call GetNativeSystemInfo if supported, GetSystemInfo otherwise + if ((pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo")) != nullptr) + pGNSI(&si); + else + GetSystemInfo(&si); + + // blanket for ancient unsupported Windows versions + if (osvi.dwMajorVersion <= 4 || osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) + return "unsupported Windows version"; + + + std::ostringstream oss; + + if (getName) + oss << "Windows "; + + switch (osvi.dwMajorVersion) { + case 10: { + if (getName) { + switch (osvi.dwMinorVersion) { + case 0: { oss << ((osvi.wProductType == VER_NT_WORKSTATION)? "10": "Server 2016"); } break; + default: { } break; + } + } + } break; + + case 6: { + if (getName) { + switch (osvi.dwMinorVersion) { + case 3: { oss << ((osvi.wProductType == VER_NT_WORKSTATION)? "8.1" : "Server 2012 R2"); } break; + case 2: { oss << ((osvi.wProductType == VER_NT_WORKSTATION)? "8" : "Server 2012" ); } break; + case 1: { oss << ((osvi.wProductType == VER_NT_WORKSTATION)? "7" : "Server 2008 R2"); } break; + case 0: { oss << ((osvi.wProductType == VER_NT_WORKSTATION)? "Vista": "Server 2008" ); } break; + default: { } break; + } + } + + if (getVersion) { + PGPI pGPI = (PGPI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); + pGPI(6, 0, 0, 0, &dwType); + + // FIXME: these might not apply to 6.2 and 6.3 + switch (dwType) { + case PRODUCT_ULTIMATE : { oss << "Ultimate Edition" ; } break; + case PRODUCT_HOME_PREMIUM : { oss << "Home Premium Edition" ; } break; + case PRODUCT_HOME_BASIC : { oss << "Home Basic Edition" ; } break; + case PRODUCT_ENTERPRISE : { oss << "Enterprise Edition" ; } break; + case PRODUCT_BUSINESS : { oss << "Business Edition" ; } break; + case PRODUCT_STARTER : { oss << "Starter Edition" ; } break; + case PRODUCT_CLUSTER_SERVER : { oss << "Cluster Server Edition" ; } break; + case PRODUCT_DATACENTER_SERVER : { oss << "Datacenter Edition" ; } break; + case PRODUCT_DATACENTER_SERVER_CORE : { oss << "Datacenter Edition (core installation)" ; } break; + case PRODUCT_ENTERPRISE_SERVER : { oss << "Enterprise Edition" ; } break; + case PRODUCT_ENTERPRISE_SERVER_CORE : { oss << "Enterprise Edition (core installation)" ; } break; + case PRODUCT_ENTERPRISE_SERVER_IA64 : { oss << "Enterprise Edition for Itanium-based Systems"; } break; + case PRODUCT_SMALLBUSINESS_SERVER : { oss << "Small Business Server" ; } break; + // undocumented? + // case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: { oss << "Small Business Server Premium Edition" ; } break; + case PRODUCT_STANDARD_SERVER : { oss << "Standard Edition" ; } break; + case PRODUCT_STANDARD_SERVER_CORE : { oss << "Standard Edition (core installation)" ; } break; + case PRODUCT_WEB_SERVER : { oss << "Web Server Edition" ; } break; + default : { } break; + } + + switch (si.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_AMD64: { oss << ", 64-bit"; } break; + case PROCESSOR_ARCHITECTURE_INTEL: { oss << ", 32-bit"; } break; + default : { } break; + } + } + } break; + + case 5: { + switch (osvi.dwMinorVersion) { + // Server 2003 or XP 64-bit + case 2: { + if (getName) { + if (GetSystemMetrics(SM_SERVERR2)) + oss << "Server 2003 R2"; + else if (osvi.wSuiteMask == VER_SUITE_STORAGE_SERVER) + oss << "Storage Server 2003"; + else if (osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) + oss << "XP Professional x64 Edition"; + else + oss << "Server 2003"; + } + + if (getVersion) { + // test for the server type + if (osvi.wProductType != VER_NT_WORKSTATION) { + switch (si.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_IA64: { + if (osvi.wSuiteMask & VER_SUITE_DATACENTER) + oss << "Datacenter Edition for Itanium-based Systems"; + else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + oss << "Enterprise Edition for Itanium-based Systems"; + } break; + case PROCESSOR_ARCHITECTURE_AMD64: { + if (osvi.wSuiteMask & VER_SUITE_DATACENTER) + oss << "Datacenter x64 Edition"; + else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + oss << "Enterprise x64 Edition"; + else + oss << "Standard x64 Edition"; + } break; + default: { + if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER) + oss << "Compute Cluster Edition"; + else if (osvi.wSuiteMask & VER_SUITE_DATACENTER) + oss << "Datacenter Edition"; + else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + oss << "Enterprise Edition" ; + else if (osvi.wSuiteMask & VER_SUITE_BLADE) + oss << "Web Edition"; + else + oss << "Standard Edition"; + } break; + } + } + } + } break; + + // XP + case 1: { + if (getName) + oss << "XP"; + + if (getVersion) + oss << ((osvi.wSuiteMask & VER_SUITE_PERSONAL)? "Home Edition": "Professional"); + } break; + + // 2000 + case 0: { + if (getName) + oss << "2000"; + + if (getVersion) { + if (osvi.wProductType == VER_NT_WORKSTATION) { + oss << "Professional"; + } else { + if (osvi.wSuiteMask & VER_SUITE_DATACENTER) + oss << "Datacenter Server"; + else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + oss << "Advanced Server"; + else + oss << "Server"; + } + } + } break; + + default: { + } break; + } + } break; + } + + if (getExtra) { + // include service pack (if any) and build number + oss << ((strlen(osvi.szCSDVersion) > 0)? (" " << osvi.szCSDVersion): ""); + oss << " (build " << osvi.dwBuildNumber << ")"; + } + + return oss.str(); } // this tries to read info about the CPU and available memory -std::string GetHardwareInfoString() +std::string windows::GetHardwareString() { std::ostringstream oss; - unsigned char regbuf[200]; - DWORD regLength=sizeof(regbuf); - DWORD regType=REG_SZ; - HKEY regkey; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "Hardware\\Description\\System\\CentralProcessor\\0", - 0, KEY_READ, ®key)==ERROR_SUCCESS) - { - if (RegQueryValueEx(regkey,"ProcessorNameString",0,®Type,regbuf,®Length)==ERROR_SUCCESS) - { - oss << regbuf << "; "; - } - else - { - oss << "cannot read processor data; "; - } - RegCloseKey(regkey); - } - else - { - oss << "cannot open key with processor data; "; - } - - MEMORYSTATUSEX statex; - const int div = 1024*1024; - statex.dwLength = sizeof (statex); - - GlobalMemoryStatusEx (&statex); - - oss << (statex.ullTotalPhys/div) << "MB RAM, " - << (statex.ullTotalPageFile/div) << "MB pagefile"; - return oss.str(); + unsigned char regbuf[200]; + DWORD regLength = sizeof(regbuf); + DWORD regType = REG_SZ; + HKEY regkey; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Hardware\\Description\\System\\CentralProcessor\\0", 0, KEY_READ, ®key) == ERROR_SUCCESS) { + if (RegQueryValueEx(regkey, "ProcessorNameString", 0, ®Type, regbuf, ®Length) == ERROR_SUCCESS) { + oss << regbuf << "; "; + } else { + oss << "cannot read processor data; "; + } + + RegCloseKey(regkey); + } else { + oss << "cannot open key with processor data; "; + } + + MEMORYSTATUSEX statex; + constexpr int div = 1024 * 1024; + statex.dwLength = sizeof(statex); + + GlobalMemoryStatusEx(&statex); + + oss << (statex.ullTotalPhys / div) << "MB RAM, "; + oss << (statex.ullTotalPageFile / div) << "MB pagefile"; + return oss.str(); } diff --git a/rts/System/Platform/Win/WinVersion.h b/rts/System/Platform/Win/WinVersion.h index 3ae8f0b0a4d..e7cf60265d8 100644 --- a/rts/System/Platform/Win/WinVersion.h +++ b/rts/System/Platform/Win/WinVersion.h @@ -5,7 +5,9 @@ #include -std::string GetOSDisplayString(); -std::string GetHardwareInfoString(); +namespace windows { + std::string GetDisplayString(bool getName, bool getVersion, bool getExtra); + std::string GetHardwareString(); +}; #endif