summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-09-28 10:14:09 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-09-28 10:14:09 +0200
commit4ddff15710c9814c1fa6875570a9a18e22943605 (patch)
treeb293d16f89898708337423aaf8b6f2370c025504
parentMerge pull request #2504 from SafwatHalaby/revert (diff)
parentAdded the _UNICODE flag on Windows (diff)
downloadcuberite-4ddff15710c9814c1fa6875570a9a18e22943605.tar
cuberite-4ddff15710c9814c1fa6875570a9a18e22943605.tar.gz
cuberite-4ddff15710c9814c1fa6875570a9a18e22943605.tar.bz2
cuberite-4ddff15710c9814c1fa6875570a9a18e22943605.tar.lz
cuberite-4ddff15710c9814c1fa6875570a9a18e22943605.tar.xz
cuberite-4ddff15710c9814c1fa6875570a9a18e22943605.tar.zst
cuberite-4ddff15710c9814c1fa6875570a9a18e22943605.zip
-rw-r--r--SetFlags.cmake3
-rw-r--r--src/LeakFinder.cpp6
-rw-r--r--src/OSSupport/Errors.cpp2
-rw-r--r--src/main.cpp16
4 files changed, 15 insertions, 12 deletions
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 076fba1f7..b4c7365fe 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -62,6 +62,9 @@ macro(set_flags)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG")
+
+ # Make build use Unicode:
+ add_definitions(-DUNICODE -D_UNICODE)
elseif(APPLE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
diff --git a/src/LeakFinder.cpp b/src/LeakFinder.cpp
index 2e352af2d..dba8275c8 100644
--- a/src/LeakFinder.cpp
+++ b/src/LeakFinder.cpp
@@ -875,7 +875,7 @@ static int MyAllocHook(int nAllocType, void *pvData,
printf("********************************************\n");
printf("Please wait\n");
- LeakFinderXmlOutput Output("memdump.xml");
+ LeakFinderXmlOutput Output(L"memdump.xml");
DumpUsedMemory(&Output);
printf("\nMemory dump complete. Server will now abort.\n");
@@ -912,7 +912,7 @@ static int MyAllocHook(int nAllocType, void *pvData,
printf("********************************************\n");
printf("Please wait\n");
- LeakFinderXmlOutput Output("memdump.xml");
+ LeakFinderXmlOutput Output(L"memdump.xml");
DumpUsedMemory(&Output);
printf("\nMemory dump complete. Server will now abort.\n");
@@ -955,7 +955,7 @@ static int MyAllocHook(int nAllocType, void *pvData,
printf("******************************************\n");
printf("Please wait\n");
- LeakFinderXmlOutput Output("memdump.xml");
+ LeakFinderXmlOutput Output(L"memdump.xml");
DumpUsedMemory(&Output);
printf("\nMemory dump complete. Server will now abort.\n");
diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp
index 407799495..7fcd3168f 100644
--- a/src/OSSupport/Errors.cpp
+++ b/src/OSSupport/Errors.cpp
@@ -10,7 +10,7 @@ AString GetOSErrorString( int a_ErrNo)
#ifdef _WIN32
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, a_ErrNo, 0, buffer, ARRAYCOUNT(buffer), nullptr);
+ FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, a_ErrNo, 0, buffer, ARRAYCOUNT(buffer), nullptr);
Printf(Out, "%d: %s", a_ErrNo, buffer);
if (!Out.empty() && (Out[Out.length() - 1] == '\n'))
{
diff --git a/src/main.cpp b/src/main.cpp
index c26e7900f..aa21d8a31 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -39,7 +39,7 @@ bool cRoot::m_RunAsService = false;
#if defined(_WIN32)
SERVICE_STATUS_HANDLE g_StatusHandle = nullptr;
HANDLE g_ServiceThread = INVALID_HANDLE_VALUE;
- #define SERVICE_NAME "CuberiteService"
+ #define SERVICE_NAME L"CuberiteService"
#endif
@@ -131,7 +131,7 @@ typedef BOOL (WINAPI *pMiniDumpWriteDump)(
pMiniDumpWriteDump g_WriteMiniDump; // The function in dbghlp DLL that creates dump files
-char g_DumpFileName[MAX_PATH]; // Filename of the dump file; hes to be created before the dump handler kicks in
+wchar_t g_DumpFileName[MAX_PATH]; // Filename of the dump file; hes to be created before the dump handler kicks in
char g_ExceptionStack[128 * 1024]; // Substitute stack, just in case the handler kicks in because of "insufficient stack space"
MINIDUMP_TYPE g_DumpFlags = MiniDumpNormal; // By default dump only the stack and some helpers
@@ -310,14 +310,14 @@ void WINAPI serviceCtrlHandler(DWORD CtrlCode)
void WINAPI serviceMain(DWORD argc, TCHAR *argv[])
{
- char applicationFilename[MAX_PATH];
- char applicationDirectory[MAX_PATH];
+ wchar_t applicationFilename[MAX_PATH];
+ wchar_t applicationDirectory[MAX_PATH];
GetModuleFileName(nullptr, applicationFilename, sizeof(applicationFilename)); // This binary's file path.
// Strip off the filename, keep only the path:
- strncpy_s(applicationDirectory, sizeof(applicationDirectory), applicationFilename, (strrchr(applicationFilename, '\\') - applicationFilename));
- applicationDirectory[strlen(applicationDirectory)] = '\0'; // Make sure new path is null terminated
+ wcsncpy_s(applicationDirectory, sizeof(applicationDirectory), applicationFilename, (wcsrchr(applicationFilename, '\\') - applicationFilename));
+ applicationDirectory[wcslen(applicationDirectory)] = '\0'; // Make sure new path is null terminated
// Services are run by the SCM, and inherit its working directory - usually System32.
// Set the working directory to the same location as the binary.
@@ -442,11 +442,11 @@ int main(int argc, char **argv)
// Magic code to produce dump-files on Windows if the server crashes:
#if defined(_WIN32) && !defined(_WIN64) && defined(_MSC_VER) // 32-bit Windows app compiled in MSVC
- HINSTANCE hDbgHelp = LoadLibrary("DBGHELP.DLL");
+ HINSTANCE hDbgHelp = LoadLibrary(L"DBGHELP.DLL");
g_WriteMiniDump = (pMiniDumpWriteDump)GetProcAddress(hDbgHelp, "MiniDumpWriteDump");
if (g_WriteMiniDump != nullptr)
{
- _snprintf_s(g_DumpFileName, ARRAYCOUNT(g_DumpFileName), _TRUNCATE, "crash_mcs_%x.dmp", GetCurrentProcessId());
+ _snwprintf_s(g_DumpFileName, ARRAYCOUNT(g_DumpFileName), _TRUNCATE, L"crash_mcs_%x.dmp", GetCurrentProcessId());
SetUnhandledExceptionFilter(LastChanceExceptionFilter);
}
#endif // 32-bit Windows app compiled in MSVC