W343-3

From NetHackWiki
Revision as of 04:18, 18 January 2008 by Ray Chason (talk | contribs) (Bilious now has a patch for this bug. Going to have to drop the link to the screenshot, it hits the spam filter.)
Jump to navigation Jump to search

W343-3 designates a bug that affects the Microsoft Windows version of NetHack 3.4.3. The DevTeam lists this bug as fixed in the next release. The bug is listed as:

Under the Polish version of Windows 2000 SP4, screen output with a raster font shows
wrong characters for many dungeon features

Nature of the bug

The bug has been reported on Polish and Russian editions of Windows 2000 and on a Czech version of Windows XP. It has been duplicated on an American Windows XP by changing a language setting. A screenshot is available by following a link from the Polish report; it cannot be linked from Wikihack because it currently hits the spam filter.

Bug W343-3 really comprises two distinct and unrelated bugs. One is a simple character set issue: many non-USA PCs are configured with different character sets, and seven symbols may look different. This issue is more fully detailed in the IBMgraphics article.

The more serious bug is that some characters appear as strange symbols or blank squares. This is not actually a bug in NetHack, but in Windows. The rest of this article will deal with this bug.

Cause of the bug

The bug is a flaw in the Windows WriteConsoleOutputCharacterA API. When its configured code page is other than 437 or 850, many non-ASCII characters can show up incorrectly.

The bug occurs when four conditions are met:

  • The version of Windows is Windows NT or one of its descendants. The bug is confirmed to exist on Windows 2000, Windows XP, and Windows Vista.
  • A bitmap font, rather than Lucida Console, is selected.
  • The command shell is running in a window, rather than full screen.
  • The language for non-Unicode programs is set to one whose OEM code page is anything other than 437 or 850. Basically this means any East European language, whether it uses Greek, Cyrillic or Latin writing.

No API other than WriteConsoleOutputCharacterA is known to be affected. In particular, the Unicode variant WriteConsoleOutputCharacterW works correctly.

Versions affected

NetHack 3.4.3 is known to have this bug. Because NetHack 3.1.1 through 3.1.3 also use the flawed API, it is likely that they have it as well. NetHack 3.2.0 through 3.4.2 use different APIs, and do not have this bug.

Patch

A patch is available to fix this bug; but no binaries or variants other than Spanish NetHack are known to incorporate it.

The patch fixes the API issue by detecting when it is running on an NT-based version of Windows, and using the Unicode API instead, avoiding the Windows bug. It fixes the character set issue as well (see IBMgraphics) by allowing less-extensive variants of IBMgraphics to be set, avoiding the characters that can vary among code pages.

The patch was posted to rec.games.roguelike.nethack as four articles:

  • Part 1 describes the API issue and provides detailed instructions to duplicate it, and a small test program to demonstrate the bug.
  • Part 2 describes the character set issue.
  • Part 3 contains the patch itself.
  • Part 4 is a description of each change the patch makes.

The Bilious Patch Database has a simpler form of this patch, that works around the faulty API but does not alter the IBMgraphics, here.