Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] Fix for door-locking bug in nhraykey.dll

25 views
Skip to first unread message

Ray Chason

unread,
Feb 14, 2004, 6:53:46 PM2/14/04
to
This patch fixes a bug in nhraykey.c in which the keyboard stops responding
after locking or unlocking a door.

--cut here--cut here--cut here--cut here--cut here--cut here--cut here--
*** nethack-3.4.3/sys/winnt/nhraykey.c.old Sat Feb 14 18:39:20 2004
--- nethack-3.4.3/sys/winnt/nhraykey.c Sat Feb 14 18:41:23 2004
***************
*** 537,554 ****
scan = ir->Event.KeyEvent.wVirtualScanCode;
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 */
ReadConsoleInput(hConIn,ir,1,&count);
}

}
else if ((ir->EventType == MOUSE_EVENT &&
--- 537,560 ----
scan = ir->Event.KeyEvent.wVirtualScanCode;
shiftstate = ir->Event.KeyEvent.dwControlKeyState;
vk = ir->Event.KeyEvent.wVirtualKeyCode;
! if (scan == 0 && vk == 0) {
! /* It's the bogus_key. Discard it */
ReadConsoleInput(hConIn,ir,1,&count);
}
+ else {
+ 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 */
+ ReadConsoleInput(hConIn,ir,1,&count);
+ }
+ }

}
else if ((ir->EventType == MOUSE_EVENT &&
--cut here--cut here--cut here--cut here--cut here--cut here--cut here--

The problem occurs because NHkbhit() falsely returns true when the bogus_key
is the next event to be read; the main code at allmain.c line 326 then
calls Getchar() with no key waiting. The patch changes NHkbhit to
recognize the bogus_key (which has scan code and virtual key both set to
zero) and discard it.

--
--------------===============<[ Ray Chason ]>===============--------------
This message was stage-managed by IBM. So say Darl McBride and SCO.
Delendae sunt RIAA, MPAA et Windoze

0 new messages