diff --git a/CMakeLists.txt b/CMakeLists.txt index 186080c4a..65a53efee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) endif() if(WIN32) + ADD_DEFINITIONS(-DUNICODE) + ADD_DEFINITIONS(-D_UNICODE) if(NOT IS_DIRECTORY "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}") set(DEPENDENCIES "dependencies") if(CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -631,6 +633,7 @@ if(MSVC OR MINGW) endif() if(MINGW) + target_link_libraries(supertuxkart -ldxguid -ldinput8) find_library(LIBGCC NAMES "libgcc_s_dw2-1.dll" "libgcc_s_sjlj-1.dll" "libgcc_s_seh-1.dll" PATHS ${CMAKE_FIND_ROOT_PATH}) if(LIBGCC) file(COPY ${LIBGCC} DESTINATION ${CMAKE_BINARY_DIR}/bin/) diff --git a/lib/glew/src/glewinfo.c b/lib/glew/src/glewinfo.c index 882654d64..1013e4585 100644 --- a/lib/glew/src/glewinfo.c +++ b/lib/glew/src/glewinfo.c @@ -16618,10 +16618,10 @@ GLboolean glewCreateContext (struct createParams* params) ZeroMemory(&wc, sizeof(WNDCLASS)); wc.hInstance = GetModuleHandle(NULL); wc.lpfnWndProc = DefWindowProc; - wc.lpszClassName = "GLEW"; + wc.lpszClassName = L"GLEW"; if (0 == RegisterClass(&wc)) return GL_TRUE; /* create window */ - wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + wnd = CreateWindow(L"GLEW", L"GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL); if (NULL == wnd) return GL_TRUE; /* get the device context */ @@ -16690,7 +16690,7 @@ void glewDestroyContext () if (NULL != rc) wglDeleteContext(rc); if (NULL != wnd && NULL != dc) ReleaseDC(wnd, dc); if (NULL != wnd) DestroyWindow(wnd); - UnregisterClass("GLEW", GetModuleHandle(NULL)); + UnregisterClass(L"GLEW", GetModuleHandle(NULL)); } /* ------------------------------------------------------------------------ */ diff --git a/lib/irrlicht/CMakeLists.txt b/lib/irrlicht/CMakeLists.txt index f350eec6c..4395e636e 100644 --- a/lib/irrlicht/CMakeLists.txt +++ b/lib/irrlicht/CMakeLists.txt @@ -6,7 +6,8 @@ if(NOT SERVER_ONLY) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/" "${JPEG_INCLUDE_DIR}" "${PNG_INCLUDE_DIRS}" - "${ZLIB_INCLUDE_DIR}") + "${ZLIB_INCLUDE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/../../src") if(MSVC) include_directories("${CMAKE_CURRENT_BINARY_DIR}/../zlib/") # For zconf.h on WIN32 @@ -61,7 +62,8 @@ if(NOT SERVER_ONLY) endif() endif() else() - include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/") + include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/" + "${CMAKE_CURRENT_SOURCE_DIR}/../../src") find_package(ZLIB REQUIRED) include_directories("${ZLIB_INCLUDE_DIR}") add_definitions(-DNO_IRR_COMPILE_WITH_LIBPNG_) @@ -93,8 +95,8 @@ if(WIN32) add_definitions(-D_IRR_STATIC_LIB_) add_definitions(-D_CRT_SECURE_NO_WARNINGS) # Shut up about unsafe stuff else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pipe -O3 -fno-exceptions -fstrict-aliasing") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pipe -O3 -fno-exceptions -fstrict-aliasing") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pipe -O3 -fstrict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pipe -O3 -fstrict-aliasing") if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexpensive-optimizations") endif() diff --git a/lib/irrlicht/include/GlyphLayout.h b/lib/irrlicht/include/GlyphLayout.h index fbd28e145..1016e53bd 100644 --- a/lib/irrlicht/include/GlyphLayout.h +++ b/lib/irrlicht/include/GlyphLayout.h @@ -96,7 +96,7 @@ inline core::dimension2d getGlyphLayoutsDimension( f32 scale, s32 cluster = -1) { core::dimension2d dim(0.0f, 0.0f); - core::dimension2d this_line(0.0f, height_per_line); + core::dimension2d this_line(0.0f, (f32)height_per_line); for (unsigned i = 0; i < gls.size(); i++) { @@ -272,7 +272,7 @@ namespace Private inline f32 getGlyphLayoutsWidth(const std::vector& gls, f32 inverse_shaping, f32 scale) { - return std::accumulate(gls.begin(), gls.end(), 0, + return std::accumulate(gls.begin(), gls.end(), 0.0f, [inverse_shaping, scale] (const f32 previous, const irr::gui::GlyphLayout& cur_gi) { diff --git a/lib/irrlicht/include/IrrCompileConfig.h b/lib/irrlicht/include/IrrCompileConfig.h index 0c079df32..df8bed8d5 100644 --- a/lib/irrlicht/include/IrrCompileConfig.h +++ b/lib/irrlicht/include/IrrCompileConfig.h @@ -153,7 +153,7 @@ so D3D8 support is now disabled by default. If you really want to build with D3D8 support, then you will have to source a DXSDK with the appropriate headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one. */ -#if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) +#if defined(_IRR_WINDOWS_API_) //! Define _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ if you want to use DirectInput for joystick handling. /** This only applies to Windows devices, currently only supported under Win32 device. diff --git a/lib/irrlicht/include/Keycodes.h b/lib/irrlicht/include/Keycodes.h index 5959e3dec..5deb364c4 100644 --- a/lib/irrlicht/include/Keycodes.h +++ b/lib/irrlicht/include/Keycodes.h @@ -90,7 +90,7 @@ namespace irr IRR_KEY_X = 0x58, // X key IRR_KEY_Y = 0x59, // Y key IRR_KEY_Z = 0x5A, // Z key - IRR_KEY_LWIN = 0x5B, // Left Windows key (Microsoft® Natural® keyboard) + IRR_KEY_LWIN = 0x5B, // Left Windows key (Microsoft Natural keyboard) IRR_KEY_RWIN = 0x5C, // Right Windows key (Natural keyboard) IRR_KEY_APPS = 0x5D, // Applications key (Natural keyboard) IRR_KEY_SLEEP = 0x5F, // Computer Sleep key diff --git a/lib/irrlicht/include/irrString.h b/lib/irrlicht/include/irrString.h index c7d20595a..1fc247ec2 100644 --- a/lib/irrlicht/include/irrString.h +++ b/lib/irrlicht/include/irrString.h @@ -527,6 +527,12 @@ public: return array; } + //! Returns character string + /** \return writable pointer to C-style NUL terminated string. */ + T* data() const + { + return array; + } //! Makes the string lower case. string& make_lower() diff --git a/lib/irrlicht/source/Irrlicht/CFileSystem.cpp b/lib/irrlicht/source/Irrlicht/CFileSystem.cpp index d5174d8fc..331804618 100644 --- a/lib/irrlicht/source/Irrlicht/CFileSystem.cpp +++ b/lib/irrlicht/source/Irrlicht/CFileSystem.cpp @@ -21,6 +21,7 @@ #include "irrList.h" #if defined (_IRR_WINDOWS_API_) + #include "utils/string_utils.hpp" #if !defined ( _WIN32_WCE ) #include // for _chdir #include // for _access @@ -831,14 +832,17 @@ IFileList* CFileSystem::createFileList(const io::path& directory) intptr_t hFile; - io::path searchPath = Path; - searchPath.append('*'); + std::string searchPath = Path.c_str(); + searchPath += '*'; + core::stringw search_path_w = StringUtils::utf8ToWide(searchPath); struct _tfinddata_t c_file; - if( (hFile = _tfindfirst( _T(searchPath.c_str()), &c_file )) != -1L ) + if( (hFile = _tfindfirst(search_path_w.c_str(), &c_file )) != -1L ) { do { - r->addItem(Path + c_file.name, 0, c_file.size, (_A_SUBDIR & c_file.attrib) != 0, 0); + std::string full_path = Path.c_str(); + full_path += StringUtils::wideToUtf8(c_file.name); + r->addItem(full_path.c_str(), 0, c_file.size, (_A_SUBDIR & c_file.attrib) != 0, 0); } while( _tfindnext( hFile, &c_file ) == 0 ); diff --git a/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp b/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp index c8548c954..9cc909c3e 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp @@ -275,7 +275,7 @@ void CGUIStaticText::breakText() LastBreakFont = font; - f32 elWidth = RelativeRect.getWidth(); + f32 elWidth = (f32)RelativeRect.getWidth(); if (Border) elWidth -= 2*skin->getSize(EGDS_TEXT_DISTANCE_X); if (!m_use_glyph_layouts_only) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp index a99ea0c01..97eb8d474 100755 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp @@ -11,6 +11,8 @@ #include "irrList.h" #include "os.h" +#include "utils/string_utils.hpp" + #include "CTimer.h" #include "irrString.h" #include "COSOperator.h" @@ -143,7 +145,7 @@ struct SJoystickWin32Control activeJoystick.Index=ActiveJoysticks.size(); activeJoystick.guid=guid; - activeJoystick.Name=lpddi->tszProductName; + activeJoystick.Name=StringUtils::wideToUtf8(lpddi->tszProductName).c_str(); if (FAILED(DirectInputDevice->CreateDevice(guid, &activeJoystick.lpdijoy, NULL))) { os::Printer::log("Could not create DirectInput device", ELL_WARNING); @@ -593,39 +595,39 @@ void setJoystickName(int index, const JOYCAPS &caps, SJoystickInfo *joystick) { // As a default use the name given in the joystick structure // - though that is always the same name, independent of joystick :( - joystick->Name = caps.szPname; + joystick->Name = StringUtils::wideToUtf8(caps.szPname).c_str(); joystick->HasGenericName = true; - core::stringc key = core::stringc(REGSTR_PATH_JOYCONFIG)+"\\"+caps.szRegKey + core::stringw key = core::stringw(REGSTR_PATH_JOYCONFIG)+"\\"+caps.szRegKey + "\\"+REGSTR_KEY_JOYCURR; HKEY hTopKey = HKEY_LOCAL_MACHINE; HKEY hKey; - long regresult = RegOpenKeyExA(hTopKey, key.c_str(), 0, KEY_READ, &hKey); + long regresult = RegOpenKeyEx(hTopKey, key.c_str(), 0, KEY_READ, &hKey); if (regresult != ERROR_SUCCESS) { hTopKey = HKEY_CURRENT_USER; - regresult = RegOpenKeyExA(hTopKey, key.c_str(), 0, KEY_READ, &hKey); + regresult = RegOpenKeyEx(hTopKey, key.c_str(), 0, KEY_READ, &hKey); } if (regresult != ERROR_SUCCESS) return; /* find the registry key name for the joystick's properties */ - char regname[256]; + wchar_t regname[256]; DWORD regsize = sizeof(regname); - core::stringc regvalue = core::stringc("Joystick")+core::stringc(index+1) + core::stringw regvalue = core::stringw(L"Joystick")+core::stringw(index+1) + REGSTR_VAL_JOYOEMNAME; - regresult = RegQueryValueExA(hKey, regvalue.c_str(), 0, 0, + regresult = RegQueryValueEx(hKey, regvalue.c_str(), 0, 0, (LPBYTE)regname, ®size); RegCloseKey(hKey); if (regresult != ERROR_SUCCESS) return; /* open that registry key */ - core::stringc regkey = core::stringc(REGSTR_PATH_JOYOEM)+"\\"+regname; - regresult = RegOpenKeyExA(hTopKey, regkey.c_str(), 0, KEY_READ, &hKey); + core::stringw regkey = core::stringw(REGSTR_PATH_JOYOEM)+"\\"+regname; + regresult = RegOpenKeyEx(hTopKey, regkey.c_str(), 0, KEY_READ, &hKey); if (regresult != ERROR_SUCCESS) return; /* find the size for the OEM name text */ regsize = sizeof(regvalue); - regresult = RegQueryValueExA(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, + regresult = RegQueryValueEx(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, NULL, ®size); if (regresult == ERROR_SUCCESS) { @@ -635,7 +637,7 @@ void setJoystickName(int index, const JOYCAPS &caps, SJoystickInfo *joystick) if (name) { /* ... and read it from the registry */ - regresult = RegQueryValueExA(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, + regresult = RegQueryValueEx(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE)name, ®size ); joystick->Name = name; joystick->HasGenericName = false; @@ -1323,7 +1325,7 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params) // create the window if we need to and we do not use the null device if (!CreationParams.WindowId && CreationParams.DriverType != video::EDT_NULL) { - const fschar_t* ClassName = __TEXT("CIrrDeviceWin32"); + const wchar_t* ClassName = L"CIrrDeviceWin32"; // Register Class WNDCLASSEX wcex; @@ -1693,7 +1695,7 @@ void CIrrDeviceWin32::closeDevice() if (!ExternalWindow) { DestroyWindow(HWnd); - const fschar_t* ClassName = __TEXT("CIrrDeviceWin32"); + const wchar_t* ClassName = L"CIrrDeviceWin32"; HINSTANCE hInstance = GetModuleHandle(0); UnregisterClass(ClassName, hInstance); } diff --git a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp index 046e32591..3be8b1592 100644 --- a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp +++ b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp @@ -208,7 +208,7 @@ static HGLRC getMeAGLContext(HDC HDc, bool force_legacy_context) bool COpenGLDriver::initDriver(CIrrDeviceWin32* device) { // Create a window to test antialiasing support - const fschar_t* ClassName = __TEXT("GLCIrrDeviceWin32"); + const wchar_t* ClassName = L"GLCIrrDeviceWin32"; HINSTANCE lhInstance = GetModuleHandle(0); // Register Class @@ -246,7 +246,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device) const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; - HWND temporary_wnd=CreateWindow(ClassName, __TEXT(""), style, windowLeft, + HWND temporary_wnd=CreateWindow(ClassName, L"", style, windowLeft, windowTop, realWidth, realHeight, NULL, NULL, lhInstance, NULL); if (!temporary_wnd) @@ -262,10 +262,10 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device) PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number - PFD_DRAW_TO_WINDOW | // Format Must Support Window + (DWORD)(PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL (Params.Doublebuffer?PFD_DOUBLEBUFFER:0) | // Must Support Double Buffering - (Params.Stereobuffer?PFD_STEREO:0), // Must Support Stereo Buffer + (Params.Stereobuffer?PFD_STEREO:0)), // Must Support Stereo Buffer PFD_TYPE_RGBA, // Request An RGBA Format Params.Bits, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored diff --git a/lib/irrlicht/source/Irrlicht/COpenGLExtensionHandler.cpp b/lib/irrlicht/source/Irrlicht/COpenGLExtensionHandler.cpp index 9af150c0b..750430444 100644 --- a/lib/irrlicht/source/Irrlicht/COpenGLExtensionHandler.cpp +++ b/lib/irrlicht/source/Irrlicht/COpenGLExtensionHandler.cpp @@ -210,7 +210,7 @@ void COpenGLExtensionHandler::dumpFramebufferFormats() const #endif ,0,0,0,0 }; - size_t nums = sizeof(atts)/sizeof(int); + u32 nums = sizeof(atts)/sizeof(int); const bool depth_float_supported= (wglExtensions.find("WGL_EXT_depth_float") != -1); if (!depth_float_supported) { diff --git a/lib/irrlicht/source/Irrlicht/CZipReader.cpp b/lib/irrlicht/source/Irrlicht/CZipReader.cpp index 1869b74ba..41119a9c8 100644 --- a/lib/irrlicht/source/Irrlicht/CZipReader.cpp +++ b/lib/irrlicht/source/Irrlicht/CZipReader.cpp @@ -17,6 +17,7 @@ extern "C" void bz_internal_error(int errorCode) #include "CFileList.h" #include "CReadFile.h" #include "coreutil.h" +#include "utils/string_utils.hpp" #include "IrrCompileConfig.h" #ifdef _IRR_COMPILE_WITH_ZLIB_ @@ -457,7 +458,7 @@ IReadFile* CZipReader::createAndOpenFile(u32 index) //99 - AES encryption, WinZip 9 const SZipFileEntry &e = FileInfo[Files[index].ID]; - wchar_t buf[64]; + wchar_t buf[256]; s16 actualCompressionMethod=e.header.CompressionMethod; IReadFile* decrypted=0; u8* decryptedBuf=0; @@ -480,7 +481,7 @@ IReadFile* CZipReader::createAndOpenFile(u32 index) c8* pBuf = new c8[ uncompressedSize ]; if (!pBuf) { - swprintf ( buf, 64, L"Not enough memory for decompressing %s", Files[index].FullName.c_str() ); + swprintf ( buf, 256, L"Not enough memory for decompressing %s", StringUtils::utf8ToWide(Files[index].FullName.c_str()).c_str()); os::Printer::log( buf, ELL_ERROR); if (decrypted) decrypted->drop(); @@ -493,7 +494,7 @@ IReadFile* CZipReader::createAndOpenFile(u32 index) pcData = new u8[decryptedSize]; if (!pcData) { - swprintf ( buf, 64, L"Not enough memory for decompressing %s", Files[index].FullName.c_str() ); + swprintf ( buf, 256, L"Not enough memory for decompressing %s", StringUtils::utf8ToWide(Files[index].FullName.c_str()).c_str()); os::Printer::log( buf, ELL_ERROR); delete [] pBuf; return 0; @@ -534,7 +535,7 @@ IReadFile* CZipReader::createAndOpenFile(u32 index) if (err != Z_OK) { - swprintf ( buf, 64, L"Error decompressing %s", Files[index].FullName.c_str() ); + swprintf ( buf, 256, L"Error decompressing %s", StringUtils::utf8ToWide(Files[index].FullName.c_str()).c_str()); os::Printer::log( buf, ELL_ERROR); delete [] pBuf; return 0; @@ -561,7 +562,7 @@ IReadFile* CZipReader::createAndOpenFile(u32 index) os::Printer::log("Decryption support not enabled. File cannot be read.", ELL_ERROR); return 0; default: - swprintf ( buf, 64, L"file has unsupported compression method. %s", Files[index].FullName.c_str() ); + swprintf ( buf, 256, L"file has unsupported compression method. %s", StringUtils::utf8ToWide(Files[index].FullName.c_str()).c_str()); os::Printer::log( buf, ELL_ERROR); return 0; }; diff --git a/lib/wiiuse/src/os_win.c b/lib/wiiuse/src/os_win.c index 205ce9177..809aaca13 100644 --- a/lib/wiiuse/src/os_win.c +++ b/lib/wiiuse/src/os_win.c @@ -128,7 +128,7 @@ int wiiuse_os_find(struct wiimote_t **wm, int max_wiimotes, int timeout) if (attr.ProductID == WM_PRODUCT_ID_TR) wm[found]->type = WIIUSE_WIIMOTE_MOTION_PLUS_INSIDE; - wm[found]->hid_overlap.hEvent = CreateEvent(NULL, 1, 1, ""); + wm[found]->hid_overlap.hEvent = CreateEvent(NULL, 1, 1, L""); wm[found]->hid_overlap.Offset = 0; wm[found]->hid_overlap.OffsetHigh = 0; diff --git a/src/config/hardware_stats.cpp b/src/config/hardware_stats.cpp index 929e2abec..d606a3eff 100644 --- a/src/config/hardware_stats.cpp +++ b/src/config/hardware_stats.cpp @@ -210,7 +210,7 @@ void determineOSVersion() HKEY hKey; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) { m_os_version = "windows-unknown"; @@ -218,7 +218,7 @@ void determineOSVersion() } char windows_version_string[20]; DWORD size = sizeof(windows_version_string); - RegQueryValueEx(hKey, "CurrentVersion", 0, 0, (LPBYTE)windows_version_string, &size); + RegQueryValueEx(hKey, L"CurrentVersion", 0, 0, (LPBYTE)windows_version_string, &size); unsigned major = 0, minor = 0; std::stringstream sstr(windows_version_string); diff --git a/src/io/file_manager.cpp b/src/io/file_manager.cpp index 3e5292e1e..6c3ffd507 100644 --- a/src/io/file_manager.cpp +++ b/src/io/file_manager.cpp @@ -1420,7 +1420,7 @@ bool FileManager::removeDirectory(const std::string &name) const } #if defined(WIN32) - return RemoveDirectory(name.c_str())==TRUE; + return RemoveDirectory(StringUtils::utf8ToWide(name).c_str())==TRUE; #else return remove(name.c_str())==0; #endif diff --git a/src/main.cpp b/src/main.cpp index 2444af550..5791d0086 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2310,7 +2310,7 @@ int main(int argc, char *argv[] ) #ifdef WIN32 //routine for running under windows int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, int nCmdShow) + LPSTR lpCmdLine, int nCmdShow) { return main(__argc, __argv); } diff --git a/src/main_loop.cpp b/src/main_loop.cpp index 314506779..6a401fd60 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -80,16 +80,16 @@ MainLoop::MainLoop(unsigned parent_pid) #ifdef WIN32 if (parent_pid != 0) { - std::string class_name = "separate_process"; - class_name += StringUtils::toString(GetCurrentProcessId()); + core::stringw class_name = L"separate_process"; + class_name += StringUtils::toWString(GetCurrentProcessId()); WNDCLASSEX wx = {}; wx.cbSize = sizeof(WNDCLASSEX); wx.lpfnWndProc = separateProcessProc; wx.hInstance = GetModuleHandle(0); - wx.lpszClassName = &class_name[0]; + wx.lpszClassName = class_name.c_str(); if (RegisterClassEx(&wx)) { - CreateWindowEx(0, &class_name[0], "stk_server_only", + CreateWindowEx(0, class_name.c_str(), L"stk_server_only", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); } } diff --git a/src/utils/log.cpp b/src/utils/log.cpp index 40ce3b146..34b123761 100644 --- a/src/utils/log.cpp +++ b/src/utils/log.cpp @@ -250,7 +250,9 @@ void Log::writeLine(const char *line, int level) } #if defined(_MSC_FULL_VER) && defined(_DEBUG) - if (m_buffer_size <= 1) OutputDebugString(line); + // We don't use utf8ToWide for performance, and debug message + // is mostly english anyway + if (m_buffer_size <= 1) OutputDebugStringA(line); #endif if (m_file_stdout) fprintf(m_file_stdout, "%s", line); diff --git a/src/utils/separate_process.cpp b/src/utils/separate_process.cpp index 88193a28f..0649395b0 100644 --- a/src/utils/separate_process.cpp +++ b/src/utils/separate_process.cpp @@ -101,12 +101,12 @@ SeparateProcess::~SeparateProcess() { bool dead = false; #if defined(WIN32) - std::string class_name = "separate_process"; - class_name += StringUtils::toString(m_child_pid); - HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, &class_name[0], NULL); + core::stringw class_name = "separate_process"; + class_name += StringUtils::toWString(m_child_pid); + HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, class_name.c_str(), NULL); if (hwnd != NULL) { - PostMessage(hwnd, WM_DESTROY, NULL, NULL); + PostMessage(hwnd, WM_DESTROY, 0, 0); if (WaitForSingleObject(m_child_handle, 5000) != WAIT_TIMEOUT) { dead = true; @@ -249,8 +249,9 @@ bool SeparateProcess::createChildProcess(const std::string& exe, // Create the child process. std::string cmd = exe + argument + " --parent-process=" + StringUtils::toString(GetCurrentProcessId()); + core::stringw cmd_w = StringUtils::utf8ToWide(cmd); bool success = CreateProcess(NULL, - &cmd[0], // command line + cmd_w.data(), // command line NULL, // process security attributes NULL, // primary thread security attributes TRUE, // handles are inherited