From 1add4a580ce0fd0121a1ed02978c86196b72b1f9 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Thu, 8 Dec 2022 22:11:58 -0800 Subject: [PATCH] Fix borked dialog box on release, defined unicode --- build_debug.bat | 2 +- gamestate.c | 11 +++++++---- main.c | 3 +-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/build_debug.bat b/build_debug.bat index bcb3f85..b772f5f 100644 --- a/build_debug.bat +++ b/build_debug.bat @@ -1,3 +1,3 @@ call shadergen.bat -set compileopts=/Fe"flight_debug" /Zi /FS /Fd"flight.pdb" /DDEBUG_RENDERING /DDEBUG +set compileopts=/Fe"flight_debug" /Zi /FS /Fd"flight.pdb" /DDEBUG call build_msvc.bat \ No newline at end of file diff --git a/gamestate.c b/gamestate.c index 87b4ae4..b70e6be 100644 --- a/gamestate.c +++ b/gamestate.c @@ -20,9 +20,12 @@ #ifdef ASSERT_DO_POPUP_AND_CRASH #ifdef _WIN32 +#ifndef UNICODE +#define UNICODE // I think? +#endif #include -wchar_t * +LPWSTR fromUTF8( const char *src, size_t src_length, /* = 0 */ @@ -39,7 +42,7 @@ fromUTF8( src_length = strlen(src); } int length = MultiByteToWideChar(CP_UTF8, 0, src, (int)src_length, 0, 0); - wchar_t *output_buffer = (wchar_t *)malloc((length + 1) * sizeof(wchar_t)); + LPWSTR output_buffer = (LPWSTR)malloc((length + 1) * sizeof(wchar_t)); if (output_buffer) { MultiByteToWideChar(CP_UTF8, 0, src, (int)src_length, output_buffer, (int)length); @@ -67,8 +70,8 @@ void quit_with_popup(const char *message_utf8, const char *title_utf8) #ifdef _WIN32 size_t message_out_len = 0; size_t title_out_len = 0; - wchar_t *message_wchar = fromUTF8(message_utf8, strlen(message_utf8), &message_out_len); - wchar_t *title_wchar = fromUTF8(title_utf8, strlen(title_utf8), &title_out_len); + LPWSTR message_wchar = fromUTF8(message_utf8, strlen(message_utf8), &message_out_len); + LPWSTR title_wchar = fromUTF8(title_utf8, strlen(title_utf8), &title_out_len); int msgboxID = MessageBox( NULL, message_wchar, diff --git a/main.c b/main.c index fe55937..4e9fb4e 100644 --- a/main.c +++ b/main.c @@ -686,9 +686,8 @@ static void init(void) /* received. Reset the peer in the event the 5 seconds */ /* had run out without any significant event. */ enet_peer_reset(peer); - Log("Failed to connecvt to server\n"); + Log("Failed to connect to server\n"); quit_with_popup("Failed to connect to server. Is your wifi down? It took too long.", "Connection Failure"); - Log("Connection to server failed.\n"); } } }