diff -U 3 -r nethack-3.4.3\sys\winnt\nhraykey.c nethack-3.4.3-win32\sys\winnt\nhraykey.c --- nethack-3.4.3\sys\winnt\nhraykey.c Sun Dec 07 18:39:13 2003 +++ nethack-3.4.3-win32\sys\winnt\nhraykey.c Wed Jan 09 19:27:34 2008 @@ -538,16 +538,22 @@ shiftstate = ir->Event.KeyEvent.dwControlKeyState; vk = ir->Event.KeyEvent.wVirtualKeyCode; keycode = MapVirtualKey(vk, 2); - if (is_altseq(shiftstate)) { - if (ch || inmap(keycode,vk)) altseq = 1; - else altseq = -1; /* invalid altseq */ - } - if (ch || iskeypad(scan) || altseq) { - done = 1; /* Stop looking */ - retval = 1; /* Found what we sought */ - } else { - /* Strange Key event; let's purge it to avoid trouble */ + if (scan == 0 && vk == 0) { + /* It's the bogus_key. Discard it */ ReadConsoleInput(hConIn,ir,1,&count); + } + else { + if (is_altseq(shiftstate)) { + if (ch || inmap(keycode,vk)) altseq = 1; + else altseq = -1; /* invalid altseq */ + } + if (ch || iskeypad(scan) || altseq) { + done = 1; /* Stop looking */ + retval = 1; /* Found what we sought */ + } else { + /* Strange Key event; let's purge it to avoid trouble */ + ReadConsoleInput(hConIn,ir,1,&count); + } } } diff -U 3 -r nethack-3.4.3\sys\winnt\nttty.c nethack-3.4.3-win32\sys\winnt\nttty.c --- nethack-3.4.3\sys\winnt\nttty.c Sun Dec 07 18:39:13 2003 +++ nethack-3.4.3-win32\sys\winnt\nttty.c Wed Jan 09 19:38:33 2008 @@ -30,6 +30,7 @@ * CreateFile * GetConsoleScreenBufferInfo * GetStdHandle + * GetVersion * SetConsoleCursorPosition * SetConsoleTextAttribute * SetConsoleCtrlHandler @@ -131,6 +132,8 @@ static DWORD ccount, acount; static COORD cursor = {0,0}; +static BOOL is_nt; + /* * Called after returning from ! or ^Z */ @@ -140,6 +143,7 @@ #ifndef TEXTCOLOR int k; #endif + is_nt = (GetVersion() & 0x80000000) == 0; erase_char = '\b'; kill_char = 21; /* cntl-U */ iflags.cbreak = TRUE; @@ -429,8 +433,18 @@ default: WriteConsoleOutputAttribute(hConOut,&attr,1, cursor,&acount); - WriteConsoleOutputCharacter(hConOut,&ch,1, - cursor,&ccount); + /* Avoid WriteConsoleOutputCharacterA in NT -- + it's broken */ + if (is_nt) { + WCHAR wch[2]; + MultiByteToWideChar(CP_OEMCP, MB_USEGLYPHCHARS, + &ch, 1, wch, 2); + WriteConsoleOutputCharacterW(hConOut,wch,1, + cursor,&ccount); + } else { + WriteConsoleOutputCharacterA(hConOut,&ch,1, + cursor,&ccount); + } cursor.X++; } } @@ -476,7 +490,17 @@ cursor.X = ttyDisplay->curx; cursor.Y = ttyDisplay->cury; WriteConsoleOutputAttribute(hConOut,&attr,1,cursor,&acount); - WriteConsoleOutputCharacter(hConOut,&ch,1,cursor,&ccount); + /* Avoid WriteConsoleOutputCharacterA in NT -- it's broken */ + if (is_nt) { + WCHAR wch[2]; + MultiByteToWideChar(CP_OEMCP, MB_USEGLYPHCHARS, + &ch, 1, wch, 2); + WriteConsoleOutputCharacterW(hConOut,wch,1, + cursor,&ccount); + } else { + WriteConsoleOutputCharacterA(hConOut,&ch,1, + cursor,&ccount); + } } void