Fix borked dialog box on release, defined unicode

main
Cameron Murphy Reikes 2 years ago
parent 6d50ebc50a
commit 1add4a580c

@ -1,3 +1,3 @@
call shadergen.bat 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 call build_msvc.bat

@ -20,9 +20,12 @@
#ifdef ASSERT_DO_POPUP_AND_CRASH #ifdef ASSERT_DO_POPUP_AND_CRASH
#ifdef _WIN32 #ifdef _WIN32
#ifndef UNICODE
#define UNICODE // I think?
#endif
#include <windows.h> #include <windows.h>
wchar_t * LPWSTR
fromUTF8( fromUTF8(
const char *src, const char *src,
size_t src_length, /* = 0 */ size_t src_length, /* = 0 */
@ -39,7 +42,7 @@ fromUTF8(
src_length = strlen(src); src_length = strlen(src);
} }
int length = MultiByteToWideChar(CP_UTF8, 0, src, (int)src_length, 0, 0); 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) if (output_buffer)
{ {
MultiByteToWideChar(CP_UTF8, 0, src, (int)src_length, output_buffer, (int)length); 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 #ifdef _WIN32
size_t message_out_len = 0; size_t message_out_len = 0;
size_t title_out_len = 0; size_t title_out_len = 0;
wchar_t *message_wchar = fromUTF8(message_utf8, strlen(message_utf8), &message_out_len); LPWSTR 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 title_wchar = fromUTF8(title_utf8, strlen(title_utf8), &title_out_len);
int msgboxID = MessageBox( int msgboxID = MessageBox(
NULL, NULL,
message_wchar, message_wchar,

@ -686,9 +686,8 @@ static void init(void)
/* received. Reset the peer in the event the 5 seconds */ /* received. Reset the peer in the event the 5 seconds */
/* had run out without any significant event. */ /* had run out without any significant event. */
enet_peer_reset(peer); 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"); quit_with_popup("Failed to connect to server. Is your wifi down? It took too long.", "Connection Failure");
Log("Connection to server failed.\n");
} }
} }
} }

Loading…
Cancel
Save