[rec.games.hack] NetHack inventory fix + more debugging tools

creps@silver.bacs.indiana.edu (Steve Creps) (12/30/87)

   Below is the fix for the problems with the inventory and with
"Things that are here." I previously posted the diffs for the
inventory bug, but since they are related to, and in the same file
as, the "Things that are here" bug, I'm posting them again.
   The problem with "Things that are here" was that when there were
more than one of a stackable item on the ground, the number of items
was not being printed. This is because the descriptions were being
passed to the routine tputs. Tputs uses leading numeric characters
as a value for a timing delay, so that's where the numbers of items
were going, and not being printed.
   Another (very subtle) problem here was that when items were printed
out (by the cornline routine), the window in which they were printed
was cut right into the map, with nothing really dividing the item
list from the rest of the screen. While this in itself was not a bug,
I found it to be hard on the eyes.
   My one solution to these two problems was to insert a leading blank
in any string being output by the cornline routine. Thus the leading
blanks in the list of items not only prevent tputs from interpreting
leading numeric characters as padding information, but also create a
column that divides this list from the rest of the screen.
   Here are the fixes for the pager stuff, with pager.c being the
original 2.2 file, and pager.c.new being my latest version:

*** pager.c	Tue Dec 29 11:48:44 1987
--- pager.c.new	Tue Dec 29 11:45:24 1987
***************
*** 12,17
  extern char *CD;
  extern char quitchars[];
  extern char *getenv(), *getlogin();
  int done1();
  
  dowhatis()

--- 12,18 -----
  extern char *CD;
  extern char quitchars[];
  extern char *getenv(), *getlogin();
+ extern xchar curx;
  int done1();
  
  dowhatis()
***************
*** 295,301
  
  	    if(!text) return;	/* superfluous, just to be sure */
  	    linect++;
! 	    len = strlen(text);
  	    if(len > maxlen)
  		maxlen = len;
  	    tl = (struct line *)

--- 296,302 -----
  
  	    if(!text) return;	/* superfluous, just to be sure */
  	    linect++;
! 	    len = strlen(text) + 1; /* allow for an extra leading space */
  	    if(len > maxlen)
  		maxlen = len;
  	    tl = (struct line *)
***************
*** 302,308
  		alloc((unsigned)(len + sizeof(struct line) + 1));
  	    tl->next_line = 0;
  	    tl->line_text = (char *)(tl + 1);
! 	    (void) strcpy(tl->line_text, text);
  	    if(!texthead)
  		texthead = tl;
  	    else

--- 303,312 -----
  		alloc((unsigned)(len + sizeof(struct line) + 1));
  	    tl->next_line = 0;
  	    tl->line_text = (char *)(tl + 1);
! /*	    (void) strcpy(tl->line_text, text);*/
! 	    tl->line_text[0] = ' ';
! 	    tl->line_text[1] = '\0';
! 	    (void) strcat(tl->line_text, text);
  	    if(!texthead)
  		texthead = tl;
  	    else
***************
*** 331,337
  		    curs (lth, curline);
  		    if(curline > 1)
  			cl_end ();
- 		    putsym(' ');
  		    xputs(tl->line_text);
  		    curline++;
  		}

--- 335,340 -----
  		    curs (lth, curline);
  		    if(curline > 1)
  			cl_end ();
  		    xputs(tl->line_text);
  		    curx = curx + strlen(tl->line_text);
  		    curline++;
***************
*** 333,338
  			cl_end ();
  		    putsym(' ');
  		    xputs(tl->line_text);
  		    curline++;
  		}
  		curs (lth, curline);

--- 336,342 -----
  		    if(curline > 1)
  			cl_end ();
  		    xputs(tl->line_text);
+ 		    curx = curx + strlen(tl->line_text);
  		    curline++;
  		}
  		curs (lth, curline);

-	-	-	-	-	-	-	-	-

   The debugging tools I added are similar to the ^I identify, and
^W wish commands added in version 2.2. I've added ^C, which does a
mapping of the level as if a magic mapping scroll were read, and
^D, which finds all traps and hidden doors in a room (like secret
door detection). Some obligatory clever remarks are included in case
a non-wizard tries to use these commands.
   Here are the diffs for these:
*** cmd.c	Tue Dec 29 11:48:43 1987
--- cmd.c.new	Tue Dec 29 11:42:33 1987
***************
*** 12,18
  doset(),doup(), dodown(), done1(), donull(), dothrow(), doextcmd(), dodip(),
  dopray(), doextlist();
  #ifdef WIZARD
! int wiz_wish(), wiz_identify();
  #endif
  #ifdef NEWCLASS
  int dosit(), doturn();

--- 12,18 -----
  doset(),doup(), dodown(), done1(), donull(), dothrow(), doextcmd(), dodip(),
  dopray(), doextlist();
  #ifdef WIZARD
! int wiz_wish(), wiz_identify(), wiz_map(), wiz_detect();
  #endif
  #ifdef NEWCLASS
  int dosit(), doturn();
***************
*** 126,131
  
  struct func_tab cmdlist[]={
  #ifdef WIZARD
  	{'\011', wiz_identify},
  #endif
  	{'\020', doredotopl},

--- 126,133 -----
  
  struct func_tab cmdlist[]={
  #ifdef WIZARD
+ 	{'\003', wiz_map},
+ 	{'\004', wiz_detect},
  	{'\011', wiz_identify},
  #endif
  	{'\020', doredotopl},
***************
*** 528,532
  				identify(obj);
  	}
  	return(0);
  }
  #endif /* WIZARD */

--- 530,548 -----
  				identify(obj);
  	}
  	return(0);
+ }
+ int wiz_map()
+ {
+ 	if (wizard)
+ 	    do_mapping();
+ 	else
+ 	    pline("If you want a map, you should stop by a filling station!");
+ }
+ int wiz_detect()
+ {
+ 	if(wizard)
+ 	    { if(!findit()) return; }
+ 	else
+ 	    pline("Don't ask me where anything is, I only work here!");
  }
  #endif /* WIZARD */

-	-	-	-	-	-	-	-	-

   I've tested all these mods on the PC version of NetHack, but they
should also be good for other operating systems. I noticed the "Things
that are here" bug when I had NetHack running under Ultrix on our Vax 8650,
but haven't done any patches on that system, as I'm doing all my NetHack
work on an XT-clone (since I own that machine).

   Now, anybody figured out that problem with your ghost being a little
dog when restoring a bones level?

-	-	-	-	-	-	-	-	-
Steve Creps on the VAX 8650 running Ultrix 2.0-1 at Indiana University.
	creps@silver.bacs.indiana.edu
"F-14 Tomcat! There IS no substitute."