From bb005b6f2f60866fa1003292b48434efa450f8f2 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:13:48 +0900 Subject: [PATCH 1/2] Fix crash on loading language files when host keyboard layout is "US" (Windows) --- src/dos/dos_keyboard_layout.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dos/dos_keyboard_layout.cpp b/src/dos/dos_keyboard_layout.cpp index 75365d3450..2abc33bc53 100644 --- a/src/dos/dos_keyboard_layout.cpp +++ b/src/dos/dos_keyboard_layout.cpp @@ -1505,12 +1505,9 @@ class DOS_KeyboardLayout: public Module_base { wants_dos_codepage = GetDefaultCP(); break; case 1033: // US, CP 437 -#if defined(HX_DOS) layoutname = "us"; wants_dos_codepage = GetDefaultCP(); break; -#endif - return; case 1032: // Greece, CP 869, Alt CP 813 layoutname = "gk"; break; @@ -1688,8 +1685,12 @@ class DOS_KeyboardLayout: public Module_base { default: break; } -#endif } + else if(!strncmp(layoutname, "none", 4)) { + layoutname = "us"; + wants_dos_codepage = 437; +#endif + } bool extract_codepage = !tocp; if (wants_dos_codepage>0) { From 64087fdd94f41a3d8c7802d6ed2bd64e04178845 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:14:52 +0900 Subject: [PATCH 2/2] Don't warn changing codepage when language file is loaded for the first time. --- src/misc/messages.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/misc/messages.cpp b/src/misc/messages.cpp index 70fb8c7a10..d7f1f46524 100644 --- a/src/misc/messages.cpp +++ b/src/misc/messages.cpp @@ -321,7 +321,8 @@ void LoadMessageFile(const char * fname) { return; } std::string msg = "The specified language file uses code page " + std::to_string(c) + ". Do you want to change to this code page accordingly?"; - if (!control->opt_langcp && !uselangcp && c != 437 && GetDefaultCP() == 437 && systemmessagebox("DOSBox-X language file", msg.c_str(), "yesno", "question", 1)) control->opt_langcp = true; + if (loadlang && !control->opt_langcp && !uselangcp && c != 437 && GetDefaultCP() == 437 && systemmessagebox("DOSBox-X language file", msg.c_str(), "yesno", "question", 1)) control->opt_langcp = true; + else control->opt_langcp = true; msgcodepage = c; dos.loaded_codepage = c; if (c == 950 && !chinasea) makestdcp950table();