Skip to content

Commit

Permalink
Merge pull request #5175 from maron2000/fix_switch_language
Browse files Browse the repository at this point in the history
Fix crash when a language file is loaded on a Windows host with US keyboard
  • Loading branch information
joncampbell123 authored Aug 15, 2024
2 parents 23be2fb + 64087fd commit 1b4761d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/dos/dos_keyboard_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/misc/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1b4761d

Please sign in to comment.