From 8630498213590a34fbdf6b2e2b9d1f2c8fdce05f Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 18 Jan 2018 12:50:34 +0000 Subject: [PATCH] Convert platform/windows.c to C++ (#7044) --- src/openrct2/platform/{windows.c => Windows.cpp} | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) rename src/openrct2/platform/{windows.c => Windows.cpp} (98%) diff --git a/src/openrct2/platform/windows.c b/src/openrct2/platform/Windows.cpp similarity index 98% rename from src/openrct2/platform/windows.c rename to src/openrct2/platform/Windows.cpp index 7ecd25b755..f4dc0e7dc0 100644 --- a/src/openrct2/platform/windows.c +++ b/src/openrct2/platform/Windows.cpp @@ -24,6 +24,7 @@ #ifdef _WIN32 +#undef interface #include #include #include @@ -31,6 +32,7 @@ #include #include "../config/Config.h" +#include "../core/Util.hpp" #include "../localisation/Date.h" #include "../localisation/Language.h" #include "../OpenRCT2.h" @@ -48,6 +50,9 @@ // The name of the mutex used to prevent multiple instances of the game from running #define SINGLE_INSTANCE_MUTEX_NAME "RollerCoaster Tycoon 2_GSKMUTEX" +extern "C" +{ + static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 }; #define OPENRCT2_DLL_MODULE_NAME "openrct2.dll" @@ -206,7 +211,7 @@ void platform_resolve_openrct_data_path() if (gCustomOpenrctDataPath[0] != 0) { wchar_t *customOpenrctDataPathW = utf8_to_widechar(gCustomOpenrctDataPath); - if (GetFullPathNameW(customOpenrctDataPathW, countof(wOutPath), wOutPath, NULL) == 0) { + if (GetFullPathNameW(customOpenrctDataPathW, (DWORD)Util::CountOf(wOutPath), wOutPath, NULL) == 0) { log_fatal("Unable to resolve path '%s'.", gCustomOpenrctDataPath); exit(-1); } @@ -507,7 +512,7 @@ bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size) { #if !defined(__MINGW32__) && ((NTDDI_VERSION >= NTDDI_VISTA) && !defined(_USING_V110_SDK71_) && !defined(_ATL_XP_TARGETING)) wchar_t *fontFolder; - if (SUCCEEDED(SHGetKnownFolderPath(&FOLDERID_Fonts, 0, NULL, &fontFolder))) + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Fonts, 0, NULL, &fontFolder))) { // Convert wchar to utf8, then copy the font folder path to the buffer. utf8 *outPathTemp = widechar_to_utf8(fontFolder); @@ -540,7 +545,7 @@ utf8 * platform_get_absolute_path(const utf8 * relativePath, const utf8 * basePa wchar_t * pathW = utf8_to_widechar(path); wchar_t fullPathW[MAX_PATH]; - DWORD fullPathLen = GetFullPathNameW(pathW, countof(fullPathW), fullPathW, NULL); + DWORD fullPathLen = GetFullPathNameW(pathW, (DWORD)Util::CountOf(fullPathW), fullPathW, NULL); free(pathW); @@ -792,3 +797,5 @@ bool platform_setup_uri_protocol() /////////////////////////////////////////////////////////////////////////////// #endif + +}