diff --git a/Source/Engine/Networking/Drivers/ENetDriver.cpp b/Source/Engine/Networking/Drivers/ENetDriver.cpp index 7a64f0d10..8d5b4b7f6 100644 --- a/Source/Engine/Networking/Drivers/ENetDriver.cpp +++ b/Source/Engine/Networking/Drivers/ENetDriver.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. +// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. // // TODO: Check defines so we can disable ENet diff --git a/Source/Engine/Platform/Win32/Win32Platform.cpp b/Source/Engine/Platform/Win32/Win32Platform.cpp index 9d2041547..6099451bf 100644 --- a/Source/Engine/Platform/Win32/Win32Platform.cpp +++ b/Source/Engine/Platform/Win32/Win32Platform.cpp @@ -10,7 +10,6 @@ #include "Engine/Core/Math/Math.h" #include "Engine/Core/Collections/HashFunctions.h" #include "Engine/Core/Log.h" -#include "Engine/Engine/CommandLine.h" #include "IncludeWindowsHeaders.h" #include #include @@ -19,7 +18,6 @@ #include #include #include -#include #pragma comment(lib, "Iphlpapi.lib") namespace @@ -65,28 +63,6 @@ bool Win32Platform::Init() if (PlatformBase::Init()) return true; - // Init console output (engine is linked with /SUBSYSTEM:WINDOWS so it lacks of proper console output on Windows) - if (CommandLine::Options.Std) - { - // Attaches output of application to parent console, returns true if running in console-mode - // [Reference: https://www.tillett.info/2013/05/13/how-to-create-a-windows-program-that-works-as-both-as-a-gui-and-console-application] - if (AttachConsole(ATTACH_PARENT_PROCESS)) - { - const HANDLE consoleHandleOut = GetStdHandle(STD_OUTPUT_HANDLE); - if (consoleHandleOut != INVALID_HANDLE_VALUE) - { - freopen("CONOUT$", "w", stdout); - setvbuf(stdout, NULL, _IONBF, 0); - } - const HANDLE consoleHandleError = GetStdHandle(STD_ERROR_HANDLE); - if (consoleHandleError != INVALID_HANDLE_VALUE) - { - freopen("CONOUT$", "w", stderr); - setvbuf(stderr, NULL, _IONBF, 0); - } - } - } - // Init timing LARGE_INTEGER frequency; const auto freqResult = QueryPerformanceFrequency(&frequency); diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.cpp b/Source/Engine/Platform/Windows/WindowsPlatform.cpp index 52b0bdaa3..759713f7c 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatform.cpp +++ b/Source/Engine/Platform/Windows/WindowsPlatform.cpp @@ -15,12 +15,14 @@ #include "Engine/Core/Collections/Array.h" #include "Engine/Platform/MessageBox.h" #include "Engine/Engine/Engine.h" +#include "Engine/Engine/CommandLine.h" #include "../Win32/IncludeWindowsHeaders.h" #include #include #include #include #include +#include #if CRASH_LOG_ENABLE #include #endif @@ -593,6 +595,28 @@ bool WindowsPlatform::Init() { if (Win32Platform::Init()) return true; + + // Init console output (engine is linked with /SUBSYSTEM:WINDOWS so it lacks of proper console output on Windows) + if (CommandLine::Options.Std) + { + // Attaches output of application to parent console, returns true if running in console-mode + // [Reference: https://www.tillett.info/2013/05/13/how-to-create-a-windows-program-that-works-as-both-as-a-gui-and-console-application] + if (AttachConsole(ATTACH_PARENT_PROCESS)) + { + const HANDLE consoleHandleOut = GetStdHandle(STD_OUTPUT_HANDLE); + if (consoleHandleOut != INVALID_HANDLE_VALUE) + { + freopen("CONOUT$", "w", stdout); + setvbuf(stdout, NULL, _IONBF, 0); + } + const HANDLE consoleHandleError = GetStdHandle(STD_ERROR_HANDLE); + if (consoleHandleError != INVALID_HANDLE_VALUE) + { + freopen("CONOUT$", "w", stderr); + setvbuf(stderr, NULL, _IONBF, 0); + } + } + } // Check if can run Engine on current platform (requires Windows Vista SP1 or above) if (!IsWindowsVistaSP1OrGreater() && !IsWindowsServer()) diff --git a/Source/ThirdParty/enet/enet.h b/Source/ThirdParty/enet/enet.h index 08ceef486..3e63c9545 100644 --- a/Source/ThirdParty/enet/enet.h +++ b/Source/ThirdParty/enet/enet.h @@ -5723,17 +5723,25 @@ extern "C" { return -1; } +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) timeBeginPeriod(1); +#endif return 0; } void enet_deinitialize(void) { +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) timeEndPeriod(1); +#endif WSACleanup(); } enet_uint64 enet_host_random_seed(void) { +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) return (enet_uint64) timeGetTime(); +#else + return (enet_uint64) time(NULL); +#endif } int enet_address_set_host_ip_old(ENetAddress *address, const char *name) {