[rec.games.hack] NetHack inventory standout mode bug

hymie@dvm.UUCP (Hyman Rosen) (08/24/87)

There is a bug in NetHack when standout mode requires padding. In termcap.c,
HI and HE are set to SO and SE respectively. The function let_to_name() then
uses HI and HE by sprintf'ing them into a buffer. Unfortunately, SO and SE
may come equipped with leading padding values (2 on vt100's on my system),
and these are simply printed. I get artifacts such as '2Armor2' in my
inventories, with 'Armor' in standout mode.

I've fixed this by having HI and HE skip over the padding. With any luck, the
padding is pessimistic, and its lack will not seriously affect the screen.
(Say, maybe I should check u.u_luck :-). The right thing to do would be to see
to it that tputs() is properly called for HI and HE, but I was lazy.

Here's the patch:
*** termcap.c.orig	Fri Jul 31 04:54:03 1987
--- termcap.c	Sun Aug 23 23:37:51 1987
***************
*** 105,110
  #ifdef SORTING
  	HI = SO;	/* I know... Its a kluge. (MRS) */
  	HE = SE;
  #endif
  	CD = tgetstr("cd", &tbufptr);
  	set_whole_screen();		/* uses LI and CD */

--- 105,119 -----
  #ifdef SORTING
  	HI = SO;	/* I know... Its a kluge. (MRS) */
  	HE = SE;
+ 
+ 	/* ...and a worse kludge; if SO or SE have padding info, it gets
+ 	   printed as a number because let_to_name() just dumps HI and HE
+ 	   into a buffer. Just hope the padding isn't that essential,
+ 	   because the following removes it. (HR)
+ 	*/
+ 	while (*HI >= '0' && *HI <= '9') ++HI;
+ 	while (*HE >= '0' && *HE <= '9') ++HE;
+ 
  #endif
  	CD = tgetstr("cd", &tbufptr);
  	set_whole_screen();		/* uses LI and CD */
-- 


								- Hymie

		...{decvax,ihnp4,ucbvax}!allegra!phri!orville!dvm!hymie